Commit 37b45031 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'rs-empty_project-for-associations' into 'master'

Factories with a project association use `:empty_project` by default

See merge request !8770
parents 3a0d9314 c1743ba4
...@@ -30,14 +30,13 @@ class Spinach::Features::RevertMergeRequests < Spinach::FeatureSteps ...@@ -30,14 +30,13 @@ class Spinach::Features::RevertMergeRequests < Spinach::FeatureSteps
end end
step 'I am signed in as a developer of the project' do step 'I am signed in as a developer of the project' do
@user = create(:user) { |u| @project.add_developer(u) }
login_as(@user) login_as(@user)
end end
step 'There is an open Merge Request' do step 'There is an open Merge Request' do
@user = create(:user) @merge_request = create(:merge_request, :with_diffs, :simple)
@project = create(:project, :public, :repository) @project = @merge_request.source_project
@project_member = create(:project_member, :developer, user: @user, project: @project)
@merge_request = create(:merge_request, :with_diffs, :simple, source_project: @project)
end end
step 'I should see a revert error' do step 'I should see a revert error' do
......
FactoryGirl.define do FactoryGirl.define do
factory :deploy_keys_project do factory :deploy_keys_project do
deploy_key deploy_key
project project factory: :empty_project
end end
end end
FactoryGirl.define do FactoryGirl.define do
factory :event do factory :event do
project project factory: :empty_project
author factory: :user author factory: :user
factory :closed_issue_event do factory :closed_issue_event do
......
FactoryGirl.define do FactoryGirl.define do
factory :file_uploader do factory :file_uploader do
project project factory: :empty_project
secret nil secret nil
transient do transient do
......
...@@ -6,7 +6,7 @@ FactoryGirl.define do ...@@ -6,7 +6,7 @@ FactoryGirl.define do
factory :issue do factory :issue do
title title
author author
project project factory: :empty_project
trait :confidential do trait :confidential do
confidential true confidential true
......
...@@ -2,7 +2,7 @@ FactoryGirl.define do ...@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :label, class: ProjectLabel do factory :label, class: ProjectLabel do
sequence(:title) { |n| "label#{n}" } sequence(:title) { |n| "label#{n}" }
color "#990000" color "#990000"
project project factory: :empty_project
transient do transient do
priority nil priority nil
......
...@@ -2,7 +2,7 @@ FactoryGirl.define do ...@@ -2,7 +2,7 @@ FactoryGirl.define do
factory :merge_request do factory :merge_request do
title title
author author
source_project factory: :project association :source_project, :repository, factory: :project
target_project { source_project } target_project { source_project }
# $ git log --pretty=oneline feature..master # $ git log --pretty=oneline feature..master
......
FactoryGirl.define do FactoryGirl.define do
factory :milestone do factory :milestone do
title title
project project factory: :empty_project
trait :active do trait :active do
state "active" state "active"
......
...@@ -4,7 +4,7 @@ include ActionDispatch::TestProcess ...@@ -4,7 +4,7 @@ include ActionDispatch::TestProcess
FactoryGirl.define do FactoryGirl.define do
factory :note do factory :note do
project project factory: :empty_project
note "Note" note "Note"
author author
on_issue on_issue
...@@ -16,10 +16,16 @@ FactoryGirl.define do ...@@ -16,10 +16,16 @@ FactoryGirl.define do
factory :note_on_personal_snippet, traits: [:on_personal_snippet] factory :note_on_personal_snippet, traits: [:on_personal_snippet]
factory :system_note, traits: [:system] factory :system_note, traits: [:system]
factory :legacy_diff_note_on_commit, traits: [:on_commit, :legacy_diff_note], class: LegacyDiffNote factory :legacy_diff_note_on_commit, traits: [:on_commit, :legacy_diff_note], class: LegacyDiffNote do
factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote association :project, :repository
end
factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote do
association :project, :repository
end
factory :diff_note_on_merge_request, traits: [:on_merge_request], class: DiffNote do factory :diff_note_on_merge_request, traits: [:on_merge_request], class: DiffNote do
association :project, :repository
position do position do
Gitlab::Diff::Position.new( Gitlab::Diff::Position.new(
old_path: "files/ruby/popen.rb", old_path: "files/ruby/popen.rb",
...@@ -37,6 +43,7 @@ FactoryGirl.define do ...@@ -37,6 +43,7 @@ FactoryGirl.define do
end end
factory :diff_note_on_commit, traits: [:on_commit], class: DiffNote do factory :diff_note_on_commit, traits: [:on_commit], class: DiffNote do
association :project, :repository
position do position do
Gitlab::Diff::Position.new( Gitlab::Diff::Position.new(
old_path: "files/ruby/popen.rb", old_path: "files/ruby/popen.rb",
...@@ -49,6 +56,7 @@ FactoryGirl.define do ...@@ -49,6 +56,7 @@ FactoryGirl.define do
end end
trait :on_commit do trait :on_commit do
association :project, :repository
noteable nil noteable nil
noteable_type 'Commit' noteable_type 'Commit'
noteable_id nil noteable_id nil
......
FactoryGirl.define do FactoryGirl.define do
factory :project_group_link do factory :project_group_link do
project project factory: :empty_project
group group
end end
end end
FactoryGirl.define do FactoryGirl.define do
factory :project_member do factory :project_member do
user user
project project factory: :empty_project
master master
trait(:guest) { access_level ProjectMember::GUEST } trait(:guest) { access_level ProjectMember::GUEST }
......
FactoryGirl.define do FactoryGirl.define do
factory :project_snippet, parent: :snippet, class: :ProjectSnippet do factory :project_snippet, parent: :snippet, class: :ProjectSnippet do
project project factory: :empty_project
end end
end end
...@@ -2,6 +2,6 @@ FactoryGirl.define do ...@@ -2,6 +2,6 @@ FactoryGirl.define do
factory :release do factory :release do
tag "v1.1.0" tag "v1.1.0"
description "Awesome release" description "Awesome release"
project project factory: :empty_project
end end
end end
FactoryGirl.define do FactoryGirl.define do
factory :sent_notification do factory :sent_notification do
project project factory: :empty_project
recipient factory: :user recipient factory: :user
noteable factory: :issue noteable factory: :issue
reply_key "0123456789abcdef" * 2 reply_key "0123456789abcdef" * 2
......
FactoryGirl.define do FactoryGirl.define do
factory :service do factory :service do
project project factory: :empty_project
end end
end end
FactoryGirl.define do FactoryGirl.define do
factory :todo do factory :todo do
project project factory: :empty_project
author author
user user
target factory: :issue target factory: :issue
......
...@@ -217,7 +217,7 @@ describe Issue, models: true do ...@@ -217,7 +217,7 @@ describe Issue, models: true do
end end
it_behaves_like 'an editable mentionable' do it_behaves_like 'an editable mentionable' do
subject { create(:issue) } subject { create(:issue, project: create(:project, :repository)) }
let(:backref_text) { "issue #{subject.to_reference}" } let(:backref_text) { "issue #{subject.to_reference}" }
let(:set_mentionable_text) { ->(txt){ subject.description = txt } } let(:set_mentionable_text) { ->(txt){ subject.description = txt } }
......
...@@ -138,7 +138,7 @@ describe Note, models: true do ...@@ -138,7 +138,7 @@ describe Note, models: true do
it_behaves_like 'an editable mentionable' do it_behaves_like 'an editable mentionable' do
subject { create :note, noteable: issue, project: issue.project } subject { create :note, noteable: issue, project: issue.project }
let(:issue) { create :issue } let(:issue) { create(:issue, project: create(:project, :repository)) }
let(:backref_text) { issue.gfm_reference } let(:backref_text) { issue.gfm_reference }
let(:set_mentionable_text) { ->(txt) { subject.note = txt } } let(:set_mentionable_text) { ->(txt) { subject.note = txt } }
end end
......
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