[Git][noosfero/noosfero][master] 2 commits: fix random failures in integration tests

Leandro Nunes gitlab at mg.gitlab.com
Tue Mar 1 10:10:28 BRT 2016


Leandro Nunes pushed to branch master at Noosfero / noosfero


Commits:
680a0a8e by Leandro Nunes dos Santos at 2016-02-29T13:22:18-03:00
fix random failures in integration tests

- - - - -
20d26058 by Leandro Nunes dos Santos at 2016-03-01T10:09:07-03:00
Merge branch 'participa/noosfero-fix_random_integration_failures'

- - - - -


5 changed files:

- test/integration/enable_disable_features_test.rb
- test/integration/enterprise_registration_test.rb
- test/integration/manage_documents_test.rb
- test/integration/manage_friendships_test.rb
- test/support/integration_test.rb


Changes:

=====================================
test/integration/enable_disable_features_test.rb
=====================================
--- a/test/integration/enable_disable_features_test.rb
+++ b/test/integration/enable_disable_features_test.rb
@@ -13,17 +13,15 @@ class EnableDisableFeaturesTest < ActionDispatch::IntegrationTest
     assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature2' }
     assert_tag :tag => 'input', :attributes => { :name => 'environment[enabled_features][]', :value => 'feature3' }
 
-    post '/admin/features/update'
-    assert_response :redirect
+    post_via_redirect '/admin/features/update'
+    assert_response :success
 
-    follow_redirect!
     assert_response :success
     assert_equal '/admin/features', path
 
-    post '/admin/features/update', :environments => { :enabled_features => [ 'feature1' ], :organization_approval_method => 'region' }
-    assert_response :redirect
+    post_via_redirect '/admin/features/update', :environments => { :enabled_features => [ 'feature1' ], :organization_approval_method => 'region' }
+    assert_response :success
 
-    follow_redirect!
     assert_equal '/admin/features', path
 
   end


=====================================
test/integration/enterprise_registration_test.rb
=====================================
--- a/test/integration/enterprise_registration_test.rb
+++ b/test/integration/enterprise_registration_test.rb
@@ -61,10 +61,9 @@ class EnterpriseRegistrationTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_tag :form, :attributes => { :action => "/myprofile/myorg/enterprise_validation/approve/#{code}" }
 
-    post "/myprofile/myorg/enterprise_validation/approve/#{code}"
-    assert_response :redirect
+    post_via_redirect "/myprofile/myorg/enterprise_validation/approve/#{code}"
+    assert_response :success
 
-    follow_redirect!
     assert_equal "/myprofile/myorg/enterprise_validation/view_processed/#{code}", path
     assert_tag :span, :attributes =>  { :class => 'validation_approved' }
   end


=====================================
test/integration/manage_documents_test.rb
=====================================
--- a/test/integration/manage_documents_test.rb
+++ b/test/integration/manage_documents_test.rb
@@ -24,11 +24,10 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest
     assert_tag :tag => 'form', :attributes => { :action => '/myprofile/myuser/cms/new', :method => /post/i }
 
     assert_difference 'Article.count' do
-      post '/myprofile/myuser/cms/new', :type => 'TinyMceArticle', :article => { :name => 'my article', :body => 'this is the body of ther article'}
+      post_via_redirect '/myprofile/myuser/cms/new', :type => 'TinyMceArticle', :article => { :name => 'my article', :body => 'this is the body of ther article'}
     end
 
-    assert_response :redirect
-    follow_redirect!
+    assert_response :success
     a = Article.find_by_path('my-article')
     assert_equal "/myuser/#{a.slug}", path
   end
@@ -55,14 +54,13 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest
     assert_tag :tag => 'form', :attributes => { :action => "/myprofile/myuser/cms/edit/#{article.id}", :method => /post/i }
 
     assert_no_difference 'Article.count' do
-      post "/myprofile/myuser/cms/edit/#{article.id}", :article => { :name => 'my article', :body => 'this is the body of the article'}
+      post_via_redirect "/myprofile/myuser/cms/edit/#{article.id}", :article => { :name => 'my article', :body => 'this is the body of the article'}
     end
 
     article.reload
     assert_equal 'this is the body of the article', article.body
 
-    assert_response :redirect
-    follow_redirect!
+    assert_response :success
     a = Article.find_by_path('my-article')
     assert_equal "/myuser/#{a.slug}", path
   end
@@ -84,10 +82,9 @@ class ManageDocumentsTest < ActionDispatch::IntegrationTest
     assert_response :success
 
     assert_tag tag: 'a', attributes: { href: "/myprofile/myuser/cms/destroy/#{article.id}", 'data-confirm' => /Are you sure/ }
-    post "/myprofile/myuser/cms/destroy/#{article.id}"
+    post_via_redirect "/myprofile/myuser/cms/destroy/#{article.id}"
 
-    assert_response :redirect
-    follow_redirect!
+    assert_response :success
     assert_equal "/myuser", path
 
     # the article was actually deleted


=====================================
test/integration/manage_friendships_test.rb
=====================================
--- a/test/integration/manage_friendships_test.rb
+++ b/test/integration/manage_friendships_test.rb
@@ -24,11 +24,10 @@ class ManageFriendshipsTest < ActionDispatch::IntegrationTest
     get "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}"
     assert_response :success
 
-    post "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}",
+    post_via_redirect "/myprofile/#{@person.identifier}/friends/remove/#{@friend.id}",
       :confirmation => '1'
-    assert_response :redirect
+    assert_response :success
 
-    follow_redirect!
 
     assert assigns(:friends).empty?
     refute @person.is_a_friend?(@friend)


=====================================
test/support/integration_test.rb
=====================================
--- a/test/support/integration_test.rb
+++ b/test/support/integration_test.rb
@@ -14,9 +14,8 @@ class ActionDispatch::IntegrationTest
   def login(username, password)
     ActionDispatch::Integration::Session.any_instance.stubs(:https?).returns(true)
 
-    post '/account/login', :user => { :login => username, :password => password }
-    assert_response :redirect
-    follow_redirect!
+    post_via_redirect '/account/login', :user => { :login => username, :password => password }
+    assert_response :success
     assert_not_equal '/account/login', path
   end
 



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/258ad13993ffa437dbcbc4951b4331100561d872...20d26058c62948e9ccac705e060af026990a8469
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160301/20f48182/attachment.html>


More information about the Noosfero-dev mailing list