attribute_ext 1.3.0 → 1.4.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.
- data/.gitignore +4 -0
- data/README.md +7 -3
- data/attribute_ext.gemspec +5 -1
- data/lib/attribute_ext/hidden_attributes.rb +3 -2
- data/lib/attribute_ext/safe_attributes.rb +24 -9
- data/lib/attribute_ext.rb +6 -1
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.gitkeep +0 -0
- data/spec/{support/stub.rb → dummy/app/models/user.rb} +19 -14
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config/application.rb +62 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20120306121700_create_users.rb +26 -0
- data/spec/dummy/lib/assets/.gitkeep +0 -0
- data/spec/dummy/log/.gitkeep +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/hidden_attributes_spec.rb +61 -11
- data/spec/safe_attributes_spec.rb +67 -34
- data/spec/spec_helper.rb +10 -4
- data/spec/support/in_memory_database.rb +11 -0
- metadata +88 -42
- data/spec/support/fake_environment.rb +0 -29
@@ -0,0 +1,58 @@
|
|
1
|
+
Dummy::Application.routes.draw do
|
2
|
+
# The priority is based upon order of creation:
|
3
|
+
# first created -> highest priority.
|
4
|
+
|
5
|
+
# Sample of regular route:
|
6
|
+
# match 'products/:id' => 'catalog#view'
|
7
|
+
# Keep in mind you can assign values other than :controller and :action
|
8
|
+
|
9
|
+
# Sample of named route:
|
10
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
11
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
12
|
+
|
13
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
14
|
+
# resources :products
|
15
|
+
|
16
|
+
# Sample resource route with options:
|
17
|
+
# resources :products do
|
18
|
+
# member do
|
19
|
+
# get 'short'
|
20
|
+
# post 'toggle'
|
21
|
+
# end
|
22
|
+
#
|
23
|
+
# collection do
|
24
|
+
# get 'sold'
|
25
|
+
# end
|
26
|
+
# end
|
27
|
+
|
28
|
+
# Sample resource route with sub-resources:
|
29
|
+
# resources :products do
|
30
|
+
# resources :comments, :sales
|
31
|
+
# resource :seller
|
32
|
+
# end
|
33
|
+
|
34
|
+
# Sample resource route with more complex sub-resources
|
35
|
+
# resources :products do
|
36
|
+
# resources :comments
|
37
|
+
# resources :sales do
|
38
|
+
# get 'recent', :on => :collection
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
|
42
|
+
# Sample resource route within a namespace:
|
43
|
+
# namespace :admin do
|
44
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
45
|
+
# # (app/controllers/admin/products_controller.rb)
|
46
|
+
# resources :products
|
47
|
+
# end
|
48
|
+
|
49
|
+
# You can have the root of your site routed with "root"
|
50
|
+
# just remember to delete public/index.html.
|
51
|
+
# root :to => 'welcome#index'
|
52
|
+
|
53
|
+
# See how all your routes lay out with "rake routes"
|
54
|
+
|
55
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
56
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
57
|
+
# match ':controller(/:action(/:id))(.:format)'
|
58
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class CreateUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :users do |t|
|
4
|
+
t.string :opts
|
5
|
+
|
6
|
+
t.string :attribute_hash
|
7
|
+
t.string :attribute_if
|
8
|
+
t.string :attribute_if_hash
|
9
|
+
t.string :attribute_unless
|
10
|
+
t.string :attribute_unless_hash
|
11
|
+
t.string :attribute_if_unless
|
12
|
+
t.string :attribute_if_format
|
13
|
+
t.string :attribute_unless_format
|
14
|
+
t.string :attribute_if_opts
|
15
|
+
t.string :attribute_unless_opts
|
16
|
+
t.string :attribute_only_xml
|
17
|
+
t.string :attribute_only_json
|
18
|
+
t.string :attribute_only_hash
|
19
|
+
t.string :attribute_except_xml
|
20
|
+
t.string :attribute_except_json
|
21
|
+
t.string :attribute_except_hash
|
22
|
+
t.string :attribute_only_xml_txt
|
23
|
+
t.string :attribute_except_xml_txt
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/404.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
23
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/422.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>The change you wanted was rejected.</h1>
|
23
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style type="text/css">
|
6
|
+
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
|
7
|
+
div.dialog {
|
8
|
+
width: 25em;
|
9
|
+
padding: 0 4em;
|
10
|
+
margin: 4em auto 0 auto;
|
11
|
+
border: 1px solid #ccc;
|
12
|
+
border-right-color: #999;
|
13
|
+
border-bottom-color: #999;
|
14
|
+
}
|
15
|
+
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
|
16
|
+
</style>
|
17
|
+
</head>
|
18
|
+
|
19
|
+
<body>
|
20
|
+
<!-- This file lives in public/500.html -->
|
21
|
+
<div class="dialog">
|
22
|
+
<h1>We're sorry, but something went wrong.</h1>
|
23
|
+
</div>
|
24
|
+
</body>
|
25
|
+
</html>
|
File without changes
|
@@ -0,0 +1,6 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
@@ -13,7 +13,7 @@ describe AttributeExt::HiddenAttributes do
|
|
13
13
|
user = User.new
|
14
14
|
user.hidden_attribute_names(:format).should_not include('attribute_if')
|
15
15
|
|
16
|
-
user = User.new :if => true
|
16
|
+
user = User.new :opts => { :if => true }
|
17
17
|
user.hidden_attribute_names(:format).should include('attribute_if')
|
18
18
|
end
|
19
19
|
|
@@ -21,7 +21,7 @@ describe AttributeExt::HiddenAttributes do
|
|
21
21
|
user = User.new
|
22
22
|
user.hidden_attribute_names(:format).should_not include('attribute_unless')
|
23
23
|
|
24
|
-
user = User.new :unless => false
|
24
|
+
user = User.new :opts => { :unless => false }
|
25
25
|
user.hidden_attribute_names(:format).should include('attribute_unless')
|
26
26
|
end
|
27
27
|
|
@@ -29,13 +29,13 @@ describe AttributeExt::HiddenAttributes do
|
|
29
29
|
user = User.new
|
30
30
|
user.hidden_attribute_names(:format).should_not include('attribute_if_unless')
|
31
31
|
|
32
|
-
user = User.new :if => true
|
32
|
+
user = User.new :opts => { :if => true }
|
33
33
|
user.hidden_attribute_names(:format).should_not include('attribute_if_unless')
|
34
34
|
|
35
|
-
user = User.new :unless => false
|
35
|
+
user = User.new :opts => { :unless => false }
|
36
36
|
user.hidden_attribute_names(:format).should_not include('attribute_if_unless')
|
37
37
|
|
38
|
-
user = User.new :unless => false, :if => true
|
38
|
+
user = User.new :opts => { :unless => false, :if => true }
|
39
39
|
user.hidden_attribute_names(:format).should include('attribute_if_unless')
|
40
40
|
end
|
41
41
|
|
@@ -70,13 +70,13 @@ describe AttributeExt::HiddenAttributes do
|
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'only applies rules to hash if wanted (if condition)' do
|
73
|
-
user = User.new :if => true
|
73
|
+
user = User.new :opts => { :if => true }
|
74
74
|
user.hidden_attribute_names(:hash).should_not include('attribute_if')
|
75
75
|
user.hidden_attribute_names(:hash).should include('attribute_if_hash')
|
76
76
|
end
|
77
77
|
|
78
78
|
it 'only applies rules to hash if wanted (unless condition)' do
|
79
|
-
user = User.new :unless => false
|
79
|
+
user = User.new :opts => { :unless => false }
|
80
80
|
user.hidden_attribute_names(:hash).should_not include('attribute_unless')
|
81
81
|
user.hidden_attribute_names(:hash).should include('attribute_unless_hash')
|
82
82
|
end
|
@@ -131,21 +131,71 @@ describe AttributeExt::HiddenAttributes do
|
|
131
131
|
|
132
132
|
it 'supports json export' do
|
133
133
|
user = User.new
|
134
|
-
user.
|
134
|
+
user.to_json.should == {
|
135
|
+
"attribute_except_json" => nil,
|
136
|
+
"attribute_if" => nil,
|
137
|
+
"attribute_if_format" => nil,
|
138
|
+
"attribute_if_hash" => nil,
|
139
|
+
"attribute_if_opts" => nil,
|
140
|
+
"attribute_if_unless" => nil,
|
141
|
+
"attribute_only_hash" => nil,
|
142
|
+
"attribute_only_xml" => nil,
|
143
|
+
"attribute_only_xml_txt" => nil,
|
144
|
+
"attribute_unless" => nil,
|
145
|
+
"attribute_unless_hash" => nil
|
146
|
+
}.to_json
|
135
147
|
end
|
136
148
|
|
137
149
|
it 'supports deep json export via serializable hash (depends on rails)' do
|
138
150
|
user = User.new
|
139
|
-
user.
|
151
|
+
user.as_json.should == {
|
152
|
+
"attribute_except_json" => nil,
|
153
|
+
"attribute_if" => nil,
|
154
|
+
"attribute_if_format" => nil,
|
155
|
+
"attribute_if_hash" => nil,
|
156
|
+
"attribute_if_opts" => nil,
|
157
|
+
"attribute_if_unless" => nil,
|
158
|
+
"attribute_only_hash" => nil,
|
159
|
+
"attribute_only_xml" => nil,
|
160
|
+
"attribute_only_xml_txt" => nil,
|
161
|
+
"attribute_unless" => nil,
|
162
|
+
"attribute_unless_hash" => nil
|
163
|
+
}
|
140
164
|
end
|
141
165
|
|
142
166
|
it 'supports xml export' do
|
143
167
|
user = User.new
|
144
|
-
user.
|
168
|
+
user.to_xml.should == {
|
169
|
+
"attribute_except_xml" => nil,
|
170
|
+
"attribute_except_xml_txt" => nil,
|
171
|
+
"attribute_if" => nil,
|
172
|
+
"attribute_if_format" => nil,
|
173
|
+
"attribute_if_hash" => nil,
|
174
|
+
"attribute_if_opts" => nil,
|
175
|
+
"attribute_if_unless" => nil,
|
176
|
+
"attribute_only_hash" => nil,
|
177
|
+
"attribute_only_json" => nil,
|
178
|
+
"attribute_unless" => nil,
|
179
|
+
"attribute_unless_hash" => nil
|
180
|
+
}.to_xml(:root => :user)
|
145
181
|
end
|
146
182
|
|
147
183
|
it 'supports hash export' do
|
148
184
|
user = User.new
|
149
|
-
user.
|
185
|
+
user.serializable_hash.should == {
|
186
|
+
"attribute_except_hash" => nil,
|
187
|
+
"attribute_if" => nil,
|
188
|
+
"attribute_if_format" => nil,
|
189
|
+
"attribute_if_hash" => nil,
|
190
|
+
"attribute_if_opts" => nil,
|
191
|
+
"attribute_if_unless" => nil,
|
192
|
+
"attribute_only_json" => nil,
|
193
|
+
"attribute_only_xml" => nil,
|
194
|
+
"attribute_only_xml_txt" => nil,
|
195
|
+
"attribute_unless" => nil,
|
196
|
+
"attribute_unless_format" => nil,
|
197
|
+
"attribute_unless_opts" => nil,
|
198
|
+
"attribute_unless_hash" => nil,
|
199
|
+
}
|
150
200
|
end
|
151
201
|
end
|
@@ -1,72 +1,105 @@
|
|
1
1
|
|
2
2
|
require File.dirname(__FILE__) + '/spec_helper'
|
3
3
|
|
4
|
-
describe AttributeExt::
|
4
|
+
describe AttributeExt::SafeAttributes do
|
5
5
|
|
6
6
|
it 'uses mass assignment authorizer' do
|
7
7
|
user = User.new
|
8
8
|
|
9
|
-
user.
|
9
|
+
user.safe_attributes_authorizer.should include('always')
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should support attr_accessible' do
|
13
|
+
user = User.new
|
14
|
+
user.safe_attributes_authorizer.should include('opts')
|
10
15
|
end
|
11
16
|
|
12
17
|
it 'uses mass assignment authorizer with role' do
|
13
18
|
user = User.new
|
14
19
|
|
15
|
-
user.
|
20
|
+
user.safe_attributes_authorizer(:admin).should include('admin_role')
|
16
21
|
end
|
17
22
|
|
18
23
|
it 'can whitelist attributes' do
|
19
24
|
user = User.new
|
20
25
|
|
21
|
-
user.
|
26
|
+
user.safe_attributes_authorizer.should include('always')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'can whitelist attributes using an if condition with proc' do
|
30
|
+
user = User.new
|
31
|
+
user.safe_attributes_authorizer.should_not include('attribute_if')
|
32
|
+
|
33
|
+
user = User.new :opts => { :if => true }
|
34
|
+
user.safe_attributes_authorizer.should include('attribute_if')
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'can whitelist attributes using an if condition with symbol' do
|
38
|
+
user = User.new
|
39
|
+
user.safe_attributes_authorizer.should_not include('attribute_if_2')
|
40
|
+
|
41
|
+
user = User.new :opts => { :if => true }
|
42
|
+
user.safe_attributes_authorizer.should include('attribute_if_2')
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'can whitelist attributes using an unless condition with proc' do
|
46
|
+
user = User.new
|
47
|
+
user.safe_attributes_authorizer.should_not include('attribute_unless')
|
48
|
+
|
49
|
+
user = User.new :opts => { :unless => false }
|
50
|
+
user.safe_attributes_authorizer.should include('attribute_unless')
|
22
51
|
end
|
23
52
|
|
24
|
-
it 'can whitelist attributes using an
|
53
|
+
it 'can whitelist attributes using an unless condition with symbol' do
|
25
54
|
user = User.new
|
26
|
-
user.
|
55
|
+
user.safe_attributes_authorizer.should_not include('attribute_unless_2')
|
27
56
|
|
28
|
-
user = User.new :
|
29
|
-
user.
|
57
|
+
user = User.new :opts => { :unless => false }
|
58
|
+
user.safe_attributes_authorizer.should include('attribute_unless_2')
|
30
59
|
end
|
31
60
|
|
32
|
-
it 'can whitelist attributes using an unless condition' do
|
61
|
+
it 'can whitelist attributes using an if and an unless condition with proc' do
|
33
62
|
user = User.new
|
34
|
-
user.
|
63
|
+
user.safe_attributes_authorizer.should_not include('attribute_if_unless')
|
64
|
+
user = User.new :opts => { :if => true }
|
65
|
+
user.safe_attributes_authorizer.should_not include('attribute_if_unless')
|
66
|
+
user = User.new :opts => { :unless => false }
|
67
|
+
user.safe_attributes_authorizer.should_not include('attribute_if_unless')
|
35
68
|
|
36
|
-
user = User.new :unless => false
|
37
|
-
user.
|
69
|
+
user = User.new :opts => { :if => true, :unless => false }
|
70
|
+
user.safe_attributes_authorizer.should include('attribute_if_unless')
|
38
71
|
end
|
39
72
|
|
40
|
-
it 'can whitelist attributes using an if and an unless condition' do
|
73
|
+
it 'can whitelist attributes using an if and an unless condition with symbol' do
|
41
74
|
user = User.new
|
42
|
-
user.
|
43
|
-
user = User.new :if => true
|
44
|
-
user.
|
45
|
-
user = User.new :unless => false
|
46
|
-
user.
|
75
|
+
user.safe_attributes_authorizer.should_not include('attribute_if_unless_2')
|
76
|
+
user = User.new :opts => { :if => true }
|
77
|
+
user.safe_attributes_authorizer.should_not include('attribute_if_unless_2')
|
78
|
+
user = User.new :opts => { :unless => false }
|
79
|
+
user.safe_attributes_authorizer.should_not include('attribute_if_unless_2')
|
47
80
|
|
48
|
-
user = User.new :if => true, :unless => false
|
49
|
-
user.
|
81
|
+
user = User.new :opts => { :if => true, :unless => false }
|
82
|
+
user.safe_attributes_authorizer.should include('attribute_if_unless_2')
|
50
83
|
end
|
51
84
|
|
52
85
|
it 'can whitelist attributes checking role in if condition' do
|
53
86
|
user = User.new
|
54
|
-
user.
|
87
|
+
user.safe_attributes_authorizer(:default).should_not include('attribute_if_admin')
|
55
88
|
user = User.new
|
56
|
-
user.
|
89
|
+
user.safe_attributes_authorizer(:admin).should include('attribute_if_admin')
|
57
90
|
end
|
58
91
|
|
59
92
|
it 'can whitelist attributes checking role in unless condition' do
|
60
93
|
user = User.new
|
61
|
-
user.
|
94
|
+
user.safe_attributes_authorizer(:default).should include('attribute_unless_admin')
|
62
95
|
user = User.new
|
63
|
-
user.
|
96
|
+
user.safe_attributes_authorizer(:admin).should_not include('attribute_unless_admin')
|
64
97
|
end
|
65
98
|
|
66
99
|
it 'can provide a global default role' do
|
67
100
|
AttributeExt::SafeAttributes.default_role = :new_default
|
68
101
|
AttributeExt::SafeAttributes.default_role.should == :new_default
|
69
|
-
User.new.
|
102
|
+
User.new.safe_attributes_authorizer.should include("new_default")
|
70
103
|
end
|
71
104
|
|
72
105
|
context '#role_mapper' do
|
@@ -106,17 +139,17 @@ describe AttributeExt::HiddenAttributes do
|
|
106
139
|
[:guest, :user, :admin].include?(role) ? role : :guest
|
107
140
|
end
|
108
141
|
|
109
|
-
User.new.
|
110
|
-
User.new.
|
111
|
-
User.new.
|
142
|
+
User.new.safe_attributes_authorizer.should include('role_mapper_guest')
|
143
|
+
User.new.safe_attributes_authorizer.should_not include('role_mapper_user')
|
144
|
+
User.new.safe_attributes_authorizer.should_not include('role_mapper_admin')
|
112
145
|
|
113
|
-
User.new.
|
114
|
-
User.new.
|
115
|
-
User.new.
|
146
|
+
User.new.safe_attributes_authorizer(:user).should_not include('role_mapper_guest')
|
147
|
+
User.new.safe_attributes_authorizer(:user).should include('role_mapper_user')
|
148
|
+
User.new.safe_attributes_authorizer(:user).should_not include('role_mapper_admin')
|
116
149
|
|
117
|
-
User.new.
|
118
|
-
User.new.
|
119
|
-
User.new.
|
150
|
+
User.new.safe_attributes_authorizer(:admin).should_not include('role_mapper_guest')
|
151
|
+
User.new.safe_attributes_authorizer(:admin).should_not include('role_mapper_user')
|
152
|
+
User.new.safe_attributes_authorizer(:admin).should include('role_mapper_admin')
|
120
153
|
end
|
121
154
|
end
|
122
155
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
|
2
|
-
|
3
|
-
require File.
|
4
|
-
require
|
2
|
+
ENV["RAILS_ENV"] ||= 'test'
|
3
|
+
require File.expand_path("../dummy/config/environment", __FILE__)
|
4
|
+
require 'rspec/rails'
|
5
|
+
require 'rspec/autorun'
|
6
|
+
|
7
|
+
Dir[File.expand_path("../support/**/*.rb", __FILE__)].each {|f| require f}
|
5
8
|
|
6
9
|
RSpec.configure do |config|
|
7
|
-
config.
|
10
|
+
config.use_transactional_fixtures = true
|
11
|
+
config.infer_base_class_for_anonymous_controllers = false
|
12
|
+
|
13
|
+
initialize_in_memory_database if in_memory_database?
|
8
14
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
def in_memory_database?
|
2
|
+
Rails.configuration.database_configuration[ENV["RAILS_ENV"]] and
|
3
|
+
Rails.configuration.database_configuration[ENV["RAILS_ENV"]]['adapter'] == 'sqlite3' and
|
4
|
+
Rails.configuration.database_configuration[ENV["RAILS_ENV"]]['database'] == ':memory:'
|
5
|
+
end
|
6
|
+
|
7
|
+
def initialize_in_memory_database
|
8
|
+
puts "Creating SQLite in memory database"
|
9
|
+
ActiveRecord::Schema.verbose = false
|
10
|
+
ActiveRecord::Migrator.up(Rails.root.join('db', 'migrate'))
|
11
|
+
end
|
metadata
CHANGED
@@ -1,33 +1,57 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: attribute_ext
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 3
|
9
|
-
- 0
|
10
|
-
version: 1.3.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jan Graichen
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
12
|
+
date: 2012-03-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rails
|
16
|
+
requirement: &5913160 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.2.2
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *5913160
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: sqlite3
|
27
|
+
requirement: &5912600 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *5912600
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec-rails
|
38
|
+
requirement: &5912020 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *5912020
|
21
47
|
description: AttributeExt provides additional access control for rails model attributes.
|
22
|
-
email:
|
48
|
+
email:
|
23
49
|
- jan.graichen@altimos.de
|
24
50
|
executables: []
|
25
|
-
|
26
51
|
extensions: []
|
27
|
-
|
28
52
|
extra_rdoc_files: []
|
29
|
-
|
30
|
-
|
53
|
+
files:
|
54
|
+
- .gitignore
|
31
55
|
- Gemfile
|
32
56
|
- LICENSE
|
33
57
|
- README.md
|
@@ -39,43 +63,65 @@ files:
|
|
39
63
|
- lib/attribute_ext/railtie.rb
|
40
64
|
- lib/attribute_ext/rspec.rb
|
41
65
|
- lib/attribute_ext/safe_attributes.rb
|
66
|
+
- spec/dummy/Rakefile
|
67
|
+
- spec/dummy/app/assets/javascripts/application.js
|
68
|
+
- spec/dummy/app/assets/stylesheets/application.css
|
69
|
+
- spec/dummy/app/controllers/application_controller.rb
|
70
|
+
- spec/dummy/app/helpers/application_helper.rb
|
71
|
+
- spec/dummy/app/mailers/.gitkeep
|
72
|
+
- spec/dummy/app/models/user.rb
|
73
|
+
- spec/dummy/app/views/layouts/application.html.erb
|
74
|
+
- spec/dummy/config.ru
|
75
|
+
- spec/dummy/config/application.rb
|
76
|
+
- spec/dummy/config/boot.rb
|
77
|
+
- spec/dummy/config/database.yml
|
78
|
+
- spec/dummy/config/environment.rb
|
79
|
+
- spec/dummy/config/environments/development.rb
|
80
|
+
- spec/dummy/config/environments/production.rb
|
81
|
+
- spec/dummy/config/environments/test.rb
|
82
|
+
- spec/dummy/config/initializers/backtrace_silencers.rb
|
83
|
+
- spec/dummy/config/initializers/inflections.rb
|
84
|
+
- spec/dummy/config/initializers/mime_types.rb
|
85
|
+
- spec/dummy/config/initializers/secret_token.rb
|
86
|
+
- spec/dummy/config/initializers/session_store.rb
|
87
|
+
- spec/dummy/config/initializers/wrap_parameters.rb
|
88
|
+
- spec/dummy/config/locales/en.yml
|
89
|
+
- spec/dummy/config/routes.rb
|
90
|
+
- spec/dummy/db/migrate/20120306121700_create_users.rb
|
91
|
+
- spec/dummy/lib/assets/.gitkeep
|
92
|
+
- spec/dummy/log/.gitkeep
|
93
|
+
- spec/dummy/log/development.log
|
94
|
+
- spec/dummy/public/404.html
|
95
|
+
- spec/dummy/public/422.html
|
96
|
+
- spec/dummy/public/500.html
|
97
|
+
- spec/dummy/public/favicon.ico
|
98
|
+
- spec/dummy/script/rails
|
42
99
|
- spec/hidden_attributes_spec.rb
|
43
100
|
- spec/safe_attributes_spec.rb
|
44
101
|
- spec/spec_helper.rb
|
45
|
-
- spec/support/
|
46
|
-
- spec/support/stub.rb
|
102
|
+
- spec/support/in_memory_database.rb
|
47
103
|
homepage: https://github.com/jgraichen/attribute_ext
|
48
104
|
licenses: []
|
49
|
-
|
50
105
|
post_install_message:
|
51
106
|
rdoc_options: []
|
52
|
-
|
53
|
-
require_paths:
|
107
|
+
require_paths:
|
54
108
|
- lib
|
55
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
110
|
none: false
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
|
62
|
-
- 0
|
63
|
-
version: "0"
|
64
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
116
|
none: false
|
66
|
-
requirements:
|
67
|
-
- -
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
|
70
|
-
segments:
|
71
|
-
- 0
|
72
|
-
version: "0"
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
73
121
|
requirements: []
|
74
|
-
|
75
122
|
rubyforge_project: attribute_ext
|
76
|
-
rubygems_version: 1.8.
|
123
|
+
rubygems_version: 1.8.15
|
77
124
|
signing_key:
|
78
125
|
specification_version: 3
|
79
126
|
summary: AttributeExt provides additional access control for rails model attributes.
|
80
127
|
test_files: []
|
81
|
-
|