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

Reorganize SystemNoteService spec a bit

parent 3e8efce3
......@@ -6,6 +6,10 @@ describe SystemNoteService do
let(:noteable) { create(:issue, project: project) }
shared_examples_for 'a system note' do
it 'is valid' do
expect(subject).to be_valid
end
it 'sets the noteable model' do
expect(subject.noteable).to eq noteable
end
......@@ -24,13 +28,13 @@ describe SystemNoteService do
end
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(:new_commits) { noteable.commits }
let(:old_commits) { [] }
let(:oldrev) { nil }
subject { described_class.add_commits(noteable, project, author, new_commits, old_commits, oldrev) }
it_behaves_like 'a system note'
describe 'note body' do
......@@ -100,10 +104,10 @@ describe SystemNoteService do
end
describe '.change_assignee' do
let(:assignee) { create(:user) }
subject { described_class.change_assignee(noteable, project, author, assignee) }
let(:assignee) { create(:user) }
it_behaves_like 'a system note'
context 'when assignee added' do
......@@ -122,12 +126,12 @@ describe SystemNoteService do
end
describe '.change_label' do
subject { described_class.change_label(noteable, project, author, added, removed) }
let(:labels) { create_list(:label, 2) }
let(:added) { [] }
let(:removed) { [] }
subject { described_class.change_label(noteable, project, author, added, removed) }
it_behaves_like 'a system note'
context 'with added labels' do
......@@ -159,10 +163,10 @@ describe SystemNoteService do
end
describe '.change_milestone' do
let(:milestone) { create(:milestone, project: project) }
subject { described_class.change_milestone(noteable, project, author, milestone) }
let(:milestone) { create(:milestone, project: project) }
it_behaves_like 'a system note'
context 'when milestone added' do
......@@ -181,11 +185,11 @@ describe SystemNoteService do
end
describe '.change_status' do
subject { described_class.change_status(noteable, project, author, status, source) }
let(:status) { 'new_status' }
let(:source) { nil }
subject { described_class.change_status(noteable, project, author, status, source) }
it_behaves_like 'a system note'
context 'with a source' do
......@@ -204,10 +208,10 @@ describe SystemNoteService do
end
describe '.cross_reference' do
let(:mentioner) { create(:issue, project: project) }
subject { described_class.cross_reference(noteable, mentioner, author) }
let(:mentioner) { create(:issue, project: project) }
it_behaves_like 'a system note'
context 'when cross-reference disallowed' do
......@@ -245,7 +249,7 @@ describe SystemNoteService do
end
end
context 'same project' do
context 'within the same project' do
context 'from Commit' do
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