@@ -36,5 +36,6 @@ RailsWebsiteTemplate::Application.configure do |
||
| 36 | 36 |
|
| 37 | 37 |
# Crapy Fix for email testing error |
| 38 | 38 |
config.action_mailer.raise_delivery_errors = true |
| 39 |
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
|
| 39 | 40 |
|
| 40 | 41 |
end |
@@ -44,8 +44,8 @@ RailsWebsiteTemplate::Application.routes.draw do |
||
| 44 | 44 |
scope '/account' do |
| 45 | 45 |
# password reset |
| 46 | 46 |
get '/reset-password' => 'devise/passwords#new', as: 'new_user_password' |
| 47 |
- put '/reset-password' => 'devise/passwords#update', as: 'user_password' |
|
| 48 |
- post '/reset-password' => 'devise/passwords#create' |
|
| 47 |
+ put '/reset-password' => 'devise/passwords#update', :as => :user_password |
|
| 48 |
+ post '/reset-password' => 'devise/passwords#create', :as => :reset_password |
|
| 49 | 49 |
get '/reset-password/change' => 'devise/passwords#edit', as: 'edit_user_password' |
| 50 | 50 |
# confirmation |
| 51 | 51 |
get '/confirm' => 'devise/confirmations#show', as: 'user_confirmation' |
@@ -178,7 +178,7 @@ end |
||
| 178 | 178 |
# Interact with Email Contents |
| 179 | 179 |
# |
| 180 | 180 |
|
| 181 |
-When /^(?:I|they|"([^"]*?)") follows? "([^"]*?)" in the email$/ do |address, link| |
|
| 181 |
+When /^(?:I|they|"([^"]*?)") clicks in the link? "([^"]*?)" in the email$/ do |address, link| |
|
| 182 | 182 |
visit_in_email(link, address) |
| 183 | 183 |
end |
| 184 | 184 |
|
@@ -48,6 +48,8 @@ Given(/^the user "(.*?)" "(.*?)" with email "(.*?)" and password "(.*?)" exists$ |
||
| 48 | 48 |
end |
| 49 | 49 |
end |
| 50 | 50 |
|
| 51 |
+# Fixes for devise post bug |
|
| 52 |
+ |
|
| 51 | 53 |
Then(/^I log in with the email "(.*?)" and password "(.*?)"$/) do |arg1, arg2| |
| 52 | 54 |
fill_in "user_email", :with => arg1 |
| 53 | 55 |
fill_in "user_password", :with => arg2 |
@@ -60,6 +62,18 @@ When(/^I submit the login form$/) do |
||
| 60 | 62 |
page.driver.submit :post, user_registration_path(:user => {first_name: "Monty", last_name: "Cantsin", email: "monty_cantsin@canada.com", password: "12345678", password_confirmation: "12345678"}), {}
|
| 61 | 63 |
end |
| 62 | 64 |
|
| 65 |
+When(/^I submit the password reset form$/) do |
|
| 66 |
+ click_button "Reset Password" |
|
| 67 |
+ page.driver.submit :post, reset_password_path(:user => {email: "monty_cantsin@canada.com"}), {}
|
|
| 68 |
+end |
|
| 69 |
+ |
|
| 70 |
+Then(/^I submit the new password form$/) do |
|
| 71 |
+ #click_button "Save Password" |
|
| 72 |
+ token = URI.parse(current_url).to_s.split('=').last
|
|
| 73 |
+ #puts token |
|
| 74 |
+ page.driver.submit :put, user_password_path(:user => {password: "87654321", password_confirmation: "87654321", reset_password_token: token}), {}
|
|
| 75 |
+end |
|
| 76 |
+ |
|
| 63 | 77 |
# METHODS |
| 64 | 78 |
|
| 65 | 79 |
def user_login |
@@ -1,4 +1,4 @@ |
||
| 1 |
-@focus |
|
| 1 |
+@user_account |
|
| 2 | 2 |
Feature: User Account |
| 3 | 3 |
In order to change content in the website |
| 4 | 4 |
As user of the system |
@@ -37,4 +37,25 @@ Feature: User Account |
||
| 37 | 37 |
Then I should see "Welcome! You have signed up successfully" |
| 38 | 38 |
And I should see "Monty Cantsin" |
| 39 | 39 |
And I should see "Logout" |
| 40 |
- And "monty_cantsin@canada.com" should receive an email with subject "Welcome to Rails Website Template" |
|
| 40 |
+ And "monty_cantsin@canada.com" should receive an email with subject "Welcome to Rails Website Template" |
|
| 41 |
+ |
|
| 42 |
+ @focus |
|
| 43 |
+ Scenario: User forgets password |
|
| 44 |
+ Given the user "Monty" "Cantsin" with email "monty_cantsin@canada.com" and password "12345678" exists |
|
| 45 |
+ And I am not logged in |
|
| 46 |
+ And I go to the login page |
|
| 47 |
+ When I click in the link "Forgot your password?" |
|
| 48 |
+ And I fill in "Email" with "monty_cantsin@canada.com" |
|
| 49 |
+ And I submit the password reset form |
|
| 50 |
+ Then I should see "You will receive an email with instructions on how to reset your password in a few minutes" |
|
| 51 |
+ And "monty_cantsin@canada.com" should receive an email with subject "Reset password instructions" |
|
| 52 |
+ When I open the email with subject "Reset password instructions" |
|
| 53 |
+ Then I should see "Someone has requested a link to change your password" in the email body |
|
| 54 |
+ Then I clicks in the link "Change my password" in the email |
|
| 55 |
+ And I fill in "New Password" with "87654321" |
|
| 56 |
+ And I fill in "Confirm New Password" with "87654321" |
|
| 57 |
+ And I submit the new password form |
|
| 58 |
+ Then I should see "Your password was changed successfully. You are now signed in." |
|
| 59 |
+ And I should see "Monty Cantsin" |
|
| 60 |
+ And I should see "Logout" |
|
| 61 |
+ |