1
0
Fork 0
mirror of https://github.com/thoughtbot/factory_bot.git synced 2022-11-09 11:43:51 -05:00
Commit graph

18 commits

Author SHA1 Message Date
Avielle
c716ce01b4 Replace 'girl' with 'bot' everywhere (#1051)
Also: add a deprecation warning to factory_girl, asking users to switch to
factory_bot

https://github.com/thoughtbot/factory_girl/issues/921
2017-10-20 15:20:28 -04:00
Bradley Priest
168bbf8e34
Stub out ActiveRecord::Base#persisted? 2017-03-25 05:46:39 -04:00
Alessandro Rodi
d33f29c490 add a default updated_at column when not defined for build_stubbed (#955) 2016-12-16 05:22:13 -05:00
Simon Coffey
fd3bf889f8
Stub strategy disables all persistence instance methods
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.
2016-07-19 05:20:26 -04:00
Milo Winningham
6f7b94b159 Clear changed attributes with build_stubbed
Fixes #837
2016-02-05 22:02:22 -05:00
Joshua Clayton
d5a3dddb46 Appraise against Rails 5.0.0.beta
Why?

With Rails' upcoming release, test against the latest beta of Rails 5.
2016-02-05 20:38:29 -05:00
Tim Diggins
deaf5529fb correct error message when stubbed reload called with transaction lock attr. Fixes #719 2014-11-18 11:43:42 -05:00
Jamie van Dyke
b97b36a42b a minor change to inform the user what model and method violated the stub 2014-04-19 00:46:43 -04:00
Ari Pollak
af282a178b Match build_stubbed's created_at type to ActiveRecord
Closes #469
2012-12-21 13:09:32 -08:00
Joshua Clayton
e85c0086aa Allow setting id for build_stubbed objects
Closes #451
2012-11-07 15:44:51 -05:00
Joshua Clayton
37fe26315e Stub update_column to raise, which will replace update_attribute in Rails 4 2012-08-02 11:06:18 -04:00
Joshua Clayton
4bccbb90d1 Allow created_at to be set when using build_stubbed
Closes #390
2012-06-22 14:33:37 -04:00
Joshua Clayton
7234f9f07e Style cleanup 2012-05-05 01:14:21 -04:00
Joshua Clayton
731a24e84a Don't refer to strategies by class anywhere 2012-04-25 15:03:10 -05:00
Joshua Clayton
89d5e944d5 Refactor Strategies
This changes Strategy from a class to a module and removes inheritance.
It introduces an Evaluation facade to make building strategies easier
2012-04-13 17:20:02 -04:00
Joshua Clayton
4dd67d1fb7 Move override handling into the evaluator 2012-02-10 18:19:18 -05:00
Joshua Clayton
7b2fbeac5c Add AssociationRunner for running associations from strategies
This extracts logic for running factories based on name and either
strategy class, symbol representing a strategy, or nil (defaulting to
the create strategy)
2012-02-10 18:19:17 -05:00
Joshua Clayton
b79a525c09 Proxy => Strategy 2012-02-10 18:19:17 -05:00
Renamed from lib/factory_girl/proxy/stub.rb (Browse further)