-
Notifications
You must be signed in to change notification settings - Fork 0
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 #7 from meyerhoferc/user-profile
User profile
- Loading branch information
Showing
9 changed files
with
93 additions
and
14 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
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,5 +1,4 @@ | ||
class WelcomeController < ApplicationController | ||
def index | ||
#@users = User.all | ||
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,3 @@ | ||
Name: <%= "#{@user.first_name} #{@user.last_name}" %> | ||
<br> | ||
Email: <%= @user.email %> |
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,38 @@ | ||
require 'rails_helper' | ||
|
||
describe 'user signup' do | ||
context 'with a new user' do | ||
it 'they can create an account' do | ||
visit root_path | ||
click_on 'Sign Up' | ||
expect(current_path).to eq signup_path | ||
fill_in('user[first_name]', with: 'Ra') | ||
fill_in('user[last_name]', with: 'Zz') | ||
fill_in('user[email]', with: '[email protected]') | ||
fill_in('user[password]', with: 'passpass') | ||
fill_in('user[password_confirmation]', with: 'passpass') | ||
click_on 'Create User' | ||
|
||
expect(current_path).to eq login_path | ||
fill_in('email', with: '[email protected]') | ||
fill_in('password', with: 'passpass') | ||
click_on 'Log In' | ||
|
||
expect(current_path).to eq root_path | ||
expect(page).to have_content 'Welcome, Ra.' | ||
expect(page).to have_link 'Sign Out' | ||
expect(page).to have_link 'Profile' | ||
expect(page).not_to have_link 'Log In' | ||
expect(page).not_to have_link 'Sign Up' | ||
end | ||
end | ||
|
||
context 'as an existing, logged in user' do | ||
it 'redirects from /signup to root' do | ||
u = User.create(first_name: 'Raa', last_name: 'Zzz', email: '[email protected]', password: 'passpass') | ||
allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(u) | ||
visit signup_path | ||
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 |
---|---|---|
|
@@ -7,4 +7,27 @@ | |
expect(u.authenticate('notthepassword')).to be_falsey | ||
expect(u.authenticate('password123')).to eq u | ||
end | ||
|
||
describe 'validations' do | ||
it 'validates email is present' do | ||
u = User.new(first_name: 'Raz', last_name: 'Z', email: '', password: 'passpass') | ||
expect(u.valid?).to eq false | ||
end | ||
|
||
it 'validates first name is present' do | ||
u = User.new(first_name: nil, last_name: 'Z', email: '[email protected]', password: 'passpass') | ||
expect(u.valid?).to be_falsey | ||
end | ||
|
||
it 'validates last name is present' do | ||
u = User.new(first_name: 'Razz', last_name: nil, email: '[email protected]', password: 'passpass') | ||
expect(u.valid?).to be_falsey | ||
end | ||
|
||
it 'validates email is unique' do | ||
User.create(first_name: 'Raz', last_name: 'Z', email: '[email protected]', password: 'passpass') | ||
v = User.new(first_name: 'Raz', last_name: 'Z', email: '[email protected]', password: 'passpass') | ||
expect(v.valid?).to eq false | ||
end | ||
end | ||
end |