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:
authorDouwe Maan <douwe@selenight.nl>2016-08-18 02:58:52 +0300
committerDouwe Maan <douwe@selenight.nl>2016-08-18 22:29:48 +0300
commit9aa3edc61586fd79ce0760b7af0946ddfadaa65a (patch)
tree2267da8f1c32a0e9fda06e5fc55048614b644415 /spec
parent3e7eeefc939f2ce5234e36684c00b8d1c7e1c7dc (diff)
Remove unneeded aliases
Diffstat (limited to 'spec')
-rw-r--r--spec/features/issues/user_uses_slash_commands_spec.rb8
-rw-r--r--spec/features/merge_requests/user_uses_slash_commands_spec.rb4
-rw-r--r--spec/lib/gitlab/slash_commands/extractor_spec.rb16
-rw-r--r--spec/services/notes/slash_commands_service_spec.rb8
-rw-r--r--spec/services/slash_commands/interpret_service_spec.rb111
-rw-r--r--spec/support/issuable_create_service_slash_commands_shared_examples.rb4
6 files changed, 68 insertions, 83 deletions
diff --git a/spec/features/issues/user_uses_slash_commands_spec.rb b/spec/features/issues/user_uses_slash_commands_spec.rb
index 510f4254b54..2883e392694 100644
--- a/spec/features/issues/user_uses_slash_commands_spec.rb
+++ b/spec/features/issues/user_uses_slash_commands_spec.rb
@@ -22,11 +22,11 @@ feature 'Issues > User uses slash commands', feature: true, js: true do
it 'does not create a note, and sets the due date accordingly' do
page.within('.js-main-target-form') do
- fill_in 'note[note]', with: "/due_date 2016-08-28"
+ fill_in 'note[note]', with: "/due 2016-08-28"
click_button 'Comment'
end
- expect(page).not_to have_content '/due_date 2016-08-28'
+ expect(page).not_to have_content '/due 2016-08-28'
expect(page).to have_content 'Your commands have been executed!'
issue.reload
@@ -42,11 +42,11 @@ feature 'Issues > User uses slash commands', feature: true, js: true do
expect(issue.due_date).to eq Date.new(2016, 8, 28)
page.within('.js-main-target-form') do
- fill_in 'note[note]', with: "/clear_due_date"
+ fill_in 'note[note]', with: "/remove_due_date"
click_button 'Comment'
end
- expect(page).not_to have_content '/clear_due_date'
+ expect(page).not_to have_content '/remove_due_date'
expect(page).to have_content 'Your commands have been executed!'
issue.reload
diff --git a/spec/features/merge_requests/user_uses_slash_commands_spec.rb b/spec/features/merge_requests/user_uses_slash_commands_spec.rb
index 08c452c6e59..d9ef0d18074 100644
--- a/spec/features/merge_requests/user_uses_slash_commands_spec.rb
+++ b/spec/features/merge_requests/user_uses_slash_commands_spec.rb
@@ -22,11 +22,11 @@ feature 'Merge Requests > User uses slash commands', feature: true, js: true do
it 'does not recognize the command nor create a note' do
page.within('.js-main-target-form') do
- fill_in 'note[note]', with: "/due_date 2016-08-28"
+ fill_in 'note[note]', with: "/due 2016-08-28"
click_button 'Comment'
end
- expect(page).not_to have_content '/due_date 2016-08-28'
+ expect(page).not_to have_content '/due 2016-08-28'
end
end
end
diff --git a/spec/lib/gitlab/slash_commands/extractor_spec.rb b/spec/lib/gitlab/slash_commands/extractor_spec.rb
index 09f909dcdd2..1e4954c4af8 100644
--- a/spec/lib/gitlab/slash_commands/extractor_spec.rb
+++ b/spec/lib/gitlab/slash_commands/extractor_spec.rb
@@ -18,7 +18,7 @@ describe Gitlab::SlashCommands::Extractor do
it 'extracts command' do
msg, commands = extractor.extract_commands(original_msg)
- expect(commands).to eq [['open']]
+ expect(commands).to eq [['reopen']]
expect(msg).to eq final_msg
end
end
@@ -45,31 +45,31 @@ describe Gitlab::SlashCommands::Extractor do
describe 'command with no argument' do
context 'at the start of content' do
it_behaves_like 'command with no argument' do
- let(:original_msg) { "/open\nworld" }
+ let(:original_msg) { "/reopen\nworld" }
let(:final_msg) { "world" }
end
end
context 'in the middle of content' do
it_behaves_like 'command with no argument' do
- let(:original_msg) { "hello\n/open\nworld" }
+ let(:original_msg) { "hello\n/reopen\nworld" }
let(:final_msg) { "hello\nworld" }
end
end
context 'in the middle of a line' do
it 'does not extract command' do
- msg = "hello\nworld /open"
+ msg = "hello\nworld /reopen"
msg, commands = extractor.extract_commands(msg)
expect(commands).to be_empty
- expect(msg).to eq "hello\nworld /open"
+ expect(msg).to eq "hello\nworld /reopen"
end
end
context 'at the end of content' do
it_behaves_like 'command with no argument' do
- let(:original_msg) { "hello\n/open" }
+ let(:original_msg) { "hello\n/reopen" }
let(:final_msg) { "hello" }
end
end
@@ -170,10 +170,10 @@ describe Gitlab::SlashCommands::Extractor do
end
it 'extracts multiple commands' do
- msg = %(hello\n/power @user.name %9.10 ~"bar baz.2" label\nworld\n/open)
+ msg = %(hello\n/power @user.name %9.10 ~"bar baz.2" label\nworld\n/reopen)
msg, commands = extractor.extract_commands(msg)
- expect(commands).to eq [['power', '@user.name %9.10 ~"bar baz.2" label'], ['open']]
+ expect(commands).to eq [['power', '@user.name %9.10 ~"bar baz.2" label'], ['reopen']]
expect(msg).to eq "hello\nworld"
end
diff --git a/spec/services/notes/slash_commands_service_spec.rb b/spec/services/notes/slash_commands_service_spec.rb
index 9a262fcf32f..4f231aab161 100644
--- a/spec/services/notes/slash_commands_service_spec.rb
+++ b/spec/services/notes/slash_commands_service_spec.rb
@@ -69,12 +69,12 @@ describe Notes::SlashCommandsService, services: true do
end
end
- describe '/open' do
+ describe '/reopen' do
before do
note.noteable.close!
expect(note.noteable).to be_closed
end
- let(:note_text) { '/open' }
+ let(:note_text) { '/reopen' }
it 'opens the noteable, and leave no note' do
content, command_params = service.extract_commands(note)
@@ -104,12 +104,12 @@ describe Notes::SlashCommandsService, services: true do
end
end
- describe '/open' do
+ describe '/reopen' do
before do
note.noteable.close
expect(note.noteable).to be_closed
end
- let(:note_text) { "HELLO\n/open\nWORLD" }
+ let(:note_text) { "HELLO\n/reopen\nWORLD" }
it 'opens the noteable' do
content, command_params = service.extract_commands(note)
diff --git a/spec/services/slash_commands/interpret_service_spec.rb b/spec/services/slash_commands/interpret_service_spec.rb
index c20aa90ddde..a616275e883 100644
--- a/spec/services/slash_commands/interpret_service_spec.rb
+++ b/spec/services/slash_commands/interpret_service_spec.rb
@@ -16,8 +16,8 @@ describe SlashCommands::InterpretService, services: true do
let(:service) { described_class.new(project, user) }
let(:merge_request) { create(:merge_request, source_project: project) }
- shared_examples 'open command' do
- it 'returns state_event: "open" if content contains /open' do
+ shared_examples 'reopen command' do
+ it 'returns state_event: "reopen" if content contains /reopen' do
issuable.close!
_, updates = service.execute(content, issuable)
@@ -26,7 +26,7 @@ describe SlashCommands::InterpretService, services: true do
end
shared_examples 'close command' do
- it 'returns state_event: "close" if content contains /open' do
+ it 'returns state_event: "close" if content contains /close' do
_, updates = service.execute(content, issuable)
expect(updates).to eq(state_event: 'close')
@@ -67,8 +67,8 @@ describe SlashCommands::InterpretService, services: true do
end
end
- shared_examples 'clear_milestone command' do
- it 'populates milestone_id: nil if content contains /clear_milestone' do
+ shared_examples 'remove_milestone command' do
+ it 'populates milestone_id: nil if content contains /remove_milestone' do
issuable.update(milestone_id: milestone.id)
_, updates = service.execute(content, issuable)
@@ -95,8 +95,8 @@ describe SlashCommands::InterpretService, services: true do
end
end
- shared_examples 'clear_labels command' do
- it 'populates label_ids: [] if content contains /clear_labels' do
+ shared_examples 'unlabel command with no argument' do
+ it 'populates label_ids: [] if content contains /unlabel with no arguments' do
issuable.update(label_ids: [inprogress.id]) # populate the label
_, updates = service.execute(content, issuable)
@@ -104,6 +104,16 @@ describe SlashCommands::InterpretService, services: true do
end
end
+ shared_examples 'relabel command' do
+ it 'populates label_ids: [] if content contains /relabel' do
+ issuable.update(label_ids: [bug.id]) # populate the label
+ inprogress # populate the label
+ _, updates = service.execute(content, issuable)
+
+ expect(updates).to eq(label_ids: [inprogress.id])
+ end
+ end
+
shared_examples 'todo command' do
it 'populates todo_event: "add" if content contains /todo' do
_, updates = service.execute(content, issuable)
@@ -138,16 +148,16 @@ describe SlashCommands::InterpretService, services: true do
end
end
- shared_examples 'due_date command' do
- it 'populates due_date: Date.new(2016, 8, 28) if content contains /due_date 2016-08-28' do
+ shared_examples 'due command' do
+ it 'populates due_date: Date.new(2016, 8, 28) if content contains /due 2016-08-28' do
_, updates = service.execute(content, issuable)
expect(updates).to eq(due_date: defined?(expected_date) ? expected_date : Date.new(2016, 8, 28))
end
end
- shared_examples 'clear_due_date command' do
- it 'populates due_date: nil if content contains /clear_due_date' do
+ shared_examples 'remove_due_date command' do
+ it 'populates due_date: nil if content contains /remove_due_date' do
issuable.update(due_date: Date.today)
_, updates = service.execute(content, issuable)
@@ -163,19 +173,14 @@ describe SlashCommands::InterpretService, services: true do
end
end
- it_behaves_like 'open command' do
- let(:content) { '/open' }
+ it_behaves_like 'reopen command' do
+ let(:content) { '/reopen' }
let(:issuable) { issue }
end
- it_behaves_like 'open command' do
- let(:content) { '/open' }
- let(:issuable) { merge_request }
- end
-
- it_behaves_like 'open command' do
+ it_behaves_like 'reopen command' do
let(:content) { '/reopen' }
- let(:issuable) { issue }
+ let(:issuable) { merge_request }
end
it_behaves_like 'close command' do
@@ -233,11 +238,6 @@ describe SlashCommands::InterpretService, services: true do
let(:issuable) { merge_request }
end
- it_behaves_like 'unassign command' do
- let(:content) { '/remove_assignee' }
- let(:issuable) { issue }
- end
-
it_behaves_like 'milestone command' do
let(:content) { "/milestone %#{milestone.title}" }
let(:issuable) { issue }
@@ -248,19 +248,14 @@ describe SlashCommands::InterpretService, services: true do
let(:issuable) { merge_request }
end
- it_behaves_like 'clear_milestone command' do
- let(:content) { '/clear_milestone' }
+ it_behaves_like 'remove_milestone command' do
+ let(:content) { '/remove_milestone' }
let(:issuable) { issue }
end
- it_behaves_like 'clear_milestone command' do
- let(:content) { '/clear_milestone' }
- let(:issuable) { merge_request }
- end
-
- it_behaves_like 'clear_milestone command' do
+ it_behaves_like 'remove_milestone command' do
let(:content) { '/remove_milestone' }
- let(:issuable) { issue }
+ let(:issuable) { merge_request }
end
it_behaves_like 'label command' do
@@ -273,11 +268,6 @@ describe SlashCommands::InterpretService, services: true do
let(:issuable) { merge_request }
end
- it_behaves_like 'label command' do
- let(:content) { %(/labels ~"#{inprogress.title}" ~#{bug.title} ~unknown) }
- let(:issuable) { issue }
- end
-
it_behaves_like 'unlabel command' do
let(:content) { %(/unlabel ~"#{inprogress.title}") }
let(:issuable) { issue }
@@ -288,31 +278,26 @@ describe SlashCommands::InterpretService, services: true do
let(:issuable) { merge_request }
end
- it_behaves_like 'unlabel command' do
- let(:content) { %(/remove_labels ~"#{inprogress.title}") }
+ it_behaves_like 'unlabel command with no argument' do
+ let(:content) { %(/unlabel) }
let(:issuable) { issue }
end
- it_behaves_like 'unlabel command' do
- let(:content) { %(/remove_label ~"#{inprogress.title}") }
- let(:issuable) { issue }
+ it_behaves_like 'unlabel command with no argument' do
+ let(:content) { %(/unlabel) }
+ let(:issuable) { merge_request }
end
- it_behaves_like 'clear_labels command' do
- let(:content) { '/clear_labels' }
+ it_behaves_like 'relabel command' do
+ let(:content) { %(/relabel ~"#{inprogress.title}") }
let(:issuable) { issue }
end
- it_behaves_like 'clear_labels command' do
- let(:content) { '/clear_labels' }
+ it_behaves_like 'relabel command' do
+ let(:content) { %(/relabel ~"#{inprogress.title}") }
let(:issuable) { merge_request }
end
- it_behaves_like 'clear_labels command' do
- let(:content) { '/clear_label' }
- let(:issuable) { issue }
- end
-
it_behaves_like 'todo command' do
let(:content) { '/todo' }
let(:issuable) { issue }
@@ -353,46 +338,46 @@ describe SlashCommands::InterpretService, services: true do
let(:issuable) { merge_request }
end
- it_behaves_like 'due_date command' do
- let(:content) { '/due_date 2016-08-28' }
+ it_behaves_like 'due command' do
+ let(:content) { '/due 2016-08-28' }
let(:issuable) { issue }
end
- it_behaves_like 'due_date command' do
+ it_behaves_like 'due command' do
let(:content) { '/due tomorrow' }
let(:issuable) { issue }
let(:expected_date) { Date.tomorrow }
end
- it_behaves_like 'due_date command' do
+ it_behaves_like 'due command' do
let(:content) { '/due 5 days from now' }
let(:issuable) { issue }
let(:expected_date) { 5.days.from_now.to_date }
end
- it_behaves_like 'due_date command' do
+ it_behaves_like 'due command' do
let(:content) { '/due in 2 days' }
let(:issuable) { issue }
let(:expected_date) { 2.days.from_now.to_date }
end
it_behaves_like 'empty command' do
- let(:content) { '/due_date foo bar' }
+ let(:content) { '/due foo bar' }
let(:issuable) { issue }
end
it_behaves_like 'empty command' do
- let(:content) { '/due_date 2016-08-28' }
+ let(:content) { '/due 2016-08-28' }
let(:issuable) { merge_request }
end
- it_behaves_like 'clear_due_date command' do
- let(:content) { '/clear_due_date' }
+ it_behaves_like 'remove_due_date command' do
+ let(:content) { '/remove_due_date' }
let(:issuable) { issue }
end
it_behaves_like 'empty command' do
- let(:content) { '/clear_due_date' }
+ let(:content) { '/remove_due_date' }
let(:issuable) { merge_request }
end
end
diff --git a/spec/support/issuable_create_service_slash_commands_shared_examples.rb b/spec/support/issuable_create_service_slash_commands_shared_examples.rb
index bd0201c866f..5f9645ed44f 100644
--- a/spec/support/issuable_create_service_slash_commands_shared_examples.rb
+++ b/spec/support/issuable_create_service_slash_commands_shared_examples.rb
@@ -14,7 +14,7 @@ shared_examples 'new issuable record that supports slash commands' do
context 'with labels in command only' do
let(:example_params) do
{
- description: "/label ~#{labels.first.name} ~#{labels.second.name}\n/remove_label ~#{labels.third.name}"
+ description: "/label ~#{labels.first.name} ~#{labels.second.name}\n/unlabel ~#{labels.third.name}"
}
end
@@ -28,7 +28,7 @@ shared_examples 'new issuable record that supports slash commands' do
let(:example_params) do
{
label_ids: [labels.second.id],
- description: "/label ~#{labels.first.name}\n/remove_label ~#{labels.third.name}"
+ description: "/label ~#{labels.first.name}\n/unlabel ~#{labels.third.name}"
}
end