clearance 1.0.0.rc3 → 1.0.0.rc4

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of clearance might be problematic. Click here for more details.

Files changed (28) hide show
  1. data/Gemfile.lock +3 -3
  2. data/NEWS.md +2 -0
  3. data/app/controllers/clearance/passwords_controller.rb +14 -3
  4. data/app/controllers/clearance/sessions_controller.rb +1 -1
  5. data/app/views/clearance_mailer/change_password.html.erb +2 -2
  6. data/app/views/layouts/application.html.erb +2 -2
  7. data/app/views/passwords/create.html.erb +1 -4
  8. data/app/views/passwords/edit.html.erb +5 -7
  9. data/app/views/passwords/new.html.erb +4 -6
  10. data/app/views/sessions/_form.html.erb +1 -1
  11. data/app/views/sessions/new.html.erb +3 -3
  12. data/app/views/users/new.html.erb +1 -1
  13. data/config/locales/clearance.en.yml +42 -0
  14. data/config/routes.rb +11 -6
  15. data/gemfiles/3.0.17.gemfile.lock +1 -1
  16. data/gemfiles/3.1.8.gemfile.lock +1 -1
  17. data/gemfiles/3.2.8.gemfile.lock +1 -1
  18. data/lib/clearance.rb +6 -0
  19. data/lib/clearance/version.rb +1 -1
  20. data/lib/generators/clearance/install/templates/README +5 -3
  21. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_resets_password_spec.rb +1 -1
  22. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_signs_in_spec.rb +4 -2
  23. data/lib/generators/clearance/specs/templates/integration/clearance/visitor_updates_password_spec.rb +3 -3
  24. data/lib/generators/clearance/specs/templates/support/integration.rb +2 -2
  25. data/lib/generators/clearance/specs/templates/support/integration/clearance_helpers.rb +11 -11
  26. data/lib/generators/clearance/views/views_generator.rb +10 -0
  27. data/spec/controllers/passwords_controller_spec.rb +4 -4
  28. metadata +2 -1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clearance (1.0.0.rc3)
4
+ clearance (1.0.0.rc4)
5
5
  bcrypt-ruby
6
6
  rails (>= 3.0)
7
7
 
@@ -149,10 +149,10 @@ GEM
149
149
  thor (0.15.4)
150
150
  tilt (1.3.3)
151
151
  timecop (0.3.5)
152
- treetop (1.4.11)
152
+ treetop (1.4.12)
153
153
  polyglot
154
154
  polyglot (>= 0.3.1)
155
- tzinfo (0.3.33)
155
+ tzinfo (0.3.34)
156
156
  xpath (0.1.4)
157
157
  nokogiri (~> 1.3)
158
158
 
data/NEWS.md CHANGED
@@ -17,6 +17,8 @@ New for 1.0.0:
17
17
  * Improve security when changing password.
18
18
  * Replace Cucumber feature generator with RSpec + Capybara.
19
19
  * Remove Diesel dependency.
20
+ * Add locales support.
21
+ * PasswordsController `params[:user]` has changed to `params[:password_reset]` to avoid locale conflicts
20
22
 
21
23
  New for 0.16.2:
22
24
 
@@ -1,3 +1,5 @@
1
+ require 'active_support/deprecation'
2
+
1
3
  class Clearance::PasswordsController < ApplicationController
2
4
  unloadable
3
5
 
@@ -25,7 +27,7 @@ class Clearance::PasswordsController < ApplicationController
25
27
  def update
26
28
  @user = find_user_for_update
27
29
 
28
- if @user.update_password params[:user][:password]
30
+ if @user.update_password password_reset_params
29
31
  sign_in @user
30
32
  redirect_to url_after_update
31
33
  else
@@ -36,6 +38,15 @@ class Clearance::PasswordsController < ApplicationController
36
38
 
37
39
  private
38
40
 
41
+ def password_reset_params
42
+ if params.has_key? :user
43
+ ActiveSupport::Deprecation.warn %{Since locales functionality was added, accessing params[:user] is no longer supported.}
44
+ params[:user][:password]
45
+ else
46
+ params[:password_reset][:password]
47
+ end
48
+ end
49
+
39
50
  def find_user_by_id_and_confirmation_token
