Skip to content
Snippets Groups Projects
Commit 40254b9a authored by GitLab Bot's avatar GitLab Bot
Browse files

Add latest changes from gitlab-org/gitlab@master

parent 22a0d312
No related branches found
No related tags found
No related merge requests found
Showing
with 616 additions and 46 deletions
Loading
Loading
@@ -3,30 +3,27 @@
require 'spec_helper'
 
describe Banzai::Filter::AbstractReferenceFilter do
let(:project) { create(:project) }
let_it_be(:project) { create(:project) }
let(:doc) { Nokogiri::HTML.fragment('') }
let(:filter) { described_class.new(doc, project: project) }
 
describe '#references_per_parent' do
it 'returns a Hash containing references grouped per parent paths' do
doc = Nokogiri::HTML.fragment("#1 #{project.full_path}#2")
filter = described_class.new(doc, project: project)
let(:doc) { Nokogiri::HTML.fragment("#1 #{project.full_path}#2 #2") }
 
expect(filter).to receive(:object_class).exactly(4).times.and_return(Issue)
expect(filter).to receive(:object_sym).twice.and_return(:issue)
it 'returns a Hash containing references grouped per parent paths' do
expect(described_class).to receive(:object_class).exactly(6).times.and_return(Issue)
 
refs = filter.references_per_parent
 
expect(refs).to be_an_instance_of(Hash)
expect(refs[project.full_path]).to eq(Set.new(%w[1 2]))
expect(refs).to match(a_hash_including(project.full_path => contain_exactly(1, 2)))
end
end
 
describe '#parent_per_reference' do
it 'returns a Hash containing projects grouped per parent paths' do
doc = Nokogiri::HTML.fragment('')
filter = described_class.new(doc, project: project)
expect(filter).to receive(:references_per_parent)
.and_return({ project.full_path => Set.new(%w[1]) })
.and_return({ project.full_path => Set.new([1]) })
 
expect(filter.parent_per_reference)
.to eq({ project.full_path => project })
Loading
Loading
@@ -34,9 +31,6 @@ describe Banzai::Filter::AbstractReferenceFilter do
end
 
describe '#find_for_paths' do
let(:doc) { Nokogiri::HTML.fragment('') }
let(:filter) { described_class.new(doc, project: project) }
context 'with RequestStore disabled' do
it 'returns a list of Projects for a list of paths' do
expect(filter.find_for_paths([project.full_path]))
Loading
Loading
Loading
Loading
@@ -28,7 +28,7 @@ describe Gitlab::ApplicationContext do
describe '.push' do
it 'passes the expected context on to labkit' do
fake_proc = duck_type(:call)
expected_context = hash_including(user: fake_proc, project: fake_proc, root_namespace: fake_proc)
expected_context = { user: fake_proc }
 
expect(Labkit::Context).to receive(:push).with(expected_context)
 
