cbac 0.6.10 → 0.7.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.
@@ -4,74 +4,73 @@ include Cbac::CbacPristine
4
4
 
5
5
  describe "CbacPristineRole" do
6
6
  describe "convert pristine role to a yml fixture" do
7
- it "should return an empty string if the pristine role is of type :context" do
7
+ it "returns an empty string if the pristine role is of type :context" do
8
8
  pristine_role = PristineRole.new(:role_id => 0, :role_type => PristineRole.ROLE_TYPES[:context], :name => "name is irrelevant")
9
9
 
10
- pristine_role.to_yml_fixture.should be_empty
10
+ expect(pristine_role.to_yml_fixture).to be_empty
11
11
  end
12
12
 
13
- it "should raise an error if the role name is not specified" do
13
+ it "raises an error if the role name is not specified" do
14
14
  pristine_role = PristineRole.new(:role_id => 0, :role_type => PristineRole.ROLE_TYPES[:admin], :name => "")
15
15
 
16
- proc{
16
+ expect(proc{
17
17
  pristine_role.to_yml_fixture
18
- }.should raise_error(ArgumentError)
18
+ }).to raise_error(ArgumentError)
19
19
  end
20
20
 
21
- it "should return a yml string starting with cbac_generic_role_ " do
21
+ it "returns a yml string starting with cbac_generic_role_ " do
22
22
  pristine_role = PristineRole.new(:role_id => 0, :role_type => PristineRole.ROLE_TYPES[:generic], :name => "name is irrelevant")
23
23
 
24
- pristine_role.to_yml_fixture.should match(/\Acbac_generic_role_/)
24
+ expect(pristine_role.to_yml_fixture).to match(/\Acbac_generic_role_/)
25
25
  end
26
26
 
27
- it "should return a yml string containing the id of the pristine role" do
27
+ it "returns a yml string containing the id of the pristine role" do
28
28
  role_id = 100
29
29
  pristine_role = PristineRole.new(:role_id => role_id, :role_type => PristineRole.ROLE_TYPES[:generic], :name => "name is irrelevant")
30
30
 