40
51
  Clearance.configuration.user_model.
41
52
  find_by_id_and_confirmation_token params[:user_id], params[:token].to_s
@@ -56,13 +67,13 @@ class Clearance::PasswordsController < ApplicationController
56
67
  def flash_failure_when_forbidden
57
68
  flash.now[:notice] = translate(:forbidden,
58
69
  :scope => [:clearance, :controllers, :passwords],
59
- :default => 'Please double check the URL or try submitting the form again.')
70
+ :default => t('flashes.failure_when_forbidden'))
60
71
  end
61
72
 
62
73
  def flash_failure_after_update
63
74
  flash.now[:notice] = translate(:blank_password,
64
75
  :scope => [:clearance, :controllers, :passwords],
65
- :default => "Password can't be blank.")
76
+ :default => t('flashes.failure_after_update'))
66
77
  end
67
78
 
68
79
  def forbid_missing_token
@@ -30,7 +30,7 @@ class Clearance::SessionsController < ApplicationController
30
30
  def flash_failure_after_create
31
31
  flash.now[:notice] = translate(:bad_email_or_password,
32
32
  :scope => [:clearance, :controllers, :sessions],
33
- :default => %{Bad email or password. Are you trying to register a new account? <a href="#{sign_up_path}">Sign up</a>.}.html_safe)
33
+ :default => t('flashes.failure_after_create', :sign_up_path => sign_up_path).html_safe)
34
34
  end
35
35
 
36
36
  def url_after_create
@@ -1,5 +1,5 @@
1
- Someone, hopefully you, requested we send you a link to change your password:
1
+ <%= t('.introduction_paragraph') %>
2
2
 
3
3
  <%= edit_user_password_url(@user, :token => @user.confirmation_token.html_safe) %>
4
4
 
5
- If you didn't request this, ignore this email. Your password hasn't been changed.
5
+ <%= t('.ending_paragraph') %>
@@ -7,9 +7,9 @@
7
7
  <body>
8
8
  <div id='header'>
9
9
  <% if signed_in? -%>
10
- <%= link_to 'Sign out', sign_out_path, :method => :delete %>
10
+ <%= link_to t('.sign_out'), sign_out_path, :method => :delete %>
11
11
  <% else -%>
12
- <%= link_to 'Sign in', sign_in_path %>
12
+ <%= link_to t('.sign_in'), sign_in_path %>
13
13
  <% end -%>
14
14
  </div>
15
15
 
@@ -1,4 +1 @@
1
- <p>
2
- You will receive an email within the next few minutes.
3
- It contains instructions for changing your password.
4
- </p>
1
+ <p><%= t '.description' %></p>
@@ -1,18 +1,16 @@
1
- <h2>Change your password</h2>
1
+ <h2><%= t '.title' %></h2>
2
2
 
3
- <p>
4
- Your password has been reset. Choose a new password below.
5
- </p>
3
+ <p><%= t '.description' %></p>
6
4
 
7
- <%= form_for :user,
5
+ <%= form_for :password_reset,
8
6
  :url => user_password_path(@user, :token => @user.confirmation_token),
9
7
  :html => { :method => :put } do |form| %>
10
8
  <div class='password_field'>
11
- <%= form.label :password, 'Choose password' %>
9
+ <%= form.label :password %>
12
10
  <%= form.password_field :password %>
13
11
  </div>
14
12
 
15
13
  <div class='submit_field'>
16
- <%= form.submit 'Save this password' %>
14
+ <%= form.submit %>
17
15
  </div>
18
16
  <% end %>
@@ -1,16 +1,14 @@
1
- <h2>Reset your password</h2>
1
+ <h2><%= t '.title' %></h2>
2
2
 
3
- <p>
4
- We will email you a link to reset your password.
5
- </p>
3
+ <p><%= t '.description' %></p>
6
4
 
7
5
  <%= form_for :password, :url => passwords_path do |form| %>
