authpwn_rails 0.14.1 → 0.14.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 73d9f6491cc0db1aefaffb07a6636cdc7c328d29
4
- data.tar.gz: e941fc3b74301db97605f6910a405b0a955d1a28
3
+ metadata.gz: 5c56c44cfe9c778f80d1a6aa1ff6d4c4cbdb4be4
4
+ data.tar.gz: 46ac32e85072239a83ce8cb997d988deb776af66
5
5
  SHA512:
6
- metadata.gz: e4cd7cc70aadf0bee5535415f2702e9d049e12977ce5ed7c2e955f0b7a4f2d801e127c695698195fd9076eb12dd9b5ac2942c07cda3669870c6bb5ce49b3b478
7
- data.tar.gz: a1e540e43c6726d38f4980b740f974909b01c0429ef4891177400d2dc2c01c980a6eace4182ecb24802b0d87d065cfbe5611136c5e1b1ac177cb3ab8123e3e7b
6
+ metadata.gz: a0d4e3563d5e3e3019fc8587af6fe2dd55c19edd3e75662e6124c67e555b4300a936a9c37be33c434263fb1b7cf19bf387ad687c37a6f1cf888fcc4df8b16ec2
7
+ data.tar.gz: 455ccfab2e29a549d552592b6edd15b588c32b15c413e6908ece34c76350b3ccb4dbbcb4efcf72bdce34e440ed2be84e0d0737d51a871aad278849397d7a6cda
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.14.1
1
+ 0.14.2
@@ -3,10 +3,23 @@ module Credentials
3
3
 
4
4
  # Associates an e-mail address with the user account.
5
5
  class Email < ::Credential
6
+ # E-mail is a user-visible attribute, so we want good error messages for some
7
+ # of its validations. This means we must re-define them.
8
+ if respond_to?(:clear_validators!)
9
+ clear_validators!
10
+ else
11
+ # Backport clear_validators! from Rails 4.
12
+ reset_callbacks :validate
13
+ _validators.clear
14
+ end
15
+
16
+ # The user whose email this is.
17
+ validates :user, presence: true
18
+
6
19
  # The e-mail address.
7
20
  alias_attribute :email, :name
8
21
  validates :name, format: /\A[A-Za-z0-9.+_]+@[^@]*\.(\w+)\Z/,
