diff options
Diffstat (limited to 'spec/services/notes')
-rw-r--r-- | spec/services/notes/build_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/notes/copy_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/notes/create_service_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/notes/quick_actions_service_spec.rb | 32 |
4 files changed, 31 insertions, 7 deletions
diff --git a/spec/services/notes/build_service_spec.rb b/spec/services/notes/build_service_spec.rb index deeab66c4e9..b7b08390dcd 100644 --- a/spec/services/notes/build_service_spec.rb +++ b/spec/services/notes/build_service_spec.rb @@ -173,7 +173,7 @@ RSpec.describe Notes::BuildService do let(:user) { create(:user) } it 'returns `Discussion to reply to cannot be found` error' do - expect(new_note.errors.first).to include("Discussion to reply to cannot be found") + expect(new_note.errors.added?(:base, "Discussion to reply to cannot be found")).to be true end end end diff --git a/spec/services/notes/copy_service_spec.rb b/spec/services/notes/copy_service_spec.rb index fd44aa7cf40..d9b6bafd7ff 100644 --- a/spec/services/notes/copy_service_spec.rb +++ b/spec/services/notes/copy_service_spec.rb @@ -7,7 +7,7 @@ RSpec.describe Notes::CopyService do let_it_be(:noteable) { create(:issue) } it 'validates that we cannot copy notes to the same Noteable' do - expect { described_class.new(noteable, noteable) }.to raise_error(ArgumentError) + expect { described_class.new(nil, noteable, noteable) }.to raise_error(ArgumentError) end end diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb index d28cb118529..31263feb947 100644 --- a/spec/services/notes/create_service_spec.rb +++ b/spec/services/notes/create_service_spec.rb @@ -176,7 +176,7 @@ RSpec.describe Notes::CreateService do end it 'note is associated with a note diff file' do - MergeRequests::MergeToRefService.new(merge_request.project, merge_request.author).execute(merge_request) + MergeRequests::MergeToRefService.new(project: merge_request.project, current_user: merge_request.author).execute(merge_request) note = described_class.new(project_with_repo, user, new_opts).execute diff --git a/spec/services/notes/quick_actions_service_spec.rb b/spec/services/notes/quick_actions_service_spec.rb index c098500b78a..9692bb08379 100644 --- a/spec/services/notes/quick_actions_service_spec.rb +++ b/spec/services/notes/quick_actions_service_spec.rb @@ -103,6 +103,30 @@ RSpec.describe Notes::QuickActionsService do expect(Timelog.last.note_id).to eq(note.id) end end + + context 'adds a system note' do + context 'when not specifying a date' do + let(:note_text) { "/spend 1h" } + + it 'does not include the date' do + _, update_params = service.execute(note) + service.apply_updates(update_params, note) + + expect(Note.last.note).to eq('added 1h of time spent') + end + end + + context 'when specifying a date' do + let(:note_text) { "/spend 1h 2020-01-01" } + + it 'does include the date' do + _, update_params = service.execute(note) + service.apply_updates(update_params, note) + + expect(Note.last.note).to eq('added 1h of time spent at 2020-01-01') + end + end + end end end @@ -214,25 +238,25 @@ RSpec.describe Notes::QuickActionsService do end end - describe '.noteable_update_service' do + describe '.noteable_update_service_class' do include_context 'note on noteable' it 'returns Issues::UpdateService for a note on an issue' do note = create(:note_on_issue, project: project) - expect(described_class.noteable_update_service(note)).to eq(Issues::UpdateService) + expect(described_class.noteable_update_service_class(note)).to eq(Issues::UpdateService) end it 'returns MergeRequests::UpdateService for a note on a merge request' do note = create(:note_on_merge_request, project: project) - expect(described_class.noteable_update_service(note)).to eq(MergeRequests::UpdateService) + expect(described_class.noteable_update_service_class(note)).to eq(MergeRequests::UpdateService) end it 'returns Commits::TagService for a note on a commit' do note = create(:note_on_commit, project: project) - expect(described_class.noteable_update_service(note)).to eq(Commits::TagService) + expect(described_class.noteable_update_service_class(note)).to eq(Commits::TagService) end end |