forked from turingschool-projects/little_shop_v2
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User story9 #101
Closed
Closed
User story9 #101
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
25020c2
Added model test for email string generation.
zachlp2016 7c32636
Refactored the email confirmation method.
zachlp2016 c9eeef7
Added test for duplicate email and verified it's working
zachlp2016 57a348f
Added test for password confirmation and verified it's working.
zachlp2016 755b475
Merge branch 'master' into user_story9
zachlp2016 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
describe 'When I visit the register new register link' do | ||
|
||
before :each do | ||
@user_1 = User.create!(name: "default_user", role: 0, active: true, password_digest: "8320280282", address: "333", city: "Denver", zip: "80000", email: "[email protected]", state: 'IL' ) | ||
@user_1 = User.create!(name: "default_user", role: 0, active: true, password_digest: "8320280282", address: "333", city: "Denver", state: "CO", zip: "80000", email: "[email protected]" ) | ||
end | ||
|
||
it 'I can register as a new user' do | ||
|
@@ -45,8 +45,58 @@ | |
|
||
end | ||
|
||
it 'Can not use an already used email address' do | ||
user_2 = User.create!(name: "User_1", role: 0, active: true, password_digest: "8320280282", address: "333", city: "Denver", zip: "80000", email: "[email protected]", state: 'IL' ) | ||
it 'I throws flash message when password isnt the same' do | ||
|
||
|
||
visit root_path | ||
|
||
within '.register-link' do | ||
click_link('Register') | ||
end | ||
|
||
expect(current_path).to eq(register_path) | ||
|
||
fill_in 'Name', with: 'User' | ||
fill_in 'Address', with: '1111 South One St.' | ||
fill_in 'City', with: 'Denver' | ||
fill_in 'State', with: 'CO' | ||
fill_in 'Zip', with: '80000' | ||
fill_in 'Email', with: '[email protected]' | ||
fill_in 'Password', with: 'password' | ||
fill_in 'Confirm password', with: 'password3' | ||
|
||
click_button 'Create User' | ||
|
||
|
||
new_user = User.last | ||
|
||
|
||
expect(current_path).to eq(register_path) | ||
|
||
expect(page).to have_content("Those passwords don't match.") | ||
|
||
end | ||
|
||
it 'Can not use a duplicate email address' do | ||
|
||
visit root_path | ||
|
||
within '.register-link' do | ||
click_link('Register') | ||
end | ||
|
||
|
||
fill_in 'Name', with: 'User_1' | ||
fill_in 'Address', with: '1111 South One St.' | ||
fill_in 'City', with: 'Denver' | ||
fill_in 'State', with: 'CO' | ||
fill_in 'Zip', with: '80000' | ||
fill_in 'Email', with: '[email protected]' | ||
fill_in 'Password', with: 'password' | ||
fill_in 'Confirm password', with: 'password' | ||
|
||
click_button 'Create User' | ||
|
||
visit root_path | ||
|
||
within '.navbar' do | ||
|
@@ -65,9 +115,13 @@ | |
click_button 'Create User' | ||
|
||
new_user = User.last | ||
|
||
expect(page).to have_content("That email address is already taken.") | ||
expect(new_user.name).to eq('User_1') | ||
end | ||
end | ||
end | ||
end | ||
|
||
# My details are not saved and I am not logged in | ||
# The form is filled in with all previous data except the email field and password fields | ||
# I see a flash message telling me the email address is already in use |
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 |
---|---|---|
|
@@ -19,4 +19,15 @@ | |
|
||
it { should validate_uniqueness_of :email } | ||
end | ||
|
||
describe 'class methods' do | ||
|
||
it 'email_string' do | ||
user_1 = User.create!(name: "default_user", role: 0, active: true, password_digest: "8320280282", address: "333", city: "Denver", state: "CO", zip: "80000", email: "[email protected]" ) | ||
user_2 = User.create!(name: "default_user1", role: 0, active: true, password_digest: "8320280282", address: "333", city: "Denver", state: "CO", zip: "80000", email: "[email protected]" ) | ||
user_3 = User.create!(name: "default_user2", role: 0, active: true, password_digest: "8320280282", address: "333", city: "Denver", state: "CO", zip: "80000", email: "[email protected]" ) | ||
|
||
expect(User.email_string).not_to eq(["[email protected]", "[email protected]", "[email protected]"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we have a positive expectation as well? |
||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you just use an
.include?
here?