summaryrefslogtreecommitdiff
path: root/spec/factories/merge_requests.rb
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2017-08-09 19:30:07 +0800
committerLin Jen-Shin <godfat@godfat.org>2017-08-09 19:30:07 +0800
commita85eed6446fa0b4b899a71cb9a3cb5e011a41c3a (patch)
tree474f584c1900bf156b9864af1e53e63abe0b23a6 /spec/factories/merge_requests.rb
parent029fb98b02f00e55243eaa781dc2849e94f16ae5 (diff)
downloadgitlab-ce-a85eed6446fa0b4b899a71cb9a3cb5e011a41c3a.tar.gz
Fake out Repository#fetch_ref for merge request if
the project didn't have a repository setup. We don't try to stub it if the repository was already there.
Diffstat (limited to 'spec/factories/merge_requests.rb')
-rw-r--r--spec/factories/merge_requests.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/factories/merge_requests.rb b/spec/factories/merge_requests.rb
index 1bc530d06db..19bf7582747 100644
--- a/spec/factories/merge_requests.rb
+++ b/spec/factories/merge_requests.rb
@@ -68,6 +68,16 @@ FactoryGirl.define do
merge_user author
end
+ after(:build) do |merge_request|
+ target_project = merge_request.target_project
+
+ # Fake `fetch_ref` if we don't have repository
+ # We have too many existing tests replying on this behaviour
+ unless target_project.repository_exists?
+ allow(target_project.repository).to receive(:fetch_ref)
+ end
+ end
+
factory :merged_merge_request, traits: [:merged]
factory :closed_merge_request, traits: [:closed]
factory :reopened_merge_request, traits: [:opened]