Loading
Loading
@@ -78,5 +78,27 @@ describe Gitlab::ApplicationContext do
expect(result(context))
.to include(project: project.full_path, root_namespace: project.full_path_components.first)
end
context 'only include values for which an option was specified' do
using RSpec::Parameterized::TableSyntax
where(:provided_options, :expected_context_keys) do
[:user, :namespace, :project] | [:user, :project, :root_namespace]
[:user, :project] | [:user, :project, :root_namespace]
[:user, :namespace] | [:user, :root_namespace]
[:user] | [:user]
[] | []
end
with_them do
it do
# Build a hash that has all `provided_options` as keys, and `nil` as value
provided_values = provided_options.map { |key| [key, nil] }.to_h
context = described_class.new(provided_values)
expect(context.to_lazy_hash.keys).to contain_exactly(*expected_context_keys)
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData, :migration, schema: 20190924152703 do
let(:services) { table(:services) }
# we need to define the classes due to encryption
class IssueTrackerData < ApplicationRecord
self.table_name = 'issue_tracker_data'
def self.encryption_options
{
key: Settings.attr_encrypted_db_key_base_32,
encode: true,
mode: :per_attribute_iv,
algorithm: 'aes-256-gcm'
}
end
attr_encrypted :project_url, encryption_options
attr_encrypted :issues_url, encryption_options
attr_encrypted :new_issue_url, encryption_options
end
class JiraTrackerData < ApplicationRecord
self.table_name = 'jira_tracker_data'
def self.encryption_options
{
key: Settings.attr_encrypted_db_key_base_32,
encode: true,
mode: :per_attribute_iv,
algorithm: 'aes-256-gcm'
}
end
attr_encrypted :url, encryption_options
attr_encrypted :api_url, encryption_options
attr_encrypted :username, encryption_options
attr_encrypted :password, encryption_options
end
let(:url) { 'http://base-url.tracker.com' }
let(:new_issue_url) { 'http://base-url.tracker.com/new_issue' }
let(:issues_url) { 'http://base-url.tracker.com/issues' }
let(:api_url) { 'http://api.tracker.com' }
let(:password) { 'passw1234' }
let(:username) { 'user9' }
let(:title) { 'Issue tracker' }
let(:description) { 'Issue tracker description' }
let(:jira_properties) do
{
'api_url' => api_url,
'jira_issue_transition_id' => '5',
'password' => password,
'url' => url,
'username' => username,
'title' => title,
'description' => description,
'other_field' => 'something'
}
end
let(:tracker_properties) do
{
'project_url' => url,
'new_issue_url' => new_issue_url,
'issues_url' => issues_url,
'title' => title,
'description' => description,
'other_field' => 'something'
}
end
let(:tracker_properties_no_url) do
{
'new_issue_url' => new_issue_url,
'issues_url' => issues_url,
'title' => title,
'description' => description
}
end
subject { described_class.new.perform(1, 100) }
shared_examples 'handle properties' do
it 'does not clear the properties' do
expect { subject }.not_to change { service.reload.properties}
end
end
context 'with jira service' do
let!(:service) do
services.create(id: 10, type: 'JiraService', title: nil, properties: jira_properties.to_json, category: 'issue_tracker')
end
it_behaves_like 'handle properties'
it 'migrates data' do
expect { subject }.to change { JiraTrackerData.count }.by(1)
service.reload
data = JiraTrackerData.find_by(service_id: service.id)
expect(data.url).to eq(url)
expect(data.api_url).to eq(api_url)
expect(data.username).to eq(username)
expect(data.password).to eq(password)
expect(service.title).to eq(title)
expect(service.description).to eq(description)
end
end
context 'with bugzilla service' do
let!(:service) do
services.create(id: 11, type: 'BugzillaService', title: nil, properties: tracker_properties.to_json, category: 'issue_tracker')
end
it_behaves_like 'handle properties'
it 'migrates data' do
expect { subject }.to change { IssueTrackerData.count }.by(1)
service.reload
data = IssueTrackerData.find_by(service_id: service.id)
expect(data.project_url).to eq(url)
expect(data.issues_url).to eq(issues_url)
expect(data.new_issue_url).to eq(new_issue_url)
expect(service.title).to eq(title)
expect(service.description).to eq(description)
end
end
context 'with youtrack service' do
let!(:service) do
services.create(id: 12, type: 'YoutrackService', title: nil, properties: tracker_properties_no_url.to_json, category: 'issue_tracker')
end
it_behaves_like 'handle properties'
it 'migrates data' do
expect { subject }.to change { IssueTrackerData.count }.by(1)
service.reload
data = IssueTrackerData.find_by(service_id: service.id)
expect(data.project_url).to be_nil
expect(data.issues_url).to eq(issues_url)
expect(data.new_issue_url).to eq(new_issue_url)
expect(service.title).to eq(title)
expect(service.description).to eq(description)
end
end
context 'with gitlab service with no properties' do
let!(:service) do
services.create(id: 13, type: 'GitlabIssueTrackerService', title: nil, properties: {}, category: 'issue_tracker')
end
it_behaves_like 'handle properties'
it 'does not migrate data' do
expect { subject }.not_to change { IssueTrackerData.count }
end
end
context 'with redmine service already with data fields' do
let!(:service) do
services.create(id: 14, type: 'RedmineService', title: nil, properties: tracker_properties_no_url.to_json, category: 'issue_tracker').tap do |service|
IssueTrackerData.create!(service_id: service.id, project_url: url, new_issue_url: new_issue_url, issues_url: issues_url)
end
end
it_behaves_like 'handle properties'
it 'does not create new data fields record' do
expect { subject }.not_to change { IssueTrackerData.count }
end
end
context 'with custom issue tracker which has data fields record inconsistent with properties field' do
let!(:service) do
services.create(id: 15, type: 'CustomIssueTrackerService', title: 'Existing title', properties: jira_properties.to_json, category: 'issue_tracker').tap do |service|
IssueTrackerData.create!(service_id: service.id, project_url: 'http://other_url', new_issue_url: 'http://other_url/new_issue', issues_url: 'http://other_url/issues')
end
end
it_behaves_like 'handle properties'
it 'does not update the data fields record' do
expect { subject }.not_to change { IssueTrackerData.count }
service.reload
data = IssueTrackerData.find_by(service_id: service.id)
expect(data.project_url).to eq('http://other_url')
expect(data.issues_url).to eq('http://other_url/issues')
expect(data.new_issue_url).to eq('http://other_url/new_issue')
expect(service.title).to eq('Existing title')
end
end
context 'with jira service which has data fields record inconsistent with properties field' do
let!(:service) do
services.create(id: 16, type: 'CustomIssueTrackerService', description: 'Existing description', properties: jira_properties.to_json, category: 'issue_tracker').tap do |service|
JiraTrackerData.create!(service_id: service.id, url: 'http://other_jira_url')
end
end
it_behaves_like 'handle properties'
it 'does not update the data fields record' do
expect { subject }.not_to change { JiraTrackerData.count }
service.reload
data = JiraTrackerData.find_by(service_id: service.id)
expect(data.url).to eq('http://other_jira_url')
expect(data.password).to be_nil
expect(data.username).to be_nil
expect(data.api_url).to be_nil
expect(service.description).to eq('Existing description')
end
end
context 'non issue tracker service' do
let!(:service) do
services.create(id: 17, title: nil, description: nil, type: 'OtherService', properties: tracker_properties.to_json)
end
it_behaves_like 'handle properties'
it 'does not migrate any data' do
expect { subject }.not_to change { IssueTrackerData.count }
service.reload
expect(service.title).to be_nil
expect(service.description).to be_nil
end
end
context 'jira service with empty properties' do
let!(:service) do
services.create(id: 18, type: 'JiraService', properties: '', category: 'issue_tracker')
end
it_behaves_like 'handle properties'
it 'does not migrate any data' do
expect { subject }.not_to change { JiraTrackerData.count }
end
end
context 'jira service with nil properties' do
let!(:service) do
services.create(id: 18, type: 'JiraService', properties: nil, category: 'issue_tracker')
end
it_behaves_like 'handle properties'
it 'does not migrate any data' do
expect { subject }.not_to change { JiraTrackerData.count }
end
end
context 'jira service with invalid properties' do
let!(:service) do
services.create(id: 18, type: 'JiraService', properties: 'invalid data', category: 'issue_tracker')
end
it_behaves_like 'handle properties'
it 'does not migrate any data' do
expect { subject }.not_to change { JiraTrackerData.count }
end
end
context 'with jira service with invalid properties, valid jira service and valid bugzilla service' do
let!(:jira_service_invalid) do
services.create(id: 19, title: 'invalid - title', description: 'invalid - description', type: 'JiraService', properties: 'invalid data', category: 'issue_tracker')
end
let!(:jira_service_valid) do
services.create(id: 20, type: 'JiraService', properties: jira_properties.to_json, category: 'issue_tracker')
end
let!(:bugzilla_service_valid) do
services.create(id: 11, type: 'BugzillaService', title: nil, properties: tracker_properties.to_json, category: 'issue_tracker')
end
it 'migrates data for the valid service' do
subject
jira_service_invalid.reload
expect(JiraTrackerData.find_by(service_id: jira_service_invalid.id)).to be_nil
expect(jira_service_invalid.title).to eq('invalid - title')
expect(jira_service_invalid.description).to eq('invalid - description')
expect(jira_service_invalid.properties).to eq('invalid data')
jira_service_valid.reload
data = JiraTrackerData.find_by(service_id: jira_service_valid.id)
expect(data.url).to eq(url)
expect(data.api_url).to eq(api_url)
expect(data.username).to eq(username)
expect(data.password).to eq(password)
expect(jira_service_valid.title).to eq(title)
expect(jira_service_valid.description).to eq(description)
bugzilla_service_valid.reload
data = IssueTrackerData.find_by(service_id: bugzilla_service_valid.id)
expect(data.project_url).to eq(url)
expect(data.issues_url).to eq(issues_url)
expect(data.new_issue_url).to eq(new_issue_url)
expect(bugzilla_service_valid.title).to eq(title)
expect(bugzilla_service_valid.description).to eq(description)
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe Gitlab::ImportExport::ImportFailureService do
let(:importable) { create(:project, :builds_enabled, :issues_disabled, name: 'project', path: 'project') }
let(:label) { create(:label) }
let(:subject) { described_class.new(importable) }
let(:relation_key) { "labels" }
let(:relation_index) { 0 }
describe '#log_import_failure' do
let(:standard_error_message) { "StandardError message" }
let(:exception) { StandardError.new(standard_error_message) }
let(:correlation_id) { 'my-correlation-id' }
let(:retry_count) { 2 }
let(:log_import_failure) do
subject.log_import_failure(relation_key, relation_index, exception, retry_count)
end
before do
# Import is running from the rake task, `correlation_id` is not assigned
allow(Labkit::Correlation::CorrelationId).to receive(:current_or_new_id).and_return(correlation_id)
end
context 'when importable is a group' do
let(:importable) { create(:group) }
it_behaves_like 'log import failure', :group_id
end
context 'when importable is a project' do
it_behaves_like 'log import failure', :project_id
end
context 'when ImportFailure does not support importable class' do
let(:importable) { create(:merge_request) }
it 'raise exception' do
expect { subject }.to raise_exception(ActiveRecord::AssociationNotFoundError, "Association named 'import_failures' was not found on MergeRequest; perhaps you misspelled it?")
end
end
end
describe '#with_retry' do
let(:perform_retry) do
subject.with_retry(relation_key, relation_index) do
label.save!
end
end
context 'when exceptions are retriable' do
where(:exception) { Gitlab::ImportExport::ImportFailureService::RETRIABLE_EXCEPTIONS }
with_them do
context 'when retry succeeds' do
before do
expect(label).to receive(:save!).and_raise(exception.new)
expect(label).to receive(:save!).and_return(true)
end
it 'retries and logs import failure once with correct params' do
expect(subject).to receive(:log_import_failure).with(relation_key, relation_index, instance_of(exception), 1).once
perform_retry
end
end
context 'when retry continues to fail with intermittent errors' do
let(:maximum_retry_count) do
Retriable.config.tries
end
before do
expect(label).to receive(:save!)
.exactly(maximum_retry_count).times
.and_raise(exception.new)
end
it 'retries the number of times allowed and raise exception', :aggregate_failures do
expect { perform_retry }.to raise_exception(exception)
end
it 'logs import failure each time and raise exception', :aggregate_failures do
maximum_retry_count.times do |index|
retry_count = index + 1
expect(subject).to receive(:log_import_failure).with(relation_key, relation_index, instance_of(exception), retry_count)
end
expect { perform_retry }.to raise_exception(exception)
end
end
end
end
context 'when exception is not retriable' do
let(:exception) { StandardError.new }
it 'raise the exception', :aggregate_failures do
expect(label).to receive(:save!).once.and_raise(exception)
expect(subject).not_to receive(:log_import_failure)
expect { perform_retry }.to raise_exception(exception)
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20190924152703_migrate_issue_trackers_data.rb')
describe MigrateIssueTrackersData, :migration do
let(:services) { table(:services) }
let(:migration_class) { Gitlab::BackgroundMigration::MigrateIssueTrackersSensitiveData }
let(:migration_name) { migration_class.to_s.demodulize }
let(:properties) do
{
'url' => 'http://example.com'
}
end
let!(:jira_service) do
services.create(id: 10, type: 'JiraService', properties: properties, category: 'issue_tracker')
end
let!(:jira_service_nil) do
services.create(id: 11, type: 'JiraService', properties: nil, category: 'issue_tracker')
end
let!(:bugzilla_service) do
services.create(id: 12, type: 'BugzillaService', properties: properties, category: 'issue_tracker')
end
let!(:youtrack_service) do
services.create(id: 13, type: 'YoutrackService', properties: properties, category: 'issue_tracker')
end
let!(:youtrack_service_empty) do
services.create(id: 14, type: 'YoutrackService', properties: '', category: 'issue_tracker')
end
let!(:gitlab_service) do
services.create(id: 15, type: 'GitlabIssueTrackerService', properties: properties, category: 'issue_tracker')
end
let!(:gitlab_service_empty) do
services.create(id: 16, type: 'GitlabIssueTrackerService', properties: {}, category: 'issue_tracker')
end
let!(:other_service) do
services.create(id: 17, type: 'OtherService', properties: properties, category: 'other_category')
end
before do
stub_const("#{described_class}::BATCH_SIZE", 2)
end
it 'schedules background migrations at correct time' do
Sidekiq::Testing.fake! do
Timecop.freeze do
migrate!
expect(migration_name).to be_scheduled_delayed_migration(3.minutes, jira_service.id, bugzilla_service.id)
expect(migration_name).to be_scheduled_delayed_migration(6.minutes, youtrack_service.id, gitlab_service.id)
expect(BackgroundMigrationWorker.jobs.size).to eq(2)
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe ImportFailure do
describe "Associations" do
it { is_expected.to belong_to(:project) }
it { is_expected.to belong_to(:group) }
end
describe 'Validations' do
context 'has no group' do
before do
allow(subject).to receive(:group).and_return(nil)
end
it { is_expected.to validate_presence_of(:project) }
end
context 'has no project' do
before do
allow(subject).to receive(:project).and_return(nil)
end
it { is_expected.to validate_presence_of(:group) }
end
end
end
Loading
Loading
@@ -40,6 +40,18 @@ describe API::Deployments do
end
end
 
