Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1. Hashes can be assigned 2. We don't need a special level anymore The method chain only works in the top level. If users need a second level they need to assign a OrderedOptions to the key: config.resque.server = ActiveSupport::OrderedOptions.new config.resque.server.url = "http://localhost" config.resque.server.port = 3000 [Rafael Mendonça França + Carlos Antonio da Silva]
- Loading branch information
1 parent
0cb3bdb
commit de48913
Showing
8 changed files
with
149 additions
and
46 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,15 +1,84 @@ | |||
require 'application/configuration/base_test' | require 'application/configuration/base_test' | ||
|
|
||
class ApplicationTests::ConfigurationTests::CustomTest < ApplicationTests::ConfigurationTests::BaseTest | class ApplicationTests::ConfigurationTests::CustomTest < ApplicationTests::ConfigurationTests::BaseTest | ||
test 'access custom configuration point' do | test 'configuration top level can be chained' do | ||
add_to_config <<-RUBY | add_to_config <<-RUBY | ||
config.x.resque.inline_jobs = :always | config.resque.inline_jobs = :always | ||
config.x.resque.timeout = 60 | config.resque.timeout = 60 | ||
RUBY | RUBY | ||
require_environment | require_environment | ||
|
|
||
assert_equal :always, Rails.configuration.x.resque.inline_jobs | assert_equal :always, Rails.configuration.resque.inline_jobs | ||
assert_equal 60, Rails.configuration.x.resque.timeout | assert_equal 60, Rails.configuration.resque.timeout | ||
assert_nil Rails.configuration.x.resque.nothing | 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) | |||
end | end | ||
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