Commit 4b0c037f0cd2a96e00822c8a5aeeab1004bc3748

Authored by Rodrigo Souto
1 parent 2e6acc56

Using assigns on trusted sites tests

test/functional/trusted_sites_controller_test.rb
@@ -33,21 +33,21 @@ class TrustedSitesControllerTest < ActionController::TestCase @@ -33,21 +33,21 @@ class TrustedSitesControllerTest < ActionController::TestCase
33 should 'create site' do 33 should 'create site' do
34 post :create, :site => 'new.site.com' 34 post :create, :site => 'new.site.com'
35 assert_redirected_to :action => :index 35 assert_redirected_to :action => :index
36 - assert @controller.environment.trusted_sites_for_iframe.include?('new.site.com'), 'Site was not included in the trusted_sites' 36 + assert assigns(:environment).trusted_sites_for_iframe.include?('new.site.com'), 'Site was not included in the trusted_sites'
37 end 37 end
38 38
39 should 'fail creation gracefully' do 39 should 'fail creation gracefully' do
40 @controller.stubs(:add_trusted_site).returns(false) 40 @controller.stubs(:add_trusted_site).returns(false)
41 post :create, :site => 'new.site.com' 41 post :create, :site => 'new.site.com'
42 assert_response :success # it actually failed, but was not redirected 42 assert_response :success # it actually failed, but was not redirected
43 - assert !@controller.environment.trusted_sites_for_iframe.include?('new.site.com'), 'Site was included in the trusted_sites!?' 43 + assert !assigns(:environment).trusted_sites_for_iframe.include?('new.site.com'), 'Site was included in the trusted_sites!?'
44 end 44 end
45 45
46 should 'destroy site' do 46 should 'destroy site' do
47 post :create, :site => 'todel.site.com' 47 post :create, :site => 'todel.site.com'
48 delete :destroy, :site => 'todel.site.com' 48 delete :destroy, :site => 'todel.site.com'
49 assert_redirected_to :action => :index 49 assert_redirected_to :action => :index
50 - assert ! @controller.environment.trusted_sites_for_iframe.include?('todel.site.com'), 'Site was not removed from trusted_sites' 50 + assert ! assigns(:environment).trusted_sites_for_iframe.include?('todel.site.com'), 'Site was not removed from trusted_sites'
51 end 51 end
52 52
53 should "get edit" do 53 should "get edit" do
@@ -64,8 +64,8 @@ class TrustedSitesControllerTest < ActionController::TestCase @@ -64,8 +64,8 @@ class TrustedSitesControllerTest < ActionController::TestCase
64 post :create, :site => 'toedit.site.com' 64 post :create, :site => 'toedit.site.com'
65 post :update, :orig_site => 'toedit.site.com', :site => 'edited.site.com' 65 post :update, :orig_site => 'toedit.site.com', :site => 'edited.site.com'
66 assert_redirected_to :action => :edit 66 assert_redirected_to :action => :edit
67 - assert ! @controller.environment.trusted_sites_for_iframe.include?('toedit.site.com'), 'Original site found. Site was not updated?'  
68 - assert @controller.environment.trusted_sites_for_iframe.include?('edited.site.com'), 'New name for site not found. Site was not updated?' 67 + assert ! assigns(:environment).trusted_sites_for_iframe.include?('toedit.site.com'), 'Original site found. Site was not updated?'
  68 + assert assigns(:environment).trusted_sites_for_iframe.include?('edited.site.com'), 'New name for site not found. Site was not updated?'
69 end 69 end
70 70
71 should 'fail update gracefully' do 71 should 'fail update gracefully' do
@@ -73,7 +73,7 @@ class TrustedSitesControllerTest < ActionController::TestCase @@ -73,7 +73,7 @@ class TrustedSitesControllerTest < ActionController::TestCase
73 post :create, :site => 'toedit.site.com' 73 post :create, :site => 'toedit.site.com'
74 post :update, :orig_site => 'toedit.site.com', :site => 'edited.site.com' 74 post :update, :orig_site => 'toedit.site.com', :site => 'edited.site.com'
75 assert_response :success # it actually failed, but was not redirected 75 assert_response :success # it actually failed, but was not redirected
76 - assert @controller.environment.trusted_sites_for_iframe.include?('toedit.site.com'), 'Original site not found. Site was updated?'  
77 - assert !@controller.environment.trusted_sites_for_iframe.include?('edited.site.com'), 'New name for site found. Site was updated?' 76 + assert assigns(:environment).trusted_sites_for_iframe.include?('toedit.site.com'), 'Original site not found. Site was updated?'
  77 + assert !assigns(:environment).trusted_sites_for_iframe.include?('edited.site.com'), 'New name for site found. Site was updated?'
78 end 78 end
79 end 79 end