canard 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/test/schema.rb ADDED
@@ -0,0 +1,12 @@
1
+ ActiveRecord::Schema.define :version => 0 do
2
+
3
+ create_table :users, :force => true do |t|
4
+ t.string :roles_mask
5
+ end
6
+ create_table :user_without_roles, :force => true do |t|
7
+ t.string :roles_mask
8
+ end
9
+ create_table :user_without_role_masks, :force => true do |t|
10
+ end
11
+
12
+ end
@@ -0,0 +1,22 @@
1
+ module MiniTest
2
+ class Unit
3
+ class TestCase
4
+
5
+ def teardown
6
+ Object.send(:remove_const, 'Canard') if Object.const_defined?('Canard')
7
+ GC.start
8
+ end
9
+
10
+ def setup
11
+ [ 'canard/abilities.rb',
12
+ 'canard/user_model.rb',
13
+ "canard/find_abilities.rb"
14
+ ].each do |file|
15
+ file_path = File.join(File.expand_path('../../../lib', __FILE__), file)
16
+ load file_path
17
+ end
18
+ end
19
+ end
20
+
21
+ end
22
+ end
data/test/test_helper.rb CHANGED
@@ -1,87 +1,18 @@
1
1
  require 'rubygems'
2
- gem 'minitest'
3
- require 'active_record'
2
+ gem 'minitest'
4
3
  require 'minitest/autorun'
5
- require 'pathname'
6
4
 
7
- module Rails
8
-
9
- module VERSION
10
- MAJOR = 0
11
- end
12
-
13
- def self.root
14
- Pathname.new(File.expand_path('..', __FILE__))
15
- end
16
- end
5
+ # Configure Rails Environment
6
+ ENV["RAILS_ENV"] = "test"
17
7
 
18
- module MiniTestWithHooks
19
- class Unit < MiniTest::Unit
20
- def before_suites
21
- end
8
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
9
+ require "rails/test_help"
22
10
 
23
- def after_suites
24
- end
11
+ Rails.backtrace_cleaner.remove_silencers!
25
12
 
26
- def _run_suites(suites, type)
27
- begin
28
- before_suites
29
- super(suites, type)
30
- ensure
31
- after_suites
32
- end
33
- end
34
- end
35
- end
13
+ # Load support files (reloadable reloads canard)
14
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
36
15
 
37
- module MiniTestWithActiveRecord
38
- class Unit < MiniTestWithHooks::Unit
39
-
40
- def before_suites
41
- super
42
- ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
43
- ActiveRecord::Migration.verbose = false
44
-
45
- @migration = Class.new(ActiveRecord::Migration) do
46
-
47
- def change
48
- create_table :users, :force => true do |t|
49
- t.string :roles_mask
50
- end
51
- create_table :user_without_roles, :force => true do |t|
52
- t.string :roles_mask
53
- end
54
- create_table :user_without_role_masks, :force => true do |t|
55
- end
56
- end
57
-
58
- end
59
-
60
- @migration.new.migrate(:up)
61
- end
62
-
63
- def after_suites
64
- @migration.new.migrate(:down)
65
- super
66
- end
67
- end
68
- end
69
-
70
- MiniTestWithActiveRecord::Unit::TestCase.add_teardown_hook do
71
- Object.send(:remove_const, 'Canard') if Object.const_defined?('Canard')
72
- GC.start
73
- end
74
-
75
- MiniTestWithActiveRecord::Unit::TestCase.add_setup_hook do
76
- [ 'canard/abilities.rb',
77
- 'canard/user_model.rb',
78
- "canard/find_abilities.rb"
79
- ].each do |file|
80
- file_path = File.join(File.expand_path('../../lib', __FILE__), file)
81
- load file_path
82
- end
83
-
84
- end
85
-
86
- MiniTest::Unit.runner = MiniTestWithActiveRecord::Unit.new
16
+ ActiveRecord::Migration.verbose = false
17
+ load(File.dirname(__FILE__) + '/schema.rb')
87
18
 
@@ -5,9 +5,6 @@ describe Canard::UserModel do
5
5
 
6
6
  before do
7
7
  Canard.abilities_path = 'abilities'
8
- require 'models/user'
9
- require 'models/user_without_role'
10
- require 'models/user_without_role_mask'
11
8
  end
12
9
 
13
10
  # Sanity test
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-26 00:00:00.000000000Z
12
+ date: 2012-04-10 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: minitest
16
- requirement: &2156040520 !ruby/object:Gem::Requirement
16
+ requirement: &2152360020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2156040520
24
+ version_requirements: *2152360020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: sqlite3
27
- requirement: &2156040060 !ruby/object:Gem::Requirement
27
+ requirement: &2152359280 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,21 +32,21 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2156040060
35
+ version_requirements: *2152359280
36
36
  - !ruby/object:Gem::Dependency