8
6
  <div class='text_field'>
9
- <%= form.label :email, 'Email address' %>
7
+ <%= form.label :email %>
10
8
  <%= form.text_field :email, :type => 'email' %>
11
9
  </div>
12
10
 
13
11
  <div class='submit_field'>
14
- <%= form.submit 'Reset password' %>
12
+ <%= form.submit %>
15
13
  </div>
16
14
  <% end %>
@@ -10,6 +10,6 @@
10
10
  </div>
11
11
 
12
12
  <div class='submit_field'>
13
- <%= form.submit 'Sign in' %>
13
+ <%= form.submit %>
14
14
  </div>
15
15
  <% end %>
@@ -1,13 +1,13 @@
1
- <h2>Sign in</h2>
1
+ <h2><%= t '.title' %></h2>
2
2
 
3
3
  <%= render :partial => '/sessions/form' %>
4
4
 
5
5
  <ul>
6
6
  <li>
7
- <%= link_to 'Sign up', sign_up_path %>
7
+ <%= link_to t('.sign_up'), sign_up_path %>
8
8
  </li>
9
9
 
10
10
  <li>
11
- <%= link_to 'Forgot password?', new_password_path %>
11
+ <%= link_to t('.forgot_password'), new_password_path %>
12
12
  </li>
13
13
  </ul>
@@ -2,5 +2,5 @@
2
2
 
3
3
  <%= form_for @user do |form| %>
4
4
  <%= render :partial => '/users/form', :object => form %>
5
- <%= form.submit 'Sign up' %>
5
+ <%= form.submit %>
6
6
  <% end %>
@@ -0,0 +1,42 @@
1
+ en:
2
+ flashes:
3
+ failure_when_forbidden: Please double check the URL or try submitting the form again.
4
+ failure_after_update: Password can't be blank.
5
+ failure_after_create: Bad email or password. Are you trying to register a new account? <a href="%{sign_up_path}">Sign up</a>.
6
+ helpers:
7
+ submit:
8
+ password:
9
+ submit: Reset password
10
+ password_reset:
11
+ submit: Save this password
12
+ session:
13
+ submit: Sign in
14
+ user:
15
+ create: Sign up
16
+ label:
17
+ password:
18
+ email: Email address
19
+ password_reset:
20
+ password: Choose password
21
+ layouts:
22
+ application:
23
+ sign_in: Sign in
24
+ sign_out: Sign out
25
+ passwords:
26
+ create:
27
+ description: You will receive an email within the next few minutes. It contains instructions for changing your password.
28
+ edit:
29
+ title: Change your password
30
+ description: Your password has been reset. Choose a new password below.
31
+ new:
32
+ title: Reset your password
33
+ description: We will email you a link to reset your password.
34
+ sessions:
35
+ new:
36
+ title: Sign in
37
+ sign_up: Sign up
38
+ forgot_password: Forgot password?
39
+ clearance_mailer:
40
+ change_password:
41
+ beginning_paragraph: 'Someone, hopefully you, requested we send you a link to change your password:'
42
+ ending_paragraph: If you didn't request this, ignore this email. Your password hasn't been changed.
@@ -1,14 +1,19 @@
1
1
  Rails.application.routes.draw do
2
- resources :passwords, :controller => 'clearance/passwords',
2
+ resources :passwords,
3
+ :controller => 'clearance/passwords',
3
4
  :only => [:create, :new]
4
5
 
5
- resource :session, :controller => 'clearance/sessions',
6
+ resource :session,
7
+ :controller => 'clearance/sessions',
6
8
  :only => [:create, :new, :destroy]
7
9
 
8
- resources :users, :controller => 'clearance/users', :only => [:create, :new] do
9
- resource :password, :controller => 'clearance/passwords',
10
- :only => [:create, :edit, :update]
11
- end
10
+ resources :users,
11
+ :controller => 'clearance/users',
12
+ :only => [:create, :new] do
13
+ resource :password,
14
+ :controller => 'clearance/passwords',
15
+ :only => [:create, :edit, :update]
16
+ end
12
17
 
