diff --git a/test/test_helper.rb b/test/test_helper.rb index b9c3f9c..533299b 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -277,16 +277,4 @@ class ActionController::IntegrationTest end -def with_constants(constants, &block) - old_constants = Hash.new - constants.each do |constant, val| - old_constants[constant] = Object.const_get(constant) - silence_stderr{ Object.const_set(constant, val) } - end - block.call - old_constants.each do |constant, val| - silence_stderr{ Object.const_set(constant, val) } - end -end - Profile diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index 4470fc8..3df5748 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -472,13 +472,13 @@ class ApplicationHelperTest < ActionView::TestCase profile = mock profile.stubs(:theme).returns('some-theme') stubs(:profile).returns(profile) - with_constants :NOOSFERO_CONF => {'gravatar' => 'crazyvatar'} do - assert_equal gravatar_default, 'crazyvatar' - end + + NOOSFERO_CONF.stubs(:[]).with('gravatar').returns('crazyvatar') + assert_equal gravatar_default, 'crazyvatar' + stubs(:theme_option).returns('gravatar' => 'nicevatar') - with_constants :NOOSFERO_CONF => {'gravatar' => 'crazyvatar'} do - assert_equal gravatar_default, 'nicevatar' - end + NOOSFERO_CONF.stubs(:[]).with('gravatar').returns('nicevatar') + assert_equal gravatar_default, 'nicevatar' end should 'use theme passed via param when in development mode' do diff --git a/test/unit/google_maps_test.rb b/test/unit/google_maps_test.rb index 8604930..5029f06 100644 --- a/test/unit/google_maps_test.rb +++ b/test/unit/google_maps_test.rb @@ -3,13 +3,12 @@ require File.dirname(__FILE__) + '/../test_helper' class GoogleMapsTest < ActiveSupport::TestCase should 'provide initial_zoom setting' do - with_constants :NOOSFERO_CONF => {'googlemaps_initial_zoom' => 2} do - assert_equal 2, GoogleMaps.initial_zoom - end + NOOSFERO_CONF.stubs(:[]).with('googlemaps_initial_zoom').returns(2) + assert_equal 2, GoogleMaps.initial_zoom end should 'use 4 as default initial_zoom' do - GoogleMaps.stubs(:config).returns({}) + NOOSFERO_CONF.stubs(:[]).with('googlemaps_initial_zoom').returns(nil) assert_equal 4, GoogleMaps.initial_zoom end diff --git a/test/unit/mail_conf_test.rb b/test/unit/mail_conf_test.rb index 08596cd..24e0f24 100644 --- a/test/unit/mail_conf_test.rb +++ b/test/unit/mail_conf_test.rb @@ -3,22 +3,22 @@ require File.dirname(__FILE__) + '/../test_helper' class MailConfTest < ActiveSupport::TestCase should 'enable if told to' do - NOOSFERO_CONF['mail_enabled'] = true + NOOSFERO_CONF.stubs(:[]).with('mail_enabled').returns(true) assert_equal true, MailConf.enabled? end should 'disable if told to' do - NOOSFERO_CONF['mail_enabled'] = false + NOOSFERO_CONF.stubs(:[]).with('mail_enabled').returns(false) assert_equal false, MailConf.enabled? end should 'disable by default' do - NOOSFERO_CONF['mail_enabled'] = nil + NOOSFERO_CONF.stubs(:[]).with('mail_enabled').returns(nil) assert_equal false, MailConf.enabled? end should 'provide webmail url preference' do - NOOSFERO_CONF['webmail_url'] = 'http://some.url/webmail/%s/%s' + NOOSFERO_CONF.stubs(:[]).with('webmail_url').returns('http://some.url/webmail/%s/%s') assert_equal 'http://some.url/webmail/login/example.com', MailConf.webmail_url('login', 'example.com') end -- libgit2 0.21.2