Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/factory_bot.rb')
-rw-r--r--spec/support/factory_bot.rb13
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/support/factory_bot.rb b/spec/support/factory_bot.rb
index c9d372993b5..5761e05d541 100644
--- a/spec/support/factory_bot.rb
+++ b/spec/support/factory_bot.rb
@@ -3,3 +3,16 @@
FactoryBot::SyntaxRunner.class_eval do
include RSpec::Mocks::ExampleMethods
end
+
+# Patching FactoryBot to allow stubbing non AR models
+# See https://github.com/thoughtbot/factory_bot/pull/1466
+module Gitlab
+ module FactoryBotStubPatch
+ def has_settable_id?(result_instance)
+ result_instance.class.respond_to?(:primary_key) &&
+ result_instance.class.primary_key
+ end
+ end
+end
+
+FactoryBot::Strategy::Stub.prepend(Gitlab::FactoryBotStubPatch)