13
18
  match 'sign_in' => 'clearance/sessions#new', :as => 'sign_in'
14
19
  match 'sign_out' => 'clearance/sessions#destroy', :as => 'sign_out', :via => :delete
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/harlow/Sites/clearance
3
3
  specs:
4
- clearance (1.0.0.rc2)
4
+ clearance (1.0.0.rc3)
5
5
  bcrypt-ruby
6
6
  rails (>= 3.0)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/harlow/Sites/clearance
3
3
  specs:
4
- clearance (1.0.0.rc2)
4
+ clearance (1.0.0.rc3)
5
5
  bcrypt-ruby
6
6
  rails (>= 3.0)
7
7
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/harlow/Sites/clearance
3
3
  specs:
4
- clearance (1.0.0.rc2)
4
+ clearance (1.0.0.rc3)
5
5
  bcrypt-ruby
6
6
  rails (>= 3.0)
7
7
 
@@ -6,3 +6,9 @@ require 'clearance/user'
6
6
  require 'clearance/engine'
7
7
  require 'clearance/password_strategies'
8
8
  require 'clearance/constraints'
9
+
10
+ module Clearance
11
+ def self.root
12
+ File.expand_path('../..', __FILE__)
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Clearance
2
- VERSION = '1.0.0.rc3'
2
+ VERSION = '1.0.0.rc4'
3
3
  end
@@ -19,9 +19,11 @@ Next steps:
19
19
  <%= link_to 'Sign in', sign_in_path %>
20
20
  <% end %>
21
21
 
22
- <% flash.each do |key, value| %>
23
- <div class="flash <%= key %>"><%= value %></div>
24
- <% end %>
22
+ <div id="flash">
23
+ <% flash.each do |key, value| %>
24
+ <div class="flash <%= key %>"><%= value %></div>
25
+ <% end %>
26
+ </div>
25
27
 
26
28
  3. Migrate:
27
29
 
@@ -23,6 +23,6 @@ feature 'Visitor resets password' do
23
23
  end
24
24
 
25
25
  def page_should_display_change_password_message
26
- page.should have_content('instructions for changing your password')
26
+ page.should have_content I18n.t('passwords.create.description')
27
27
  end
28
28
  end
@@ -37,6 +37,8 @@ feature 'Visitor signs in' do
37
37
  end
38
38
 
39
39
  def page_should_display_sign_in_error
40
- page.should have_content('Bad email or password')
40
+ page.body.should include(
41
+ I18n.t('flashes.failure_after_create', :sign_up_path => sign_up_path)
42
+ )
41
43
  end
42
- end
44
+ end
@@ -22,7 +22,7 @@ feature 'Visitor updates password' do
22
22
  visit_password_reset_page_for user
23
23
  change_password_to ''
24
24
 
25
- page.should have_content("Password can't be blank")
25
+ page.should have_content I18n.t('flashes.failure_after_update')
26
26
  user_should_be_signed_out
27
27
  end
28
28
 
@@ -41,7 +41,7 @@ feature 'Visitor updates password' do
41
41
  end
42
42
 
43
43
  def change_password_to(password)
44
- fill_in 'Choose password', :with => password
45
- click_button 'Save this password'
44
+ fill_in 'password_reset_password', :with => password
45
+ click_button I18n.t('helpers.submit.password_reset.submit')
46
46
  end
47
47
  end
@@ -1,4 +1,4 @@
1
1
  RSpec.configure do |config|
2
- config.include Integration::ClearanceHelpers
3
- config.include Integration::ActionMailerHelpers
2
+ config.include Integration::ClearanceHelpers, :type => :request
3
+ config.include Integration::ActionMailerHelpers, :type => :request
4
4
  end
@@ -2,16 +2,16 @@ module Integration
2
2
  module ClearanceHelpers
3
3
  def sign_up_with(email, password)
4
4
  visit sign_up_path
5
- fill_in 'Email', :with => email
6
- fill_in 'Password', :with => password
7
- click_button 'Sign up'
5
+ fill_in 'user_email', :with => email
6
+ fill_in 'user_password', :with => password
7
+ click_button I18n.t('helpers.submit.user.create')
8
8
  end