context 'with the environment filter specifed' do
it 'returns deployments for the environment' do
get(
api("/projects/#{project.id}/deployments", user),
params: { environment: deployment_1.environment.name }
)
expect(json_response.size).to eq(1)
expect(json_response.first['iid']).to eq(deployment_1.iid)
end
end
describe 'ordering' do
let(:order_by) { 'iid' }
let(:sort) { 'desc' }
Loading
Loading
Loading
Loading
@@ -74,7 +74,9 @@ describe MergeRequests::Conflicts::ListService do
it 'returns a falsey value when the MR has a missing ref after a force push' do
merge_request = create_merge_request('conflict-resolvable')
service = conflicts_service(merge_request)
allow_any_instance_of(Gitlab::GitalyClient::ConflictsService).to receive(:list_conflict_files).and_raise(GRPC::Unknown)
allow_next_instance_of(Gitlab::GitalyClient::ConflictsService) do |instance|
allow(instance).to receive(:list_conflict_files).and_raise(GRPC::Unknown)
end
 
expect(service.can_be_resolved_in_ui?).to be_falsey
end
Loading
Loading
Loading
Loading
@@ -55,7 +55,9 @@ describe MergeRequests::CreateFromIssueService do
end
 
it 'creates the new_issue_branch system note when the branch could be created but the merge_request cannot be created', :sidekiq_might_not_need_inline do
expect_any_instance_of(MergeRequest).to receive(:valid?).at_least(:once).and_return(false)
expect_next_instance_of(MergeRequest) do |instance|
expect(instance).to receive(:valid?).at_least(:once).and_return(false)
end
 
