declarative_authorization 0.4.1 → 0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +15 -0
- data/README.rdoc +8 -7
- data/Rakefile +0 -8
- data/app/controllers/authorization_rules_controller.rb +1 -1
- data/app/helpers/authorization_rules_helper.rb +3 -3
- data/config/routes.rb +5 -2
- data/lib/declarative_authorization.rb +2 -0
- data/lib/declarative_authorization/authorization.rb +20 -14
- data/lib/declarative_authorization/in_controller.rb +2 -5
- data/lib/declarative_authorization/in_model.rb +13 -10
- data/lib/declarative_authorization/maintenance.rb +4 -4
- data/lib/declarative_authorization/obligation_scope.rb +51 -13
- data/lib/declarative_authorization/rails_legacy.rb +9 -1
- data/lib/declarative_authorization/railsengine.rb +6 -0
- data/lib/declarative_authorization/reader.rb +61 -7
- data/lib/tasks/authorization_tasks.rake +82 -0
- data/test/authorization_test.rb +108 -0
- data/test/controller_test.rb +4 -3
- data/test/dsl_reader_test.rb +21 -0
- data/test/helper_test.rb +1 -0
- data/test/model_test.rb +229 -91
- data/test/test_helper.rb +44 -13
- metadata +23 -9
data/test/test_helper.rb
CHANGED
@@ -1,25 +1,39 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
require 'pathname'
|
3
|
+
|
4
|
+
unless defined?(RAILS_ROOT)
|
5
|
+
RAILS_ROOT = ENV['RAILS_ROOT'] ?
|
6
|
+
ENV['RAILS_ROOT'] + "" :
|
7
|
+
File.join(File.dirname(__FILE__), %w{.. .. .. ..})
|
8
|
+
end
|
7
9
|
|
8
10
|
unless defined?(ActiveRecord)
|
9
11
|
if File.directory? RAILS_ROOT + '/config'
|
10
|
-
puts '
|
12
|
+
puts 'Using config/boot.rb'
|
11
13
|
ENV['RAILS_ENV'] = 'test'
|
12
|
-
require File.join(RAILS_ROOT, 'config', '
|
14
|
+
require File.join(RAILS_ROOT, 'config', 'environment.rb')
|
13
15
|
else
|
14
16
|
# simply use installed gems if available
|
15
|
-
|
17
|
+
version_requirement = ENV['RAILS_VERSION'] ? "= #{ENV['RAILS_VERSION']}" : "> 2.1.0"
|
18
|
+
puts "Using Rails from RubyGems (#{version_requirement || "default"})"
|
16
19
|
require 'rubygems'
|
17
|
-
|
20
|
+
%w{actionpack activerecord activesupport rails}.each do |gem_name|
|
21
|
+
gem gem_name, version_requirement
|
22
|
+
end
|
18
23
|
end
|
19
24
|
|
20
|
-
|
25
|
+
unless defined?(Rails) # needs to be explicit in Rails < 3
|
26
|
+
%w(action_pack action_controller active_record active_support initializer).each {|f| require f}
|
27
|
+
end
|
21
28
|
end
|
22
29
|
|
30
|
+
DA_ROOT = Pathname.new(File.expand_path("..", File.dirname(__FILE__)))
|
31
|
+
|
32
|
+
require DA_ROOT + File.join(%w{lib declarative_authorization rails_legacy})
|
33
|
+
require DA_ROOT + File.join(%w{lib declarative_authorization authorization})
|
34
|
+
require DA_ROOT + File.join(%w{lib declarative_authorization in_controller})
|
35
|
+
require DA_ROOT + File.join(%w{lib declarative_authorization maintenance})
|
36
|
+
|
23
37
|
begin
|
24
38
|
require 'ruby-debug'
|
25
39
|
rescue MissingSourceFile; end
|
@@ -99,11 +113,22 @@ class MocksController < ActionController::Base
|
|
99
113
|
end
|
100
114
|
end
|
101
115
|
|
102
|
-
|
103
|
-
|
116
|
+
if Rails.version < "3"
|
117
|
+
ActionController::Routing::Routes.draw do |map|
|
118
|
+
map.connect ':controller/:action/:id'
|
119
|
+
end
|
120
|
+
else
|
121
|
+
Rails::Application.routes.draw do
|
122
|
+
match '/name/spaced_things(/:action)' => 'name/spaced_things'
|
123
|
+
match '/deep/name_spaced/things(/:action)' => 'deep/name_spaced/things'
|
124
|
+
match '/:controller(/:action(/:id))'
|
125
|
+
end
|
104
126
|
end
|
127
|
+
|
105
128
|
ActionController::Base.send :include, Authorization::AuthorizationInController
|
106
|
-
|
129
|
+
if Rails.version < "3"
|
130
|
+
require "action_controller/test_process"
|
131
|
+
end
|
107
132
|
|
108
133
|
class Test::Unit::TestCase
|
109
134
|
include Authorization::TestHelper
|
@@ -118,4 +143,10 @@ class Test::Unit::TestCase
|
|
118
143
|
end
|
119
144
|
get action, params
|
120
145
|
end
|
146
|
+
|
147
|
+
unless Rails.version < "3"
|
148
|
+
def setup
|
149
|
+
@routes = Rails::Application.routes
|
150
|
+
end
|
151
|
+
end
|
121
152
|
end
|
metadata
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: declarative_authorization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 5
|
8
|
+
version: "0.5"
|
5
9
|
platform: ruby
|
6
10
|
authors:
|
7
11
|
- Steffen Bartsch
|
@@ -9,19 +13,23 @@ autorequire:
|
|
9
13
|
bindir: bin
|
10
14
|
cert_chain: []
|
11
15
|
|
12
|
-
date: 2010-
|
16
|
+
date: 2010-07-21 00:00:00 +02:00
|
13
17
|
default_executable:
|
14
18
|
dependencies:
|
15
19
|
- !ruby/object:Gem::Dependency
|
16
20
|
name: rails
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
prerelease: false
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
23
|
requirements:
|
21
24
|
- - ">="
|
22
25
|
- !ruby/object:Gem::Version
|
26
|
+
segments:
|
27
|
+
- 2
|
28
|
+
- 1
|
29
|
+
- 0
|
23
30
|
version: 2.1.0
|
24
|
-
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
25
33
|
description:
|
26
34
|
email: sbartsch@tzi.org
|
27
35
|
executables: []
|
@@ -56,6 +64,7 @@ files:
|
|
56
64
|
- lib/declarative_authorization/reader.rb
|
57
65
|
- lib/declarative_authorization/rails_legacy.rb
|
58
66
|
- lib/declarative_authorization/obligation_scope.rb
|
67
|
+
- lib/declarative_authorization/railsengine.rb
|
59
68
|
- lib/declarative_authorization/in_model.rb
|
60
69
|
- lib/declarative_authorization/helper.rb
|
61
70
|
- lib/declarative_authorization/development_support/analyzer.rb
|
@@ -64,6 +73,7 @@ files:
|
|
64
73
|
- lib/declarative_authorization/development_support/development_support.rb
|
65
74
|
- lib/declarative_authorization/authorization.rb
|
66
75
|
- lib/declarative_authorization/maintenance.rb
|
76
|
+
- lib/tasks/authorization_tasks.rake
|
67
77
|
- test/authorization_test.rb
|
68
78
|
- test/schema.sql
|
69
79
|
- test/maintenance_test.rb
|
@@ -86,18 +96,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
96
|
requirements:
|
87
97
|
- - ">="
|
88
98
|
- !ruby/object:Gem::Version
|
99
|
+
segments:
|
100
|
+
- 1
|
101
|
+
- 8
|
102
|
+
- 6
|
89
103
|
version: 1.8.6
|
90
|
-
version:
|
91
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
105
|
requirements:
|
93
106
|
- - ">="
|
94
107
|
- !ruby/object:Gem::Version
|
108
|
+
segments:
|
109
|
+
- 0
|
95
110
|
version: "0"
|
96
|
-
version:
|
97
111
|
requirements: []
|
98
112
|
|
99
113
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.3.
|
114
|
+
rubygems_version: 1.3.6
|
101
115
|
signing_key:
|
102
116
|
specification_version: 3
|
103
117
|
summary: declarative_authorization is a Rails plugin for authorization based on readable authorization rules.
|