docbrown/spec/support/initializers
gverger c7de0d762b Add let_it_be_readonly to avoid updating variables (#5407)
With let_it_be, we define variables that are created for the whole
context. In case we update them in an example, there might be a
discrepancy between the object and its value in the database, since the
database is cleaned between examples, but not the object itself.

This is what happened here with the `article` object. In one of the
tests, we update its organization, and in another, we reupdate it. The
problem is that the `article` object still thinks it has an
organization, but it has been cleaned in the database. So setting the
same organization id to the object doesn't trigger the SQL query, and
the article in the database still doesn't have an organization attached.

One solution is to use `reload: true` as a parameter of `let_it_be`: it
will reload the object from the database at the beginning of each test. To
make sure we don't have other dormant traps like this one, what I
propose is to either have `reload: true`, or to have the object
readonly to avoid getting to a difference between the object and its
database value.
2020-01-16 10:53:30 -05:00
..
approvals.rb Update test suite configuration (#702) 2018-09-24 14:40:22 -04:00
capybara.rb Add wait_for_javascript to flaky system tests (#5405) 2020-01-08 13:47:08 -05:00
rspec_retry.rb Update test suite configuration (#702) 2018-09-24 14:40:22 -04:00
shoulda_matchers.rb Update test suite configuration (#702) 2018-09-24 14:40:22 -04:00
test_prof.rb Add let_it_be_readonly to avoid updating variables (#5407) 2020-01-16 10:53:30 -05:00
vcr.rb Update test suite configuration (#702) 2018-09-24 14:40:22 -04:00