expect(SystemNoteService).to receive(:new_issue_branch).with(issue, project, user, issue.to_branch_name, branch_project: target_project)
 
Loading
Loading
Loading
Loading
@@ -714,9 +714,9 @@ describe MergeRequests::PushOptionsHandlerService do
let(:exception) { StandardError.new('My standard error') }
 
def run_service_with_exception
allow_any_instance_of(
MergeRequests::BuildService
).to receive(:execute).and_raise(exception)
allow_next_instance_of(MergeRequests::BuildService) do |instance|
allow(instance).to receive(:execute).and_raise(exception)
end
 
service.execute
end
Loading
Loading
@@ -766,9 +766,9 @@ describe MergeRequests::PushOptionsHandlerService do
invalid_merge_request = MergeRequest.new
invalid_merge_request.errors.add(:base, 'my error')
 
expect_any_instance_of(
MergeRequests::CreateService
).to receive(:execute).and_return(invalid_merge_request)
expect_next_instance_of(MergeRequests::CreateService) do |instance|
expect(instance).to receive(:execute).and_return(invalid_merge_request)
end
 
service.execute
 
Loading
Loading
Loading
Loading
@@ -31,7 +31,9 @@ describe Milestones::PromoteService do
it 'does not promote milestone and update issuables if promoted milestone is not valid' do
issue = create(:issue, milestone: milestone, project: project)
merge_request = create(:merge_request, milestone: milestone, source_project: project)
allow_any_instance_of(Milestone).to receive(:valid?).and_return(false)
allow_next_instance_of(Milestone) do |instance|
allow(instance).to receive(:valid?).and_return(false)
end
 