9
9
 
10
10
  def sign_in_with(email, password)
11
11
  visit sign_in_path
12
- fill_in 'Email', :with => email
13
- fill_in 'Password', :with => password
14
- click_button 'Sign in'
12
+ fill_in 'session_email', :with => email
13
+ fill_in 'session_password', :with => password
14
+ click_button I18n.t('helpers.submit.session.submit')
15
15
  end
16
16
 
17
17
  def signed_in_user
@@ -23,15 +23,15 @@ module Integration
23
23
 
24
24
  def user_should_be_signed_in
25
25
  visit root_path
26
- page.should have_content('Sign out')
26
+ page.should have_content I18n.t('layouts.application.sign_out')
27
27
  end
28
28
 
29
29
  def sign_out
30
- click_link 'Sign out'
30
+ click_link I18n.t('layouts.application.sign_out')
31
31
  end
32
32
 
33
33
  def user_should_be_signed_out
34
- page.should have_content('Sign in')
34
+ page.should have_content I18n.t('layouts.application.sign_in')
35
35
  end
36
36
 
37
37
  def user_with_reset_password
@@ -42,8 +42,8 @@ module Integration
42
42
 
43
43
  def reset_password_for(email)
44
44
  visit new_password_path
45
- fill_in 'Email address', :with => email
46
- click_button 'Reset password'
45
+ fill_in 'password_email', :with => email
46
+ click_button I18n.t('helpers.submit.password.submit')
47
47
  end
48
48
  end
49
49
  end
@@ -11,12 +11,22 @@ module Clearance
11
11
  end
12
12
  end
13
13
 
14
+ def create_locales
15
+ locales.each do |locale|
16
+ copy_file locale
17
+ end
18
+ end
19
+
14
20
  private
15
21
 
16
22
  def views
17
23
  files_within_root('.', 'app/views/**/*.*')
18
24
  end
19
25
 
26
+ def locales
27
+ files_within_root('.', 'config/locales/**/*.*')
28
+ end
29
+
20
30
  def files_within_root(prefix, glob)
21
31
  root = "#{self.class.source_root}/#{prefix}"
22
32
 
@@ -101,7 +101,7 @@ describe Clearance::PasswordsController do
101
101
  @new_password = 'new_password'
102
102
  @user.encrypted_password.should_not == @new_password
103
103
  put :update, :user_id => @user, :token => @user.confirmation_token,
104
- :user => { :password => @new_password }
104
+ :password_reset => { :password => @new_password }
105
105
  @user.reload
106
106
  end
107
107
 
@@ -123,7 +123,7 @@ describe Clearance::PasswordsController do
123
123
  describe 'on PUT to #update with blank password' do
124
124
  before do
125
125
  put :update, :user_id => @user.to_param, :token => @user.confirmation_token,
126
- :user => { :password => '' }
126
+ :password_reset => { :password => '' }
127
127
  @user.reload
128
128
  end
129
129
 
@@ -147,9 +147,9 @@ describe Clearance::PasswordsController do
147
147
  describe 'on PUT to #update with an empty token after the user sets a password' do
148
148
  before do
149
149
  put :update, :user_id => @user.to_param, :token => @user.confirmation_token,
150
- :user => { :password => 'good password' }
150
+ :password_reset => { :password => 'good password' }
151
151
  put :update, :user_id => @user.to_param, :token => [nil],
152
- :user => { :password => 'new password' }
152
+ :password_reset => { :password => 'new password' }
153
153
  end
154
154
 
155
155
  it { should set_the_flash.to(/double check the URL/i).now }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clearance
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc3
4
+ version: 1.0.0.rc4
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -277,6 +277,7 @@ files:
277
277
  - app/views/users/_form.html.erb
278
278
  - app/views/users/new.html.erb
279
279
  - clearance.gemspec
280
+ - config/locales/clearance.en.yml
280
281
  - config/routes.rb
281
282
  - cucumber.yml
282
283
  - db/migrate/20110111224543_create_clearance_users.rb