-
Notifications
You must be signed in to change notification settings - Fork 4
Add integration test for signup functionality #99
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| require 'rails_helper' | ||
|
|
||
| RSpec.describe 'Signup feature' do | ||
| it 'should create new user successfully' do | ||
| visit new_user_registration_path | ||
| expect(page).to have_content('Sign up new account') | ||
|
|
||
| fill_in('user_full_name', with: 'John Doe') | ||
| select "ASHA", :from => "user_role" | ||
| fill_in('user_email', with: 'johndoe@example.com') | ||
| fill_in('user_phone', with: '9988776677') | ||
| fill_in('user_password', with: 'JohnDoe') | ||
|
Comment on lines
+10
to
+12
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. We can fill these info using
Contributor
Author
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. Okay. Will use that.
Contributor
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. @abhinandanarya06 We also need to store the names and password as well as we need the same for Login as well 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. Then I think we have Or we can use rspec fixtures if we need to store and reuse in different tests. |
||
|
|
||
| click_button('Sign Up', exact: true) | ||
| expect(current_path).to eql('/') | ||
|
|
||
| expect(page).to have_content('Your account is not verified!') | ||
| end | ||
|
|
||
|
Comment on lines
+17
to
+19
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. Indentation seems too much.
Contributor
Author
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. @peeyush14goyal What do you think?
Contributor
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. Prettier now supports Ruby formatting as well. Is your prettier working @divyagar ? |
||
| it 'should not create user due to no email' do | ||
| visit new_user_registration_path | ||
| expect(page).to have_content('Sign up new account') | ||
|
|
||
| fill_in('user_full_name', with: 'John Doe') | ||
| select "ASHA", :from => "user_role" | ||
| fill_in('user_phone', with: '9988776677') | ||
| fill_in('user_password', with: 'JohnDoe') | ||
|
|
||
| click_button('Sign Up', exact: true) | ||
| expect(current_path).to eql('/users') | ||
|
|
||
| expect(page).to have_content("Attention needed") | ||
| expect(page).to have_content("Email can't be blank") | ||
| end | ||
|
|
||
| it 'should not create user due to no password' do | ||
| visit new_user_registration_path | ||
| expect(page).to have_content('Sign up new account') | ||
|
|
||
| fill_in('user_full_name', with: 'John Doe') | ||
| select "ASHA", :from => "user_role" | ||
| fill_in('user_email', with: 'johndoe@example.com') | ||
| fill_in('user_phone', with: '9988776677') | ||
|
|
||
| click_button('Sign Up', exact: true) | ||
| expect(current_path).to eql('/users') | ||
|
|
||
| expect(page).to have_content("Attention needed") | ||
| expect(page).to have_content("Password can't be blank") | ||
| end | ||
|
|
||
| it 'should not create user due to short password' do | ||
| visit new_user_registration_path | ||
| expect(page).to have_content('Sign up new account') | ||
|
|
||
| fill_in('user_full_name', with: 'John Doe') | ||
| select "ASHA", :from => "user_role" | ||
| fill_in('user_email', with: 'johndoe@example.com') | ||
| fill_in('user_phone', with: '9988776677') | ||
| fill_in('user_password', with: 'John') | ||
|
|
||
| click_button('Sign Up', exact: true) | ||
| expect(current_path).to eql('/users') | ||
|
|
||
| expect(page).to have_content("Attention needed") | ||
| expect(page).to have_content("Password is too short (minimum is 6 characters)") | ||
| end | ||
|
|
||
| it 'should not create user due to duplicate email' do | ||
| visit new_user_registration_path | ||
| expect(page).to have_content('Sign up new account') | ||
|
|
||
| fill_in('user_full_name', with: 'John Doe') | ||
| select "ASHA", :from => "user_role" | ||
| fill_in('user_email', with: 'johndoe@example.com') | ||
| fill_in('user_phone', with: '9988776677') | ||
| fill_in('user_password', with: 'JohnDoe') | ||
|
|
||
| click_button('Sign Up', exact: true) | ||
| expect(current_path).to eql('/') | ||
|
|
||
| visit new_user_registration_path | ||
| expect(page).to have_content('Sign up new account') | ||
|
|
||
| fill_in('user_full_name', with: 'John Doe') | ||
| select "ASHA", :from => "user_role" | ||
| fill_in('user_email', with: 'johndoe@example.com') | ||
| fill_in('user_phone', with: '99887766') | ||
| fill_in('user_password', with: 'JohnDoe') | ||
|
|
||
| click_button('Sign Up', exact: true) | ||
| expect(current_path).to eql('/users') | ||
|
|
||
| expect(page).to have_content("Attention needed") | ||
| expect(page).to have_content("Email has already been taken") | ||
| end | ||
|
|
||
| it 'should not create user due to duplicate phone numbers' do | ||
| visit new_user_registration_path | ||
| expect(page).to have_content('Sign up new account') | ||
|
|
||
| fill_in('user_full_name', with: 'John Doe') | ||
| select "ASHA", :from => "user_role" | ||
| fill_in('user_email', with: 'johndoe@example.com') | ||
| fill_in('user_phone', with: '9988776677') | ||
| fill_in('user_password', with: 'JohnDoe') | ||
|
|
||
| click_button('Sign Up', exact: true) | ||
| expect(current_path).to eql('/') | ||
|
|
||
| visit new_user_registration_path | ||
| expect(page).to have_content('Sign up new account') | ||
|
|
||
| fill_in('user_full_name', with: 'John Doe2') | ||
| select "ASHA", :from => "user_role" | ||
| fill_in('user_email', with: 'johndoe2@example.com') | ||
| fill_in('user_phone', with: '9988776677') | ||
| fill_in('user_password', with: 'JohnDoe2') | ||
|
|
||
| click_button('Sign Up', exact: true) | ||
| expect(current_path).to eql('/users') | ||
|
|
||
| expect(page).to have_content("Attention needed") | ||
| expect(page).to have_content("Phone has already been taken") | ||
| end | ||
|
|
||
| end | ||
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.
These lines are repeating in every test iteration. Can we use
before(:each)hereThere 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.
Okay. Will do that.