expect { service.execute(milestone) }.to raise_error(described_class::PromoteMilestoneError)
 
Loading
Loading
Loading
Loading
@@ -71,7 +71,9 @@ describe Milestones::TransferService do
 
context 'when find_or_create_milestone returns nil' do
before do
allow_any_instance_of(Milestones::FindOrCreateService).to receive(:execute).and_return(nil)
allow_next_instance_of(Milestones::FindOrCreateService) do |instance|
allow(instance).to receive(:execute).and_return(nil)
end
end
 
it 'removes issues group milestone' do
Loading
Loading
Loading
Loading
@@ -17,7 +17,9 @@ describe Namespaces::StatisticsRefresherService, '#execute' do
end
 
it 'recalculate the namespace statistics' do
expect_any_instance_of(Namespace::RootStorageStatistics).to receive(:recalculate!).once
expect_next_instance_of(Namespace::RootStorageStatistics) do |instance|
expect(instance).to receive(:recalculate!).once
end
 
service.execute(group)
end
Loading
Loading
@@ -45,8 +47,9 @@ describe Namespaces::StatisticsRefresherService, '#execute' do
 
context 'when something goes wrong' do
before do
allow_any_instance_of(Namespace::RootStorageStatistics)
.to receive(:recalculate!).and_raise(ActiveRecord::ActiveRecordError)
allow_next_instance_of(Namespace::RootStorageStatistics) do |instance|
allow(instance).to receive(:recalculate!).and_raise(ActiveRecord::ActiveRecordError)
end
end
 
