Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added some more test, and removed some extra devise stuff not needed …
…for bootstrapping
- Loading branch information
Graeme Nelson
committed
Aug 28, 2010
1 parent
d509dec
commit fe601ea
Showing
15 changed files
with
304 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
bootstrap/setup/templates/app/controllers/application_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class ApplicationController < ActionController::Base | ||
|
||
layout proc{ |controller| controller.devise_controller? ? devise_layout : "application" } | ||
|
||
protect_from_forgery | ||
|
||
private | ||
|
||
def devise_layout | ||
devise_layout = "public" | ||
devise_layout = "application" if devise_actions_for_application_layout.include?( "#{controller_path}##{action_name}" ) | ||
devise_layout | ||
end | ||
|
||
def devise_actions_for_application_layout | ||
@_devise_actions_for_application_layout ||= | ||
[ "devise/registrations#edit", | ||
"devise/registrations#update", | ||
"devise/passwords#edit", | ||
"devise/passwords#update" ] | ||
end | ||
|
||
end |
3 changes: 2 additions & 1 deletion
3
bootstrap/setup/templates/app/views/resource_mailer/welcome.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
bootstrap/setup/templates/config/locales/views/passwords/en.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
en: | ||
passwords: | ||
new: | ||
header: "Reset Your Password" | ||
buttons: | ||
commit: "Reset" | ||
edit: | ||
header: "Update Your Password" | ||
buttons: | ||
commit: "Update Password" |
6 changes: 6 additions & 0 deletions
6
bootstrap/setup/templates/config/locales/views/sessions/en.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
en: | ||
sessions: | ||
new: | ||
header: "Sign Into Your Account" | ||
buttons: | ||
commit: "Sign In" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
162 changes: 156 additions & 6 deletions
162
bootstrap/setup/templates/devise/test/functional/devise/passwords_controller_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,162 @@ | ||
require 'test_helper' | ||
<% singular = @resource.singularize -%> | ||
class Devise::PasswordsControllerTest < ActionController::TestCase | ||
context "routes" do | ||
context "new" do | ||
context "without an authenticated <%= singular %>" do | ||
setup do | ||
get :new | ||
end | ||
should render_template(:new) | ||
should render_with_layout(:public) | ||
should "render appropriate view elements" do | ||
assert_select "body#passwords.new" do | ||
assert_select "h2", :text => I18n.t('passwords.new.header') | ||
assert_select "form[action='#{<%= singular %>_password_path}']" do | ||
assert_select "fieldset.inputs" do | ||
assert_select "ol" do | ||
assert_select "li#<%= singular %>_email_input" do | ||
assert_select "label[for='<%= singular %>_email']", :text => "#{I18n.t('activerecord.attributes.<%= singular %>.email')}*" | ||
assert_select "input[type='text'][name='<%= singular %>[email]']" | ||
end | ||
end | ||
end | ||
assert_select "fieldset.buttons" do | ||
assert_select "ol" do | ||
assert_select "li.commit" do | ||
assert_select "input[type='submit'][value='#{I18n.t('passwords.new.buttons.commit')}']" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
should "/<%= @resource %>/password/new should route to {:controller => 'devise/passwords', :action => 'new'}" do | ||
assert_routing( "/<%= @resource %>/password/new", {:controller => 'devise/passwords', :action => 'new'}) | ||
end | ||
|
||
end | ||
context "with an authenticated <%= singular %>" do | ||
|
||
setup do | ||
sign_in( Factory.create(:<%= singular %>) ) | ||
get :new | ||
end | ||
|
||
should redirect_to("<%= singular %> path") { <%= singular %>_root_path } | ||
end | ||
end | ||
context "create" do | ||
context "with valid email address" do | ||
setup do | ||
@<%= singular %> = Factory.create(:<%= singular %>) | ||
ActionMailer::Base.deliveries.clear | ||
post :create, :<%= singular %> => {:email => @<%= singular %>.email} | ||
end | ||
|
||
should "send reset password email" do | ||
assert_equal 1, ActionMailer::Base.deliveries.size | ||
end | ||
|
||
should "set reset password token" do | ||
assert_not_nil @<%= singular %>.reload.reset_password_token | ||
end | ||
|
||
end | ||
|
||
context "without a valid email address" do | ||
|
||
setup do | ||
@<%= singular %> = Factory.create(:<%= singular %>) | ||
ActionMailer::Base.deliveries.clear | ||
post :create, :<%= singular %> => {:email => ""} | ||
end | ||
|
||
should render_template(:new) | ||
|
||
end | ||
|
||
end | ||
|
||
context "edit" do | ||
|
||
context "with token" do | ||
|
||
setup do | ||
reset_password_token = "myspecialtoken" | ||
@<%= singular %> = Factory.create(:<%= singular %>) | ||
@<%= singular %>.update_attribute(:reset_password_token, reset_password_token) | ||
get :edit, :reset_password_token => reset_password_token | ||
end | ||
|
||
should render_template(:edit) | ||
should render_with_layout(:application) | ||
|
||
should "render appropriate view elements" do | ||
assert_select "body#passwords.edit" do | ||
assert_select "h2", :text => I18n.t('passwords.edit.header') | ||
assert_select "form[action='#{<%= singular %>_password_path}']" do | ||
assert_select "fieldset.inputs" do | ||
assert_select "ol" do | ||
assert_select "li#<%= singular %>_reset_password_token_input.hidden" do | ||
assert_select "input[type='hidden'][name='<%= singular %>[reset_password_token]']" | ||
end | ||
assert_select "li#<%= singular %>_password_input.required" do | ||
assert_select "label[for='<%= singular %>_password']", :text => "#{I18n.t('activerecord.attributes.<%= singular %>.password')}*" | ||
assert_select "input[type='password'][name='<%= singular %>[password]']" | ||
end | ||
assert_select "li#<%= singular %>_password_confirmation_input.optional" do | ||
assert_select "label[for='<%= singular %>_password_confirmation']", :text => "#{I18n.t('activerecord.attributes.<%= singular %>.password_confirmation')}" | ||
assert_select "input[type='password'][name='<%= singular %>[password_confirmation]']" | ||
end | ||
end | ||
end | ||
assert_select "fieldset.buttons" do | ||
assert_select "ol" do | ||
assert_select "li.commit" do | ||
assert_select "input[type='submit'][value='#{I18n.t('passwords.edit.buttons.commit')}']" | ||
end | ||
end | ||
end | ||
end | ||
end | ||
end | ||
|
||
end | ||
|
||
end | ||
|
||
context "update" do | ||
|
||
context "with authenticated account" do | ||
|
||
context "with valid password and password confirmation" do | ||
|
||
should "change password" | ||
|
||
end | ||
|
||
context "with invalid password and password confirmation" do | ||
|
||
should "edit template with errors" | ||
|
||
end | ||
|
||
context "with invalid reset password token" do | ||
|
||
should "render update template with errors" | ||
|
||
end | ||
|
||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.