viva-declarative_authorization 0.3.2.2.1 → 0.3.2.3.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.
@@ -360,7 +360,10 @@ See Authorization::TestHelper for more information.
360
360
 
361
361
  One of three options to install the plugin:
362
362
  * Install by Gem: Add to your environment.rb in the initializer block:
363
- config.gem "stffn-declarative_authorization", :lib => "declarative_authorization"
363
+ config.gem "declarative_authorization"
364
+ Note: you need gemcutter support in place, i.e. call
365
+ gem install gemcutter
366
+ gem tumble
364
367
  And call from your application's root directory
365
368
  rake gems:install
366
369
  * Alternatively, to install from github, execute in your application's root directory
@@ -229,7 +229,8 @@ module Authorization
229
229
 
230
230
  # Returns the role symbols of the given user.
231
231
  def roles_for (user)
232
- raise AuthorizationUsageError, "User object doesn't respond to roles" \
232
+ user ||= Authorization.current_user
233
+ raise AuthorizationUsageError, "User object doesn't respond to roles (#{user.inspect})" \
233
234
  if !user.respond_to?(:role_symbols) and !user.respond_to?(:roles)
234
235
 
235
236
  RAILS_DEFAULT_LOGGER.info("The use of user.roles is deprecated. Please add a method " +
@@ -112,6 +112,23 @@ class HelperTest < ActionController::TestCase
112
112
  end
113
113
  assert !block_evaled
114
114
  end
115
+
116
+ def test_has_role_with_guest_user
117
+ reader = Authorization::Reader::DSLReader.new
118
+ reader.parse %{
119
+ authorization do
120
+ end
121
+ }
122
+ request!(nil, :action, reader)
123
+
124
+ assert !has_role?(:test_role)
125
+
126
+ block_evaled = false
127
+ has_role?(:test_role) do
128
+ block_evaled = true
129
+ end
130
+ assert !block_evaled
131
+ end
115
132
 
116
133
  def test_has_role_with_hierarchy
117
134
  reader = Authorization::Reader::DSLReader.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viva-declarative_authorization
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2.2.1
4
+ version: 0.3.2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steffen Bartsch
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-13 00:00:00 +02:00
12
+ date: 2009-10-15 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -42,36 +42,36 @@ files:
42
42
  - app/controllers/authorization_rules_controller.rb
43
43
  - app/controllers/authorization_usages_controller.rb
44
44
  - app/helpers/authorization_rules_helper.rb
45
- - app/views/authorization_rules/_change.erb
45
+ - app/views/authorization_usages/index.html.erb
46
+ - app/views/authorization_rules/index.html.erb
46
47
  - app/views/authorization_rules/_show_graph.erb
48
+ - app/views/authorization_rules/_change.erb
47
49
  - app/views/authorization_rules/_suggestions.erb
48
- - app/views/authorization_rules/change.html.erb
49
50
  - app/views/authorization_rules/graph.dot.erb
51
+ - app/views/authorization_rules/change.html.erb
50
52
  - app/views/authorization_rules/graph.html.erb
51
- - app/views/authorization_rules/index.html.erb
52
- - app/views/authorization_usages/index.html.erb
53
53
  - config/routes.rb
54
54
  - lib/declarative_authorization.rb
55
- - lib/declarative_authorization/authorization.rb
55
+ - lib/declarative_authorization/in_controller.rb
56
+ - lib/declarative_authorization/reader.rb
57
+ - lib/declarative_authorization/rails_legacy.rb
58
+ - lib/declarative_authorization/obligation_scope.rb
59
+ - lib/declarative_authorization/in_model.rb
60
+ - lib/declarative_authorization/helper.rb
56
61
  - lib/declarative_authorization/development_support/analyzer.rb
57
62
  - lib/declarative_authorization/development_support/change_analyzer.rb
58
63
  - lib/declarative_authorization/development_support/change_supporter.rb
59
64
  - lib/declarative_authorization/development_support/development_support.rb
60
- - lib/declarative_authorization/helper.rb
61
- - lib/declarative_authorization/in_controller.rb
62
- - lib/declarative_authorization/in_model.rb
65
+ - lib/declarative_authorization/authorization.rb
63
66
  - lib/declarative_authorization/maintenance.rb
64
- - lib/declarative_authorization/obligation_scope.rb
65
- - lib/declarative_authorization/rails_legacy.rb
66
- - lib/declarative_authorization/reader.rb
67
67
  - test/authorization_test.rb
68
- - test/controller_filter_resource_access_test.rb
69
- - test/controller_test.rb
70
- - test/dsl_reader_test.rb
71
- - test/helper_test.rb
68
+ - test/schema.sql
72
69
  - test/maintenance_test.rb
73
70
  - test/model_test.rb
74
- - test/schema.sql
71
+ - test/controller_test.rb
72
+ - test/helper_test.rb
73
+ - test/dsl_reader_test.rb
74
+ - test/controller_filter_resource_access_test.rb
75
75
  - test/test_helper.rb
76
76
  has_rdoc: true
77
77
  homepage: http://github.com/stffn/declarative_authorization