From 680a0a8e558eb8f9abb49f49458fd49ca7303c1b Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Mon, 22 Feb 2016 08:56:29 -0300 Subject: [PATCH] fix random failures in integration tests --- test/integration/enable_disable_features_test.rb | 10 ++++------ test/integration/enterprise_registration_test.rb | 5 ++--- test/integration/manage_documents_test.rb | 15 ++++++--------- test/integration/manage_friendships_test.rb | 5 ++--- test/support/integration_test.rb | 5 ++--- 5 files changed, 16 insertions(+), 24 deletions(-) diff --git a/test/integration/enable_disable_features_test.rb b/test/integration/enable_disable_features_test.rb index 1c7a036..faa1ef5 100644 --- 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 diff --git a/test/integration/enterprise_registration_test.rb b/test/integration/enterprise_registration_test.rb index 69d5f8a..4b15f39 100644 --- 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 diff --git a/test/integration/manage_documents_test.rb b/test/integration/manage_documents_test.rb index a8cec6b..7afa33f 100644 --- 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 diff --git a/test/integration/manage_friendships_test.rb b/test/integration/manage_friendships_test.rb index 27885aa..db4b977 100644 --- 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) diff --git a/test/support/integration_test.rb b/test/support/integration_test.rb index 2c3a82f..17941ce 100644 --- 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 -- libgit2 0.21.2