-
-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1155 from eip-ewi/system-test-login
- Loading branch information
Showing
4 changed files
with
71 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
standard_user: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: standard_user | ||
is_global_admin: false | ||
|
@@ -9,7 +9,7 @@ standard_user: | |
|
||
closer: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: closer | ||
website: https://example.com/closer | ||
|
@@ -22,7 +22,7 @@ closer: | |
|
||
editor: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: editor | ||
is_global_admin: false | ||
|
@@ -33,7 +33,7 @@ editor: | |
|
||
deleter: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: deleter | ||
is_global_admin: false | ||
|
@@ -42,7 +42,7 @@ deleter: | |
|
||
moderator: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: moderator | ||
is_global_admin: false | ||
|
@@ -51,7 +51,7 @@ moderator: | |
|
||
admin: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: admin | ||
is_global_admin: false | ||
|
@@ -60,7 +60,7 @@ admin: | |
|
||
global_moderator: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: global-moderator | ||
is_global_admin: false | ||
|
@@ -69,7 +69,7 @@ global_moderator: | |
|
||
global_admin: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: global-admin | ||
is_global_admin: true | ||
|
@@ -78,7 +78,7 @@ global_admin: | |
|
||
no_community_user: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: no_community_user | ||
is_global_admin: false | ||
|
@@ -88,7 +88,7 @@ no_community_user: | |
system: | ||
id: -99 | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: system | ||
is_global_admin: true | ||
|
@@ -97,7 +97,7 @@ system: | |
|
||
deleted_account: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: deleted_account | ||
confirmed_at: 2020-01-01T00:00:00.000000Z | ||
|
@@ -107,7 +107,7 @@ deleted_account: | |
|
||
deleted_profile: | ||
email: [email protected] | ||
encrypted_password: abcdefghijklmnopqrstuvwxyz | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: deleted_profile | ||
confirmed_at: 2020-01-01T00:00:00.000000Z |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
require 'application_system_test_case' | ||
|
||
class LoginTest < ApplicationSystemTestCase | ||
test 'User can register a new account and sign-in to it after confirming their email' do | ||
email = '[email protected]' | ||
username = 'Test User' | ||
password = 'login_test_1' | ||
|
||
# Sign up for an account | ||
visit root_url | ||
click_on 'Sign Up' | ||
fill_in 'Email', with: email | ||
fill_in 'Username', with: username | ||
fill_in 'Password', with: password | ||
fill_in 'Password confirmation', with: password | ||
|
||
# Check that the user is created in the DB | ||
assert_difference 'User.count' do | ||
click_on 'Sign up' | ||
end | ||
|
||
user = User.last | ||
|
||
# Try logging in directly, this should fail because not confirmed yet | ||
log_in user, password | ||
assert_selector '.notice', text: 'You have to confirm your email address before continuing.' | ||
|
||
# Confirm email and sign in again, should succeed this time | ||
confirm_email user | ||
log_in user, password | ||
assert_selector '.notice', text: 'Signed in successfully.' | ||
end | ||
|
||
test 'User can sign in and is redirected back to the page they were on' do | ||
# Start on the users page | ||
visit users_url | ||
|
||
# Click the sign in button (top right) | ||
# Don't go through log_in helper, since we want to test the sign-in fully here | ||
click_on 'Sign In' | ||
fill_in 'Email', with: users(:standard_user).email | ||
fill_in 'Password', with: 'test123' | ||
click_button 'Sign in' | ||
|
||
# We should see a message that we have signed in, and we should be on the users page again. | ||
assert_selector '.notice', text: 'Signed in successfully.' | ||
assert_current_path users_url | ||
end | ||
|
||
test 'User can sign out' do | ||
log_in :standard_user | ||
assert_selector '.notice', text: 'Signed in successfully.' | ||
|
||
log_out | ||
assert_selector '.notice', text: 'Signed out successfully.' | ||
end | ||
end |