ae_declarative_authorization 0.6.0.pre2 → 0.6.0.pre3

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: 7c781d5e787dca8a3622047bf89ac2fc18bf6482
4
- data.tar.gz: 851f84598cb1b17040034c529e7f0733422d28ad
3
+ metadata.gz: 9b32026106200839d7c0b87b1b00ce72bc8656bf
4
+ data.tar.gz: 002a81249ed4976c82902fe1c9c74996d70a1f11
5
5
  SHA512:
6
- metadata.gz: d9e7a70c4b8b7e278f5fb6ed28d76aa82751dd47387d626622f70cc28caf7db7289c13ae7cd8a0764718b627ad3b2b51e9bddab4418bdf54d35efb8e6b934528
7
- data.tar.gz: 1a027f140d59cc974ce34ee61a5a75f718715f1bf5c09a1655be0c047d73f58939b6076bcdad549afd29195234af5ab75cd523715541636fda1a00223127d08b
6
+ metadata.gz: db6eeaadd8ed3967feb98022e667bc38210d5438277d7f2c032651b579dc661d44a0478df130983ec8865643d971024b20280e3c22709966c8c50d7298efa855
7
+ data.tar.gz: a25e17d7c478f5df03a9f8f2bcabe8f1cec181fe87ebd6eaa9629fbe0ad48e723d5df19f03029607a108d083787c107f140787f7b3a4b2b1650242c6902b0ce8
@@ -60,7 +60,7 @@ module DeclarativeAuthorization
60
60
  privileges = @privileges
61
61
 
62
62
  actions = options[:to]
63
- raise ":to is a required option!" unless actions
63
+ raise ':to is a required option!' unless actions
64
64
 
65
65
  actions = [actions] unless actions.is_a?(Array)
66
66
  params_name = options[:with]
@@ -127,10 +127,14 @@ module DeclarativeAuthorization
127
127
  module ClassMethods
128
128
  attr_reader :access_tests_defined
129
129
 
130
+ def skip_access_tests_for_actions(*actions)
131
+ @skipped_access_test_actions ||= []
132
+ @skipped_access_test_actions += actions.map(&:to_sym)
133
+ end
134
+
130
135
  def access_tests(&block)
131
136
  @access_tests_defined = true
132
- @access_tests_defined = true
133
- file_output ||= [ 'test/profiles/access_checking', ENV['TEST_ENV_NUMBER'] ].compact.join(".")
137
+ file_output ||= [ 'test/profiles/access_checking', ENV['TEST_ENV_NUMBER'] ].compact.join('.')
134
138
  unless File.exists?(file_output)
135
139
  FileUtils.mkdir_p(File.dirname(file_output))
136
140
  end
@@ -151,18 +155,22 @@ module DeclarativeAuthorization
151
155
  alias :access_tests_not_required :this_is_an_abstract_controller_so_it_needs_no_access_tests
152
156
 
153
157
  def all_public_actions
154
- actions = controller_class.public_instance_methods(false).map(&:to_s)
155
- actions += controller_class.superclass.public_instance_methods(false).map(&:to_s)
156
- actions.reject! { |method| method =~ /^_/ || method.starts_with?('rescue_action') }
158
+ actions = controller_class.public_instance_methods(false)
159
+ actions += controller_class.superclass.public_instance_methods(false)
160
+ actions.reject! do |method|
161
+ method =~ /^_/ ||
162
+ method =~ /^rescue_action/ ||
163
+ (@skipped_access_test_actions.is_a?(Array) && @skipped_access_test_actions.include?(method))
164
+ end
157
165
 
158
- actions.uniq.map(&:to_s) - %w(permitted_to? has_role? has_role_with_hierarchy? has_any_role? has_any_role_with_hierarchy?)
166
+ actions.uniq
159
167
  end
160
168
 
161
169
  def inherited(child)
162
170
  super
163
171
 
164
172
  child.send(:define_method, :test_access_tests_defined) do
165
- assert self.class.access_tests_defined, "Access tests needed but not defined."
173
+ assert self.class.access_tests_defined, 'Access tests needed but not defined.'
166
174
  end
167
175
 
168
176
  child.send(:define_method, :test_all_public_actions_covered_by_role_tests) do
@@ -183,7 +191,7 @@ module DeclarativeAuthorization
183
191
  protected
184
192
 
185
193
  def response_forbidden?
186
- flash[:error] == "You do not have the correct permissions to access that page. Click the back button to return to your previous page." ||
194
+ flash[:error] == 'You do not have the correct permissions to access that page. Click the back button to return to your previous page.' ||
187
195
  flash[:error] =~ /You do not have the correct permissions to view this/ ||
188
196
  flash[:error] =~ /You do not have access to/ ||
189
197
  flash[:alert] =~ /You need to sign in/ ||
@@ -211,7 +219,7 @@ module DeclarativeAuthorization
211
219
  end
212
220
 
213
221
  def access_test_user(role, privilege)
214
- raise "MUST IMPLEMENT!!"
222
+ raise 'MUST IMPLEMENT!!!'
215
223
  end
216
224
 
217
225
  def forbidden_with_role_and_privilege?(action, role, privilege, params_name = nil, options = {})
@@ -1,3 +1,3 @@
1
1
  module DeclarativeAuthorization
2
- VERSION = '0.6.0.pre2'.freeze
2
+ VERSION = '0.6.0.pre3'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ae_declarative_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0.pre2
4
+ version: 0.6.0.pre3
5
5
  platform: ruby
6
6
  authors:
7
7
  - AppFolio
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-06-14 00:00:00.000000000 Z
12
+ date: 2018-06-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: blockenspiel
@@ -60,6 +60,7 @@ files:
60
60
  - README.md
61
61
  - README.rdoc
62
62
  - Rakefile
63
+ - ae_declarative_authorization-0.6.0.pre2.gem
63
64
  - authorization_rules.dist.rb
64
65
  - declarative_authorization.gemspec
65
66
  - gemfiles/4.1.gemfile.lock