it 'raises RefreshError' do
Loading
Loading
Loading
Loading
@@ -17,7 +17,9 @@ describe Notes::ResolveService do
end
 
it "sends notifications if all discussions are resolved" do
expect_any_instance_of(MergeRequests::ResolvedDiscussionNotificationService).to receive(:execute).with(merge_request)
expect_next_instance_of(MergeRequests::ResolvedDiscussionNotificationService) do |instance|
expect(instance).to receive(:execute).with(merge_request)
end
 
described_class.new(merge_request.project, user).execute(note)
end
Loading
Loading
Loading
Loading
@@ -32,9 +32,9 @@ describe PagesDomains::ObtainLetsEncryptCertificateService do
def stub_lets_encrypt_order(url, status)
order = ::Gitlab::LetsEncrypt::Order.new(acme_order_double(status: status))
 
allow_any_instance_of(::Gitlab::LetsEncrypt::Client).to(
receive(:load_order).with(url).and_return(order)
)
allow_next_instance_of(::Gitlab::LetsEncrypt::Client) do |instance|
allow(instance).to receive(:load_order).with(url).and_return(order)
end
 
order
end
Loading
Loading
Loading
Loading
@@ -247,7 +247,9 @@ describe Projects::CreateService, '#execute' do
 
context 'repository creation' do
it 'synchronously creates the repository' do
expect_any_instance_of(Project).to receive(:create_repository)
expect_next_instance_of(Project) do |instance|
expect(instance).to receive(:create_repository)
end
 
project = create_project(user, opts)
expect(project).to be_valid
Loading
Loading
Loading
Loading
@@ -94,7 +94,9 @@ describe Projects::ImportExport::ExportService do
end
 