9
- presence: true, uniqueness: { scope: [:type],
22
+ presence: true, length: 1..128, uniqueness: { scope: [:type],
10
23
  message: 'This e-mail address is already claimed by an account' }
11
24
 
12
25
  # '1' if the user proved ownership of the e-mail address.
@@ -2,15 +2,14 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: authpwn_rails 0.14.1 ruby lib
6
5
 
7
6
  Gem::Specification.new do |s|
8
7
  s.name = "authpwn_rails"
9
- s.version = "0.14.1"
8
+ s.version = "0.14.2"
10
9
 
11
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
11
  s.authors = ["Victor Costan"]
13
- s.date = "2013-12-07"
12
+ s.date = "2013-12-11"
14
13
  s.description = "Works with Facebook."
15
14
  s.email = "victor@costan.us"
16
15
  s.extra_rdoc_files = [
@@ -118,7 +117,7 @@ Gem::Specification.new do |s|
118
117
  s.homepage = "http://github.com/pwnall/authpwn_rails"
119
118
  s.licenses = ["MIT"]
120
119
  s.require_paths = ["lib"]
121
- s.rubygems_version = "2.1.11"
120
+ s.rubygems_version = "2.0.14"
122
121
  s.summary = "User authentication for Rails 3 applications."
123
122
 
124
123
  if s.respond_to? :specification_version then
@@ -13,8 +13,13 @@ module EmailField
13
13
  extend ActiveSupport::Concern
14
14
 
15
15
  included do
16
- validates :email, format: /\A[A-Za-z0-9.+_]+@[^@]*\.(\w+)\Z/,
17
- presence: true
16
+ validates_each :email do |record, attr, value|
17
+ unless record.email_credential.valid?
18
+ record.email_credential.errors.each do |_, message|
19
+ record.errors.add attr, message
20
+ end
21
+ end
22
+ end
18
23
  if ActiveRecord::Base.respond_to? :mass_assignment_sanitizer=
19
24
  attr_accessible :email
20
25
  end
@@ -46,18 +46,27 @@ class EmailCredentialTest < ActiveSupport::TestCase
46
46
  test 'email length' do
47
47
  @credential.email = 'abcde' * 25 + '@mit.edu'
48
48
  assert !@credential.valid?, 'Overly long email'
49
+ assert @credential.errors[:name].any? { |m| /too long/i =~ m },
50
+ 'Validation errors include length error'
49
51
  end
50
52
 
51
53
  test 'email format' do
52
54
  ['cos tan@gmail.com', 'costan@x@mit.edu'].each do |email|
53
55
  @credential.email = email
54
56
  assert !@credential.valid?, "Bad email format - #{email}"
57
+ assert @credential.errors[:name].any? { |m| /invalid/i =~ m },
58
+ 'Validation errors include format error'
55
59
  end
56
60
  end
57
61
 
58
62
  test 'email uniqueness' do
59
63
  @credential.email = credentials(:john_email).email
60
64
  assert !@credential.valid?
65
+ assert @credential.errors[:name].any? { |m| /already claimed/i =~ m },
66
+ 'Validation errors include custom uniqueness error'
67
+ assert !@credential.errors[:name].
68
+ any? { |m| m == 'has already been taken' },
69
+ 'Validation errors do not include default uniqueness error'
61
70
  end
62
71
 
63
72
  test 'authenticate' do
@@ -7,12 +7,12 @@ end
7
7
  class EmailFieldTest < ActiveSupport::TestCase
8
8
  def setup
9
9
  @user = UserWithEmail.new email: 'blah@gmail.com'
10
-
10
+
11
11
  @john = UserWithEmail.find_by_id(users(:john).id)
12
12
  @jane = UserWithEmail.find_by_id(users(:jane).id)
13
13
  @bill = UserWithEmail.find_by_id(users(:bill).id)
14
14
  end
15
-
15
+
16
16
  test 'setup' do
17
17
  assert @user.valid?
18
18
  end
@@ -21,7 +21,7 @@ class EmailFieldTest < ActiveSupport::TestCase
21
21
  @user.email = nil
22
22
  assert !@user.valid?
23
23
  end
24
-
24
+
25
25
  test 'email_credential' do
26
26
  assert_equal credentials(:john_email), @john.email_credential
27
27
  assert_equal credentials(:jane_email), @jane.email_credential
@@ -31,13 +31,27 @@ class EmailFieldTest < ActiveSupport::TestCase
31
31
  test 'email length' do
32
32
  @user.email = 'abcde' * 25 + '@mit.edu'
33
33
  assert !@user.valid?, 'Overly long email'
34
+ assert_not_nil @user.errors[:email], 'No validation errors on e-mail'
35
+ assert @user.errors[:email].any? { |m| /too long/i =~ m },
36
+ 'E-mail validation errors include length error'
34
37
  end
35
-
38
+
36
39
  test 'email format' do
37
40
  ['cos tan@gmail.com', 'costan@x@mit.edu'].each do |email|
38
41
  @user.email = email
39
42
  assert !@user.valid?, "Bad email format - #{email}"
40
- end
43
+ assert_not_nil @user.errors[:email], 'No validation errors on e-mail'
44
+ assert @user.errors[:email].any? { |m| /invalid/i =~ m },
45
+ 'E-mail validation errors include format error'
46
+ end
47
+ end
48
+
49
+ test 'email uniqueness' do
50
+ @user.email = @john.email
51
+ assert !@user.valid?, 'Using existent e-mail'
52
+ assert_not_nil @user.errors[:email], 'No validation errors on e-mail'
53
+ assert @user.errors[:email].any? { |m| /already claimed/i =~ m },
54
+ 'E-mail validation errors include uniqueness error'
41
55
  end
42
56
 
43
57
  test 'email' do
@@ -50,7 +64,7 @@ class EmailFieldTest < ActiveSupport::TestCase
50
64
  assert_equal users(:john),
51
65
  UserWithEmail.with_email(credentials(:john_email).email)
52
66
  assert_equal users(:jane),
53
- UserWithEmail.with_email(credentials(:jane_email).email)
67
+ UserWithEmail.with_email(credentials(:jane_email).email)
54
68
  assert_nil UserWithEmail.with_email('nosuch@email.com')
55
69
  end
56
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authpwn_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.14.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Costan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-07 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fbgraph_rails
@@ -260,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
260
260
  version: '0'
261
261
  requirements: []
262
262
  rubyforge_project:
263
- rubygems_version: 2.1.11
263
+ rubygems_version: 2.0.14
264
264
  signing_key:
265
265
  specification_version: 4
266
266
  summary: User authentication for Rails 3 applications.