pillowfort 0.3.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/pillowfort/concerns/model_activation.rb +21 -6
- data/app/models/pillowfort/concerns/model_authentication.rb +8 -1
- data/app/models/pillowfort/concerns/model_password_reset.rb +8 -10
- data/lib/pillowfort/model_finder.rb +3 -1
- data/lib/pillowfort/version.rb +1 -1
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +9698 -0
- data/spec/models/account_spec.rb +34 -10
- metadata +2 -3
data/spec/models/account_spec.rb
CHANGED
|
@@ -74,13 +74,13 @@ RSpec.describe Account, :type => :model do
|
|
|
74
74
|
context "when it's too short" do
|
|
75
75
|
let(:password) { "x"*3 }
|
|
76
76
|
|
|
77
|
-
it { should include(password: [/is too short/])}
|
|
77
|
+
it { should include(password: [/is too short/]) }
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
context "when it's too long" do
|
|
81
81
|
let(:password) { "x"*80 }
|
|
82
82
|
|
|
83
|
-
it { should include(password: [/is too long/])}
|
|
83
|
+
it { should include(password: [/is too long/]) }
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
context "when the record is persisted" do
|
|
@@ -157,6 +157,18 @@ RSpec.describe Account, :type => :model do
|
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
159
|
|
|
160
|
+
describe 'its callbacks' do
|
|
161
|
+
describe 'email normalization' do
|
|
162
|
+
let(:account) { FactoryGirl.create :account, email: email }
|
|
163
|
+
let(:email) { ' HotCarl@Gmail.Com ' }
|
|
164
|
+
let(:expected) { 'hotcarl@gmail.com' }
|
|
165
|
+
|
|
166
|
+
subject { account.email }
|
|
167
|
+
|
|
168
|
+
it { should eq(expected) }
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
160
172
|
describe 'the instance methods' do
|
|
161
173
|
let(:account) {
|
|
162
174
|
FactoryGirl.create :account,
|
|
@@ -362,6 +374,20 @@ RSpec.describe Account, :type => :model do
|
|
|
362
374
|
activation_token_expires_at: activation_token_expires_at
|
|
363
375
|
}
|
|
364
376
|
|
|
377
|
+
describe '.find_by_email_case_insensitive' do
|
|
378
|
+
subject { Account.find_by_email_case_insensitive(search_email) }
|
|
379
|
+
|
|
380
|
+
context 'when an email is provided' do
|
|
381
|
+
let(:search_email) { email }
|
|
382
|
+
it { should_not be_nil}
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
context 'when no email is provided' do
|
|
386
|
+
let(:search_email) { nil }
|
|
387
|
+
it { should be_nil }
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
|
|
365
391
|
describe '.authenticate_securely' do
|
|
366
392
|
let(:email_param) { email }
|
|
367
393
|
let(:token_param) { token }
|
|
@@ -452,6 +478,8 @@ RSpec.describe Account, :type => :model do
|
|
|
452
478
|
expect { |b| Account.find_and_activate(email_param, token_param, &b) }.to yield_with_args(account)
|
|
453
479
|
end
|
|
454
480
|
|
|
481
|
+
it { should == account }
|
|
482
|
+
|
|
455
483
|
context "when the activation_token is expired" do
|
|
456
484
|
let(:activation_token_expires_at) { 1.day.ago }
|
|
457
485
|
it { should be_falsey }
|
|
@@ -471,14 +499,8 @@ RSpec.describe Account, :type => :model do
|
|
|
471
499
|
end
|
|
472
500
|
|
|
473
501
|
describe '.find_and_validate_password_reset_token' do
|
|
474
|
-
let(:email_param) { email }
|
|
475
502
|
let(:token_param) { password_reset_token }
|
|
476
|
-
subject { Account.find_and_validate_password_reset_token(
|
|
477
|
-
|
|
478
|
-
context "when the email doesn't match" do
|
|
479
|
-
let(:email_param) { "bad_actor@gmail.com" }
|
|
480
|
-
it { should be_falsey }
|
|
481
|
-
end
|
|
503
|
+
subject { Account.find_and_validate_password_reset_token(token_param) }
|
|
482
504
|
|
|
483
505
|
context "when the token doesn't match" do
|
|
484
506
|
let(:token_param) { 'notmytoken' }
|
|
@@ -486,8 +508,10 @@ RSpec.describe Account, :type => :model do
|
|
|
486
508
|
end
|
|
487
509
|
|
|
488
510
|
it 'should yield the matched account' do
|
|
489
|
-
expect { |b| Account.find_and_validate_password_reset_token(
|
|
511
|
+
expect { |b| Account.find_and_validate_password_reset_token(token_param, &b) }.to yield_with_args(account)
|
|
490
512
|
end
|
|
513
|
+
|
|
514
|
+
it { should == account }
|
|
491
515
|
end
|
|
492
516
|
|
|
493
517
|
describe '.find_and_authenticate' do
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pillowfort
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 1.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tim Lowrimore
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-
|
|
11
|
+
date: 2015-10-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -264,4 +264,3 @@ test_files:
|
|
|
264
264
|
- spec/rails_helper.rb
|
|
265
265
|
- spec/spec_helper.rb
|
|
266
266
|
- spec/support/helpers/authentication_helper.rb
|
|
267
|
-
has_rdoc:
|