diff options
Diffstat (limited to 'spec/services')
-rw-r--r-- | spec/services/issues/create_service_spec.rb | 17 | ||||
-rw-r--r-- | spec/services/merge_requests/merge_service_spec.rb | 17 | ||||
-rw-r--r-- | spec/services/merge_requests/post_merge_service_spec.rb | 1 | ||||
-rw-r--r-- | spec/services/merge_requests/squash_service_spec.rb | 18 | ||||
-rw-r--r-- | spec/services/snippets/create_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/spam/spam_check_service_spec.rb | 8 |
6 files changed, 14 insertions, 49 deletions
diff --git a/spec/services/issues/create_service_spec.rb b/spec/services/issues/create_service_spec.rb index 09fff389cec..a316c8a4219 100644 --- a/spec/services/issues/create_service_spec.rb +++ b/spec/services/issues/create_service_spec.rb @@ -383,20 +383,21 @@ describe Issues::CreateService do context 'when recaptcha was verified' do let(:log_user) { user } let(:spam_logs) { create_list(:spam_log, 2, user: log_user, title: 'Awesome issue') } + let(:target_spam_log) { spam_logs.last } before do opts[:recaptcha_verified] = true - opts[:spam_log_id] = spam_logs.last.id + opts[:spam_log_id] = target_spam_log.id expect(Spam::AkismetService).not_to receive(:new) end - it 'does no mark an issue as a spam ' do + it 'does not mark an issue as spam' do expect(issue).not_to be_spam end - it 'an issue is valid ' do - expect(issue.valid?).to be_truthy + it 'issue is valid ' do + expect(issue).to be_valid end it 'does not assign a spam_log to an issue' do @@ -431,7 +432,7 @@ describe Issues::CreateService do end context 'when issuables_recaptcha_enabled feature flag is true' do - it 'marks an issue as a spam ' do + it 'marks an issue as spam' do expect(issue).to be_spam end @@ -444,7 +445,7 @@ describe Issues::CreateService do .to have_spam_log(title: issue.title, description: issue.description, user_id: user.id, noteable_type: 'Issue') end - it 'assigns a spam_log to an issue' do + it 'assigns a spam_log to the issue' do expect(issue.spam_log).to eq(SpamLog.last) end end @@ -454,7 +455,7 @@ describe Issues::CreateService do stub_feature_flags(allow_possible_spam: true) end - it 'does not mark an issue as a spam ' do + it 'does not mark an issue as spam' do expect(issue).not_to be_spam end @@ -480,7 +481,7 @@ describe Issues::CreateService do end end - it 'does not mark an issue as a spam ' do + it 'does not mark an issue as spam' do expect(issue).not_to be_spam end diff --git a/spec/services/merge_requests/merge_service_spec.rb b/spec/services/merge_requests/merge_service_spec.rb index 2283f480895..fa7f745d8a0 100644 --- a/spec/services/merge_requests/merge_service_spec.rb +++ b/spec/services/merge_requests/merge_service_spec.rb @@ -47,23 +47,6 @@ describe MergeRequests::MergeService do expect(note.note).to include 'merged' end - it 'is idempotent' do - repository = project.repository - commit_count = repository.commit_count - merge_commit = merge_request.merge_commit.id - - # a first invocation of execute is performed on the before block - service.execute(merge_request) - - expect(merge_request.merge_error).to be_falsey - expect(merge_request).to be_valid - expect(merge_request).to be_merged - - expect(repository.commits_by(oids: [merge_commit]).size).to eq(1) - expect(repository.commit_count).to eq(commit_count) - expect(merge_request.in_progress_merge_commit_sha).to be_nil - end - context 'when squashing' do let(:merge_params) do { commit_message: 'Merge commit message', diff --git a/spec/services/merge_requests/post_merge_service_spec.rb b/spec/services/merge_requests/post_merge_service_spec.rb index 06735d25ad5..fff6ddf3928 100644 --- a/spec/services/merge_requests/post_merge_service_spec.rb +++ b/spec/services/merge_requests/post_merge_service_spec.rb @@ -17,6 +17,7 @@ describe MergeRequests::PostMergeService do it 'refreshes the number of open merge requests for a valid MR', :use_clean_rails_memory_store_caching do # Cache the counter before the MR changed state. project.open_merge_requests_count + merge_request.update!(state: 'merged') service = described_class.new(project, user, {}) diff --git a/spec/services/merge_requests/squash_service_spec.rb b/spec/services/merge_requests/squash_service_spec.rb index 4636f26bb16..cb278eec692 100644 --- a/spec/services/merge_requests/squash_service_spec.rb +++ b/spec/services/merge_requests/squash_service_spec.rb @@ -137,24 +137,6 @@ describe MergeRequests::SquashService do include_examples 'the squash succeeds' end - context 'when the merge request has already been merged' do - let(:merge_request) { merge_request_with_one_commit } - - it 'checks the side-effects for multiple calls' do - merge_request.mark_as_merged - - expect(service).to be_idempotent - expect { IdempotentWorkerHelper::WORKER_EXEC_TIMES.times { service.execute } }.not_to raise_error - end - - it 'idempotently returns a success' do - merge_request.mark_as_merged - result = service.execute - - expect(result).to match(status: :success, squash_sha: merge_request.diff_head_sha) - end - end - context 'git errors' do let(:merge_request) { merge_request_with_only_new_files } let(:error) { 'A test error' } diff --git a/spec/services/snippets/create_service_spec.rb b/spec/services/snippets/create_service_spec.rb index 8c91763cc48..690aa2c066e 100644 --- a/spec/services/snippets/create_service_spec.rb +++ b/spec/services/snippets/create_service_spec.rb @@ -76,7 +76,7 @@ describe Snippets::CreateService do shared_examples 'spam check is performed' do shared_examples 'marked as spam' do - it 'marks a snippet as spam ' do + it 'marks a snippet as spam' do expect(snippet).to be_spam end diff --git a/spec/services/spam/spam_check_service_spec.rb b/spec/services/spam/spam_check_service_spec.rb index 3ebde2a92c6..3d0cb1447bd 100644 --- a/spec/services/spam/spam_check_service_spec.rb +++ b/spec/services/spam/spam_check_service_spec.rb @@ -91,9 +91,7 @@ describe Spam::SpamCheckService do end it 'updates spam log' do - subject - - expect(existing_spam_log.reload.recaptcha_verified).to be_truthy + expect { subject }.to change { existing_spam_log.reload.recaptcha_verified }.from(false).to(true) end end @@ -137,7 +135,7 @@ describe Spam::SpamCheckService do it 'marks as spam' do subject - expect(issue.reload.spam).to be_truthy + expect(issue).to be_spam end end @@ -147,7 +145,7 @@ describe Spam::SpamCheckService do it 'does not mark as spam' do subject - expect(issue.spam).to be_falsey + expect(issue).not_to be_spam end end end |