From a14e7505d3e43ec2bd141b300e6b3ce673693706 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Tue, 5 Feb 2019 01:06:39 +0000 Subject: [PATCH 1/3] Resolved merge conflict; Gemfile.lock bundled with 1.17.3 --- src/Gemfile | 1 + src/Gemfile.lock | 10 ++++- src/config/environments/test.rb | 4 ++ src/spec/features/password_resets_spec.rb | 50 +++++++++++++++++++++++ src/spec/spec_helper.rb | 1 + 5 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/spec/features/password_resets_spec.rb diff --git a/src/Gemfile b/src/Gemfile index 6b3311d5..b6ca6bb2 100644 --- a/src/Gemfile +++ b/src/Gemfile @@ -54,6 +54,7 @@ group :development, :test do gem "rspec-rails", "~> 3.1" gem 'rails-controller-testing' gem 'capybara' + gem 'capybara-email', '3.0.1' gem 'pry' gem 'coveralls', require: false end diff --git a/src/Gemfile.lock b/src/Gemfile.lock index d3f343d1..eb548e9e 100644 --- a/src/Gemfile.lock +++ b/src/Gemfile.lock @@ -59,6 +59,13 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) +<<<<<<< HEAD +======= + capybara-email (3.0.1) + capybara (>= 2.4, < 4.0) + mail + choice (0.2.0) +>>>>>>> 0658425... Added integration test of the password reset process cliver (0.3.2) coderay (1.1.2) coffee-rails (4.2.2) @@ -264,6 +271,7 @@ DEPENDENCIES bcrypt-ruby (~> 3.1) cancancan capybara + capybara-email (= 3.0.1) coffee-rails (~> 4.2) coveralls database_cleaner @@ -298,4 +306,4 @@ RUBY VERSION ruby 2.4.2p198 BUNDLED WITH - 1.15.4 + 1.17.3 diff --git a/src/config/environments/test.rb b/src/config/environments/test.rb index 094dedb7..6c367ef1 100644 --- a/src/config/environments/test.rb +++ b/src/config/environments/test.rb @@ -1,6 +1,10 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + # BEGIN: needed for email confirmations + config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } + # END: needed for email confirmations + # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped diff --git a/src/spec/features/password_resets_spec.rb b/src/spec/features/password_resets_spec.rb new file mode 100644 index 00000000..0eba5545 --- /dev/null +++ b/src/spec/features/password_resets_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper' + +feature 'Password reset' do + let(:user) { create(:participant, name: 'Hedy Lamarr', email: 'freq-hopper@example.org') } + + scenario 'The home page has a link to the reset password page' do + visit root_path + assert page.has_link?('Forgot Password?', href: new_password_reset_path) + end + + scenario 'The reset password page has the expected content' do + visit new_password_reset_path + assert page.has_css?('h1', text: 'Reset Password') + assert page.has_text?('Please enter your email address below') + end + + scenario 'Participant can reset password' do + # Event needed until Pull Request #202 is merged into the code base + Event.create!(name: 'Event 1', date: Time.now) + + visit new_password_reset_path + fill_in 'email', with: user.email + click_button 'Reset Password' + + # Open and follow instructions + open_email(user.email) + assert current_email.subject.include?('Password Reset Instructions') + assert current_email.body.include?('A request to reset your password has been made.') + current_email.click_link 'Reset Password!' + clear_emails + + # Provide new password + assert page.has_css?('h1', text: 'Update your password') + assert page.has_text?('Please enter the new password below') + fill_in('password', with: 'MN Tech Community') + sleep 4.1 + click_on 'Update Password' + assert page.has_text?('Your password was successfully updated') + click_on 'Log out' + + # Log in under the normal method + visit root_path + click_link "Log in" + fill_in 'Email', with: user.email + fill_in 'Password', with: 'MN Tech Community' + check 'Remember me' + click_button "Log in" + expect(page).to have_content "You're logged in. Welcome back." + end +end diff --git a/src/spec/spec_helper.rb b/src/spec/spec_helper.rb index 1f67c889..400bc9bb 100644 --- a/src/spec/spec_helper.rb +++ b/src/spec/spec_helper.rb @@ -18,6 +18,7 @@ Capybara.default_max_wait_time = ENV['TRAVIS'] ? 30 : 15 require 'capybara/rspec' require 'capybara/rails' +require 'capybara/email/rspec' require 'authlogic/test_case' From 9c477334d4886260f5f2f6bfb4a0b41b4d8f50a8 Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Tue, 5 Feb 2019 01:12:54 +0000 Subject: [PATCH 2/3] Removed merge conflict in src/Gemfile.lock --- src/Gemfile.lock | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Gemfile.lock b/src/Gemfile.lock index eb548e9e..42d1e901 100644 --- a/src/Gemfile.lock +++ b/src/Gemfile.lock @@ -59,13 +59,10 @@ GEM rack (>= 1.0.0) rack-test (>= 0.5.4) xpath (~> 2.0) -<<<<<<< HEAD -======= capybara-email (3.0.1) capybara (>= 2.4, < 4.0) mail choice (0.2.0) ->>>>>>> 0658425... Added integration test of the password reset process cliver (0.3.2) coderay (1.1.2) coffee-rails (4.2.2) From 35c82a8dcba619feb70db800596027bc8652a58c Mon Sep 17 00:00:00 2001 From: Jason Hsu Date: Tue, 5 Feb 2019 06:18:23 +0000 Subject: [PATCH 3/3] Added test for attempting to reset password for invalid email address --- src/spec/features/password_resets_spec.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/spec/features/password_resets_spec.rb b/src/spec/features/password_resets_spec.rb index 0eba5545..60a042f0 100644 --- a/src/spec/features/password_resets_spec.rb +++ b/src/spec/features/password_resets_spec.rb @@ -18,9 +18,17 @@ # Event needed until Pull Request #202 is merged into the code base Event.create!(name: 'Event 1', date: Time.now) + # Enter an invalid email address + visit new_password_reset_path + fill_in 'email', with: 'not_exist@example.com' + click_button 'Reset Password' + assert page.has_text?('No participant was found with email address not_exist@example.com') + + # Enter a valid email address visit new_password_reset_path fill_in 'email', with: user.email click_button 'Reset Password' + assert page.has_text?('Instructions to reset your password have been emailed to you') # Open and follow instructions open_email(user.email)