tests: fix null uploader_ip_addr exceptions in create(:post).
Caused by a change in FactoryBot 5. Associations in factories are now constructed using the same strategy as the base object, meaning that using `build` to construct an object will also construct the associations using `build`. This meant that overriding `create` to do `build` + `save` broke the way that associations were constructed. https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#associations
This commit is contained in:
@@ -26,13 +26,6 @@ Shoulda::Matchers.configure do |config|
|
||||
end
|
||||
|
||||
module TestHelpers
|
||||
def create(factory_bot_model, params = {})
|
||||
record = FactoryBot.build(factory_bot_model, params)
|
||||
record.save
|
||||
raise ActiveRecord::RecordInvalid.new(record) if record.errors.any?
|
||||
record
|
||||
end
|
||||
|
||||
def as(user, &block)
|
||||
CurrentUser.as(user, &block)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user