diff --git a/features/steps/project/merge_requests/revert.rb b/features/steps/project/merge_requests/revert.rb
index 3cc4fe9dafbed44e4864fd3bb5cdfd76ac31626c..31f95b524b3c46be32fb06e0dbaa5b36ad124326 100644
--- a/features/steps/project/merge_requests/revert.rb
+++ b/features/steps/project/merge_requests/revert.rb
@@ -30,14 +30,13 @@ class Spinach::Features::RevertMergeRequests < Spinach::FeatureSteps
   end
 
   step 'I am signed in as a developer of the project' do
+    @user = create(:user) { |u| @project.add_developer(u) }
     login_as(@user)
   end
 
   step 'There is an open Merge Request' do
-    @user = create(:user)
-    @project = create(:project, :public, :repository)
-    @project_member = create(:project_member, :developer, user: @user, project: @project)
-    @merge_request = create(:merge_request, :with_diffs, :simple, source_project: @project)
+    @merge_request = create(:merge_request, :with_diffs, :simple)
+    @project = @merge_request.source_project
   end
 
   step 'I should see a revert error' do
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb
index 37eb49c94df104885d82cd3f1b6cf66da5163dad..22f84150bb39f15636f52df8ec45047b0596e538 100644
--- a/spec/factories/merge_requests.rb
+++ b/spec/factories/merge_requests.rb
@@ -2,7 +2,7 @@ FactoryGirl.define do
   factory :merge_request do
     title
     author
-    source_project factory: :project
+    association :source_project, :repository, factory: :project
     target_project { source_project }
 
     # $ git log --pretty=oneline feature..master
diff --git a/spec/factories/notes.rb b/spec/factories/notes.rb
index 07474f7e4ba5d509b779d98424b53605940ecccb..a750bf2300877eb462d99ca4c2c3edd8c1022f89 100644
--- a/spec/factories/notes.rb
+++ b/spec/factories/notes.rb
@@ -15,10 +15,16 @@ FactoryGirl.define do
     factory :note_on_project_snippet,    traits: [:on_project_snippet]
     factory :system_note,                traits: [:system]
 
-    factory :legacy_diff_note_on_commit, traits: [:on_commit, :legacy_diff_note], class: LegacyDiffNote
-    factory :legacy_diff_note_on_merge_request, traits: [:on_merge_request, :legacy_diff_note], class: LegacyDiffNote
+    factory :legacy_diff_note_on_commit, traits: [:on_commit, :legacy_diff_note], class: LegacyDiffNote do
+      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
+      association :project, :repository
       position do
         Gitlab::Diff::Position.new(
           old_path: "files/ruby/popen.rb",
@@ -49,6 +55,7 @@ FactoryGirl.define do
     end
 
     trait :on_commit do
+      association :project, :repository
       noteable nil
       noteable_type 'Commit'
       noteable_id nil
diff --git a/spec/models/issue_spec.rb b/spec/models/issue_spec.rb
index bfa36d92ac3812f37f82f9a1c97e9837c5ad1f62..61d729257366bd982593bb5d9508c936a1b9995d 100644
--- a/spec/models/issue_spec.rb
+++ b/spec/models/issue_spec.rb
@@ -217,7 +217,7 @@ describe Issue, models: true do
   end
 
   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(:set_mentionable_text) { ->(txt){ subject.description = txt } }
diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb
index 310fecd8a5cc5f05a190730814ca89ce1e6f9b4c..296213ab034a067025cb87a2d7a30dc9f7eae919 100644
--- a/spec/models/note_spec.rb
+++ b/spec/models/note_spec.rb
@@ -125,7 +125,7 @@ describe Note, models: true do
   it_behaves_like 'an editable mentionable' do
     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(:set_mentionable_text) { ->(txt) { subject.note = txt } }
   end