Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 18:07:45 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-04-01 18:07:45 +0300
commit1219a9dce91f4edbc135dfc08299b4122b4825a8 (patch)
treee7d12a55d75a2d56e60d9527bef3724e3578866d /spec/services
parent1a0d6dbdc2ac3047f4953a359ef27ba6e26074ae (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/error_tracking/issue_update_service_spec.rb2
-rw-r--r--spec/services/issues/update_service_spec.rb4
-rw-r--r--spec/services/labels/available_labels_service_spec.rb2
-rw-r--r--spec/services/members/update_highest_role_service_spec.rb4
-rw-r--r--spec/services/notes/create_service_spec.rb2
-rw-r--r--spec/services/projects/participants_service_spec.rb4
-rw-r--r--spec/services/quick_actions/interpret_service_spec.rb4
-rw-r--r--spec/services/repository_archive_clean_up_service_spec.rb6
-rw-r--r--spec/services/snippets/update_service_spec.rb14
-rw-r--r--spec/services/todos/destroy/entity_leave_service_spec.rb2
-rw-r--r--spec/services/users/activity_service_spec.rb4
11 files changed, 27 insertions, 21 deletions
diff --git a/spec/services/error_tracking/issue_update_service_spec.rb b/spec/services/error_tracking/issue_update_service_spec.rb
index ffb15901f80..a13d42ec141 100644
--- a/spec/services/error_tracking/issue_update_service_spec.rb
+++ b/spec/services/error_tracking/issue_update_service_spec.rb
@@ -5,7 +5,7 @@ require 'spec_helper'
describe ErrorTracking::IssueUpdateService do
include_context 'sentry error tracking context'
- let(:arguments) { { issue_id: 1234, status: 'resolved' } }
+ let(:arguments) { { issue_id: non_existing_record_id, status: 'resolved' } }
subject(:update_service) { described_class.new(project, user, arguments) }
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 69e47d890a5..c32bef5a1a5 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -824,14 +824,14 @@ describe Issues::UpdateService, :mailer do
context 'when moving an issue ' do
it 'raises an error for invalid move ids within a project' do
- opts = { move_between_ids: [9000, 9999] }
+ opts = { move_between_ids: [9000, non_existing_record_id] }
expect { described_class.new(issue.project, user, opts).execute(issue) }
.to raise_error(ActiveRecord::RecordNotFound)
end
it 'raises an error for invalid move ids within a group' do
- opts = { move_between_ids: [9000, 9999], board_group_id: create(:group).id }
+ opts = { move_between_ids: [9000, non_existing_record_id], board_group_id: create(:group).id }
expect { described_class.new(issue.project, user, opts).execute(issue) }
.to raise_error(ActiveRecord::RecordNotFound)
diff --git a/spec/services/labels/available_labels_service_spec.rb b/spec/services/labels/available_labels_service_spec.rb
index ce120344f16..3ba1add121d 100644
--- a/spec/services/labels/available_labels_service_spec.rb
+++ b/spec/services/labels/available_labels_service_spec.rb
@@ -65,7 +65,7 @@ describe Labels::AvailableLabelsService do
end
describe '#filter_labels_ids_in_param' do
- let(:label_ids) { labels.map(&:id).push(99999) }
+ let(:label_ids) { labels.map(&:id).push(non_existing_record_id) }
context 'when parent is a project' do
it 'returns only relevant label ids' do
diff --git a/spec/services/members/update_highest_role_service_spec.rb b/spec/services/members/update_highest_role_service_spec.rb
index b56a51f83f9..6fcb939203d 100644
--- a/spec/services/members/update_highest_role_service_spec.rb
+++ b/spec/services/members/update_highest_role_service_spec.rb
@@ -22,7 +22,9 @@ describe Members::UpdateHighestRoleService, :clean_gitlab_redis_shared_state do
expect(service.exclusive_lease.exists?).to be_truthy
end
- it 'schedules a job' do
+ it 'schedules a job in the future', :aggregate_failures do
+ expect(UpdateHighestRoleWorker).to receive(:perform_in).with(described_class::DELAY, user.id).and_call_original
+
Sidekiq::Testing.fake! do
expect { subject }.to change(UpdateHighestRoleWorker.jobs, :size).by(1)
end
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb
index 7ba069d1e39..a03b78a9a7a 100644
--- a/spec/services/notes/create_service_spec.rb
+++ b/spec/services/notes/create_service_spec.rb
@@ -50,7 +50,7 @@ describe Notes::CreateService do
end
it 'enqueues NewNoteWorker' do
- note = build(:note, id: 999, project: project)
+ note = build(:note, id: non_existing_record_id, project: project)
allow(Note).to receive(:new).with(opts) { note }
expect(NewNoteWorker).to receive(:perform_async).with(note.id)
diff --git a/spec/services/projects/participants_service_spec.rb b/spec/services/projects/participants_service_spec.rb
index 6eaf7a71b23..f4a04159db4 100644
--- a/spec/services/projects/participants_service_spec.rb
+++ b/spec/services/projects/participants_service_spec.rb
@@ -92,7 +92,7 @@ describe Projects::ParticipantsService do
let_it_be(:group_ancestor_owner) { create(:user) }
- before(:context) do
+ before_all do
public_group.add_owner public_group_owner
private_group.add_developer private_group_member
public_project.add_maintainer public_project_maintainer
@@ -102,7 +102,7 @@ describe Projects::ParticipantsService do
end
context 'when the private group is invited to the public project' do
- before(:context) do
+ before_all do
create(:project_group_link, group: private_group, project: public_project)
end
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb
index 7db94d4a4ac..6cc2e2b6abe 100644
--- a/spec/services/quick_actions/interpret_service_spec.rb
+++ b/spec/services/quick_actions/interpret_service_spec.rb
@@ -1218,7 +1218,7 @@ describe QuickActions::InterpretService do
end
it_behaves_like 'empty command' do
- let(:content) { "/copy_metadata imaginary#1234" }
+ let(:content) { "/copy_metadata imaginary##{non_existing_record_iid}" }
let(:issuable) { issue }
end
@@ -1253,7 +1253,7 @@ describe QuickActions::InterpretService do
end
it_behaves_like 'empty command', _('Failed to mark this issue as a duplicate because referenced issue was not found.') do
- let(:content) { "/duplicate imaginary#1234" }
+ let(:content) { "/duplicate imaginary##{non_existing_record_iid}" }
let(:issuable) { issue }
end
diff --git a/spec/services/repository_archive_clean_up_service_spec.rb b/spec/services/repository_archive_clean_up_service_spec.rb
index 60a14d7a107..c0b286ac675 100644
--- a/spec/services/repository_archive_clean_up_service_spec.rb
+++ b/spec/services/repository_archive_clean_up_service_spec.rb
@@ -9,7 +9,7 @@ describe RepositoryArchiveCleanUpService do
let(:sha) { "0" * 40 }
it 'removes outdated archives and directories in a new-style path' do
- in_directory_with_files("project-999/#{sha}", %w[tar tar.bz2 tar.gz zip], 3.hours) do |dirname, files|
+ in_directory_with_files("project-#{non_existing_record_id}/#{sha}", %w[tar tar.bz2 tar.gz zip], 3.hours) do |dirname, files|
service.execute
files.each { |filename| expect(File.exist?(filename)).to be_falsy }
@@ -19,7 +19,7 @@ describe RepositoryArchiveCleanUpService do
end
it 'does not remove directories when they contain outdated non-archives' do
- in_directory_with_files("project-999/#{sha}", %w[tar conf rb], 2.hours) do |dirname, files|
+ in_directory_with_files("project-#{non_existing_record_id}/#{sha}", %w[tar conf rb], 2.hours) do |dirname, files|
service.execute
expect(File.directory?(dirname)).to be_truthy
@@ -27,7 +27,7 @@ describe RepositoryArchiveCleanUpService do
end
it 'does not remove in-date archives in a new-style path' do
- in_directory_with_files("project-999/#{sha}", %w[tar tar.bz2 tar.gz zip], 1.hour) do |dirname, files|
+ in_directory_with_files("project-#{non_existing_record_id}/#{sha}", %w[tar tar.bz2 tar.gz zip], 1.hour) do |dirname, files|
service.execute
files.each { |filename| expect(File.exist?(filename)).to be_truthy }
diff --git a/spec/services/snippets/update_service_spec.rb b/spec/services/snippets/update_service_spec.rb
index 03dc857c666..9c88e741d51 100644
--- a/spec/services/snippets/update_service_spec.rb
+++ b/spec/services/snippets/update_service_spec.rb
@@ -141,14 +141,16 @@ describe Snippets::UpdateService do
end
it 'returns error when the commit action fails' do
+ error_message = 'foobar'
+
allow_next_instance_of(SnippetRepository) do |instance|
- allow(instance).to receive(:multi_files_action).and_raise(SnippetRepository::CommitError)
+ allow(instance).to receive(:multi_files_action).and_raise(SnippetRepository::CommitError, error_message)
end
response = subject
expect(response).to be_error
- expect(response.payload[:snippet].errors.full_messages).to eq ['Repository Error updating the snippet']
+ expect(response.payload[:snippet].errors[:repository].to_sentence).to eq error_message
end
end
@@ -168,12 +170,14 @@ describe Snippets::UpdateService do
end
context 'when an error is raised' do
+ let(:error_message) { 'foobar' }
+
before do
- allow(snippet.snippet_repository).to receive(:multi_files_action).and_raise(SnippetRepository::CommitError, 'foobar')
+ allow(snippet.snippet_repository).to receive(:multi_files_action).and_raise(SnippetRepository::CommitError, error_message)
end
it 'logs the error' do
- expect(Gitlab::AppLogger).to receive(:error).with('foobar')
+ expect(Gitlab::AppLogger).to receive(:error).with(error_message)
subject
end
@@ -182,7 +186,7 @@ describe Snippets::UpdateService do
response = subject
expect(response).to be_error
- expect(response.payload[:snippet].errors.full_messages).to eq ['Repository Error updating the snippet']
+ expect(response.payload[:snippet].errors[:repository].to_sentence).to eq error_message
end
end
diff --git a/spec/services/todos/destroy/entity_leave_service_spec.rb b/spec/services/todos/destroy/entity_leave_service_spec.rb
index ce809bbf6c5..45e3bf381fb 100644
--- a/spec/services/todos/destroy/entity_leave_service_spec.rb
+++ b/spec/services/todos/destroy/entity_leave_service_spec.rb
@@ -298,7 +298,7 @@ describe Todos::Destroy::EntityLeaveService do
context 'when entity was not found' do
it 'does not remove any todos' do
- expect { described_class.new(user.id, 999999, 'Group').execute }
+ expect { described_class.new(user.id, non_existing_record_id, 'Group').execute }
.not_to change { Todo.count }
end
end
diff --git a/spec/services/users/activity_service_spec.rb b/spec/services/users/activity_service_spec.rb
index f477eee1dd6..5f068a2033c 100644
--- a/spec/services/users/activity_service_spec.rb
+++ b/spec/services/users/activity_service_spec.rb
@@ -30,7 +30,7 @@ describe Users::ActivityService do
end
it 'tries to obtain ExclusiveLease' do
- expect(Gitlab::ExclusiveLease).to receive(:new).and_call_original
+ expect(Gitlab::ExclusiveLease).to receive(:new).with("activity_service:#{user.id}", anything).and_call_original
subject.execute
end
@@ -56,7 +56,7 @@ describe Users::ActivityService do
end
it 'does not try to obtain ExclusiveLease' do
- expect(Gitlab::ExclusiveLease).not_to receive(:new)
+ expect(Gitlab::ExclusiveLease).not_to receive(:new).with("activity_service:#{user.id}", anything)
subject.execute
end