diff options
author | Robert Speicher <rspeicher@gmail.com> | 2017-06-05 14:22:37 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2017-06-19 17:43:54 -0500 |
commit | c1cbc27314dd4a83b6a337072e4c386cbcd14ca7 (patch) | |
tree | b40fbfb997a97af313e80018135c516031690e5b | |
parent | 6ac777a7592533d9c7b3682b2b9ca8caccca3f4d (diff) | |
download | gitlab-ce-c1cbc27314dd4a83b6a337072e4c386cbcd14ca7.tar.gz |
Rename methods in the LoginHelpers module
- [x] Rename `login_as` to `gitlab_sign_in`
- [x] Rename `login_with` to `gitlab_sign_in_with`
- [x] Rename `login_via` to `gitlab_sign_in_via`
- [x] Rename `logout` to `gitlab_sign_out`
- [x] Rename `logout_direct` to `gitlab_sign_out_direct`
- [x] Make `gitlab_login_with` (née `login_with`) private
- [x] Make `mock_auth_hash` private
-rw-r--r-- | spec/support/login_helpers.rb | 57 |
1 files changed, 31 insertions, 26 deletions
diff --git a/spec/support/login_helpers.rb b/spec/support/login_helpers.rb index e6da852e728..cd6af454f48 100644 --- a/spec/support/login_helpers.rb +++ b/spec/support/login_helpers.rb @@ -6,15 +6,15 @@ module LoginHelpers # Examples: # # # Create a user automatically - # login_as(:user) + # gitlab_sign_in(:user) # # # Create an admin automatically - # login_as(:admin) + # gitlab_sign_in(:admin) # # # Provide an existing User record # user = create(:user) - # login_as(user) - def login_as(user_or_role) + # gitlab_sign_in(user) + def gitlab_sign_in(user_or_role) @user = if user_or_role.is_a?(User) user_or_role @@ -22,26 +22,44 @@ module LoginHelpers create(user_or_role) end - login_with(@user) + gitlab_sign_in_with(@user) end - # Internal: Login as the specified user + def gitlab_sign_in_via(provider, user, uid) + mock_auth_hash(provider, uid, user.email) + visit new_user_session_path + click_link provider + end + + # Requires Javascript driver. + def gitlab_sign_out + find(".header-user-dropdown-toggle").click + click_link "Sign out" + # check the sign_in button + expect(page).to have_button('Sign in') + end + + # Logout without JavaScript driver + def gitlab_sign_out_direct + page.driver.submit :delete, '/users/sign_out', {} + end + + private + + # Private: Login as the specified user # # user - User instance to login with # remember - Whether or not to check "Remember me" (default: false) - def login_with(user, remember: false) + def gitlab_sign_in_with(user, remember: false) visit new_user_session_path + fill_in "user_login", with: user.email fill_in "user_password", with: "12345678" check 'user_remember_me' if remember + click_button "Sign in" - Thread.current[:current_user] = user - end - def login_via(provider, user, uid) - mock_auth_hash(provider, uid, user.email) - visit new_user_session_path - click_link provider + Thread.current[:current_user] = user end def mock_auth_hash(provider, uid, email) @@ -71,17 +89,4 @@ module LoginHelpers }) Rails.application.env_config['omniauth.auth'] = OmniAuth.config.mock_auth[:saml] end - - # Requires Javascript driver. - def logout - find(".header-user-dropdown-toggle").click - click_link "Sign out" - # check the sign_in button - expect(page).to have_button('Sign in') - end - - # Logout without JavaScript driver - def logout_direct - page.driver.submit :delete, '/users/sign_out', {} - end end |