Chris@210: # Redmine - project management software Chris@1494: # Copyright (C) 2006-2014 Jean-Philippe Lang Chris@210: # Chris@210: # This program is free software; you can redistribute it and/or Chris@210: # modify it under the terms of the GNU General Public License Chris@210: # as published by the Free Software Foundation; either version 2 Chris@210: # of the License, or (at your option) any later version. Chris@909: # Chris@210: # This program is distributed in the hope that it will be useful, Chris@210: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@210: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@210: # GNU General Public License for more details. Chris@909: # Chris@210: # You should have received a copy of the GNU General Public License Chris@210: # along with this program; if not, write to the Free Software Chris@210: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@210: Chris@210: require File.expand_path('../../../../test_helper', __FILE__) Chris@210: Chris@210: class Redmine::ConfigurationTest < ActiveSupport::TestCase Chris@210: def setup Chris@210: @conf = Redmine::Configuration Chris@210: end Chris@210: Chris@210: def test_empty Chris@210: assert_kind_of Hash, load_conf('empty.yml', 'test') Chris@210: end Chris@909: Chris@210: def test_default Chris@210: assert_kind_of Hash, load_conf('default.yml', 'test') Chris@210: assert_equal 'foo', @conf['somesetting'] Chris@210: end Chris@909: Chris@210: def test_no_default Chris@210: assert_kind_of Hash, load_conf('no_default.yml', 'test') Chris@210: assert_equal 'foo', @conf['somesetting'] Chris@210: end Chris@909: Chris@210: def test_overrides Chris@210: assert_kind_of Hash, load_conf('overrides.yml', 'test') Chris@210: assert_equal 'bar', @conf['somesetting'] Chris@210: end Chris@909: Chris@245: def test_with Chris@245: load_conf('default.yml', 'test') Chris@245: assert_equal 'foo', @conf['somesetting'] Chris@245: @conf.with 'somesetting' => 'bar' do Chris@245: assert_equal 'bar', @conf['somesetting'] Chris@245: end Chris@245: assert_equal 'foo', @conf['somesetting'] Chris@245: end Chris@909: Chris@210: private Chris@909: Chris@210: def load_conf(file, env) Chris@210: @conf.load( Chris@210: :file => File.join(Rails.root, 'test', 'fixtures', 'configuration', file), Chris@210: :env => env Chris@210: ) Chris@210: end Chris@210: end