summaryrefslogtreecommitdiff
path: root/spec/services/notes
diff options
context:
space:
mode:
authorJarka Kadlecova <jarka@gitlab.com>2017-01-05 14:36:06 +0100
committerJarka Kadlecova <jarka@gitlab.com>2017-01-18 18:38:17 -0500
commitd6b11dafd37e78c12c982c42f274928293cdfa53 (patch)
treee20c62bc3b11b77e366bce2251146d5f5ec86e0c /spec/services/notes
parent270dc22658424ee7f279db99e56c6fc69acd3eb7 (diff)
downloadgitlab-ce-d6b11dafd37e78c12c982c42f274928293cdfa53.tar.gz
Support notes without project
Diffstat (limited to 'spec/services/notes')
-rw-r--r--spec/services/notes/create_service_spec.rb35
1 files changed, 31 insertions, 4 deletions
diff --git a/spec/services/notes/create_service_spec.rb b/spec/services/notes/create_service_spec.rb
index b0cc3ce5f5a..b99cdfbae2d 100644
--- a/spec/services/notes/create_service_spec.rb
+++ b/spec/services/notes/create_service_spec.rb
@@ -32,9 +32,15 @@ describe Notes::CreateService, services: true do
expect(note.note).to eq(opts[:note])
end
+ it 'note belongs to the correct project' do
+ note = Notes::CreateService.new(project, user, opts).execute
+
+ expect(note.project).to eq(project)
+ end
+
it 'TodoService#new_note is called' do
- note = build(:note)
- allow(project).to receive_message_chain(:notes, :new).with(opts) { note }
+ note = build(:note, project: project)
+ allow(Note).to receive(:new).with(opts) { note }
expect_any_instance_of(TodoService).to receive(:new_note).with(note, user)
@@ -42,8 +48,8 @@ describe Notes::CreateService, services: true do
end
it 'enqueues NewNoteWorker' do
- note = build(:note, id: 999)
- allow(project).to receive_message_chain(:notes, :new).with(opts) { note }
+ note = build(:note, id: 999, project: project)
+ allow(Note).to receive(:new).with(opts) { note }
expect(NewNoteWorker).to receive(:perform_async).with(note.id)
@@ -75,6 +81,27 @@ describe Notes::CreateService, services: true do
end
end
end
+
+ describe 'personal snippet note' do
+ subject { described_class.new(nil, user, params).execute }
+
+ let(:snippet) { create(:personal_snippet) }
+ let(:params) do
+ { note: 'comment', noteable_type: 'Snippet', noteable_id: snippet.id }
+ end
+
+ it 'returns a valid note' do
+ expect(subject).to be_valid
+ end
+
+ it 'returns a persisted note' do
+ expect(subject).to be_persisted
+ end
+
+ it 'note has valid content' do
+ expect(subject.note).to eq(params[:note])
+ end
+ end
end
describe "award emoji" do