Support after_commit callbacks in transactional fixtures #18458

Merged
merged 1 commit into from Jan 20, 2015

Conversation

Projects
None yet
4 participants
@brainopia
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

This comment has been minimized.

Show comment
Hide comment
@arthurnn

arthurnn Jan 12, 2015

Member

Good job buddy!
馃憤

Member

arthurnn commented Jan 12, 2015

Good job buddy!
馃憤

@arthurnn

This comment has been minimized.

Show comment
Hide comment
@arthurnn

arthurnn Jan 12, 2015

Member

Interested to see what @jeremy things about this.

Member

arthurnn commented Jan 12, 2015

Interested to see what @jeremy things about this.

after_commit runs after transactions with non-joinable parents
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`.

jeremy added a commit that referenced this pull request Jan 20, 2015

Merge pull request #18458 from brainopia/fix_after_commit_for_fixtures
Support after_commit callbacks in transactional fixtures

@jeremy jeremy merged commit b477ad5 into rails:master Jan 20, 2015

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@jeremy

This comment has been minimized.

Show comment
Hide comment
@jeremy

jeremy Jan 20, 2015

Member

Great simplification! 馃

Member

jeremy commented Jan 20, 2015

Great simplification! 馃

@san983

This comment has been minimized.

Show comment
Hide comment

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

Add open and closed post counts to project
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#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

@christopherstyles christopherstyles referenced this pull request in code-corps/deprecated-code-corps-rails-api Jun 23, 2016

Merged

Add open and closed post counts to project #342

joshsmith added a commit to code-corps/deprecated-code-corps-rails-api that referenced this pull request Jun 23, 2016

Add open and closed post counts to project
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#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

@fdibartolo fdibartolo referenced this pull request in elastic/elasticsearch-ruby Sep 10, 2017

Closed

Question: callbacks on port different than default 9200 #459

@jharbert jharbert referenced this pull request in composite-primary-keys/composite_primary_keys Feb 17, 2018

Open

Composite keys seems to prevent after_commit callback on touch #427

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment