Latest commit fd3bf88
Jun 29, 2016
Previously, instances created with the Stub strategy disabled a number of methods defined by ActiveRecord::Persistence, to ensure that stubbed instances did not read or write to the database. However, this blacklist was incomplete, allowing some methods (e.g. #save!) to be called on stub instances. This expands the blacklist to disable all methods defined by ActiveRecord::Persistence that are not explicitly defined on stub instances (currently #new_record?, #persisted?), or do not talk to the database at all (#becomes, #becomes!). The blacklist is correct as of current Rails master (the pre-release for Rails 5.0). It also, as a result, includes a couple of methods that are not defined by ActiveRecord::Persistence in earlier versions of Rails, and will not automatically include methods added to this module in future versions of Rails. It would be possible to make this automatic using reflection, and instead using a whitelist of allowed methods: ActiveRecord::Persistence.public_instance_methods However, at present this test is not dependent on ActiveRecord, so I have left this for future work if desired.
|Failed to load latest commit information.|