Do not override foreign attributes in note factory

This commit is contained in:
Grzegorz Bizon 2016-04-26 13:50:48 +02:00 committed by Robert Speicher
parent 0e613db76d
commit 21d0cddd45
2 changed files with 5 additions and 6 deletions

View File

@ -34,7 +34,7 @@ class Note < ActiveRecord::Base
validates :author, presence: true
validate unless: :for_commit? do |note|
unless note.noteable.try(:project) == project
unless note.noteable.try(:project) == note.project
errors.add(:invalid_project, 'Note and noteable project mismatch')
end
end

View File

@ -4,10 +4,10 @@ include ActionDispatch::TestProcess
FactoryGirl.define do
factory :note do
project
note "Note"
author
noteable { create(:issue) }
project { noteable.project }
noteable { create(:issue, project: project) }
factory :note_on_issue, aliases: [:votable_note]
factory :note_on_commit, traits: [:on_commit]
@ -20,7 +20,6 @@ FactoryGirl.define do
factory :upvote_note, traits: [:award, :upvote]
trait :on_commit do
project
noteable nil
commit_id RepoHelpers.sample_commit.id
noteable_type "Commit"
@ -31,11 +30,11 @@ FactoryGirl.define do
end
trait :on_merge_request do
noteable { create(:merge_request) }
noteable { create(:merge_request, project: project) }
end
trait :on_project_snippet do
noteable { create(:snippet) }
noteable { create(:snippet, project: project) }
end
trait :system do