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
path: root/spec
diff options
context:
space:
mode:
authorRyan Scott <ryan@ryan-scott.me>2017-04-05 05:31:48 +0300
committerSean McGivern <sean@gitlab.com>2017-07-20 17:33:24 +0300
commit7e3d34595c3e090fe505b4fbd49cde2a303b1b6f (patch)
tree17a81203a5e9b224c4974a991c5fce81b44953b4 /spec
parent01c9488f4a559063eba77074ba2d369de87b8018 (diff)
Changes based on MR feedback.
Marking an issue as a duplicate will now also add an upvote on behalf of the author on the original issue.
Diffstat (limited to 'spec')
-rw-r--r--spec/features/issues/user_uses_slash_commands_spec.rb8
-rw-r--r--spec/services/issues/update_service_spec.rb48
-rw-r--r--spec/services/quick_actions/interpret_service_spec.rb52
3 files changed, 54 insertions, 54 deletions
diff --git a/spec/features/issues/user_uses_slash_commands_spec.rb b/spec/features/issues/user_uses_slash_commands_spec.rb
index d5de060b033..28f27c76e35 100644
--- a/spec/features/issues/user_uses_slash_commands_spec.rb
+++ b/spec/features/issues/user_uses_slash_commands_spec.rb
@@ -147,9 +147,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do
expect(page).to have_content 'Commands applied'
expect(page).to have_content "marked this issue as a duplicate of #{original_issue.to_reference}"
- issue.reload
-
- expect(issue.closed?).to be_truthy
+ expect(issue.reload).to be_closed
end
end
@@ -169,9 +167,7 @@ feature 'Issues > User uses quick actions', feature: true, js: true do
expect(page).not_to have_content 'Commands applied'
expect(page).not_to have_content "marked this issue as a duplicate of #{original_issue.to_reference}"
- issue.reload
-
- expect(issue.closed?).to be_falsey
+ expect(issue.reload).to be_open
end
end
end
diff --git a/spec/services/issues/update_service_spec.rb b/spec/services/issues/update_service_spec.rb
index 3e7abf85106..e7f3ab93395 100644
--- a/spec/services/issues/update_service_spec.rb
+++ b/spec/services/issues/update_service_spec.rb
@@ -492,57 +492,43 @@ describe Issues::UpdateService, services: true do
end
context 'duplicate issue' do
- let(:issues_finder) { spy(:issues_finder) }
- let(:close_service) { spy(:close_service) }
-
- before do
- allow(IssuesFinder).to receive(:new).and_return(issues_finder)
- allow(Issues::CloseService).to receive(:new).and_return(close_service)
- allow(SystemNoteService).to receive(:cross_reference)
- allow(SystemNoteService).to receive(:mark_duplicate_issue)
- end
+ let(:original_issue) { create(:issue, project: project) }
context 'invalid original_issue_id' do
- let(:original_issue_id) { double }
- before { update_issue({ original_issue_id: original_issue_id }) }
-
- it 'finds the root issue' do
- expect(issues_finder).to have_received(:find).with(original_issue_id)
+ before do
+ update_issue(original_issue_id: 123456789)
end
it 'does not close the issue' do
- expect(close_service).not_to have_received(:execute)
+ expect(issue.reload).not_to be_closed
end
- it 'does not create system notes' do
- expect(SystemNoteService).not_to have_received(:cross_reference)
- expect(SystemNoteService).not_to have_received(:mark_duplicate_issue)
+ it 'does not create a system note' do
+ note = find_note("marked this issue as a duplicate of #{original_issue.to_reference}")
+ expect(note).to be_nil
+ end
+
+ it 'does not upvote the issue on behalf of the author' do
+ expect(original_issue).not_to be_awarded_emoji(AwardEmoji::UPVOTE_NAME, issue.author)
end
end
context 'valid original_issue_id' do
- let(:original_issue) { create(:issue, project: project) }
- let(:original_issue_id) { double }
-
before do
- allow(issues_finder).to receive(:find).and_return(original_issue)
- update_issue({ original_issue_id: original_issue_id })
- end
-
- it 'finds the root issue' do
- expect(issues_finder).to have_received(:find).with(original_issue_id)
+ update_issue(original_issue_id: original_issue.id)
end
it 'closes the issue' do
- expect(close_service).to have_received(:execute).with(issue)
+ expect(issue.reload).to be_closed
end
it 'creates a system note that this issue is a duplicate' do
- expect(SystemNoteService).to have_received(:mark_duplicate_issue).with(issue, project, user, original_issue)
+ note = find_note("marked this issue as a duplicate of #{original_issue.to_reference}")
+ expect(note).not_to be_nil
end
- it 'creates a cross reference system note in the other issue' do
- expect(SystemNoteService).to have_received(:cross_reference).with(original_issue, issue, user)
+ it 'upvotes the issue on behalf of the author' do
+ expect(original_issue).to be_awarded_emoji(AwardEmoji::UPVOTE_NAME, issue.author)
end
end
end
diff --git a/spec/services/quick_actions/interpret_service_spec.rb b/spec/services/quick_actions/interpret_service_spec.rb
index 3e4aa66756c..1d60b74e566 100644
--- a/spec/services/quick_actions/interpret_service_spec.rb
+++ b/spec/services/quick_actions/interpret_service_spec.rb
@@ -262,8 +262,6 @@ describe QuickActions::InterpretService, services: true do
end
shared_examples 'duplicate command' do
- let(:issue_duplicate) { create(:issue, project: project) }
-
it 'fetches issue and populates original_issue_id if content contains /duplicate issue_reference' do
issue_duplicate # populate the issue
_, updates = service.execute(content, issuable)
@@ -655,24 +653,44 @@ describe QuickActions::InterpretService, services: true do
let(:issuable) { issue }
end
- it_behaves_like 'duplicate command' do
- let(:content) { "/duplicate #{issue_duplicate.to_reference}" }
- let(:issuable) { issue }
- end
+ context '/duplicate command' do
+ it_behaves_like 'duplicate command' do
+ let(:issue_duplicate) { create(:issue, project: project) }
+ let(:content) { "/duplicate #{issue_duplicate.to_reference}" }
+ let(:issuable) { issue }
+ end
- it_behaves_like 'empty command' do
- let(:content) { '/duplicate #{issue.to_reference}' }
- let(:issuable) { issue }
- end
+ it_behaves_like 'empty command' do
+ let(:content) { "/duplicate #{issue.to_reference}" }
+ let(:issuable) { issue }
+ end
- it_behaves_like 'empty command' do
- let(:content) { '/duplicate' }
- let(:issuable) { issue }
- end
+ it_behaves_like 'empty command' do
+ let(:content) { '/duplicate' }
+ let(:issuable) { issue }
+ end
- it_behaves_like 'empty command' do
- let(:content) { '/duplicate imaginary#1234' }
- let(:issuable) { issue }
+ context 'cross project references' do
+ it_behaves_like 'duplicate command' do
+ let(:other_project) { create(:empty_project, :public) }
+ let(:issue_duplicate) { create(:issue, project: other_project) }
+ let(:content) { "/duplicate #{issue_duplicate.to_reference(project)}" }
+ let(:issuable) { issue }
+ end
+
+ it_behaves_like 'empty command' do
+ let(:content) { '/duplicate imaginary#1234' }
+ let(:issuable) { issue }
+ end
+
+ it_behaves_like 'empty command' do
+ let(:other_project) { create(:empty_project, :private) }
+ let(:issue_duplicate) { create(:issue, project: other_project) }
+
+ let(:content) { "/duplicate #{issue_duplicate.to_reference(project)}" }
+ let(:issuable) { issue }
+ end
+ end
end
context 'when current_user cannot :admin_issue' do