Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support after_commit callbacks in transactional fixtures #18458

Merged
merged 1 commit into from Jan 20, 2015

Conversation

@brainopia
Copy link
Contributor

brainopia commented Jan 11, 2015

Continuation of #18415

Sorry, I've accidentally amended to a wrong commit. And then github wouldn't pickup any changes 馃槶
Had to create a new one.

This is a result of discussions with @arthurnn and @matthewd
There is a question whether it's possible to merge :joinable and :top_level settings, but it can be discussed in a different request.

cc @jeremy

@arthurnn
Copy link
Member

arthurnn commented Jan 12, 2015

Good job buddy!
馃憤

@arthurnn
Copy link
Member

arthurnn commented Jan 12, 2015

Interested to see what @jeremy things about this.

@brainopia brainopia force-pushed the brainopia:fix_after_commit_for_fixtures branch 4 times, most recently Jan 16, 2015
after_commit callbacks run after committing a transaction whose parent
is not `joinable?`: un-nested transactions, transactions within test
cases, and transactions in `console --sandbox`.
@brainopia brainopia force-pushed the brainopia:fix_after_commit_for_fixtures branch to eb72e34 Jan 16, 2015
jeremy added a commit that referenced this pull request Jan 20, 2015
Support after_commit callbacks in transactional fixtures
@jeremy jeremy merged commit b477ad5 into rails:master Jan 20, 2015
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
@jeremy
Copy link
Member

jeremy commented Jan 20, 2015

Great simplification! 馃

@san983
Copy link

san983 commented Jun 1, 2015

馃憤

christopherstyles added a commit to code-corps/deprecated-code-corps-rails-api that referenced this pull request Jun 23, 2016
A project should be able to return the number of open posts as well as
the number of closed posts.

This update adds two counter caches to the project model:
`open_posts_count` and `closed_posts_count`. These new attributes
reflect the count of posts matching the statuses of their namesake.

The [`test_after_commit`](https://github.com/grosser/test_after_commit)
gem is needed, as transactional fixtures are enabled and counter caches
are updated in an `after_commit` callback. See
[magnusvk/counter_culture#a-note-on-testing](https://github.com/magnusvk
/counter_culture#a-note-on-testing) for more info. This will no longer
be needed in Rails 5:
[rails/rails/pull/18458](rails/rails#18458).

To update existing counters, run the following:
```ruby
Post.counter_culture_fix_counts
#
https://github.com/magnusvk/counter_culture#manually-populating-counter-
cache-values
```

Resolves #323
joshsmith added a commit to code-corps/deprecated-code-corps-rails-api that referenced this pull request Jun 23, 2016
A project should be able to return the number of open posts as well as
the number of closed posts.

This update adds two counter caches to the project model:
`open_posts_count` and `closed_posts_count`. These new attributes
reflect the count of posts matching the statuses of their namesake.

The [`test_after_commit`](https://github.com/grosser/test_after_commit)
gem is needed, as transactional fixtures are enabled and counter caches
are updated in an `after_commit` callback. See
[magnusvk/counter_culture#a-note-on-testing](https://github.com/magnusvk
/counter_culture#a-note-on-testing) for more info. This will no longer
be needed in Rails 5:
[rails/rails/pull/18458](rails/rails#18458).

To update existing counters, run the following:
```ruby
Post.counter_culture_fix_counts
https://github.com/magnusvk/counter_culture#manually-populating-counter-
cache-values
```

Resolves #323

Ignore localhost

Enable elasticsearch on circleci
hallelujah added a commit to 3scale/porta that referenced this pull request Sep 18, 2018
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Oct 5, 2018
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Oct 29, 2018
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Dec 12, 2018
Rails 5 feature rails/rails#18458
notapatch added a commit to BCS-io/letting that referenced this pull request Jan 11, 2019
 - if I was indexing documents and doing further tests with the
   expectation that the document was now present in the search
   indexing makes sense. However, this is not the case - so
   I will skip this.
 - index will require elasticsearch being active and will slow
   down tests
 - Rails bug fixed in 5.0 which probably meant that the
   after_commits weren't being called until now
   rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 23, 2019
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 23, 2019
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 29, 2019
Rails 5 feature rails/rails#18458
lizconlan pushed a commit to mysociety/alaveteli that referenced this pull request Feb 27, 2019
In addition to our call to InfoRequest.find() with a string (from
params) in the controller, Rails 5 calls after_commit callbacks in
tests: rails/rails#18458

For InfoRequest, this results in additional calls to find() with an
integer (or an array thereof) which breaks our tests unless we unstub
the general case for find(), allowing it to call the original method.

The change in this commit avoids raising the error:
lizconlan pushed a commit to mysociety/alaveteli that referenced this pull request Apr 2, 2019
In addition to our call to InfoRequest.find() with a string (from
params) in the controller, Rails 5 calls after_commit callbacks in
tests: rails/rails#18458

For InfoRequest, this results in additional calls to find() with an
integer (or an array thereof) which breaks our tests unless we unstub
the general case for find(), allowing it to call the original method.

The change in this commit avoids raising the error:
hallelujah added a commit to 3scale/porta that referenced this pull request Sep 22, 2019
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Sep 28, 2019
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Sep 28, 2019
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Oct 2, 2019
Rails 5 feature rails/rails#18458
duduribeiro added a commit to 3scale/porta that referenced this pull request Nov 8, 2019
Rails 5 feature rails/rails#18458
duduribeiro added a commit to 3scale/porta that referenced this pull request Nov 18, 2019
Rails 5 feature rails/rails#18458
duduribeiro added a commit to 3scale/porta that referenced this pull request Nov 18, 2019
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Dec 12, 2019
Rails 5 feature rails/rails#18458
duduribeiro added a commit to 3scale/porta that referenced this pull request Dec 12, 2019
Rails 5 feature rails/rails#18458
duduribeiro added a commit to 3scale/porta that referenced this pull request Dec 26, 2019
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 13, 2020
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 15, 2020
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 23, 2020
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 31, 2020
Rails 5 feature rails/rails#18458
duduribeiro added a commit to 3scale/porta that referenced this pull request Jan 31, 2020
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 31, 2020
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Feb 4, 2020
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Feb 4, 2020
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Feb 6, 2020
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Feb 10, 2020
Rails 5 feature rails/rails#18458
hallelujah added a commit to 3scale/porta that referenced this pull request Feb 10, 2020
Rails 5 feature rails/rails#18458
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can鈥檛 perform that action at this time.