37
- name: activerecord
38
- requirement: &2156039580 !ruby/object:Gem::Requirement
37
+ name: rails
38
+ requirement: &2152358360 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ! '>='
41
+ - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: '0'
43
+ version: 3.2.3
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2156039580
46
+ version_requirements: *2152358360
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: activesupport
49
- requirement: &2156038960 !ruby/object:Gem::Requirement
49
+ requirement: &2152357560 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2156038960
57
+ version_requirements: *2152357560
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: cancan
60
- requirement: &2156038380 !ruby/object:Gem::Requirement
60
+ requirement: &2152356620 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *2156038380
68
+ version_requirements: *2152356620
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: role_model
71
- requirement: &2156037880 !ruby/object:Gem::Requirement
71
+ requirement: &2152355660 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *2156037880
79
+ version_requirements: *2152355660
80
80
  description: Wraps CanCan and RoleModel up to make role based authorisation really
81
81
  easy in Rails 3.x.
82
82
  email:
@@ -107,12 +107,31 @@ files:
107
107
  - lib/generators/rspec/ability/templates/abilities_spec.rb.erb
108
108
  - test/abilities/admins.rb
109
109
  - test/abilities_test.rb
110
- - test/app/abilities/moderators.rb
111
110
  - test/canard_test.rb
111
+ - test/dummy/Rakefile
112
+ - test/dummy/app/abilities/moderators.rb
113
+ - test/dummy/app/controllers/application_controller.rb
114
+ - test/dummy/app/models/user.rb
115
+ - test/dummy/app/models/user_without_role.rb
116
+ - test/dummy/app/models/user_without_role_mask.rb
117
+ - test/dummy/config.ru
118
+ - test/dummy/config/application.rb
119
+ - test/dummy/config/boot.rb
120
+ - test/dummy/config/database.yml
121
+ - test/dummy/config/environment.rb
122
+ - test/dummy/config/environments/development.rb
123
+ - test/dummy/config/environments/test.rb
124
+ - test/dummy/config/initializers/secret_token.rb
125
+ - test/dummy/config/initializers/session_store.rb
126
+ - test/dummy/config/initializers/wrap_parameters.rb
127
+ - test/dummy/config/locales/en.yml
128
+ - test/dummy/config/routes.rb
129
+ - test/dummy/db/test.sqlite3
130
+ - test/dummy/log/.gitkeep
131
+ - test/dummy/log/test.log
112
132
  - test/find_abilities_test.rb
113
- - test/models/user.rb
114
- - test/models/user_without_role.rb
115
- - test/models/user_without_role_mask.rb
133
+ - test/schema.rb
134
+ - test/support/reloadable.rb
116
135
  - test/test_helper.rb
117
136
  - test/user_model_test.rb
118
137
  homepage: https://github.com/james2m/canard
@@ -142,11 +161,30 @@ summary: Adds role based authorisation to Rails by combining RoleModel and CanCa
142
161
  test_files:
143
162
  - test/abilities/admins.rb
144
163
  - test/abilities_test.rb
145
- - test/app/abilities/moderators.rb
146
164
  - test/canard_test.rb
165
+ - test/dummy/Rakefile
166
+ - test/dummy/app/abilities/moderators.rb
167
+ - test/dummy/app/controllers/application_controller.rb
168
+ - test/dummy/app/models/user.rb
169
+ - test/dummy/app/models/user_without_role.rb
170
+ - test/dummy/app/models/user_without_role_mask.rb
171
+ - test/dummy/config.ru
172
+ - test/dummy/config/application.rb
173
+ - test/dummy/config/boot.rb
174
+ - test/dummy/config/database.yml
175
+ - test/dummy/config/environment.rb
176
+ - test/dummy/config/environments/development.rb
177
+ - test/dummy/config/environments/test.rb
178
+ - test/dummy/config/initializers/secret_token.rb
179
+ - test/dummy/config/initializers/session_store.rb
180
+ - test/dummy/config/initializers/wrap_parameters.rb
181
+ - test/dummy/config/locales/en.yml
182
+ - test/dummy/config/routes.rb
183
+ - test/dummy/db/test.sqlite3
184
+ - test/dummy/log/.gitkeep
185
+ - test/dummy/log/test.log
147
186
  - test/find_abilities_test.rb
148
- - test/models/user.rb
149
- - test/models/user_without_role.rb
150
- - test/models/user_without_role_mask.rb
187
+ - test/schema.rb
188
+ - test/support/reloadable.rb
151
189
  - test/test_helper.rb
152
190
  - test/user_model_test.rb