Fix password reset, add cucumber feature
This commit is contained in:
parent
8c1e64a080
commit
495dd89dd2
8 changed files with 37 additions and 11 deletions
2
Gemfile
2
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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ include HelperMethods
|
|||
|
||||
Before do
|
||||
DatabaseCleaner.clean
|
||||
Devise.mailer.deliveries = []
|
||||
end
|
||||
|
||||
silence_warnings do
|
||||
|
|
|
|||
|
|
@ -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
|
||||
end
|
||||
|
|
|
|||
|
|
@ -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
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue