-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RSpec testing for user sign-up and sign-in
- Loading branch information
1 parent
4b6ec8b
commit cd2f5c2
Showing
12 changed files
with
179 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,3 +15,6 @@ | |
/log/* | ||
!/log/.keep | ||
/tmp | ||
|
||
# Ignore application configuration | ||
/config/application.yml |
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
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,2 +1,2 @@ | ||
module ApplicationHelper | ||
end | ||
end |
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
SENDGRID_PASSWORD: | ||
This comment has been minimized.
Sorry, something went wrong. |
||
SENDGRID_USERNAME: |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
require 'rails_helper' | ||
|
||
describe "Edit user attributes" do | ||
|
||
describe "change user password" do | ||
before do | ||
@user = create(:user) | ||
|
||
#Sign in User | ||
visit new_user_session_path | ||
|
||
fill_in "Email", with: @user.email | ||
fill_in "Password", with: @user.password | ||
click_button "Log in" | ||
expect( current_path ).to eq(root_path) | ||
visit edit_user_registration_path | ||
end | ||
|
||
it "is not updated without current password" do | ||
|
||
fill_in "Password", with: 'newpassword' | ||
fill_in "Password confirmation", with: 'newpassword' | ||
fill_in "Current password", with: '' | ||
This comment has been minimized.
Sorry, something went wrong.
felixclack
|
||
click_button "Update" | ||
expect( page ).to have_content("Current password can't be blank") | ||
end | ||
|
||
it "is not updated if 'password confirmation' does not mach password" do | ||
|
||
fill_in "Password", with: 'newpassword' | ||
fill_in "Password confirmation", with: 'password' | ||
fill_in "Current password", with: @user.password | ||
This comment has been minimized.
Sorry, something went wrong.
felixclack
|
||
click_button "Update" | ||
expect( page ).to have_content("Password confirmation doesn't match Password") | ||
end | ||
|
||
it "is not updated if password is shorter than 8 characters" do | ||
|
||
fill_in "Password", with: 'word' | ||
fill_in "Password confirmation", with: 'word' | ||
fill_in "Current password", with: @user.password | ||
click_button "Update" | ||
expect( page ).to have_content("Password is too short") | ||
end | ||
|
||
it "updates password with all fields correctly entered" do | ||
fill_in "Password", with: 'newpassword' | ||
fill_in "Password confirmation", with: 'newpassword' | ||
fill_in "Current password", with: @user.password | ||
click_button "Update" | ||
expect( current_path ).to eq(root_path) | ||
end | ||
|
||
end | ||
end | ||
|
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,48 @@ | ||
require 'rails_helper' | ||
|
||
describe 'User sign-in' do | ||
|
||
describe "successful sign-in" do | ||
before do | ||
@user = create(:user) | ||
end | ||
|
||
it "allows confirmed user to sign-in" do | ||
|
||
visit new_user_session_path | ||
|
||
fill_in "Email", with: @user.email | ||
fill_in "Password", with: @user.password | ||
click_button "Log in" | ||
expect( current_path ).to eq(root_path) | ||
end | ||
end | ||
|
||
describe "navigation changes to reflect #current_user" do | ||
before do | ||
@user = create(:user) | ||
end | ||
|
||
it "shows #user.name when signed in" do | ||
|
||
visit new_user_session_path | ||
|
||
fill_in "Email", with: @user.email | ||
fill_in "Password", with: @user.password | ||
click_button "Log in" | ||
expect( page ).to have_content(@user.name) | ||
end | ||
|
||
it "shows link to 'sign-in' when no user is signed in" do | ||
|
||
visit root_path | ||
|
||
within '.user-info' do | ||
expect( page ).to have_content("Sign In") | ||
end | ||
end | ||
end | ||
end | ||
|
||
|
||
|
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
The extension of this file should be
.yml
rather than.rb