it 'notifies the user' do
expect_any_instance_of(NotificationService).to receive(:project_not_exported)
expect_next_instance_of(NotificationService) do |instance|
expect(instance).to receive(:project_not_exported)
end
end
 
it 'notifies logger' do
Loading
Loading
@@ -122,7 +124,9 @@ describe Projects::ImportExport::ExportService do
end
 
it 'notifies the user' do
expect_any_instance_of(NotificationService).to receive(:project_not_exported)
expect_next_instance_of(NotificationService) do |instance|
expect(instance).to receive(:project_not_exported)
end
end
 
it 'notifies logger' do
Loading
Loading
Loading
Loading
@@ -16,7 +16,9 @@ describe Projects::LfsPointers::LfsImportService do
 
it 'downloads lfs objects' do
service = double
expect_any_instance_of(Projects::LfsPointers::LfsObjectDownloadListService).to receive(:execute).and_return(oid_download_links)
expect_next_instance_of(Projects::LfsPointers::LfsObjectDownloadListService) do |instance|
expect(instance).to receive(:execute).and_return(oid_download_links)
end
expect(Projects::LfsPointers::LfsDownloadService).to receive(:new).and_return(service).twice
expect(service).to receive(:execute).twice
 
Loading
Loading
@@ -27,7 +29,9 @@ describe Projects::LfsPointers::LfsImportService do
 
context 'when no downloadable lfs object links' do
it 'does not call LfsDownloadService' do
expect_any_instance_of(Projects::LfsPointers::LfsObjectDownloadListService).to receive(:execute).and_return({})
expect_next_instance_of(Projects::LfsPointers::LfsObjectDownloadListService) do |instance|
expect(instance).to receive(:execute).and_return({})
end
expect(Projects::LfsPointers::LfsDownloadService).not_to receive(:new)
 
result = subject.execute
Loading
Loading
@@ -39,7 +43,9 @@ describe Projects::LfsPointers::LfsImportService do
context 'when an exception is raised' do
it 'returns error' do
error_message = "error message"
expect_any_instance_of(Projects::LfsPointers::LfsObjectDownloadListService).to receive(:execute).and_raise(StandardError, error_message)
expect_next_instance_of(Projects::LfsPointers::LfsObjectDownloadListService) do |instance|
expect(instance).to receive(:execute).and_raise(StandardError, error_message)
end
 
result = subject.execute
 
Loading
Loading
Loading
Loading
@@ -110,8 +110,9 @@ describe Projects::UpdatePagesService do
 
context 'when timeout happens by DNS error' do
before do
allow_any_instance_of(described_class)
.to receive(:extract_zip_archive!).and_raise(SocketError)
allow_next_instance_of(described_class) do |instance|
allow(instance).to receive(:extract_zip_archive!).and_raise(SocketError)
end
end
 
it 'raises an error' do
Loading
Loading
@@ -125,9 +126,10 @@ describe Projects::UpdatePagesService do
 
context 'when failed to extract zip artifacts' do
before do
expect_any_instance_of(described_class)
.to receive(:extract_zip_archive!)
.and_raise(Projects::UpdatePagesService::FailedToExtractError)
expect_next_instance_of(described_class) do |instance|
expect(instance).to receive(:extract_zip_archive!)
.and_raise(Projects::UpdatePagesService::FailedToExtractError)
end
end
 
it 'raises an error' do
Loading
Loading
Loading
Loading
@@ -265,7 +265,9 @@ describe ::SystemNotes::IssuablesService do
 
context 'when cross-reference disallowed' do
before do
expect_any_instance_of(described_class).to receive(:cross_reference_disallowed?).and_return(true)
expect_next_instance_of(described_class) do |instance|
expect(instance).to receive(:cross_reference_disallowed?).and_return(true)
end
end
 
it 'returns nil' do
Loading
Loading
@@ -279,7 +281,9 @@ describe ::SystemNotes::IssuablesService do
 
context 'when cross-reference allowed' do
before do
expect_any_instance_of(described_class).to receive(:cross_reference_disallowed?).and_return(false)
expect_next_instance_of(described_class) do |instance|
expect(instance).to receive(:cross_reference_disallowed?).and_return(false)
end
end
 
it_behaves_like 'a system note' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment