devise_g5_authenticatable 0.1.2 → 0.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efb202ccac3050c390f4aee7ef1afdf625437574
4
- data.tar.gz: 89c6a1f7f1aaebe7123a321c1ceec726ee17e4b7
3
+ metadata.gz: 647e697e95fa5a4f468529c0c016c5e9a8f2a8bd
4
+ data.tar.gz: 5795af637ed1ba2bce1bc36eae8fc765ea9ce88b
5
5
  SHA512:
6
- metadata.gz: 4af967f531a3b3e974cdb46d462cf86a25302357af9a46ff62bc864f4253a0c99759e0bd14c7a4394798bb331dfe559b7d072c6fe54aeecd60ee71564e28bf19
7
- data.tar.gz: 075ebbe92655bb91e49b35df46341d546a6dc6994f6e482e22ebd74844b07ee234f1c138660edecc8bcd49b1a9c84eaa011a9a8a6a6ea4594f013001dac4c865
6
+ metadata.gz: 6a17aa3b3d6cdb0a1e3b2c93aa973df48e6b6a13d6ed923cc2da1b1be813c14e110e7dcebc4ffbdc6449c7224b099bd305234a3f1024b16efb3fe79b5ed788a1
7
+ data.tar.gz: a59a344ee27a3927e89bae41de06c72a654b9a12acd62e36c7ddfc7e5a05743a07bbeb237e6cab70cf8637c6be1b6ea3bef4b2c95dcef241b72ff05bf6a140bf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## v0.1.3 (2014-12-19)
2
+
3
+ * Fix sign out when there isn't a locally authenticated user
4
+ ([#16](https://github.com/G5/devise_g5_authenticatable/pull/16)).
5
+
1
6
  ## v0.1.2 (2014-08-04)
2
7
  * Use existing user with updated password on duplicate user creation with
3
8
  duplicate email.
data/Gemfile CHANGED
@@ -11,6 +11,7 @@ gem 'protected_attributes'
11
11
 
12
12
  group :test, :development do
13
13
  gem 'rspec-rails', '~> 2.14'
14
+ gem 'rspec-activemodel-mocks'
14
15
  gem 'pry'
15
16
  end
16
17
 
data/README.md CHANGED
@@ -10,7 +10,7 @@ G5 users.
10
10
 
11
11
  ## Current Version
12
12
 
13
- 0.1.0
13
+ 0.1.3
14
14
 
15
15
  ## Requirements
16
16
 
@@ -16,7 +16,7 @@ module DeviseG5Authenticatable
16
16
  end
17
17
 
18
18
  def destroy
19
- signed_in_resource.revoke_g5_credentials!
19
+ signed_in_resource.try(:revoke_g5_credentials!)
20
20
  local_sign_out
21
21
  remote_sign_out
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module DeviseG5Authenticatable
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -145,39 +145,47 @@ describe DeviseG5Authenticatable::SessionsController do
145
145
  end
146
146
 
147
147
  let(:model) { create(scope) }
148
-
149
- before do
150
- sign_in(scope, model)
151
- allow(model).to receive(:revoke_g5_credentials!)
152
- end
148
+ before { allow(model).to receive(:revoke_g5_credentials!) }
153
149
 
154
150
  context 'with user scope' do
155
151
  let(:scope) { :user }
156
152
 
157
- it 'should sign out the user locally' do
158
- expect { destroy_session }.to change { controller.current_user }.to(nil)
159
- end
153
+ context 'when there is a current user' do
154
+ before { sign_in(scope, model) }
160
155
 
161
- it 'should construct the sign out URL with the correct redirect URL' do
162
- expect(auth_client).to receive(:sign_out_url).
163
- with(root_url).
164
- and_return(auth_sign_out_url)
165
- destroy_session
166
- end
156
+ it 'should sign out the user locally' do
157
+ expect { destroy_session }.to change { controller.current_user }.to(nil)
158
+ end
159
+
160
+ it 'should construct the sign out URL with the correct redirect URL' do
161
+ expect(auth_client).to receive(:sign_out_url).
162
+ with(root_url).
163
+ and_return(auth_sign_out_url)
164
+ destroy_session
165
+ end
166
+
167
+ it 'should redirect to the auth server to sign out globally' do
168
+ expect(destroy_session).to redirect_to(auth_sign_out_url)
169
+ end
167
170
 
168
- it 'should redirect to the auth server to sign out globally' do
169
- expect(destroy_session).to redirect_to(auth_sign_out_url)
171
+ it 'should revoke the g5 access token' do
172
+ expect(controller.current_user).to receive(:revoke_g5_credentials!)
173
+ destroy_session
174
+ end
170
175
  end
171
176
 
172
- it 'should revoke the g5 access token' do
173
- expect(controller.current_user).to receive(:revoke_g5_credentials!)
174
- destroy_session
177
+ context 'when there is not a current user' do
178
+ it 'should redirect to the auth server to sign out globally' do
179
+ expect(destroy_session).to redirect_to(auth_sign_out_url)
180
+ end
175
181
  end
176
182
  end
177
183
 
178
184
  context 'with admin scope' do
179
185
  let(:scope) { :admin }
180
186
 
187
+ before { sign_in(scope, model) }
188
+
181
189
  it 'should sign out the admin locally' do
182
190
  expect { destroy_session }.to change { controller.current_admin }.to(nil)
183
191
  end
@@ -39,7 +39,7 @@ describe Devise::G5::AuthPasswordValidator do
39
39
  end
40
40
 
41
41
  it 'should return true' do
42
- expect(valid_password?).to be_true
42
+ expect(valid_password?).to be_truthy
43
43
  end
44
44
  end
45
45
 
@@ -52,7 +52,7 @@ describe Devise::G5::AuthPasswordValidator do
52
52
  end
53
53
 
54
54
  it 'should return false' do
55
- expect(valid_password?).to be_false
55
+ expect(valid_password?).to be_falsey
56
56
  end
57
57
  end
58
58
 
@@ -61,7 +61,7 @@ describe Devise::G5::AuthPasswordValidator do
61
61
  let(:runtime_error) { RuntimeError.new('Insufficient credentials for access token. Supply a username/password or authentication code.') }
62
62
 
63
63
  it 'should return false' do
64
- expect(valid_password?).to be_false
64
+ expect(valid_password?).to be_falsey
65
65
  end
66
66
  end
67
67
 
@@ -184,7 +184,7 @@ describe Devise::Models::G5Authenticatable do
184
184
 
185
185
  context 'with valid input' do
186
186
  it 'should return true' do
187
- expect(update_with_password).to be_true
187
+ expect(update_with_password).to be_truthy
188
188
  end
189
189
 
190
190
  it 'should initialize the auth user updater' do
@@ -204,7 +204,7 @@ describe Devise::Models::G5Authenticatable do
204
204
  let(:updated_email) { '' }
205
205
 
206
206
  it 'should return false' do
207
- expect(update_with_password).to be_false
207
+ expect(update_with_password).to be_falsey
208
208
  end
209
209
 
210
210
  it 'should not update the credentials on the auth server' do
@@ -226,7 +226,7 @@ describe Devise::Models::G5Authenticatable do
226
226
  let(:current_password) { '' }
227
227
 
228
228
  it 'should return false' do
229
- expect(update_with_password).to be_false
229
+ expect(update_with_password).to be_falsey
230
230
  end
231
231
 
232
232
  it 'should set an error on the current_password attribute' do
@@ -242,7 +242,7 @@ describe Devise::Models::G5Authenticatable do
242
242
  let(:current_password) { 'something wrong' }
243
243
 
244
244
  it 'should return false' do
245
- expect(update_with_password).to be_false
245
+ expect(update_with_password).to be_falsey
246
246
  end
247
247
 
248
248
  it 'should set an error on the current_password attribute' do
@@ -293,7 +293,7 @@ describe Devise::Models::G5Authenticatable do
293
293
  let(:valid) { true }
294
294
 
295
295
  it 'should return true' do
296
- expect(valid_password?).to be_true
296
+ expect(valid_password?).to be_truthy
297
297
  end
298
298
 
299
299
  it 'should initialize the validator with the model' do
@@ -309,7 +309,7 @@ describe Devise::Models::G5Authenticatable do
309
309
  let(:valid) { false }
310
310
 
311
311
  it 'should return false' do
312
- expect(valid_password?).to be_false
312
+ expect(valid_password?).to be_falsey
313
313
  end
314
314
 
315
315
  it 'should initialize the validator with the model' do
@@ -442,7 +442,7 @@ describe Devise::Models::G5Authenticatable do
442
442
 
443
443
  it 'should not save the changes' do
444
444
  update_g5_credentials
445
- expect(model.g5_access_token_changed?).to be_true
445
+ expect(model.g5_access_token_changed?).to be_truthy
446
446
  end
447
447
  end
448
448
 
@@ -499,19 +499,37 @@ describe Devise::Models::G5Authenticatable do
499
499
  context 'with session data' do
500
500
  let(:session) { {'omniauth.auth' => auth_data} }
501
501
 
502
- it { should be_new_record }
503
- its(:email) { should == email_param }
504
- its(:provider) { should == auth_data.provider }
505
- its(:uid) { should == auth_data.uid }
502
+ it { is_expected.to be_new_record }
503
+
504
+ it 'should set the email from the params' do
505
+ expect(new_with_session.email).to eq(email_param)
506
+ end
507
+
508
+ it 'should set the provider from the session' do
509
+ expect(new_with_session.provider).to eq(auth_data.provider)
510
+ end
511
+
512
+ it 'should set the uid from the session' do
513
+ expect(new_with_session.uid).to eq(auth_data.uid)
514
+ end
506
515
  end
507
516
 
508
517
  context 'without session data' do
509
518
  let(:session) { Hash.new }
510
519
 
511
- it { should be_new_record }
512
- its(:email) { should == email_param }
513
- its(:provider) { should be_nil }
514
- its(:uid) { should be_nil }
520
+ it { is_expected.to be_new_record }
521
+
522
+ it 'should set the email from the params' do
523
+ expect(new_with_session.email).to eq(email_param)
524
+ end
525
+
526
+ it 'should not set the provider' do
527
+ expect(new_with_session.provider).to be_nil
528
+ end
529
+
530
+ it 'should not set the uid' do
531
+ expect(new_with_session.uid).to be_nil
532
+ end
515
533
  end
516
534
  end
517
535
 
@@ -521,19 +539,37 @@ describe Devise::Models::G5Authenticatable do
521
539
  context 'with session data' do
522
540
  let(:session) { {'omniauth.auth' => auth_data} }
523
541
 
524
- it { should be_new_record }
525
- its(:email) { should == auth_data.info[:email] }
526
- its(:provider) { should == auth_data.provider }
527
- its(:uid) { should == auth_data.uid }
542
+ it { is_expected.to be_new_record }
543
+
544
+ it 'should set the email from the session' do
545
+ expect(new_with_session.email).to eq(auth_data.info[:email])
546
+ end
547
+
548
+ it 'should set the provider from the session' do
549
+ expect(new_with_session.provider).to eq(auth_data.provider)
550
+ end
551
+
552
+ it 'should set the uid from the session' do
553
+ expect(new_with_session.uid).to eq(auth_data.uid)
554
+ end
528
555
  end
529
556
 
530
557
  context 'without session data' do
531
558
  let(:session) { Hash.new }
532
559
 
533
- it { should be_new_record }
534
- its(:email) { should be_blank }
535
- its(:provider) { should be_nil }
536
- its(:uid) { should be_nil }
560
+ it { is_expected.to be_new_record }
561
+
562
+ it 'should not set the email' do
563
+ expect(new_with_session.email).to be_blank
564
+ end
565
+
566
+ it 'should not set the provider' do
567
+ expect(new_with_session.provider).to be_nil
568
+ end
569
+
570
+ it 'should not set the uid' do
571
+ expect(new_with_session.uid).to be_nil
572
+ end
537
573
  end
538
574
  end
539
575
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devise_g5_authenticatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maeve Revels
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-04 00:00:00.000000000 Z
11
+ date: 2014-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise