diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-05-04 12:17:16 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-05-29 22:03:00 +0300 |
commit | fc57d36018a23c15da013bebf42d51f7a8e9a955 (patch) | |
tree | 8b0b5331eaf4a4925e68562418b7027bfd64eff0 /spec/models | |
parent | 99ef3a84b558e7b51bce7cbb11a6e235a6cc310b (diff) |
Minor changes in note validation specs
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/concerns/issuable_spec.rb | 6 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/note_spec.rb | 11 |
3 files changed, 10 insertions, 9 deletions
diff --git a/spec/models/concerns/issuable_spec.rb b/spec/models/concerns/issuable_spec.rb index 331ebaf4ac4..70bbe633269 100644 --- a/spec/models/concerns/issuable_spec.rb +++ b/spec/models/concerns/issuable_spec.rb @@ -228,9 +228,11 @@ describe Issue, "Issuable" do end describe "votes" do + let(:project) { issue.project } + before do - issue.notes.awards.create!(note: "thumbsup", author: user, project: issue.project) - issue.notes.awards.create!(note: "thumbsdown", author: user, project: issue.project) + issue.notes.awards.create!(note: "thumbsup", author: user, project: project) + issue.notes.awards.create!(note: "thumbsdown", author: user, project: project) end it "returns correct values" do diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 20e383e03b4..4b67c2facf3 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -120,7 +120,6 @@ describe MergeRequest, models: true do before do allow(merge_request).to receive(:commits) { [merge_request.source_project.repository.commit] } create(:note_on_commit, commit_id: merge_request.commits.first.id, - noteable_type: 'Commit', project: merge_request.project) create(:note, noteable: merge_request, project: merge_request.project) end @@ -132,7 +131,6 @@ describe MergeRequest, models: true do it "should include notes for commits from target project as well" do create(:note_on_commit, commit_id: merge_request.commits.first.id, - noteable_type: 'Commit', project: merge_request.target_project) expect(merge_request.commits).not_to be_empty diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index 20d40c47aa6..e1b81b23d4b 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -13,29 +13,30 @@ describe Note, models: true do it { is_expected.to validate_presence_of(:note) } it { is_expected.to validate_presence_of(:project) } - context 'when note is comment on commit' do + context 'when note is on commit' do before { allow(subject).to receive(:for_commit?).and_return(true) } it { is_expected.to validate_presence_of(:commit_id) } it { is_expected.to_not validate_presence_of(:noteable_id) } end - context 'when note is not comment on commit' do + context 'when note is not on commit' do before { allow(subject).to receive(:for_commit?).and_return(false) } it { is_expected.to_not validate_presence_of(:commit_id) } it { is_expected.to validate_presence_of(:noteable_id) } end - context 'when noteable and note project is different' do + context 'when noteable and note project differ' do subject do - build(:note, noteable: create(:issue), project: create(:project)) + build(:note, noteable: build_stubbed(:issue), + project: build_stubbed(:project)) end it { is_expected.to be_invalid } end - context 'when noteable and note project is the same one' do + context 'when noteable and note project are the same' do subject { create(:note) } it { is_expected.to be_valid } end |