diff options
Diffstat (limited to 'spec/support/factory_bot.rb')
-rw-r--r-- | spec/support/factory_bot.rb | 13 |
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) |