authorizy 0.6.0 → 0.6.1

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
  SHA256:
3
- metadata.gz: d473bd8a20f491dd718805097a7060d9c3b792657beb535441bdab3d2520e65f
4
- data.tar.gz: 8dff226b40401c2acb2b09252022ecbf55c512c93180b61ef72c5d1ac0256692
3
+ metadata.gz: 7f16633e82f4cc1ce7b11df3a35d68316e024b16cf721f37820f3db5ecf067c7
4
+ data.tar.gz: 2aec88984c8d221de642b3ba49228f6e1f133339f12953712412c4d928875576
5
5
  SHA512:
6
- metadata.gz: 26519151ed8c405d60f11958cb07768b17b2fc9cd0ecc0335473f1b9cee81ea46cff277f7be4fdf9afb1d071e18b26d10a5d66f5954fcf3bff0df9d6dca817a3
7
- data.tar.gz: 2ad9b69333e08dd84b0f3124619877af35bf7966c63776d2920ff9b42d4deaee493b515b49714fc8d928884dda2a51ff3f0abb871ede0fdc258a5258a1cd947f
6
+ metadata.gz: 072f85780dedbe23346a68e9b29787f1afad1b0a573ec9e7210d71962422adb4fc63cf07d9ed8c2d5f608dda507df4c5501c440a87dec7148e04979f797e0934
7
+ data.tar.gz: 5b88b71f9fe7b22ea2d54eb6fbd09aad79e9312218846161d5856849f8e3fc869a2d6018f64c626d0efe150c84a0c136dd4e9ab3049aa2e6ed30438deda2c54f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ # v0.6.1
2
+
3
+ ## Fixes
4
+
5
+ - Denied JSON requests now will render JSON correctly
6
+
1
7
  # v0.6.0
2
8
 
3
9
  ## Updates
@@ -12,9 +12,9 @@ module Authorizy
12
12
  @denied = lambda { |context|
13
13
  info = I18n.t('authorizy.denied', controller: context.params[:controller], action: context.params[:action])
14
14
 
15
- return context.render(json: { message: info }, status: 403) if context.request.xhr?
15
+ return context.redirect_to(redirect_url.call(context), info:) if context.request.format.html?
16
16
 
17
- context.redirect_to(redirect_url.call(context), info:)
17
+ context.render(json: { message: info }, status: 403)
18
18
  }
19
19
 
20
20
  @dependencies = {}
@@ -23,8 +23,27 @@ RSpec::Matchers.define :be_authorized do |controller, action, params: {}, sessio
23
23
  maybe_params_or_session("expected #{user.class}##{user.id} not to be authorized in #{data}", params, session)
24
24
  end
25
25
 
26
+ description do
27
+ parts = [%(be authorized "#{expected[0]}", "#{expected[1]}")]
28
+
29
+ options = [].tap do |item|
30
+ item << "params: #{format_hash(params)}" if params.any?
31
+ item << "session: #{format_hash(session)}" if session.any?
32
+ end
33
+
34
+ parts << "and {#{options.join(', ')}}" if options.any?
35
+
36
+ parts.join(', ')
37
+ end
38
+
26
39
  private
27
40
 
41
+ def format_hash(hash)
42
+ pairs = hash.map { |k, v| "#{k}: #{v.is_a?(Hash) ? format_hash(v) : v.inspect}" }
43
+
44
+ "{#{pairs.join(', ')}}"
45
+ end
46
+
28
47
  def access?(user, params, session)
29
48
  cop = Authorizy.config.cop.new(user, params, session)
30
49
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Authorizy
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: authorizy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Washington Botelho
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-02 00:00:00.000000000 Z
10
+ date: 2026-04-25 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: activesupport