Commit b84fbc8bc50aa52f421d08155017f5a3627b8de6
1 parent
096703be
Exists in
master
and in
29 other branches
ActionItem765: removing old buggy code
Also added some tests, but could not reproduce the bug. :(
Showing
5 changed files
with
75 additions
and
47 deletions
Show diff stats
app/controllers/admin/admin_panel_controller.rb
... | ... | @@ -4,10 +4,6 @@ class AdminPanelController < AdminController |
4 | 4 | |
5 | 5 | protect 'view_environment_admin_panel', :environment |
6 | 6 | |
7 | - #FIXME This is not necessary because the application controller define the envrioment | |
8 | - # as the default holder | |
9 | - before_filter :load_default_enviroment | |
10 | - | |
11 | 7 | def boxes_holder |
12 | 8 | environment |
13 | 9 | end |
... | ... | @@ -23,9 +19,4 @@ class AdminPanelController < AdminController |
23 | 19 | def edit_templates |
24 | 20 | end |
25 | 21 | |
26 | - protected | |
27 | - | |
28 | - def load_default_enviroment | |
29 | - @environment = Environment.default | |
30 | - end | |
31 | 22 | end | ... | ... |
test/functional/admin_controller_test.rb
test/functional/admin_panel_controller_test.rb
... | ... | @@ -22,6 +22,20 @@ class AdminPanelControllerTest < Test::Unit::TestCase |
22 | 22 | def test_valid_xhtml |
23 | 23 | assert_valid_xhtml |
24 | 24 | end |
25 | + | |
26 | + should 'manage the correct environment' do | |
27 | + Environment.destroy_all | |
28 | + | |
29 | + default = Environment.create!(:name => 'default env', :is_default => true) | |
30 | + Environment.stubs(:default).returns(default) | |
31 | + | |
32 | + current = Environment.create!(:name => 'test environment', :is_default => false) | |
33 | + current.domains.create!(:name => 'example.com') | |
34 | + | |
35 | + @request.expects(:host).returns('example.com').at_least_once | |
36 | + get :index | |
37 | + assert_equal current, assigns(:environment) | |
38 | + end | |
25 | 39 | |
26 | 40 | should 'link to site_info editing page' do |
27 | 41 | get :index | ... | ... |
test/functional/application_controller_test.rb
... | ... | @@ -12,6 +12,53 @@ class ApplicationControllerTest < Test::Unit::TestCase |
12 | 12 | @response = ActionController::TestResponse.new |
13 | 13 | end |
14 | 14 | |
15 | + def test_detection_of_environment_by_host | |
16 | + uses_host 'www.colivre.net' | |
17 | + get :index | |
18 | + | |
19 | + assert_kind_of Environment, assigns(:environment) | |
20 | + | |
21 | + assert_kind_of Domain, assigns(:domain) | |
22 | + assert_equal 'colivre.net', assigns(:domain).name | |
23 | + | |
24 | + assert_nil assigns(:profile) | |
25 | + end | |
26 | + | |
27 | + def test_detect_profile_by_host | |
28 | + uses_host 'www.jrh.net' | |
29 | + get :index | |
30 | + | |
31 | + assert_kind_of Environment, assigns(:environment) | |
32 | + | |
33 | + assert_kind_of Domain, assigns(:domain) | |
34 | + assert_equal 'jrh.net', assigns(:domain).name | |
35 | + | |
36 | + assert_kind_of Profile, assigns(:profile) | |
37 | + end | |
38 | + | |
39 | + def test_unknown_domain_falls_back_to_default_environment | |
40 | + uses_host 'veryunprobabledomain.com' | |
41 | + | |
42 | + get :index | |
43 | + assert_kind_of Environment, assigns(:environment) | |
44 | + assert assigns(:environment).is_default? | |
45 | + end | |
46 | + | |
47 | + should 'detect the current environment' do | |
48 | + default = Environment.default | |
49 | + Environment.stubs(:default).returns(default) | |
50 | + default.stubs(:top_url).returns('http://default.com/') | |
51 | + | |
52 | + current = Environment.create!(:name => 'test environment') | |
53 | + current.domains.create!(:name => 'example.com') | |
54 | + | |
55 | + @request.expects(:host).returns('example.com').at_least_once | |
56 | + get :index | |
57 | + | |
58 | + assert_equal current, assigns(:environment) | |
59 | + end | |
60 | + | |
61 | + | |
15 | 62 | def test_local_files_reference |
16 | 63 | assert_local_files_reference |
17 | 64 | end |
... | ... | @@ -200,6 +247,19 @@ class ApplicationControllerTest < Test::Unit::TestCase |
200 | 247 | assert_tag :tag => 'base', :attributes => { :href => 'https://www.lala.net/' } |
201 | 248 | end |
202 | 249 | |
250 | + should 'use correct environment for base tag' do | |
251 | + default = Environment.default | |
252 | + Environment.stubs(:default).returns(default) | |
253 | + default.stubs(:top_url).returns('http://default.com/') | |
254 | + | |
255 | + current = Environment.create!(:name => 'test environment') | |
256 | + current.domains.create!(:name => 'example.com') | |
257 | + | |
258 | + @request.expects(:host).returns('example.com').at_least_once | |
259 | + get :index | |
260 | + assert_tag :tag => 'base', :attributes => { :href => 'http://example.com' } | |
261 | + end | |
262 | + | |
203 | 263 | should 'display theme test panel when testing theme' do |
204 | 264 | @request.session[:theme] = 'my-test-theme' |
205 | 265 | theme = mock | ... | ... |
test/functional/home_controller_test.rb
... | ... | @@ -22,41 +22,4 @@ all_fixtures |
22 | 22 | assert_valid_xhtml |
23 | 23 | end |
24 | 24 | |
25 | - def test_detection_of_environment_by_host | |
26 | - uses_host 'www.colivre.net' | |
27 | - get :index | |
28 | - assert_template 'index' | |
29 | - | |
30 | - assert_kind_of Environment, assigns(:environment) | |
31 | - | |
32 | - assert_kind_of Domain, assigns(:domain) | |
33 | - assert_equal 'colivre.net', assigns(:domain).name | |
34 | - | |
35 | - assert_nil assigns(:profile) | |
36 | - end | |
37 | - | |
38 | - def test_detect_profile_by_host | |
39 | - uses_host 'www.jrh.net' | |
40 | - get :index | |
41 | - assert_template 'index' | |
42 | - | |
43 | - assert_kind_of Environment, assigns(:environment) | |
44 | - | |
45 | - assert_kind_of Domain, assigns(:domain) | |
46 | - assert_equal 'jrh.net', assigns(:domain).name | |
47 | - | |
48 | - assert_kind_of Profile, assigns(:profile) | |
49 | - end | |
50 | - | |
51 | - def test_unknown_domain_falls_back_to_default_environment | |
52 | - uses_host 'veryunprobabledomain.com' | |
53 | - | |
54 | - get :index | |
55 | - assert_template 'index' | |
56 | - | |
57 | - assert_kind_of Environment, assigns(:environment) | |
58 | - assert assigns(:environment).is_default? | |
59 | - | |
60 | - end | |
61 | - | |
62 | 25 | end | ... | ... |