Commit 54db527b authored by Robert Speicher's avatar Robert Speicher

Reorganize SystemNoteService spec a bit

parent 3e8efce3
...@@ -6,6 +6,10 @@ describe SystemNoteService do ...@@ -6,6 +6,10 @@ describe SystemNoteService do
let(:noteable) { create(:issue, project: project) } let(:noteable) { create(:issue, project: project) }
shared_examples_for 'a system note' do shared_examples_for 'a system note' do
it 'is valid' do
expect(subject).to be_valid
end
it 'sets the noteable model' do it 'sets the noteable model' do
expect(subject.noteable).to eq noteable expect(subject.noteable).to eq noteable
end end
...@@ -24,13 +28,13 @@ describe SystemNoteService do ...@@ -24,13 +28,13 @@ describe SystemNoteService do
end end
describe '.add_commits' do describe '.add_commits' do
subject { described_class.add_commits(noteable, project, author, new_commits, old_commits, oldrev) }
let(:noteable) { create(:merge_request, source_project: project) } let(:noteable) { create(:merge_request, source_project: project) }
let(:new_commits) { noteable.commits } let(:new_commits) { noteable.commits }
let(:old_commits) { [] } let(:old_commits) { [] }
let(:oldrev) { nil } let(:oldrev) { nil }
subject { described_class.add_commits(noteable, project, author, new_commits, old_commits, oldrev) }
it_behaves_like 'a system note' it_behaves_like 'a system note'
describe 'note body' do describe 'note body' do
...@@ -100,10 +104,10 @@ describe SystemNoteService do ...@@ -100,10 +104,10 @@ describe SystemNoteService do
end end
describe '.change_assignee' do describe '.change_assignee' do
let(:assignee) { create(:user) }
subject { described_class.change_assignee(noteable, project, author, assignee) } subject { described_class.change_assignee(noteable, project, author, assignee) }
let(:assignee) { create(:user) }
it_behaves_like 'a system note' it_behaves_like 'a system note'
context 'when assignee added' do context 'when assignee added' do
...@@ -122,12 +126,12 @@ describe SystemNoteService do ...@@ -122,12 +126,12 @@ describe SystemNoteService do
end end
describe '.change_label' do describe '.change_label' do
subject { described_class.change_label(noteable, project, author, added, removed) }
let(:labels) { create_list(:label, 2) } let(:labels) { create_list(:label, 2) }
let(:added) { [] } let(:added) { [] }
let(:removed) { [] } let(:removed) { [] }
subject { described_class.change_label(noteable, project, author, added, removed) }
it_behaves_like 'a system note' it_behaves_like 'a system note'
context 'with added labels' do context 'with added labels' do
...@@ -159,10 +163,10 @@ describe SystemNoteService do ...@@ -159,10 +163,10 @@ describe SystemNoteService do
end end
describe '.change_milestone' do describe '.change_milestone' do
let(:milestone) { create(:milestone, project: project) }
subject { described_class.change_milestone(noteable, project, author, milestone) } subject { described_class.change_milestone(noteable, project, author, milestone) }
let(:milestone) { create(:milestone, project: project) }
it_behaves_like 'a system note' it_behaves_like 'a system note'
context 'when milestone added' do context 'when milestone added' do
...@@ -181,11 +185,11 @@ describe SystemNoteService do ...@@ -181,11 +185,11 @@ describe SystemNoteService do
end end
describe '.change_status' do describe '.change_status' do
subject { described_class.change_status(noteable, project, author, status, source) }
let(:status) { 'new_status' } let(:status) { 'new_status' }
let(:source) { nil } let(:source) { nil }
subject { described_class.change_status(noteable, project, author, status, source) }
it_behaves_like 'a system note' it_behaves_like 'a system note'
context 'with a source' do context 'with a source' do
...@@ -204,10 +208,10 @@ describe SystemNoteService do ...@@ -204,10 +208,10 @@ describe SystemNoteService do
end end
describe '.cross_reference' do describe '.cross_reference' do
let(:mentioner) { create(:issue, project: project) }
subject { described_class.cross_reference(noteable, mentioner, author) } subject { described_class.cross_reference(noteable, mentioner, author) }
let(:mentioner) { create(:issue, project: project) }
it_behaves_like 'a system note' it_behaves_like 'a system note'
context 'when cross-reference disallowed' do context 'when cross-reference disallowed' do
...@@ -245,7 +249,7 @@ describe SystemNoteService do ...@@ -245,7 +249,7 @@ describe SystemNoteService do
end end
end end
context 'same project' do context 'within the same project' do
context 'from Commit' do context 'from Commit' do
let(:mentioner) { project.repository.commit } let(:mentioner) { project.repository.commit }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment