summaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
Diffstat (limited to 'features')
-rw-r--r--features/profile/profile.feature4
-rw-r--r--features/project/forked_merge_requests.feature3
-rw-r--r--features/steps/project/forked_merge_requests.rb2
-rw-r--r--features/steps/project/merge_requests/acceptance.rb2
-rw-r--r--features/steps/project/merge_requests/revert.rb2
-rw-r--r--features/steps/shared/authentication.rb51
-rw-r--r--features/support/login_helpers.rb19
7 files changed, 70 insertions, 13 deletions
diff --git a/features/profile/profile.feature b/features/profile/profile.feature
index dc1339deb4c..70f47c97173 100644
--- a/features/profile/profile.feature
+++ b/features/profile/profile.feature
@@ -60,7 +60,9 @@ Feature: Profile
Then I should see a password error message
Scenario: I visit history tab
- Given I have activity
+ Given I logout
+ And I sign in via the UI
+ And I have activity
When I visit Audit Log page
Then I should see my activity
diff --git a/features/project/forked_merge_requests.feature b/features/project/forked_merge_requests.feature
index 67f1e117f7f..9809b0ea0fe 100644
--- a/features/project/forked_merge_requests.feature
+++ b/features/project/forked_merge_requests.feature
@@ -41,8 +41,7 @@ Feature: Project Forked Merge Requests
@javascript
Scenario: I see the users in the target project for a new merge request
- Given I logout
- And I sign in as an admin
+ Given I sign in as an admin
And I have a project forked off of "Shop" called "Forked Shop"
Then I visit project "Forked Shop" merge requests page
And I click link "New Merge Request"
diff --git a/features/steps/project/forked_merge_requests.rb b/features/steps/project/forked_merge_requests.rb
index ef1bb453615..8081b764be6 100644
--- a/features/steps/project/forked_merge_requests.rb
+++ b/features/steps/project/forked_merge_requests.rb
@@ -6,7 +6,7 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
include Select2Helper
step 'I am a member of project "Shop"' do
- @project = Project.find_by(name: "Shop")
+ @project = ::Project.find_by(name: "Shop")
@project ||= create(:project, :repository, name: "Shop")
@project.team << [@user, :reporter]
end
diff --git a/features/steps/project/merge_requests/acceptance.rb b/features/steps/project/merge_requests/acceptance.rb
index d7167352e02..7521a9439e3 100644
--- a/features/steps/project/merge_requests/acceptance.rb
+++ b/features/steps/project/merge_requests/acceptance.rb
@@ -43,7 +43,7 @@ class Spinach::Features::ProjectMergeRequestsAcceptance < Spinach::FeatureSteps
end
step 'I am signed in as a developer of the project' do
- login_as(@user)
+ sign_in(@user)
end
step 'I should see merge request merged' do
diff --git a/features/steps/project/merge_requests/revert.rb b/features/steps/project/merge_requests/revert.rb
index a8f4e4ef027..1149c1c2426 100644
--- a/features/steps/project/merge_requests/revert.rb
+++ b/features/steps/project/merge_requests/revert.rb
@@ -31,7 +31,7 @@ class Spinach::Features::RevertMergeRequests < Spinach::FeatureSteps
step 'I am signed in as a developer of the project' do
@user = create(:user) { |u| @project.add_developer(u) }
- login_as(@user)
+ sign_in(@user)
end
step 'There is an open Merge Request' do
diff --git a/features/steps/shared/authentication.rb b/features/steps/shared/authentication.rb
index 5c3e724746b..97fac595d8e 100644
--- a/features/steps/shared/authentication.rb
+++ b/features/steps/shared/authentication.rb
@@ -1,23 +1,33 @@
-require Rails.root.join('spec', 'support', 'login_helpers')
+require Rails.root.join('features', 'support', 'login_helpers')
module SharedAuthentication
include Spinach::DSL
include LoginHelpers
step 'I sign in as a user' do
- login_as :user
+ sign_out(@user) if @user
+
+ @user = create(:user)
+ sign_in(@user)
+ end
+
+ step 'I sign in via the UI' do
+ gitlab_sign_in(create(:user))
end
step 'I sign in as an admin' do
- login_as :admin
+ sign_out(@user) if @user
+
+ @user = create(:admin)
+ sign_in(@user)
end
step 'I sign in as "John Doe"' do
- login_with(user_exists("John Doe"))
+ gitlab_sign_in(user_exists("John Doe"))
end
step 'I sign in as "Mary Jane"' do
- login_with(user_exists("Mary Jane"))
+ gitlab_sign_in(user_exists("Mary Jane"))
end
step 'I should be redirected to sign in page' do
@@ -25,14 +35,41 @@ module SharedAuthentication
end
step "I logout" do
- logout
+ gitlab_sign_out
end
step "I logout directly" do
- logout_direct
+ gitlab_sign_out
end
def current_user
@user || User.reorder(nil).first
end
+
+ private
+
+ def gitlab_sign_in(user)
+ visit new_user_session_path
+
+ fill_in "user_login", with: user.email
+ fill_in "user_password", with: "12345678"
+ check 'user_remember_me'
+ click_button "Sign in"
+
+ @user = user
+ end
+
+ def gitlab_sign_out
+ return unless @user
+
+ if Capybara.current_driver == Capybara.javascript_driver
+ find('.header-user-dropdown-toggle').click
+ click_link 'Sign out'
+ expect(page).to have_button('Sign in')
+ else
+ sign_out(@user)
+ end
+
+ @user = nil
+ end
end
diff --git a/features/support/login_helpers.rb b/features/support/login_helpers.rb
new file mode 100644
index 00000000000..540ff25a4f2
--- /dev/null
+++ b/features/support/login_helpers.rb
@@ -0,0 +1,19 @@
+module LoginHelpers
+ # After inclusion, IntegrationHelpers calls these two methods that aren't
+ # supported by Spinach, so we perform the end results ourselves
+ class << self
+ def setup(*args)
+ Spinach.hooks.before_scenario do
+ Warden.test_mode!
+ end
+ end
+
+ def teardown(*args)
+ Spinach.hooks.after_scenario do
+ Warden.test_reset!
+ end
+ end
+ end
+
+ include Devise::Test::IntegrationHelpers
+end