31
- pristine_role.to_yml_fixture.should match(/id: #{role_id}/)
31
+ expect(pristine_role.to_yml_fixture).to match(/id: #{role_id}/)
32
32
  end
33
33
 
34
- it "should return a yml string containing the name of the pristine role" do
34
+ it "returns a yml string containing the name of the pristine role" do
35
35
  name = "Administrator"
36
36
  pristine_role = PristineRole.new(:role_id => 0, :role_type => PristineRole.ROLE_TYPES[:generic], :name => name)
37
- pristine_role.to_yml_fixture.should match(/name: #{name}/)
37
+
38
+ expect(pristine_role.to_yml_fixture).to match(/name: #{name}/)
38
39
  end
39
40
 
40
- it "should return a yml string containing created_at and updated_at" do
41
+ it "returns a yml string containing created_at and updated_at" do
41
42
  pristine_role = PristineRole.new(:role_id => 0, :role_type => PristineRole.ROLE_TYPES[:generic], :name => "name is irrelevant")
42
43
 
43
- pristine_role.to_yml_fixture.should match(/created_at:.+updated_at:/m)
44
+ expect(pristine_role.to_yml_fixture).to match(/created_at:.+updated_at:/m)
44
45
  end
45
46
  end
46
47
 
47
48
  describe "admin role" do
48
- it "should return a role with the admin role_type" do
49
+ it "returns a role with the admin role_type" do
49
50
  admin_role = PristineRole.admin_role
50
51
 
51
- admin_role.role_type.should == PristineRole.ROLE_TYPES[:admin]
52
+ expect(admin_role.role_type).to eq(PristineRole.ROLE_TYPES[:admin])
52
53
  end
53
54
 
54
- it "should return a new admin role if the role does not exist in the database" do
55
+ it "returns a new admin role if the role does not exist in the database" do
55
56
  admin_role = PristineRole.admin_role
56
57
 
57
- admin_role.id.should be_nil
58
+ expect(admin_role.id).to be_nil
58
59
  end
59
60
 
60
- it "should return an existing admin role if possible" do
61
+ it "returns an existing admin role if possible" do
61
62
  existing_admin_role = PristineRole.create(:role_id => 0, :role_type => PristineRole.ROLE_TYPES[:admin], :name => "administrator")
62
-
63
63
  admin_role = PristineRole.admin_role
64
64
 
65
- admin_role.should == existing_admin_role
65
+ expect(admin_role).to eq(existing_admin_role)
66
66
  end
67
67
 
68
- it "should not return an existing admin role if database should not be used" do
68
+ it "does not return an existing admin role if database should not be used" do
69
69
  existing_admin_role = PristineRole.create(:role_id => 0, :role_type => PristineRole.ROLE_TYPES[:admin], :name => "administrator")
70
-
71
70
  admin_role = PristineRole.admin_role(false)
72
71
 
73
- admin_role.should_not == existing_admin_role
74
- admin_role.id.should be_nil
72
+ expect(admin_role).not_to eq(existing_admin_role)
73
+ expect(admin_role.id).to be_nil
75
74
  end
76
75
  end
77
76
  end
@@ -5,7 +5,8 @@ module Dating
5
5
  def take_to_dinner; end
6
6
  def bring_home; end
7
7
 
8
- private
9
- attr_accessor :current_user
8
+ def authorize
9
+ authorization_check(params[:controller], params[:action], request.request_method.downcase, self)
10
+ end
10
11
  end
11
12
  end
data/tasks/cbac.rake CHANGED
@@ -16,7 +16,7 @@
16
16
 
17
17
  # Get a privilege set that fulfills the provided conditions
18
18
  def get_privilege_set(conditions)
19
- Cbac::PrivilegeSetRecord.first(:conditions => conditions)
19
+ Cbac::PrivilegeSetRecord.where(conditions).first
20
20
  end
21
21
 
22
22
  # Get a Hash containing all entries from the provided table
data/test/test_helper.rb CHANGED
@@ -14,7 +14,7 @@ ActiveRecord::Base.establish_connection(
14
14
  )
15
15
  fixture_files = Dir.glob(File.join(File.dirname(__FILE__), "fixtures", "*.yml"))
16
16
  fixture_files.each do |filename|
17
- Fixtures.create_fixtures('test/fixtures', File.basename(filename, ".*"))
17
+ ActiveRecord::FixtureSet.create_fixtures('test/fixtures', File.basename(filename, ".*"))
18
18
  end
19
19
  RAILS_ROOT ||= "."
20
20
 
metadata CHANGED
@@ -1,133 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cbac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.10
5
- prerelease:
4
+ version: 0.7.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Bert Meerman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-09 00:00:00.000000000 Z
11
+ date: 2016-08-15 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rails
14
+ name: database_cleaner
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '3.0'
22
- type: :runtime
19
+ version: '1.5'
20
+ type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '3.0'
26
+ version: '1.5'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec-rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '3'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: sqlite3
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: '1.3'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: '1.3'
62
55
  - !ruby/object:Gem::Dependency
63
- name: database_cleaner
56
+ name: echoe
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
61
+ version: '4'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rails
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.2'
76
+ type: :runtime
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
79
  requirements:
75
- - - ! '>='
80
+ - - "~>"
76
81
  - !ruby/object:Gem::Version
77
- version: '0'
82
+ version: '4.2'
78
83
  description: Simple authorization system for Rails applications. Allows you to develop
79
84
  applications with a mixed role based authorization and a context based authorization
80
85
  model. Does not supply authentication.
81
86
  email: bertm@rubyforge.org
82
87
  executables: []
83
88
  extensions: []
84
- extra_rdoc_files:
85
- - README.rdoc
86
- - lib/cbac.rb
87
- - lib/cbac/cbac_pristine/pristine.rb
88
- - lib/cbac/cbac_pristine/pristine_file.rb
89
- - lib/cbac/cbac_pristine/pristine_permission.rb
90
- - lib/cbac/cbac_pristine/pristine_role.rb
91
- - lib/cbac/config.rb
92
- - lib/cbac/context_role.rb
93
- - lib/cbac/generic_role.rb
94
- - lib/cbac/known_permission.rb
95
- - lib/cbac/membership.rb
96
- - lib/cbac/permission.rb
97
- - lib/cbac/privilege.rb
98
- - lib/cbac/privilege_new_api.rb
99
- - lib/cbac/privilege_set.rb
100
- - lib/cbac/privilege_set_record.rb
101
- - lib/cbac/setup.rb
102
- - lib/cbac/version.rb
103
- - lib/generators/cbac/USAGE
104
- - lib/generators/cbac/cbac_generator.rb
105
- - lib/generators/cbac/copy_files/config/cbac.pristine
106
- - lib/generators/cbac/copy_files/config/context_roles.rb
107
- - lib/generators/cbac/copy_files/config/privileges.rb
108
- - lib/generators/cbac/copy_files/controllers/generic_roles_controller.rb
109
- - lib/generators/cbac/copy_files/controllers/memberships_controller.rb
110
- - lib/generators/cbac/copy_files/controllers/permissions_controller.rb
111
- - lib/generators/cbac/copy_files/controllers/upgrade_controller.rb
112
- - lib/generators/cbac/copy_files/fixtures/cbac_generic_roles.yml
113
- - lib/generators/cbac/copy_files/fixtures/cbac_memberships.yml
114
- - lib/generators/cbac/copy_files/fixtures/cbac_permissions.yml
115
- - lib/generators/cbac/copy_files/initializers/cbac_config.rb
116
- - lib/generators/cbac/copy_files/migrate/create_cbac_from_scratch.rb
117
- - lib/generators/cbac/copy_files/stylesheets/cbac.css
118
- - lib/generators/cbac/copy_files/tasks/cbac.rake
119
- - lib/generators/cbac/copy_files/views/generic_roles/index.html.erb
120
- - lib/generators/cbac/copy_files/views/layouts/cbac.html.erb
121
- - lib/generators/cbac/copy_files/views/memberships/_update.html.erb
122
- - lib/generators/cbac/copy_files/views/memberships/index.html.erb
123
- - lib/generators/cbac/copy_files/views/permissions/_update_context_role.html.erb
124
- - lib/generators/cbac/copy_files/views/permissions/_update_generic_role.html.erb
125
- - lib/generators/cbac/copy_files/views/permissions/index.html.erb
126
- - lib/generators/cbac/copy_files/views/upgrade/index.html.erb
127
- - tasks/cbac.rake
89
+ extra_rdoc_files: []
128
90
  files:
91
+ - ".gitignore"
92
+ - ".rspec"
129
93
  - Gemfile
130
- - Gemfile.lock
94
+ - Manifest
131
95
  - README.rdoc
132
96
  - Rakefile
133
97
  - cbac.gemspec
@@ -199,41 +163,40 @@ files:
199
163
  - test/test_cbac_privilege.rb
200
164
  - test/test_cbac_privilege_set.rb
201
165
  - test/test_helper.rb
202
- - Manifest
203
166
  homepage: http://cbac.rubyforge.org
204
- licenses: []
167
+ licenses:
168
+ - MIT
169
+ metadata: {}
205
170
  post_install_message:
206
171
  rdoc_options:
207
- - --line-numbers
208
- - --inline-source
209
- - --title
172
+ - "--line-numbers"
173
+ - "--inline-source"
174
+ - "--title"
210
175
  - Cbac
211
- - --main
176
+ - "--main"
212
177
  - README.rdoc
213
178
  require_paths:
214
179
  - lib
215
180
  required_ruby_version: !ruby/object:Gem::Requirement
216
- none: false
217
181
  requirements:
218
- - - ! '>='
182
+ - - ">="
219
183
  - !ruby/object:Gem::Version
220
- version: '0'
184
+ version: 1.9.3
221
185
  required_rubygems_version: !ruby/object:Gem::Requirement
222
- none: false
223
186
  requirements:
224
- - - ! '>='
187
+ - - ">="
225
188
  - !ruby/object:Gem::Version
226
- version: '1.2'
189
+ version: 1.8.11
227
190
  requirements: []
228
191
  rubyforge_project: cbac
229
- rubygems_version: 1.8.24
192
+ rubygems_version: 2.4.8
230
193
  signing_key:
231
- specification_version: 3
194
+ specification_version: 4
232
195
  summary: CBAC - Simple authorization system for Rails applications.
233
196
  test_files:
234
- - test/test_cbac_privilege.rb
235
- - test/test_cbac_context_role.rb
236
- - test/test_helper.rb
237
197
  - test/test_cbac_actions.rb
238
- - test/test_cbac_privilege_set.rb
239
198
  - test/test_cbac_authorize_generic_roles.rb
199
+ - test/test_cbac_context_role.rb
200
+ - test/test_cbac_privilege.rb
201
+ - test/test_cbac_privilege_set.rb
202
+ - test/test_helper.rb
data/Gemfile.lock DELETED
@@ -1,121 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- cbac (0.6.5)
5
- rails (>= 3.0)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- actionmailer (3.2.10)
11
- actionpack (= 3.2.10)
12
- mail (~> 2.4.4)
13
- actionpack (3.2.10)
14
- activemodel (= 3.2.10)
15
- activesupport (= 3.2.10)
16
- builder (~> 3.0.0)
17
- erubis (~> 2.7.0)
18
- journey (~> 1.0.4)
19
- rack (~> 1.4.0)
20
- rack-cache (~> 1.2)
21
- rack-test (~> 0.6.1)
22
- sprockets (~> 2.2.1)
23
- activemodel (3.2.10)
24
- activesupport (= 3.2.10)
25
- builder (~> 3.0.0)
26
- activerecord (3.2.10)
27
- activemodel (= 3.2.10)
28
- activesupport (= 3.2.10)
29
- arel (~> 3.0.2)
30
- tzinfo (~> 0.3.29)
31
- activeresource (3.2.10)
32
- activemodel (= 3.2.10)
33
- activesupport (= 3.2.10)
34
- activesupport (3.2.10)
35
- i18n (~> 0.6)
36
- multi_json (~> 1.0)
37
- allison (2.0.3)
38
- arel (3.0.2)
39
- builder (3.0.4)
40
- database_cleaner (0.9.1)
41
- diff-lcs (1.1.3)
42
- echoe (4.6.3)
43
- allison (>= 2.0.3)
44
- gemcutter (>= 0.7.0)
45
- rake (>= 0.9.2)
46
- rdoc (>= 3.6.1)
47
- rubyforge (>= 2.0.4)
48
- erubis (2.7.0)
49
- gemcutter (0.7.1)
50
- hike (1.2.1)
51
- i18n (0.6.1)
52
- journey (1.0.4)
53
- json (1.7.5)
54
- json_pure (1.7.5)
55
- mail (2.4.4)
56
- i18n (>= 0.4.0)
57
- mime-types (~> 1.16)
58
- treetop (~> 1.4.8)
59
- mime-types (1.19)
60
- multi_json (1.5.0)
61
- polyglot (0.3.3)
62
- rack (1.4.3)
63
- rack-cache (1.2)
64
- rack (>= 0.4)
65
- rack-ssl (1.3.2)
66
- rack
67
- rack-test (0.6.2)
68
- rack (>= 1.0)
69
- rails (3.2.10)
70
- actionmailer (= 3.2.10)
71
- actionpack (= 3.2.10)
72
- activerecord (= 3.2.10)
73
- activeresource (= 3.2.10)
74
- activesupport (= 3.2.10)
75
- bundler (~> 1.0)
76
- railties (= 3.2.10)
77
- railties (3.2.10)
78
- actionpack (= 3.2.10)
79
- activesupport (= 3.2.10)
80
- rack-ssl (~> 1.3.2)
81
- rake (>= 0.8.7)
82
- rdoc (~> 3.4)
83
- thor (>= 0.14.6, < 2.0)
84
- rake (0.9.2.2)
85
- rdoc (3.12)
86
- json (~> 1.4)
87
- rspec-core (2.12.2)
88
- rspec-expectations (2.12.1)
89
- diff-lcs (~> 1.1.3)
90
- rspec-mocks (2.12.1)
91
- rspec-rails (2.12.1)
92
- actionpack (>= 3.0)
93
- activesupport (>= 3.0)
94
- railties (>= 3.0)
95
- rspec-core (~> 2.12.0)
96
- rspec-expectations (~> 2.12.0)
97
- rspec-mocks (~> 2.12.0)
98
- rubyforge (2.0.4)
99
- json_pure (>= 1.1.7)
100
- sprockets (2.2.2)
101
- hike (~> 1.2)
102
- multi_json (~> 1.0)
103
- rack (~> 1.0)
104
- tilt (~> 1.1, != 1.3.0)
105
- sqlite3 (1.3.6)
106
- thor (0.16.0)
107
- tilt (1.3.3)
108
- treetop (1.4.12)
109
- polyglot
110
- polyglot (>= 0.3.1)
111
- tzinfo (0.3.35)
112
-
113
- PLATFORMS
114
- ruby
115
-
116
- DEPENDENCIES
117
- cbac!
118
- database_cleaner
119
- echoe
120
- rspec-rails
121
- sqlite3