diff --git a/Gemfile b/Gemfile index cb6d11592f9f9011ed309662023d43129259d512..0bb2aa8f9ad3967af43285e8b355b32561af899b 100644 --- a/Gemfile +++ b/Gemfile @@ -11,7 +11,7 @@ gem 'ohai', '0.5.8', :require => false #Chef dependency gem 'nokogiri', '1.4.3.1' #Security -gem 'devise', '1.3.1' +gem 'devise', '~> 1.3.1' gem 'devise_invitable', '0.5.0' #Authentication diff --git a/Gemfile.lock b/Gemfile.lock index 4c14681c6b5fad3a9d5eb70ac527bd789b448f84..db08a1db0267b066f63e65303d4ec8f1f0f2b541 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -158,7 +158,7 @@ GEM culerity (0.2.15) daemons (1.1.2) database_cleaner (0.6.0) - devise (1.3.1) + devise (1.3.4) bcrypt-ruby (~> 2.1.2) orm_adapter (~> 0.0.3) warden (~> 1.0.3) @@ -415,7 +415,7 @@ DEPENDENCIES cloudfiles (= 1.4.10) cucumber-rails (= 0.3.2) database_cleaner (= 0.6.0) - devise (= 1.3.1) + devise (~> 1.3.1) devise_invitable (= 0.5.0) em-websocket! excon (= 0.2.4) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 595d963a846a65534cadf4eea7303415e1fbd96c..95956d75415f257530461bf003d8270b9e52c814 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -107,4 +107,8 @@ class ApplicationController < ActionController::Base def grammatical_gender @grammatical_gender || nil end + + def after_sign_in_path_for(resource) + stored_location_for(:user) || aspects_path(:a_ids => current_user.aspects.where(:open => true).select(:id).all.map{|a| a.id}) + end end diff --git a/features/change_password.feature b/features/change_password.feature index aeb80bad23faac17d4e9011728f2cd14d17bf8f0..31da98c01cc748a41f2bfd3b6fd8c3d27b2e000e 100644 --- a/features/change_password.feature +++ b/features/change_password.feature @@ -14,3 +14,16 @@ Feature: Change password Then I should be on the new user session page When I sign in with password "newsecret" Then I should be on the aspects page + + Scenario: Reset my password + Given a user with email "forgetful@users.net" + Given I am on the new user password page + And I fill in "Email" with "forgetful@users.net" + And I press "Send me reset password instructions" + Then I should see "You will receive an email with instructions" + And I follow the "Change my password" link from the Devise.mailer + Then I should see "Change your password" + And I fill in "Password" with "supersecret" + And I fill in "Password confirmation" with "supersecret" + And I press "Change my password" + Then I should see "Your password was changed successfully" diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 2a8e4ac2f7c6f1b642b6524e1d917503d141fa98..92fbcff539ccf39907aeedd13fbbd16396560694 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -154,3 +154,11 @@ Given /^many posts from alice for bob$/ do time_interval += 1000 end end + +And /^I follow the "([^\"]*)" link from the Devise.mailer$/ do |link_text| + doc = Nokogiri(Devise.mailer.deliveries.first.body.to_s) + links = doc.css('a') + link = links.detect{ |link| link.text == link_text } + path = link.attributes["href"].value + visit URI::parse(path).request_uri +end diff --git a/features/support/env.rb b/features/support/env.rb index 09827a3f5a29d38a190dc400683c0e7d456230e3..b0bb208b8ddf85161f09bc1b20ed3bc91b91f950 100644 --- a/features/support/env.rb +++ b/features/support/env.rb @@ -48,6 +48,7 @@ include HelperMethods Before do DatabaseCleaner.clean + Devise.mailer.deliveries = [] end silence_warnings do diff --git a/spec/controllers/registrations_controller_spec.rb b/spec/controllers/registrations_controller_spec.rb index 99256d3b14c5769429d969f0b884a402dfd836de..1ce5002681574aa0d9a853a0b9d27660ffd32fe4 100644 --- a/spec/controllers/registrations_controller_spec.rb +++ b/spec/controllers/registrations_controller_spec.rb @@ -63,9 +63,9 @@ describe RegistrationsController do flash[:notice].should_not be_empty end - it "redirects to the root path" do + it "redirects to the home path" do get :create, @valid_params - response.should redirect_to root_path + response.should redirect_to aspects_path end end @@ -99,4 +99,4 @@ describe RegistrationsController do end end end -end \ No newline at end of file +end diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index 3337787e5c2ea5520183f0bbbfbee3380ca77484..5197c3f8413cdf87f591c0819fbce2c1d002bcd7 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -24,15 +24,15 @@ describe SessionsController do end describe "#create" do - it "redirects to / for a non-mobile user" do + it "redirects to /aspects for a non-mobile user" do post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}} - response.should redirect_to root_path + response.should redirect_to aspects_path end - it "redirects to / for a mobile user" do + it "redirects to /aspects for a mobile user" do @request.env['HTTP_USER_AGENT'] = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_1 like Mac OS X; en-us) AppleWebKit/532.9 (KHTML, like Gecko) Version/4.0.5 Mobile/8B117 Safari/6531.22.7' post :create, {"user" => {"remember_me" => "0", "username" => @user.username, "password" => "evankorth"}} - response.should redirect_to root_path + response.should redirect_to aspects_path end it 'queues up an update job' do @@ -59,4 +59,4 @@ describe SessionsController do response.should redirect_to root_path end end -end \ No newline at end of file +end