From b84fbc8bc50aa52f421d08155017f5a3627b8de6 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Sat, 27 Sep 2008 12:35:11 -0300 Subject: [PATCH] ActionItem765: removing old buggy code --- app/controllers/admin/admin_panel_controller.rb | 9 --------- test/functional/admin_controller_test.rb | 2 +- test/functional/admin_panel_controller_test.rb | 14 ++++++++++++++ test/functional/application_controller_test.rb | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/functional/home_controller_test.rb | 37 ------------------------------------- 5 files changed, 75 insertions(+), 47 deletions(-) diff --git a/app/controllers/admin/admin_panel_controller.rb b/app/controllers/admin/admin_panel_controller.rb index 925b930..f62c526 100644 --- a/app/controllers/admin/admin_panel_controller.rb +++ b/app/controllers/admin/admin_panel_controller.rb @@ -4,10 +4,6 @@ class AdminPanelController < AdminController protect 'view_environment_admin_panel', :environment - #FIXME This is not necessary because the application controller define the envrioment - # as the default holder - before_filter :load_default_enviroment - def boxes_holder environment end @@ -23,9 +19,4 @@ class AdminPanelController < AdminController def edit_templates end - protected - - def load_default_enviroment - @environment = Environment.default - end end diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb index 8ed9953..b559c16 100644 --- a/test/functional/admin_controller_test.rb +++ b/test/functional/admin_controller_test.rb @@ -8,7 +8,7 @@ class AdminControllerTest < Test::Unit::TestCase class AdminTestController < AdminController def index - render :text => 'ok', :layout => false + render :text => 'ok', :layout => 'application' end end diff --git a/test/functional/admin_panel_controller_test.rb b/test/functional/admin_panel_controller_test.rb index 129abea..fac6a0b 100644 --- a/test/functional/admin_panel_controller_test.rb +++ b/test/functional/admin_panel_controller_test.rb @@ -22,6 +22,20 @@ class AdminPanelControllerTest < Test::Unit::TestCase def test_valid_xhtml assert_valid_xhtml end + + should 'manage the correct environment' do + Environment.destroy_all + + default = Environment.create!(:name => 'default env', :is_default => true) + Environment.stubs(:default).returns(default) + + current = Environment.create!(:name => 'test environment', :is_default => false) + current.domains.create!(:name => 'example.com') + + @request.expects(:host).returns('example.com').at_least_once + get :index + assert_equal current, assigns(:environment) + end should 'link to site_info editing page' do get :index diff --git a/test/functional/application_controller_test.rb b/test/functional/application_controller_test.rb index 1d88b8b..98dc674 100644 --- a/test/functional/application_controller_test.rb +++ b/test/functional/application_controller_test.rb @@ -12,6 +12,53 @@ class ApplicationControllerTest < Test::Unit::TestCase @response = ActionController::TestResponse.new end + def test_detection_of_environment_by_host + uses_host 'www.colivre.net' + get :index + + assert_kind_of Environment, assigns(:environment) + + assert_kind_of Domain, assigns(:domain) + assert_equal 'colivre.net', assigns(:domain).name + + assert_nil assigns(:profile) + end + + def test_detect_profile_by_host + uses_host 'www.jrh.net' + get :index + + assert_kind_of Environment, assigns(:environment) + + assert_kind_of Domain, assigns(:domain) + assert_equal 'jrh.net', assigns(:domain).name + + assert_kind_of Profile, assigns(:profile) + end + + def test_unknown_domain_falls_back_to_default_environment + uses_host 'veryunprobabledomain.com' + + get :index + assert_kind_of Environment, assigns(:environment) + assert assigns(:environment).is_default? + end + + should 'detect the current environment' do + default = Environment.default + Environment.stubs(:default).returns(default) + default.stubs(:top_url).returns('http://default.com/') + + current = Environment.create!(:name => 'test environment') + current.domains.create!(:name => 'example.com') + + @request.expects(:host).returns('example.com').at_least_once + get :index + + assert_equal current, assigns(:environment) + end + + def test_local_files_reference assert_local_files_reference end @@ -200,6 +247,19 @@ class ApplicationControllerTest < Test::Unit::TestCase assert_tag :tag => 'base', :attributes => { :href => 'https://www.lala.net/' } end + should 'use correct environment for base tag' do + default = Environment.default + Environment.stubs(:default).returns(default) + default.stubs(:top_url).returns('http://default.com/') + + current = Environment.create!(:name => 'test environment') + current.domains.create!(:name => 'example.com') + + @request.expects(:host).returns('example.com').at_least_once + get :index + assert_tag :tag => 'base', :attributes => { :href => 'http://example.com' } + end + should 'display theme test panel when testing theme' do @request.session[:theme] = 'my-test-theme' theme = mock diff --git a/test/functional/home_controller_test.rb b/test/functional/home_controller_test.rb index 34a1ebe..eea00aa 100644 --- a/test/functional/home_controller_test.rb +++ b/test/functional/home_controller_test.rb @@ -22,41 +22,4 @@ all_fixtures assert_valid_xhtml end - def test_detection_of_environment_by_host - uses_host 'www.colivre.net' - get :index - assert_template 'index' - - assert_kind_of Environment, assigns(:environment) - - assert_kind_of Domain, assigns(:domain) - assert_equal 'colivre.net', assigns(:domain).name - - assert_nil assigns(:profile) - end - - def test_detect_profile_by_host - uses_host 'www.jrh.net' - get :index - assert_template 'index' - - assert_kind_of Environment, assigns(:environment) - - assert_kind_of Domain, assigns(:domain) - assert_equal 'jrh.net', assigns(:domain).name - - assert_kind_of Profile, assigns(:profile) - end - - def test_unknown_domain_falls_back_to_default_environment - uses_host 'veryunprobabledomain.com' - - get :index - assert_template 'index' - - assert_kind_of Environment, assigns(:environment) - assert assigns(:environment).is_default? - - end - end -- libgit2 0.21.2