From 2c3626884efb86ac4477754780e5c5d612e5264e Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Wed, 18 Jun 2014 16:02:38 +0200 Subject: Test the redirect after sign in. --- features/project/redirects.feature | 6 ++++++ features/steps/project/redirects.rb | 6 ++++++ 2 files changed, 12 insertions(+) (limited to 'features') diff --git a/features/project/redirects.feature b/features/project/redirects.feature index ce197912f64..1f85bab71f1 100644 --- a/features/project/redirects.feature +++ b/features/project/redirects.feature @@ -24,3 +24,9 @@ Feature: Project Redirects Given I sign in as a user When I visit project "Enterprise" page Then page status code should be 404 + + Scenario: I visit a public project without signing in + When I visit project "Community" page + And I should see project "Community" home page + And I sign in as a user + Then I should be redirected to "Community" page diff --git a/features/steps/project/redirects.rb b/features/steps/project/redirects.rb index cfa4ce82be3..16c32a4d56a 100644 --- a/features/steps/project/redirects.rb +++ b/features/steps/project/redirects.rb @@ -31,5 +31,11 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps project = Project.find_by(name: 'Community') visit project_path(project) + 'DoesNotExist' end + + step 'I should be redirected to "Community" page' do + project = Project.find_by(name: 'Community') + page.current_path.should == "/#{project.path_with_namespace}" + page.status_code.should == 200 + end end -- cgit v1.2.3 From 26d1bd7c2a285da734ed0b8eab5c31cd5237caa4 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 19 Jun 2014 14:20:25 +0200 Subject: Set return url as param. --- features/project/redirects.feature | 2 +- features/steps/project/redirects.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'features') diff --git a/features/project/redirects.feature b/features/project/redirects.feature index 1f85bab71f1..10e5fbf55c7 100644 --- a/features/project/redirects.feature +++ b/features/project/redirects.feature @@ -28,5 +28,5 @@ Feature: Project Redirects Scenario: I visit a public project without signing in When I visit project "Community" page And I should see project "Community" home page - And I sign in as a user + And I click on "Sign In" Then I should be redirected to "Community" page diff --git a/features/steps/project/redirects.rb b/features/steps/project/redirects.rb index 16c32a4d56a..2ce0e836119 100644 --- a/features/steps/project/redirects.rb +++ b/features/steps/project/redirects.rb @@ -32,6 +32,10 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps visit project_path(project) + 'DoesNotExist' end + step 'I click on "Sign In"' do + click_link "Sign in" + end + step 'I should be redirected to "Community" page' do project = Project.find_by(name: 'Community') page.current_path.should == "/#{project.path_with_namespace}" -- cgit v1.2.3 From db88797ef9e9012238b45857dfcec15a12838305 Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 19 Jun 2014 16:46:01 +0200 Subject: Fix test --- features/project/redirects.feature | 1 + features/steps/project/redirects.rb | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'features') diff --git a/features/project/redirects.feature b/features/project/redirects.feature index 10e5fbf55c7..776ab83a876 100644 --- a/features/project/redirects.feature +++ b/features/project/redirects.feature @@ -29,4 +29,5 @@ Feature: Project Redirects When I visit project "Community" page And I should see project "Community" home page And I click on "Sign In" + And Authenticate Then I should be redirected to "Community" page diff --git a/features/steps/project/redirects.rb b/features/steps/project/redirects.rb index 2ce0e836119..5a4342dba30 100644 --- a/features/steps/project/redirects.rb +++ b/features/steps/project/redirects.rb @@ -33,7 +33,19 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps end step 'I click on "Sign In"' do - click_link "Sign in" + within '.pull-right' do + click_link "Sign in" + end + end + + step 'Authenticate' do + admin = create(:admin) + project = Project.find_by(name: 'Community') + find(:xpath, "//input[@id='return_to']").set "/#{project.path_with_namespace}" + fill_in "user_login", with: admin.email + fill_in "user_password", with: admin.password + click_button "Sign in" + Thread.current[:current_user] = admin end step 'I should be redirected to "Community" page' do -- cgit v1.2.3