-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Improve custom configuration"
This reverts commit de48913. Conflicts: railties/lib/rails/railtie/configuration.rb It added regression. Will be back after the beta
- Loading branch information
1 parent
867631f
commit 43073b3
Showing
8 changed files
with
46 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,15 @@ | ||
require 'application/configuration/base_test' | ||
|
||
class ApplicationTests::ConfigurationTests::CustomTest < ApplicationTests::ConfigurationTests::BaseTest | ||
test 'configuration top level can be chained' do | ||
test 'access custom configuration point' do | ||
add_to_config <<-RUBY | ||
config.resque.inline_jobs = :always | ||
config.resque.timeout = 60 | ||
config.x.resque.inline_jobs = :always | ||
config.x.resque.timeout = 60 | ||
RUBY | ||
require_environment | ||
|
||
assert_equal :always, Rails.configuration.resque.inline_jobs | ||
assert_equal 60, Rails.configuration.resque.timeout | ||
assert_nil Rails.configuration.resque.nothing | ||
end | ||
|
||
test 'configuration top level accept normal values' do | ||
add_to_config <<-RUBY | ||
config.timeout = 60 | ||
config.something_nil = nil | ||
config.something_false = false | ||
config.something_true = true | ||
RUBY | ||
require_environment | ||
|
||
assert_equal 60, Rails.configuration.timeout | ||
assert_equal nil, Rails.configuration.something_nil | ||
assert_equal false, Rails.configuration.something_false | ||
assert_equal true, Rails.configuration.something_true | ||
end | ||
|
||
test 'configuration top level builds options from hashes' do | ||
add_to_config <<-RUBY | ||
config.resque = { timeout: 60, inline_jobs: :always } | ||
RUBY | ||
require_environment | ||
|
||
assert_equal :always, Rails.configuration.resque.inline_jobs | ||
assert_equal 60, Rails.configuration.resque.timeout | ||
assert_nil Rails.configuration.resque.nothing | ||
end | ||
|
||
test 'configuration top level builds options from hashes with string keys' do | ||
add_to_config <<-RUBY | ||
config.resque = { 'timeout' => 60, 'inline_jobs' => :always } | ||
RUBY | ||
require_environment | ||
|
||
assert_equal :always, Rails.configuration.resque.inline_jobs | ||
assert_equal 60, Rails.configuration.resque.timeout | ||
assert_nil Rails.configuration.resque.nothing | ||
end | ||
|
||
test 'configuration top level builds nested options from hashes with symbol keys' do | ||
add_to_config <<-RUBY | ||
config.resque = { timeout: 60, inline_jobs: :always, url: { host: 'localhost', port: 8080 } } | ||
config.resque.url.protocol = 'https' | ||
config.resque.queues = { production: ['low_priority'] } | ||
RUBY | ||
require_environment | ||
|
||
assert_equal(:always, Rails.configuration.resque.inline_jobs) | ||
assert_equal(60, Rails.configuration.resque.timeout) | ||
assert_equal({ host: 'localhost', port: 8080, protocol: 'https' }, Rails.configuration.resque.url) | ||
assert_equal('localhost', Rails.configuration.resque.url.host) | ||
assert_equal(8080, Rails.configuration.resque.url.port) | ||
assert_equal('https', Rails.configuration.resque.url.protocol) | ||
assert_equal(['low_priority'], Rails.configuration.resque.queues.production) | ||
assert_nil(Rails.configuration.resque.nothing) | ||
end | ||
|
||
test 'configuration top level builds nested options from hashes with string keys' do | ||
add_to_config <<-RUBY | ||
config.resque = { 'timeout' => 60, 'inline_jobs' => :always, 'url' => { 'host' => 'localhost', 'port' => 8080 } } | ||
RUBY | ||
require_environment | ||
|
||
assert_equal(:always, Rails.configuration.resque.inline_jobs) | ||
assert_equal(60, Rails.configuration.resque.timeout) | ||
assert_equal({ host: 'localhost', port: 8080 }, Rails.configuration.resque.url) | ||
assert_equal('localhost', Rails.configuration.resque.url.host) | ||
assert_equal(8080, Rails.configuration.resque.url.port) | ||
assert_nil(Rails.configuration.resque.nothing) | ||
assert_equal :always, Rails.configuration.x.resque.inline_jobs | ||
assert_equal 60, Rails.configuration.x.resque.timeout | ||
assert_nil Rails.configuration.x.resque.nothing | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43073b3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rafaelfranca was the plan to bring this back aborted for some reason or just overlooked?
43073b3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My plan was to bring it back but after some discussion at campfire I decided to leave the x namespace since it make explicit that the configuration is a custom object of the application