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

[Fix #495] Default rails console strategy configuration #780

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@

### Changes

* [#778](https://github.com/toptal/chewy/pull/778): **(Breaking)** Drop support for Ruby 2.5 ([@Vitalina-Vakulchyk][]):
* [#495](https://github.com/toptal/chewy/issues/495): Ability to change Rails console strategy with `Chewy.console_strategy` ([@Vitalina-Vakulchyk][])
* [#778](https://github.com/toptal/chewy/pull/778): **(Breaking)** Drop support for Ruby 2.5 ([@Vitalina-Vakulchyk][])
* [#776](https://github.com/toptal/chewy/pull/776): **(Breaking)** Removal of unnecessary features and integrations ([@Vitalina-Vakulchyk][]):
* `aws-sdk-sqs` / `shoryuken`
* `mongoid`
Expand Down
4 changes: 4 additions & 0 deletions lib/chewy/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class Config
# for more info.
#
:request_strategy,
# Rails console strategy, `:urgent` by default.
#
:console_strategy,
# Use after_commit callbacks for RDBMS instead of
# after_save and after_destroy. True by default. Useful
# in tests with transactional fixtures or transactional
Expand Down Expand Up @@ -49,6 +52,7 @@ def initialize
@settings = {}
@root_strategy = :base
@request_strategy = :atomic
@console_strategy = :urgent
@use_after_commit_callbacks = true
@reset_disable_refresh_interval = false
@reset_no_replicas = false
Expand Down
2 changes: 1 addition & 1 deletion lib/chewy/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def migrate(*args)
if app.sandbox?
Chewy.strategy(:bypass)
else
Chewy.strategy(:urgent)
Chewy.strategy(Chewy.console_strategy)
end
puts "Chewy console strategy is `#{Chewy.strategy.current.name}`"
end
Expand Down
1 change: 1 addition & 0 deletions spec/chewy/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
its(:transport_logger) { should be_nil }
its(:root_strategy) { should == :base }
its(:request_strategy) { should == :atomic }
its(:console_strategy) { should == :urgent }
its(:use_after_commit_callbacks) { should == true }
its(:indices_path) { should == 'app/chewy' }
its(:reset_disable_refresh_interval) { should == false }
Expand Down