Commit 680a0a8e558eb8f9abb49f49458fd49ca7303c1b

Authored by Leandro Santos
1 parent 258ad139

fix random failures in integration tests

test/integration/enable_disable_features_test.rb
@@ -13,17 +13,15 @@ class EnableDisableFeaturesTest < ActionDispatch::IntegrationTest @@ -13,17 +13,15 @@ class EnableDisableFeaturesTest < ActionDispatch::IntegrationTest
13 assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature2' } 13 assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature2' }
14 assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature3' } 14 assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature3' }
15 15
16 - post '/admin/features/update'  
17 - assert_response :redirect 16 + post_via_redirect '/admin/features/update'
  17 + assert_response :success
18 18
19 - follow_redirect!  
20 assert_response :success 19 assert_response :success
21 assert_equal '/admin/features', path 20 assert_equal '/admin/features', path
22 21
23 - post '/admin/features/update', :environments => { :enabled_features => [ 'feature1' ], :organization_approval_method => 'region' }  
24 - assert_response :redirect 22 + post_via_redirect '/admin/features/update', :environments => { :enabled_features => [ 'feature1' ], :organization_approval_method => 'region' }
  23 + assert_response :success
25 24
26 - follow_redirect!  
27 assert_equal '/admin/features', path 25 assert_equal '/admin/features', path
28 26
29 end 27 end
test/integration/enterprise_registration_test.rb
@@ -61,10 +61,9 @@ class EnterpriseRegistrationTest < ActionDispatch::IntegrationTest @@ -61,10 +61,9 @@ class EnterpriseRegistrationTest < ActionDispatch::IntegrationTest
61 assert_response :success 61 assert_response :success
62 assert_tag :form, :attributes => { :action => "/myprofile/myorg/enterprise_validation/approve/#{code}" } 62 assert_tag :form, :attributes => { :action => "/myprofile/myorg/enterprise_validation/approve/#{code}" }
63 63
64 - post "/myprofile/myorg/enterprise_validation/approve/#{code}"  
65 - assert_response :redirect 64 + post_via_redirect "/myprofile/myorg/enterprise_validation/approve/#{code}"
  65 + assert_response :success
66 66
67 - follow_redirect!  
68 assert_equal "/myprofile/myorg/enterprise_validation/view_processed/#{code}", path 67 assert_equal "/myprofile/myorg/enterprise_validation/view_processed/#{code}", path
69 assert_tag :span, :attributes => { :class => 'validation_approved' } 68 assert_tag :span, :attributes => { :class => 'validation_approved' }
70 end 69 end
test/integration/manage_documents_test.rb
@@ -24,11 +24,10 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest @@ -24,11 +24,10 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest
24 assert_tag :tag => 'form', :attributes => { :action => '/myprofile/myuser/cms/new', :method => /post/i } 24 assert_tag :tag => 'form', :attributes => { :action => '/myprofile/myuser/cms/new', :method => /post/i }
25 25
26 assert_difference 'Article.count' do 26 assert_difference 'Article.count' do
27 - post '/myprofile/myuser/cms/new', :type => 'TinyMceArticle', :article => { :name => 'my article', :body => 'this is the body of ther article'} 27 + post_via_redirect '/myprofile/myuser/cms/new', :type => 'TinyMceArticle', :article => { :name => 'my article', :body => 'this is the body of ther article'}
28 end 28 end
29 29
30 - assert_response :redirect  
31 - follow_redirect! 30 + assert_response :success
32 a = Article.find_by_path('my-article') 31 a = Article.find_by_path('my-article')
33 assert_equal "/myuser/#{a.slug}", path 32 assert_equal "/myuser/#{a.slug}", path
34 end 33 end
@@ -55,14 +54,13 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest @@ -55,14 +54,13 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest
55 assert_tag :tag => 'form', :attributes => { :action => "/myprofile/myuser/cms/edit/#{article.id}", :method => /post/i } 54 assert_tag :tag => 'form', :attributes => { :action => "/myprofile/myuser/cms/edit/#{article.id}", :method => /post/i }
56 55
57 assert_no_difference 'Article.count' do 56 assert_no_difference 'Article.count' do
58 - post "/myprofile/myuser/cms/edit/#{article.id}", :article => { :name => 'my article', :body => 'this is the body of the article'} 57 + post_via_redirect "/myprofile/myuser/cms/edit/#{article.id}", :article => { :name => 'my article', :body => 'this is the body of the article'}
59 end 58 end
60 59
61 article.reload 60 article.reload
62 assert_equal 'this is the body of the article', article.body 61 assert_equal 'this is the body of the article', article.body
63 62
64 - assert_response :redirect  
65 - follow_redirect! 63 + assert_response :success
66 a = Article.find_by_path('my-article') 64 a = Article.find_by_path('my-article')
67 assert_equal "/myuser/#{a.slug}", path 65 assert_equal "/myuser/#{a.slug}", path
68 end 66 end
@@ -84,10 +82,9 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest @@ -84,10 +82,9 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest
84 assert_response :success 82 assert_response :success
85 83
86 assert_tag tag: 'a', attributes: { href: "/myprofile/myuser/cms/destroy/#{article.id}", 'data-confirm' => /Are you sure/ } 84 assert_tag tag: 'a', attributes: { href: "/myprofile/myuser/cms/destroy/#{article.id}", 'data-confirm' => /Are you sure/ }
87 - post "/myprofile/myuser/cms/destroy/#{article.id}" 85 + post_via_redirect "/myprofile/myuser/cms/destroy/#{article.id}"
88 86
89 - assert_response :redirect  
90 - follow_redirect! 87 + assert_response :success
91 assert_equal "/myuser", path 88 assert_equal "/myuser", path
92 89
93 # the article was actually deleted 90 # the article was actually deleted
test/integration/manage_friendships_test.rb
@@ -24,11 +24,10 @@ class ManageFriendshipsTest < ActionDispatch::IntegrationTest @@ -24,11 +24,10 @@ class ManageFriendshipsTest < ActionDispatch::IntegrationTest
24 get "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}" 24 get "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}"
25 assert_response :success 25 assert_response :success
26 26
27 - post "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}", 27 + post_via_redirect "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}",
28 :confirmation => '1' 28 :confirmation => '1'
29 - assert_response :redirect 29 + assert_response :success
30 30
31 - follow_redirect!  
32 31
33 assert assigns(:friends).empty? 32 assert assigns(:friends).empty?
34 refute @person.is_a_friend?(@friend) 33 refute @person.is_a_friend?(@friend)
test/support/integration_test.rb
@@ -14,9 +14,8 @@ class ActionDispatch::IntegrationTest @@ -14,9 +14,8 @@ class ActionDispatch::IntegrationTest
14 def login(username, password) 14 def login(username, password)
15 ActionDispatch::Integration::Session.any_instance.stubs(:https?).returns(true) 15 ActionDispatch::Integration::Session.any_instance.stubs(:https?).returns(true)
16 16
17 - post '/account/login', :user => { :login => username, :password => password }  
18 - assert_response :redirect  
19 - follow_redirect! 17 + post_via_redirect '/account/login', :user => { :login => username, :password => password }
  18 + assert_response :success
20 assert_not_equal '/account/login', path 19 assert_not_equal '/account/login', path
21 end 20 end
22 21