From 43073b393d234acd094ac7c220163f4e419d11f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Tue, 19 Aug 2014 19:41:15 -0300 Subject: Revert "Improve custom configuration" This reverts commit de4891344ccc074f6d5693f4fac6ad610584e336. Conflicts: railties/lib/rails/railtie/configuration.rb It added regression. Will be back after the beta --- .../test/application/configuration/base_test.rb | 6 +- .../test/application/configuration/custom_test.rb | 81 ++-------------------- railties/test/railties/engine_test.rb | 2 +- 3 files changed, 9 insertions(+), 80 deletions(-) (limited to 'railties/test') diff --git a/railties/test/application/configuration/base_test.rb b/railties/test/application/configuration/base_test.rb index 6e2b618160..d6a82b139d 100644 --- a/railties/test/application/configuration/base_test.rb +++ b/railties/test/application/configuration/base_test.rb @@ -5,8 +5,6 @@ require 'env_helpers' module ApplicationTests module ConfigurationTests class BaseTest < ActiveSupport::TestCase - include ActiveSupport::Testing::Isolation - def setup build_app boot_rails @@ -32,8 +30,8 @@ module ApplicationTests end def require_environment - require "#{app_path}/config/environment" + require "#{app_path}/config/environment" end end end -end +end \ No newline at end of file diff --git a/railties/test/application/configuration/custom_test.rb b/railties/test/application/configuration/custom_test.rb index e8c7a37913..045537fc28 100644 --- a/railties/test/application/configuration/custom_test.rb +++ b/railties/test/application/configuration/custom_test.rb @@ -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 diff --git a/railties/test/railties/engine_test.rb b/railties/test/railties/engine_test.rb index da4eccd2b7..ec64ce5941 100644 --- a/railties/test/railties/engine_test.rb +++ b/railties/test/railties/engine_test.rb @@ -840,7 +840,7 @@ YAML Rails.application.load_seed assert Rails.application.config.app_seeds_loaded - assert_empty Bukkits::Engine.config.bukkits_seeds_loaded + assert_raise(NoMethodError) { Bukkits::Engine.config.bukkits_seeds_loaded } Bukkits::Engine.load_seed assert Bukkits::Engine.config.bukkits_seeds_loaded -- cgit v1.2.3