Skip to content

Support after_commit callbacks in transactional fixtures#18458

Merged
jeremy merged 1 commit into
rails:masterfrom
brainopia:fix_after_commit_for_fixtures
Jan 20, 2015
Merged

Support after_commit callbacks in transactional fixtures#18458
jeremy merged 1 commit into
rails:masterfrom
brainopia:fix_after_commit_for_fixtures

Conversation

@brainopia

Copy link
Copy Markdown
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
Copy Markdown
Member

Good job buddy!
👍

@arthurnn

Copy link
Copy Markdown
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

jeremy commented Jan 20, 2015

Copy link
Copy Markdown
Member

Great simplification! 🤘

@san983

san983 commented Jun 1, 2015

Copy link
Copy Markdown

👍

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