diff options
author | Douwe Maan <douwe@selenight.nl> | 2016-08-13 19:58:51 +0300 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2016-08-17 01:42:34 +0300 |
commit | 029b7d2e9266246feff2f165a10b16be1d7fe88e (patch) | |
tree | 41581f4e08043530161c95aef9ccb533ec58a5e7 /spec/services/notes | |
parent | b2b1b4a4226267dbc442d62e19949909d9e58235 (diff) |
Fixed specs and fixes based on failing specs
Diffstat (limited to 'spec/services/notes')
-rw-r--r-- | spec/services/notes/create_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/notes/slash_commands_service_spec.rb | 33 |
2 files changed, 23 insertions, 12 deletions
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index 92dbccf0729..93885c84dc3 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -56,7 +56,7 @@ describe Notes::CreateService, services: true do it "creates regular note if emoji name is invalid" do opts = { - note: ':smile: moretext: ', + note: ':smile: moretext:', noteable_type: 'Issue', noteable_id: issue.id } diff --git a/spec/services/notes/slash_commands_service_spec.rb b/spec/services/notes/slash_commands_service_spec.rb index 5632ec09834..9a262fcf32f 100644 --- a/spec/services/notes/slash_commands_service_spec.rb +++ b/spec/services/notes/slash_commands_service_spec.rb @@ -12,7 +12,6 @@ describe Notes::SlashCommandsService, services: true do before do note.note = note_text - described_class.new(project, master).execute(note) end describe 'note with only command' do @@ -20,7 +19,10 @@ describe Notes::SlashCommandsService, services: true do let(:note_text) { %(/close\n/assign @#{assignee.username}") } it 'saves the note and does not alter the note text' do - expect(note.note).to eq note_text + content, command_params = service.extract_commands(note) + + expect(content).to eq note_text + expect(command_params).to be_empty end end end @@ -30,7 +32,10 @@ describe Notes::SlashCommandsService, services: true do let(:note_text) { %(HELLO\n/close\n/assign @#{assignee.username}\nWORLD) } it 'saves the note and does not alter the note text' do - expect(note.note).to eq note_text + content, command_params = service.extract_commands(note) + + expect(content).to eq note_text + expect(command_params).to be_empty end end end @@ -53,9 +58,10 @@ describe Notes::SlashCommandsService, services: true do end it 'closes noteable, sets labels, assigns, and sets milestone to noteable, and leave no note' do - described_class.new(project, master).execute(note) + content, command_params = service.extract_commands(note) + service.execute(command_params, note) - expect(note.note).to eq '' + expect(content).to eq '' expect(note.noteable).to be_closed expect(note.noteable.labels).to match_array(labels) expect(note.noteable.assignee).to eq(assignee) @@ -71,9 +77,10 @@ describe Notes::SlashCommandsService, services: true do let(:note_text) { '/open' } it 'opens the noteable, and leave no note' do - described_class.new(project, master).execute(note) + content, command_params = service.extract_commands(note) + service.execute(command_params, note) - expect(note.note).to eq '' + expect(content).to eq '' expect(note.noteable).to be_open end end @@ -86,9 +93,10 @@ describe Notes::SlashCommandsService, services: true do end it 'closes noteable, sets labels, assigns, and sets milestone to noteable' do - described_class.new(project, master).execute(note) + content, command_params = service.extract_commands(note) + service.execute(command_params, note) - expect(note.note).to eq "HELLO\nWORLD" + expect(content).to eq "HELLO\nWORLD" expect(note.noteable).to be_closed expect(note.noteable.labels).to match_array(labels) expect(note.noteable.assignee).to eq(assignee) @@ -104,9 +112,10 @@ describe Notes::SlashCommandsService, services: true do let(:note_text) { "HELLO\n/open\nWORLD" } it 'opens the noteable' do - described_class.new(project, master).execute(note) + content, command_params = service.extract_commands(note) + service.execute(command_params, note) - expect(note.note).to eq "HELLO\nWORLD" + expect(content).to eq "HELLO\nWORLD" expect(note.noteable).to be_open end end @@ -114,6 +123,8 @@ describe Notes::SlashCommandsService, services: true do end describe '#execute' do + let(:service) { described_class.new(project, master) } + it_behaves_like 'note on noteable that supports slash commands' do let(:note) { build(:note_on_issue, project: project) } end |