Commit 1f2d4e35 authored by Peter Leitzen's avatar Peter Leitzen

Add FactoryBot to allow stubbing non ActiveRecord models

parent 58acfc19
......@@ -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)
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