rails_jwt_auth 0.4.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3494e45b64c0d552272f8e20af88201294d4bf68
4
- data.tar.gz: 3930404dd79c4d8c6807451579289f13085c4199
3
+ metadata.gz: 590d1c824e7a0171f9e8c084046dc0351181487d
4
+ data.tar.gz: ef843896d84008e223cefa7fa805ef646bdd4926
5
5
  SHA512:
6
- metadata.gz: 0391f7c10a5819b25b42511b1546566e730e4145082bd8237aa5b6050874a493ca7816a803139c3eba336b53ca1a30d418d493ce341e14b1146fa901dd3ad7be
7
- data.tar.gz: afae862ba2e5714b56a76206ee940c7d5f53ccfc77d5f65baea5a1d31d1a372eaf79649abc03a54d2fa4e47fbbeb7b2fb3876e848afd87f1295e22b9b8d40477
6
+ metadata.gz: 80f81e20135779d4d172fce4d06d0f92cb21aee8a5b45a81a93e1d6d2fdba20dd6c37de4747315d8df5b6b13e08b44b78d7bc6d2f75c869af6708e0186d9da79
7
+ data.tar.gz: 69a6d187020c8acb0984adbedbaed96aa45d622bea1ad63d9b657cd04dc769c6a8770fd2b0eb0b7509331e536cda01de58fa1072a05e270d49c2f1cf963e1968
data/README.md CHANGED
@@ -350,7 +350,7 @@ resource :registration, controller: 'registrations', only: [:create, :update, :d
350
350
 
351
351
  ## Testing (rspec)
352
352
 
353
- Require the RailsJwtAuth::Spec::Helpers helper module in `spec_helper.rb`.
353
+ Require the RailsJwtAuth::Spec::Helpers helper module in `rails_helper.rb`.
354
354
 
355
355
  ```ruby
356
356
  require 'rails_jwt_auth/spec/helpers'
@@ -358,22 +358,23 @@ Require the RailsJwtAuth::Spec::Helpers helper module in `spec_helper.rb`.
358
358
  RSpec.configure do |config|
359
359
  ...
360
360
  config.include RailsJwtAuth::Spec::Helpers, :type => :controller
361
- ...
362
361
  end
363
362
  ```
364
363
 
365
- And then in controller examples we can just call sign_in(user) to sign in as a user, or sign_out for examples that have no user signed in. Here's two quick examples:
364
+ And then we can just call sign_in(user) to sign in as a user, or sign_out for examples that have no user signed in. Here's two quick examples:
366
365
 
367
366
  ```ruby
368
- it "blocks unauthenticated access" do
369
- sign_out
370
- expect { get :index }.to raise_error(RailsJwtAuth::Errors::NotAuthorized)
371
- end
367
+ describe ExampleController
368
+ it "blocks unauthenticated access" do
369
+ sign_out
370
+ expect { get :index }.to raise_error(RailsJwtAuth::Errors::NotAuthorized)
371
+ end
372
372
 
373
- it "allows authenticated access" do
374
- sign_in
375
- get :index
376
- expect(response).to be_success
373
+ it "allows authenticated access" do
374
+ sign_in
375
+ get :index
376
+ expect(response).to be_success
377
+ end
377
378
  end
378
379
  ```
379
380
 
@@ -16,8 +16,12 @@ module RailsJwtAuth
16
16
  warden.authenticate!
17
17
  end
18
18
 
19
- def render_401
20
- render json: {}, status: 401
19
+ def self.included(base)
20
+ return unless Rails.env.test? && base.name == 'ApplicationController'
21
+
22
+ base.send(:rescue_from, RailsJwtAuth::Spec::NotAuthorized) do
23
+ render json: {}, status: 401
24
+ end
21
25
  end
22
26
  end
23
27
  end
@@ -1,12 +1,12 @@
1
1
  module RailsJwtAuth
2
2
  module Spec
3
3
  module Helpers
4
- require 'rails_jwt_auth/errors/not_authorized'
4
+ require 'rails_jwt_auth/spec/not_authorized'
5
5
  require 'rails_jwt_auth/jwt/manager'
6
6
 
7
7
  def sign_out
8
8
  request.env['warden'] = RailsJwtAuth::Strategies::Jwt.new request.env
9
- allow(request.env['warden']).to receive(:authenticate!).and_raise(RailsJwtAuth::Errors::NotAuthorized)
9
+ allow(request.env['warden']).to receive(:authenticate!).and_raise(RailsJwtAuth::Spec::NotAuthorized)
10
10
  end
11
11
 
12
12
  def sign_in(user)
@@ -1,5 +1,5 @@
1
1
  module RailsJwtAuth
2
- module Errors
2
+ module Spec
3
3
  class NotAuthorized < StandardError
4
4
  end
5
5
  end
@@ -1,3 +1,3 @@
1
1
  module RailsJwtAuth
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_jwt_auth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - rjurado
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-01 00:00:00.000000000 Z
11
+ date: 2017-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -95,10 +95,10 @@ files:
95
95
  - lib/generators/templates/initializer.rb
96
96
  - lib/rails_jwt_auth.rb
97
97
  - lib/rails_jwt_auth/engine.rb
98
- - lib/rails_jwt_auth/errors/not_authorized.rb
99
98
  - lib/rails_jwt_auth/jwt/manager.rb
100
99
  - lib/rails_jwt_auth/jwt/request.rb
101
100
  - lib/rails_jwt_auth/spec/helpers.rb
101
+ - lib/rails_jwt_auth/spec/not_authorized.rb
102
102
  - lib/rails_jwt_auth/strategies/jwt.rb
103
103
  - lib/rails_jwt_auth/version.rb
104
104
  - lib/tasks/rails_token_jwt_tasks.rake