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’ll 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

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

Good job buddy!
👍

@arthurnn
Copy link
Member

Interested to see what @jeremy things about this.

@brainopia brainopia force-pushed the fix_after_commit_for_fixtures branch 4 times, most recently from 5d18103 to 1087078 Compare January 16, 2015 00:19
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 fix_after_commit_for_fixtures branch from 1087078 to eb72e34 Compare January 16, 2015 00:52
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
@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 pushed 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
hallelujah added a commit to 3scale/porta that referenced this pull request Oct 5, 2018
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 10, 2019
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 29, 2019
lizconlan added 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 added 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 Oct 2, 2019
duduribeiro pushed a commit to 3scale/porta that referenced this pull request Nov 8, 2019
duduribeiro pushed a commit to 3scale/porta that referenced this pull request Nov 18, 2019
duduribeiro pushed a commit to 3scale/porta that referenced this pull request Dec 12, 2019
duduribeiro pushed a commit to 3scale/porta that referenced this pull request Dec 26, 2019
hallelujah added a commit to 3scale/porta that referenced this pull request Jan 23, 2020
duduribeiro pushed a commit to 3scale/porta that referenced this pull request Jan 31, 2020
hallelujah added a commit to 3scale/porta that referenced this pull request Feb 4, 2020
hallelujah added a commit to 3scale/porta that referenced this pull request Feb 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants