clearance 1.4.0 → 1.4.1

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b85f77997240efd1427372cbc15a24e658acffd
4
- data.tar.gz: 5ca6fb26641354dbc90fb1415cc9b8a1a00c0f3e
3
+ metadata.gz: c0998695d86d391312a288b68a0721140249641b
4
+ data.tar.gz: 1995891a282666fee645519061cf0cd848aeff86
5
5
  SHA512:
6
- metadata.gz: 98db9d506f81c47c7c4ca09a11d7e5bef8265460becde5e73959c342629b43f2d019a047d12cece15b8ffc31ba10ca20a0f15f5026ec4ccc41b7c056384afc6b
7
- data.tar.gz: 6ef805fc817c6aedc195042aa15b473f16ed3b195fa180762e1365e7fd32dad57d957b8432617ef98fbbb72907d57584ad497e23a9bd948816d40f54f9667a22
6
+ metadata.gz: 9fca14ac8e1a9650c7acd431642331bbd0eb7365f1f03c070e83be7a7e2bddbb6cec28b7942cade5687b9a28aeb7a0d316e0a21087a71211724cdeaa034db7f1
7
+ data.tar.gz: c4097377a618028dba3656e1da534fa8d566dc5ea6107c94f45dc585bfaab77e8fa1cd9015a9c33fb43ac270fab2799d2c21e17b5e2e248fedc5fd9d47465442
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- clearance (1.4.0)
4
+ clearance (1.4.1)
5
5
  bcrypt
6
6
  email_validator (~> 1.4)
7
7
  rails (>= 3.1)
data/NEWS.md CHANGED
@@ -1,5 +1,9 @@
1
1
  Thank you to all the [contributors](https://github.com/thoughtbot/clearance/graphs/contributors)!
2
2
 
3
+ New for 1.4.1 (September 5, 2014)
4
+ * Prevent BCrypt strategy from raising an exception when `encypted_password`
5
+ is nil.
6
+
3
7
  New for 1.4.0 (July 18, 2014)
4
8
  * The sign out link in the default application layout has been replaced with a
5
9
  semantically correct sign out button. This also removes an unnecessary
@@ -6,7 +6,9 @@ module Clearance
6
6
  extend ActiveSupport::Concern
7
7
 
8
8
  def authenticated?(password)
9
- ::BCrypt::Password.new(encrypted_password) == password
9
+ if encrypted_password.present?
10
+ ::BCrypt::Password.new(encrypted_password) == password
11
+ end
10
12
  end
11
13
 
12
14
  def password=(new_password)
@@ -1,3 +1,3 @@
1
1
  module Clearance
2
- VERSION = '1.4.0'
2
+ VERSION = '1.4.1'
3
3
  end
@@ -1,3 +1,3 @@
1
1
  Clearance.configure do |config|
2
- config.mailer_sender = 'reply@example.com'
2
+ config.mailer_sender = "reply@example.com"
3
3
  end
@@ -10,7 +10,7 @@ class AddClearanceToUsers < ActiveRecord::Migration
10
10
  <%= index %>
11
11
  <% end -%>
12
12
 
13
- users = select_all('SELECT id FROM users WHERE remember_token IS NULL')
13
+ users = select_all("SELECT id FROM users WHERE remember_token IS NULL")
14
14
 
15
15
  users.each do |user|
16
16
  update <<-SQL
@@ -24,7 +24,7 @@ class AddClearanceToUsers < ActiveRecord::Migration
24
24
  def self.down
25
25
  change_table :users do |t|
26
26
  <% if config[:new_columns].any? -%>
27
- t.remove <%= new_columns.keys.map { |column| ":#{column}" }.join(',') %>
27
+ t.remove <%= new_columns.keys.map { |column| ":#{column}" }.join(",") %>
28
28
  <% end -%>
29
29
  end
30
30
  end
@@ -1,5 +1,5 @@
1
1
  class CreateUsers < ActiveRecord::Migration
2
- def self.up
2
+ def change
3
3
  create_table :users do |t|
4
4
  t.timestamps null: false
5
5
  t.string :email, null: false
@@ -11,8 +11,4 @@ class CreateUsers < ActiveRecord::Migration
11
11
  add_index :users, :email
12
12
  add_index :users, :remember_token
13
13
  end
14
-
15
- def self.down
16
- drop_table :users
17
- end
18
14
  end
@@ -5,6 +5,6 @@ FactoryGirl.define do
5
5
 
6
6
  factory :user do
7
7
  email
8
- password 'password'
8
+ password "password"
9
9
  end
10
10
  end
@@ -1,8 +1,8 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- feature 'User signs out' do
4
- scenario 'signs out' do
5
- user = signed_in_user
3
+ feature "User signs out" do
4
+ scenario "signs out" do
5
+ sign_in
6
6
  sign_out
7
7
 
8
8
  user_should_be_signed_out
@@ -1,23 +1,23 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- feature 'Visitor resets password' do
4
- scenario 'by navigating to the page' do
3
+ feature "Visitor resets password" do
4
+ scenario "by navigating to the page" do
5
5
  visit sign_in_path
6
6
 
7
- click_link I18n.t('sessions.form.forgot_password')
7
+ click_link I18n.t("sessions.form.forgot_password")
8
8
 
9
- current_path.should eq new_password_path
9
+ expect(current_path).to eq new_password_path
10
10
  end
11
11
 
12
- scenario 'with valid email' do
12
+ scenario "with valid email" do
13
13
  user = user_with_reset_password
14
14
 
15
15
  page_should_display_change_password_message
16
16
  reset_notification_should_be_sent_to user
17
17
  end
18
18
 
19
- scenario 'with non-user account' do
20
- reset_password_for 'unknown.email@example.com'
19
+ scenario "with non-user account" do
20
+ reset_password_for "unknown.email@example.com"
21
21
 
22
22
  page_should_display_change_password_message
23
23
  mailer_should_have_no_deliveries
@@ -26,16 +26,16 @@ feature 'Visitor resets password' do
26
26
  private
27
27
 
28
28
  def reset_notification_should_be_sent_to(user)
29
- user.confirmation_token.should_not be_blank
30
- mailer_should_have_delivery user.email, 'password', user.confirmation_token
29
+ expect(user.confirmation_token).not_to be_blank
30
+ mailer_should_have_delivery user.email, "password", user.confirmation_token
31
31
  end
32
32
 
33
33
  def page_should_display_change_password_message
34
- page.should have_content I18n.t('passwords.create.description')
34
+ expect(page).to have_content I18n.t("passwords.create.description")
35
35
  end
36
36
 
37
37
  def mailer_should_have_delivery(recipient, subject, body)
38
- ActionMailer::Base.deliveries.should_not be_empty
38
+ expect(ActionMailer::Base.deliveries).not_to be_empty
39
39
 
40
40
  message = ActionMailer::Base.deliveries.any? do |email|
41
41
  email.to == [recipient] &&
@@ -43,10 +43,10 @@ feature 'Visitor resets password' do
43
43
  email.body =~ /#{body}/
44
44
  end
45
45
 
46
- message.should be
46
+ expect(message).to be
47
47
  end
48
48
 
49
49
  def mailer_should_have_no_deliveries
50
- ActionMailer::Base.deliveries.should be_empty
50
+ expect(ActionMailer::Base.deliveries).to be_empty
51
51
  end
52
52
  end
@@ -1,30 +1,30 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- feature 'Visitor signs in' do
4
- scenario 'with valid email and password' do
5
- create_user 'user@example.com', 'password'
6
- sign_in_with 'user@example.com', 'password'
3
+ feature "Visitor signs in" do
4
+ scenario "with valid email and password" do
5
+ create_user "user@example.com", "password"
6
+ sign_in_with "user@example.com", "password"
7
7
 
8
8
  user_should_be_signed_in
9
9
  end
10
10
 
11
- scenario 'with valid mixed-case email and password ' do
12
- create_user 'user.name@example.com', 'password'
13
- sign_in_with 'User.Name@example.com', 'password'
11
+ scenario "with valid mixed-case email and password " do
12
+ create_user "user.name@example.com", "password"
13
+ sign_in_with "User.Name@example.com", "password"
14
14
 
15
15
  user_should_be_signed_in
16
16
  end
17
17
 
18
- scenario 'tries with invalid password' do
19
- create_user 'user@example.com', 'password'
20
- sign_in_with 'user@example.com', 'wrong_password'
18
+ scenario "tries with invalid password" do
19
+ create_user "user@example.com", "password"
20
+ sign_in_with "user@example.com", "wrong_password"
21
21
 
22
22
  page_should_display_sign_in_error
23
23
  user_should_be_signed_out
24
24
  end
25
25
 
26
- scenario 'tries with invalid email' do
27
- sign_in_with 'unknown.email@example.com', 'password'
26
+ scenario "tries with invalid email" do
27
+ sign_in_with "unknown.email@example.com", "password"
28
28
 
29
29
  page_should_display_sign_in_error
30
30
  user_should_be_signed_out
@@ -37,8 +37,8 @@ feature 'Visitor signs in' do
37
37
  end
38
38
 
39
39
  def page_should_display_sign_in_error
40
- page.body.should include(
41
- I18n.t('flashes.failure_after_create', sign_up_path: sign_up_path)
40
+ expect(page.body).to include(
41
+ I18n.t("flashes.failure_after_create", sign_up_path: sign_up_path)
42
42
  )
43
43
  end
44
44
  end
@@ -1,28 +1,28 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- feature 'Visitor signs up' do
4
- scenario 'by navigating to the page' do
3
+ feature "Visitor signs up" do
4
+ scenario "by navigating to the page" do
5
5
  visit sign_in_path
6
6
 
7
- click_link I18n.t('sessions.form.sign_up')
7
+ click_link I18n.t("sessions.form.sign_up")
8
8
 
9
- current_path.should eq sign_up_path
9
+ expect(current_path).to eq sign_up_path
10
10
  end
11
11
 
12
- scenario 'with valid email and password' do
13
- sign_up_with 'valid@example.com', 'password'
12
+ scenario "with valid email and password" do
13
+ sign_up_with "valid@example.com", "password"
14
14
 
15
15
  user_should_be_signed_in
16
16
  end
17
17
 
18
- scenario 'tries with invalid email' do
19
- sign_up_with 'invalid_email', 'password'
18
+ scenario "tries with invalid email" do
19
+ sign_up_with "invalid_email", "password"
20
20
 
21
21
  user_should_be_signed_out
22
22
  end
23
23
 
24
- scenario 'tries with blank password' do
25
- sign_up_with 'valid@example.com', ''
24
+ scenario "tries with blank password" do
25
+ sign_up_with "valid@example.com", ""
26
26
 
27
27
  user_should_be_signed_out
28
28
  end
@@ -1,28 +1,28 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- feature 'Visitor updates password' do
4
- scenario 'with valid password' do
3
+ feature "Visitor updates password" do
4
+ scenario "with valid password" do
5
5
  user = user_with_reset_password
6
- update_password user, 'newpassword'
6
+ update_password user, "newpassword"
7
7
 
8
8
  user_should_be_signed_in
9
9
  end
10
10
 
11
- scenario 'signs in with new password' do
11
+ scenario "signs in with new password" do
12
12
  user = user_with_reset_password
13
- update_password user, 'newpassword'
13
+ update_password user, "newpassword"
14
14
  sign_out
15
- sign_in_with user.email, 'newpassword'
15
+ sign_in_with user.email, "newpassword"
16
16
 
17
17
  user_should_be_signed_in
18
18
  end
19
19
 
20
- scenario 'tries with a blank password' do
20
+ scenario "tries with a blank password" do
21
21
  user = user_with_reset_password
22
22
  visit_password_reset_page_for user
23
- change_password_to ''
23
+ change_password_to ""
24
24
 
25
- page.should have_content I18n.t('flashes.failure_after_update')
25
+ expect(page).to 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 'password_reset_password', with: password
45
- click_button I18n.t('helpers.submit.password_reset.submit')
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,3 +1,3 @@
1
1
  RSpec.configure do |config|
2
2
  config.before(:each) { ActionMailer::Base.deliveries.clear }
3
- end
3
+ end
@@ -1 +1 @@
1
- require 'clearance/rspec'
1
+ require "clearance/rspec"
@@ -1,5 +1,5 @@
1
- require 'factory_girl_rails'
1
+ require "factory_girl_rails"
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.include FactoryGirl::Syntax::Methods
5
- end
5
+ end
@@ -1,4 +1,4 @@
1
- Dir[Rails.root.join('spec/support/features/*.rb')].each { |f| require f }
1
+ Dir[Rails.root.join("spec/support/features/*.rb")].each { |f| require f }
2
2
 
3
3
  RSpec.configure do |config|
4
4
  config.include Features::ClearanceHelpers, type: :feature
@@ -1,37 +1,42 @@
1
1
  module Features
2
2
  module ClearanceHelpers
3
- def sign_up_with(email, password)
4
- visit sign_up_path
5
- fill_in 'user_email', with: email
6
- fill_in 'user_password', with: password
7
- click_button I18n.t('helpers.submit.user.create')
3
+ def reset_password_for(email)
4
+ visit new_password_path
5
+ fill_in "password_email", with: email
6
+ click_button I18n.t("helpers.submit.password.submit")
7
+ end
8
+
9
+ def sign_in
10
+ password = "password"
11
+ user = create(:user, password: password)
12
+ sign_in_with user.email, password
8
13
  end
9
14
 
10
15
  def sign_in_with(email, password)
11
16
  visit sign_in_path
12
- fill_in 'session_email', with: email
13
- fill_in 'session_password', with: password
14
- click_button I18n.t('helpers.submit.session.submit')
17
+ fill_in "session_email", with: email
18
+ fill_in "session_password", with: password
19
+ click_button I18n.t("helpers.submit.session.submit")
15
20
  end
16
21
 
17
- def signed_in_user
18
- password = 'password'
19
- user = create(:user, password: password)
20
- sign_in_with user.email, password
21
- user
22
+ def sign_out
23
+ click_button I18n.t("layouts.application.sign_out")
22
24
  end
23
25
 
24
- def user_should_be_signed_in
25
- visit root_path
26
- page.should have_button I18n.t('layouts.application.sign_out')
26
+ def sign_up_with(email, password)
27
+ visit sign_up_path
28
+ fill_in "user_email", with: email
29
+ fill_in "user_password", with: password
30
+ click_button I18n.t("helpers.submit.user.create")
27
31
  end
28
32
 
29
- def sign_out
30
- click_button I18n.t('layouts.application.sign_out')
33
+ def user_should_be_signed_in
34
+ visit root_path
35
+ expect(page).to have_button I18n.t("layouts.application.sign_out")
31
36
  end
32
37
 
33
38
  def user_should_be_signed_out
34
- page.should have_content I18n.t('layouts.application.sign_in')
39
+ expect(page).to have_content I18n.t("layouts.application.sign_in")
35
40
  end
36
41
 
37
42
  def user_with_reset_password
@@ -40,10 +45,5 @@ module Features
40
45
  user.reload
41
46
  end
42
47
 
43
- def reset_password_for(email)
44
- visit new_password_path
45
- fill_in 'password_email', with: email
46
- click_button I18n.t('helpers.submit.password.submit')
47
- end
48
48
  end
49
49
  end
@@ -41,14 +41,25 @@ describe Clearance::PasswordStrategies::BCrypt do
41
41
  end
42
42
 
43
43
  describe '#authenticated?' do
44
- let(:password) { 'password' }
45
44
 
46
45
  before do
47
46
  subject.password = password
48
47
  end
49
48
 
50
- it 'is authenticated with BCrypt' do
51
- subject.should be_authenticated(password)
49
+ context 'given a password' do
50
+ let(:password) { 'password' }
51
+
52
+ it 'is authenticated with BCrypt' do
53
+ subject.should be_authenticated(password)
54
+ end
55
+ end
56
+
57
+ context 'given no password' do
58
+ let(:password) { nil }
59
+
60
+ it 'is not authenticated' do
61
+ subject.should_not be_authenticated(password)
62
+ end
52
63
  end
53
64
  end
54
65
  end
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.4.0
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Croak
@@ -25,7 +25,7 @@ authors:
25
25
  autorequire:
26
26
  bindir: bin
27
27
  cert_chain: []
28
- date: 2014-07-18 00:00:00.000000000 Z
28
+ date: 2014-09-08 00:00:00.000000000 Z
29
29
  dependencies:
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: bcrypt