Commit bf0b51d2 authored by Grzegorz Bizon's avatar Grzegorz Bizon Committed by Robert Speicher

Update note factory to include noteable association

parent 87c44b0e
......@@ -4,13 +4,14 @@ include ActionDispatch::TestProcess
FactoryGirl.define do
factory :note do
project
note "Note"
author
noteable { create(:issue) }
project { noteable.project }
factory :note_on_issue, aliases: [:votable_note]
factory :note_on_commit, traits: [:on_commit]
factory :note_on_commit_diff, traits: [:on_commit, :on_diff], class: LegacyDiffNote
factory :note_on_issue, traits: [:on_issue], aliases: [:votable_note]
factory :note_on_merge_request, traits: [:on_merge_request]
factory :note_on_merge_request_diff, traits: [:on_merge_request, :on_diff], class: LegacyDiffNote
factory :note_on_project_snippet, traits: [:on_project_snippet]
......@@ -20,6 +21,7 @@ FactoryGirl.define do
trait :on_commit do
project
noteable nil
commit_id RepoHelpers.sample_commit.id
noteable_type "Commit"
end
......@@ -29,19 +31,11 @@ FactoryGirl.define do
end
trait :on_merge_request do
project
noteable_id 1
noteable_type "MergeRequest"
end
trait :on_issue do
noteable_id 1
noteable_type "Issue"
noteable { create(:merge_request) }
end
trait :on_project_snippet do
noteable_id 1
noteable_type "Snippet"
noteable { create(:snippet) }
end
trait :system do
......
......@@ -89,8 +89,8 @@ describe Note, models: true do
end
describe "#all_references" do
let!(:note1) { create(:note) }
let!(:note2) { create(:note) }
let!(:note1) { create(:note_on_issue) }
let!(:note2) { create(:note_on_issue) }
it "reads the rendered note body from the cache" do
expect(Banzai::Renderer).to receive(:render).with(note1.note, pipeline: :note, cache_key: [note1, "note"], project: note1.project)
......@@ -102,7 +102,7 @@ describe Note, models: true do
end
describe '.search' do
let(:note) { create(:note, note: 'WoW') }
let(:note) { create(:note_on_issue, note: 'WoW') }
it 'returns notes with matching content' do
expect(described_class.search(note.note)).to eq([note])
......
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