authorized_rails_scaffolds 0.0.6 → 0.0.7
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/lib/authorized_rails_scaffolds.rb +5 -1
- data/lib/{generators/authorized_rails_scaffolds/install_scaffold/templates/initializer.rb → authorized_rails_scaffolds/helper.rb} +23 -13
- data/lib/authorized_rails_scaffolds/version.rb +1 -1
- data/lib/generators/authorized_rails_scaffolds/install_scaffold/install_scaffold_generator.rb +0 -4
- data/lib/generators/authorized_rails_scaffolds/install_scaffold/templates/controller.rb +6 -23
- data/lib/generators/authorized_rails_scaffolds/install_scaffold/templates/index.html.erb +4 -4
- data/lib/generators/authorized_rails_scaffolds/install_spec/templates/controller_spec.rb +20 -20
- data/lib/generators/authorized_rails_scaffolds/install_spec/templates/edit_spec.rb +1 -1
- data/lib/generators/authorized_rails_scaffolds/install_spec/templates/index_spec.rb +5 -5
- data/lib/generators/authorized_rails_scaffolds/install_spec/templates/new_spec.rb +1 -1
- data/lib/generators/authorized_rails_scaffolds/install_spec/templates/routing_spec.rb +3 -3
- data/lib/generators/authorized_rails_scaffolds/install_spec/templates/show_spec.rb +1 -1
- metadata +17 -24
- checksums.yaml +0 -7
@@ -1,7 +1,5 @@
|
|
1
1
|
module AuthorizedRailsScaffolds
|
2
|
-
|
3
|
-
PARENT_MODELS = [] # i.e. ['Category', 'User'] for Awesome/FooBar => awesome_category_user_foo_bars_path
|
4
|
-
|
2
|
+
|
5
3
|
class Helper
|
6
4
|
|
7
5
|
def initialize(class_name, singular_table_name, file_name, plural_file_name = nil)
|
@@ -13,13 +11,13 @@ module AuthorizedRailsScaffolds
|
|
13
11
|
@namespace_prefix = singular_table_name[0..-(file_name.length + 2)]
|
14
12
|
|
15
13
|
# Determine Parent Prefix i.e. user_company
|
16
|
-
parent_prefix = AuthorizedRailsScaffolds
|
14
|
+
parent_prefix = AuthorizedRailsScaffolds.parent_models.collect{ |x| x.underscore }.join('_')
|
17
15
|
parent_prefix = "#{parent_prefix}_" unless parent_prefix.blank?
|
18
16
|
|
19
17
|
# Route Prefix i.e. awesome_user_company
|
20
18
|
@route_prefix = @namespace_prefix.blank? ? parent_prefix : "#{@namespace_prefix}_#{parent_prefix}"
|
21
19
|
|
22
|
-
@parent_variables = AuthorizedRailsScaffolds
|
20
|
+
@parent_variables = AuthorizedRailsScaffolds.parent_models.collect{ |x| "@#{x.underscore}" }.join(', ')
|
23
21
|
|
24
22
|
# Route Helpers
|
25
23
|
@route_params_prefix = @parent_variables.blank? ? "" : "#{@parent_variables}, "
|
@@ -39,6 +37,15 @@ module AuthorizedRailsScaffolds
|
|
39
37
|
@plural_var_name
|
40
38
|
end
|
41
39
|
|
40
|
+
def create_model_with_attributes(attributes)
|
41
|
+
extra_params = ''
|
42
|
+
attribute = AuthorizedRailsScaffolds.parent_models.any? ? AuthorizedRailsScaffolds.parent_models.last.underscore : nil
|
43
|
+
if attribute && attributes.collect{|a|a.name.underscore}.include?(attribute)
|
44
|
+
extra_params = ", :#{attribute} => @#{attribute}"
|
45
|
+
end
|
46
|
+
"FactoryGirl.create(:#{var_name}#{extra_params})"
|
47
|
+
end
|
48
|
+
|
42
49
|
def form_object_array(variable = nil)
|
43
50
|
variable ||= "@#{var_name}"
|
44
51
|
namespace_prefix = ":#{@namespace_prefix}" unless @namespace_prefix.blank?
|
@@ -47,8 +54,12 @@ module AuthorizedRailsScaffolds
|
|
47
54
|
end
|
48
55
|
|
49
56
|
def controller_show_route(variable = nil)
|
50
|
-
variable ||= "
|
51
|
-
|
57
|
+
variable ||= ""
|
58
|
+
if variable.blank?
|
59
|
+
"#{@single_path_prefix}_path(#{@parent_variables})"
|
60
|
+
else
|
61
|
+
"#{@single_path_prefix}_path(#{@route_params_prefix}#{variable})"
|
62
|
+
end
|
52
63
|
end
|
53
64
|
|
54
65
|
def controller_index_path
|
@@ -69,8 +80,8 @@ module AuthorizedRailsScaffolds
|
|
69
80
|
|
70
81
|
# call arguments
|
71
82
|
def index_action_params_prefix
|
72
|
-
if AuthorizedRailsScaffolds
|
73
|
-
AuthorizedRailsScaffolds
|
83
|
+
if AuthorizedRailsScaffolds.parent_models.any?
|
84
|
+
AuthorizedRailsScaffolds.parent_models.collect{|x| ":#{x.underscore}_id => @#{x.underscore}.to_param"}.join(', ')
|
74
85
|
else
|
75
86
|
''
|
76
87
|
end
|
@@ -78,7 +89,7 @@ module AuthorizedRailsScaffolds
|
|
78
89
|
|
79
90
|
def references_show_route(attribute_name, variable = nil)
|
80
91
|
variable ||= "@#{@var_name}.#{attribute_name}"
|
81
|
-
if AuthorizedRailsScaffolds
|
92
|
+
if AuthorizedRailsScaffolds.parent_models.any? && AuthorizedRailsScaffolds.parent_models.last.underscore == attribute_name
|
82
93
|
references_path = "#{@route_prefix}path(#{variable})"
|
83
94
|
else
|
84
95
|
references_path = "#{attribute_name}_path(#{variable})"
|
@@ -132,6 +143,5 @@ module AuthorizedRailsScaffolds
|
|
132
143
|
end
|
133
144
|
|
134
145
|
end
|
135
|
-
|
136
|
-
end
|
137
|
-
|
146
|
+
|
147
|
+
end
|
data/lib/generators/authorized_rails_scaffolds/install_scaffold/install_scaffold_generator.rb
CHANGED
@@ -9,10 +9,6 @@ class AuthorizedRailsScaffolds::InstallScaffoldGenerator < Rails::Generators::Ba
|
|
9
9
|
copy_erb_template 'show.html.erb'
|
10
10
|
end
|
11
11
|
|
12
|
-
def copy_initializer
|
13
|
-
copy_file 'initializer.rb', 'config/initializers/authorized_rails_scaffolds.rb'
|
14
|
-
end
|
15
|
-
|
16
12
|
def copy_rails_templates
|
17
13
|
copy_rails_template 'controller.rb'
|
18
14
|
end
|
@@ -12,30 +12,13 @@ plural_var_name = var_name.pluralize # Pluralized non-namespaced variable name
|
|
12
12
|
|
13
13
|
orm_instance = Rails::Generators::ActiveModel.new var_name
|
14
14
|
|
15
|
-
# Determine namespace prefix i.e awesome_
|
16
|
-
namespace_prefix = singular_table_name[0..-(file_name.length + 1)]
|
17
|
-
|
18
|
-
# Determine Parent Prefix i.e. user_company
|
19
|
-
parent_prefix = AuthorizedRailsScaffolds::PARENT_MODELS.collect{ |x| x.underscore }.join('_')
|
20
|
-
parent_prefix = "#{parent_prefix}_" unless parent_prefix.blank?
|
21
|
-
|
22
|
-
# Route Prefix i.e. awesome_user_company
|
23
|
-
route_prefix = namespace_prefix + parent_prefix
|
24
|
-
|
25
|
-
parent_variables = AuthorizedRailsScaffolds::PARENT_MODELS.collect { |x| "@#{x.underscore}" }.join(', ')
|
26
|
-
|
27
|
-
# Route Helpers
|
28
|
-
route_params_prefix = parent_variables.blank? ? "" : "#{parent_variables}, "
|
29
|
-
index_path_prefix = "#{route_prefix}#{plural_var_name}"
|
30
|
-
single_path_prefix = "#{route_prefix}#{var_name}"
|
31
|
-
|
32
15
|
-%>
|
33
16
|
<% module_namespacing do -%>
|
34
17
|
class <%= controller_class_name %>Controller < ApplicationController
|
35
|
-
<%- AuthorizedRailsScaffolds
|
36
|
-
load_resource :<%= model.underscore %><% if model_index > 0 %>, :through => :<%= AuthorizedRailsScaffolds
|
18
|
+
<%- AuthorizedRailsScaffolds.parent_models.each_with_index do |model, model_index| -%>
|
19
|
+
load_resource :<%= model.underscore %><% if model_index > 0 %>, :through => :<%= AuthorizedRailsScaffolds.parent_models[model_index - 1].underscore %><% end %>
|
37
20
|
<%- end -%>
|
38
|
-
load_and_authorize_resource :<%= var_name%><% if AuthorizedRailsScaffolds
|
21
|
+
load_and_authorize_resource :<%= var_name%><% if AuthorizedRailsScaffolds.parent_models.any? %>, :through => :<%= AuthorizedRailsScaffolds.parent_models.last.underscore %><% end %>
|
39
22
|
|
40
23
|
# GET <%= route_url %>
|
41
24
|
# GET <%= route_url %>.json
|
@@ -82,8 +65,8 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
82
65
|
|
83
66
|
respond_to do |format|
|
84
67
|
if @<%= orm_instance.save %>
|
85
|
-
format.html { redirect_to <%= "
|
86
|
-
format.json { render <%= key_value :json, "@#{var_name}" %>, <%= key_value :status, ':created' %>, <%= key_value :location, "
|
68
|
+
format.html { redirect_to <%= t_helper.controller_show_route("@#{var_name}") %>, <%= key_value :notice, "'#{human_name} was successfully created.'" %> }
|
69
|
+
format.json { render <%= key_value :json, "@#{var_name}" %>, <%= key_value :status, ':created' %>, <%= key_value :location, t_helper.controller_show_route("@#{var_name}") %> }
|
87
70
|
else
|
88
71
|
format.html { render <%= key_value :action, '"new"' %> }
|
89
72
|
format.json { render <%= key_value :json, "@#{orm_instance.errors}" %>, <%= key_value :status, ':unprocessable_entity' %> }
|
@@ -98,7 +81,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
98
81
|
|
99
82
|
respond_to do |format|
|
100
83
|
if @<%= orm_instance.update_attributes("params[:#{var_name}]") %>
|
101
|
-
format.html { redirect_to <%= "
|
84
|
+
format.html { redirect_to <%= t_helper.controller_show_route "@#{var_name}" %>, <%= key_value :notice, "'#{human_name} was successfully updated.'" %> }
|
102
85
|
format.json { head :no_content }
|
103
86
|
else
|
104
87
|
format.html { render <%= key_value :action, '"edit"' %> }
|
@@ -27,7 +27,7 @@ plural_var_name = var_name.pluralize # Pluralized non-namespaced variable name
|
|
27
27
|
<tr class="<%= var_name %>_<%%= <%= var_name %>.id %>">
|
28
28
|
<td class="id-column"><%%= <%= var_name %>.id %></td>
|
29
29
|
<%- if attributes.any? -%>
|
30
|
-
<td class="title-column"><%%= link_to <%= var_name %>.<%= attributes[0].name %>, <%=
|
30
|
+
<td class="title-column"><%%= link_to <%= var_name %>.<%= attributes[0].name %>, <%= t_helper.controller_show_route(var_name) %> %></td>
|
31
31
|
<%- attributes[1..-1].each do |attribute| -%>
|
32
32
|
<%- if [:datetime, :timestamp, :time, :date].include? attribute.type -%>
|
33
33
|
<td><%% unless <%= var_name %>.<%= attribute.name %>.nil? %><%%=l <%= var_name %>.<%= attribute.name %><% if attribute.type == :datetime %>, :format => :long<% end %><% if attribute.type == :time %>, :format => :short<% end %> %><%% end %></td>
|
@@ -39,12 +39,12 @@ plural_var_name = var_name.pluralize # Pluralized non-namespaced variable name
|
|
39
39
|
<td><%%=l <%= var_name %>.created_at, :format => :long %></td>
|
40
40
|
<td class="table-actions">
|
41
41
|
<%%= link_to t('.edit', :default => t("helpers.links.edit")),
|
42
|
-
edit_<%=
|
42
|
+
edit_<%= t_helper.controller_show_route var_name %>,
|
43
43
|
:class => 'btn btn-mini',
|
44
44
|
:disabled => !can?(:update, <%= var_name %>)
|
45
45
|
%>
|
46
46
|
<%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
|
47
|
-
<%=
|
47
|
+
<%= t_helper.controller_show_route var_name %>,
|
48
48
|
:method => :delete,
|
49
49
|
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
|
50
50
|
:class => 'btn btn-mini btn-danger',
|
@@ -58,6 +58,6 @@ plural_var_name = var_name.pluralize # Pluralized non-namespaced variable name
|
|
58
58
|
|
59
59
|
<%% if can?(:create, <%= local_class_name %>) %>
|
60
60
|
<%%= link_to t('.new', :default => t("helpers.links.new")),
|
61
|
-
new_<%=
|
61
|
+
new_<%= t_helper.controller_show_route %>,
|
62
62
|
:class => 'btn btn-primary' %>
|
63
63
|
<%% end %>
|
@@ -42,9 +42,9 @@ describe <%= controller_class_name %>Controller do
|
|
42
42
|
FactoryGirl.attributes_for(:<%= var_name %>)
|
43
43
|
end
|
44
44
|
|
45
|
-
<%- if AuthorizedRailsScaffolds
|
45
|
+
<%- if AuthorizedRailsScaffolds.parent_models.any? -%>
|
46
46
|
before(:each) do
|
47
|
-
<%- AuthorizedRailsScaffolds
|
47
|
+
<%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
|
48
48
|
@<%= model.underscore %> = FactoryGirl.create(:<%= model.underscore %>)
|
49
49
|
<%- end -%>
|
50
50
|
end
|
@@ -55,7 +55,7 @@ describe <%= controller_class_name %>Controller do
|
|
55
55
|
context 'without a user' do
|
56
56
|
describe 'with valid request' do
|
57
57
|
before(:each) do
|
58
|
-
@<%= var_name %> =
|
58
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
59
59
|
get :index, {<%= t_helper.index_action_params_prefix %>}
|
60
60
|
end
|
61
61
|
it { should redirect_to(new_user_session_path) }
|
@@ -66,7 +66,7 @@ describe <%= controller_class_name %>Controller do
|
|
66
66
|
login_unauthorized_user
|
67
67
|
describe 'with valid request' do
|
68
68
|
before(:each) do
|
69
|
-
@<%= var_name %> =
|
69
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
70
70
|
get :index, {<%= t_helper.index_action_params_prefix %>}
|
71
71
|
end
|
72
72
|
it { should redirect_to(root_url) }
|
@@ -77,7 +77,7 @@ describe <%= controller_class_name %>Controller do
|
|
77
77
|
login_user_with_ability :read, <%= local_class_name %>
|
78
78
|
describe 'with valid request' do
|
79
79
|
before(:each) do
|
80
|
-
@<%= var_name %> =
|
80
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
81
81
|
get :index, {<%= t_helper.index_action_params_prefix %>}
|
82
82
|
end
|
83
83
|
it { should respond_with(:success) }
|
@@ -95,7 +95,7 @@ describe <%= controller_class_name %>Controller do
|
|
95
95
|
context 'without a user' do
|
96
96
|
describe 'with valid request' do
|
97
97
|
before(:each) do
|
98
|
-
@<%= var_name %> =
|
98
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
99
99
|
get :show, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
|
100
100
|
end
|
101
101
|
it { should redirect_to(new_user_session_path) }
|
@@ -106,7 +106,7 @@ describe <%= controller_class_name %>Controller do
|
|
106
106
|
login_unauthorized_user
|
107
107
|
describe 'with valid request' do
|
108
108
|
before(:each) do
|
109
|
-
@<%= var_name %> =
|
109
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
110
110
|
get :show, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
|
111
111
|
end
|
112
112
|
it { should redirect_to(<%= t_helper.controller_index_route %>) }
|
@@ -117,7 +117,7 @@ describe <%= controller_class_name %>Controller do
|
|
117
117
|
login_user_with_ability :read, <%= local_class_name %>
|
118
118
|
describe 'with valid request' do
|
119
119
|
before(:each) do
|
120
|
-
@<%= var_name %> =
|
120
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
121
121
|
get :show, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
|
122
122
|
end
|
123
123
|
it { should respond_with(:success) }
|
@@ -170,7 +170,7 @@ describe <%= controller_class_name %>Controller do
|
|
170
170
|
context 'without a user' do
|
171
171
|
describe 'with valid request' do
|
172
172
|
before(:each) do
|
173
|
-
@<%= var_name %> =
|
173
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
174
174
|
get :edit, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
|
175
175
|
end
|
176
176
|
it { should redirect_to(new_user_session_path) }
|
@@ -181,7 +181,7 @@ describe <%= controller_class_name %>Controller do
|
|
181
181
|
login_unauthorized_user
|
182
182
|
describe 'with valid request' do
|
183
183
|
before(:each) do
|
184
|
-
@<%= var_name %> =
|
184
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
185
185
|
get :edit, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
|
186
186
|
end
|
187
187
|
it { should redirect_to(<%= t_helper.controller_index_route %>) }
|
@@ -192,7 +192,7 @@ describe <%= controller_class_name %>Controller do
|
|
192
192
|
login_user_with_ability :update, <%= local_class_name %>
|
193
193
|
describe 'with valid request' do
|
194
194
|
before(:each) do
|
195
|
-
@<%= var_name %> =
|
195
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
196
196
|
get :edit, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
|
197
197
|
end
|
198
198
|
it { should respond_with(:success) }
|
@@ -265,7 +265,7 @@ describe <%= controller_class_name %>Controller do
|
|
265
265
|
context 'without a user' do
|
266
266
|
describe 'with valid params' do
|
267
267
|
before(:each) do
|
268
|
-
@<%= var_name %> =
|
268
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
269
269
|
put :update, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param, :<%= var_name %> => valid_update_attributes}
|
270
270
|
end
|
271
271
|
it { should redirect_to(new_user_session_path) }
|
@@ -276,7 +276,7 @@ describe <%= controller_class_name %>Controller do
|
|
276
276
|
login_unauthorized_user
|
277
277
|
describe "with valid params" do
|
278
278
|
before(:each) do
|
279
|
-
@<%= var_name %> =
|
279
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
280
280
|
put :update, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param, :<%= var_name %> => valid_update_attributes}
|
281
281
|
end
|
282
282
|
it { should redirect_to(<%= t_helper.controller_index_route %>) }
|
@@ -287,7 +287,7 @@ describe <%= controller_class_name %>Controller do
|
|
287
287
|
login_user_with_ability :update, <%= local_class_name %>
|
288
288
|
describe "with valid params" do
|
289
289
|
it "updates the requested <%= var_name %>" do
|
290
|
-
@<%= var_name %> =
|
290
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
291
291
|
# Assuming there are no other <%= var_name %> in the database, this
|
292
292
|
# specifies that the <%= local_class_name %> created on the previous line
|
293
293
|
# receives the :update_attributes message with whatever params are
|
@@ -302,7 +302,7 @@ describe <%= controller_class_name %>Controller do
|
|
302
302
|
end
|
303
303
|
describe "with valid params" do
|
304
304
|
before(:each) do
|
305
|
-
@<%= var_name %> =
|
305
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
306
306
|
put :update, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param, :<%= var_name %> => valid_update_attributes}
|
307
307
|
end
|
308
308
|
it "assigns the requested <%= var_name %> as @<%= var_name %>" do
|
@@ -314,7 +314,7 @@ describe <%= controller_class_name %>Controller do
|
|
314
314
|
end
|
315
315
|
describe "with invalid params" do
|
316
316
|
before(:each) do
|
317
|
-
@<%= var_name %> =
|
317
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
318
318
|
# Trigger the behavior that occurs when invalid params are submitted
|
319
319
|
<%= local_class_name %>.any_instance.stub(:save).and_return(false)
|
320
320
|
put :update, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param, :<%= var_name %> => <%= formatted_hash(example_invalid_attributes) %>}
|
@@ -332,7 +332,7 @@ describe <%= controller_class_name %>Controller do
|
|
332
332
|
context 'without a user' do
|
333
333
|
describe 'with valid request' do
|
334
334
|
before(:each) do
|
335
|
-
@<%= var_name %> =
|
335
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
336
336
|
delete :destroy, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
|
337
337
|
end
|
338
338
|
it { should redirect_to(new_user_session_path) }
|
@@ -343,7 +343,7 @@ describe <%= controller_class_name %>Controller do
|
|
343
343
|
login_unauthorized_user
|
344
344
|
describe "with valid request" do
|
345
345
|
before(:each) do
|
346
|
-
@<%= var_name %> =
|
346
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
347
347
|
delete :destroy, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
|
348
348
|
end
|
349
349
|
it { should redirect_to(<%= t_helper.controller_index_route %>) }
|
@@ -353,14 +353,14 @@ describe <%= controller_class_name %>Controller do
|
|
353
353
|
context 'as user with destroy ability' do
|
354
354
|
login_user_with_ability :destroy, <%= local_class_name %>
|
355
355
|
it "destroys the requested <%= var_name %>" do
|
356
|
-
@<%= var_name %> =
|
356
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
357
357
|
expect {
|
358
358
|
delete :destroy, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
|
359
359
|
}.to change(<%= local_class_name %>, :count).by(-1)
|
360
360
|
end
|
361
361
|
describe 'with valid request' do
|
362
362
|
before(:each) do
|
363
|
-
@<%= var_name %> =
|
363
|
+
@<%= var_name %> = <%= t_helper.create_model_with_attributes attributes %>
|
364
364
|
delete :destroy, {<%= t_helper.action_params_prefix %>:id => @<%= var_name %>.to_param}
|
365
365
|
end
|
366
366
|
it "redirects to the <%= var_name %> list" do
|
@@ -14,7 +14,7 @@ datetime_attributes = attributes.reject{|attribute| ![:time, :date, :datetime].i
|
|
14
14
|
-%>
|
15
15
|
describe "<%= ns_table_name %>/edit" do
|
16
16
|
before(:each) do
|
17
|
-
<%- AuthorizedRailsScaffolds
|
17
|
+
<%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
|
18
18
|
@<%= model.underscore %> = assign(:<%= model.underscore %>, FactoryGirl.build_stubbed(:<%= model.underscore %>))
|
19
19
|
<%- end -%>
|
20
20
|
@<%= var_name %> = assign(:<%= var_name %>, FactoryGirl.build_stubbed(:<%= var_name %><%= output_attributes.empty? ? '))' : ',' %>
|
@@ -13,7 +13,7 @@ output_attributes = attributes.reject{|attribute| [:timestamp].include? attrib
|
|
13
13
|
-%>
|
14
14
|
describe "<%= ns_table_name %>/index" do
|
15
15
|
before(:each) do
|
16
|
-
<%- AuthorizedRailsScaffolds
|
16
|
+
<%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
|
17
17
|
@<%= model.underscore %> = assign(:<%= model.underscore %>, FactoryGirl.build_stubbed(:<%= model.underscore %>))
|
18
18
|
<%- end -%>
|
19
19
|
<% [1,2].each_with_index do |id, model_index| -%>
|
@@ -157,9 +157,9 @@ describe "<%= ns_table_name %>/index" do
|
|
157
157
|
it "does not render a link to new_<%= ns_file_name %>_path" do
|
158
158
|
render
|
159
159
|
<% if webrat? -%>
|
160
|
-
rendered.should_not have_selector("a[href=?]", :href => new_<%=
|
160
|
+
rendered.should_not have_selector("a[href=?]", :href => new_<%= t_helper.controller_show_route %>, :count => 1)
|
161
161
|
<% else -%>
|
162
|
-
assert_select "a[href=?]", new_<%=
|
162
|
+
assert_select "a[href=?]", new_<%= t_helper.controller_show_route %>, :count => 0
|
163
163
|
<% end -%>
|
164
164
|
end
|
165
165
|
end
|
@@ -168,9 +168,9 @@ describe "<%= ns_table_name %>/index" do
|
|
168
168
|
@ability.can :create, <%= local_class_name %>
|
169
169
|
render
|
170
170
|
<% if webrat? -%>
|
171
|
-
rendered.should have_selector("a[href=?]", new_<%=
|
171
|
+
rendered.should have_selector("a[href=?]", new_<%= t_helper.controller_show_route %>, :count => 1)
|
172
172
|
<% else -%>
|
173
|
-
assert_select "a[href=?]", new_<%=
|
173
|
+
assert_select "a[href=?]", new_<%= t_helper.controller_show_route %>, :count => 1
|
174
174
|
<% end -%>
|
175
175
|
end
|
176
176
|
end
|
@@ -14,7 +14,7 @@ datetime_attributes = attributes.reject{|attribute| ![:time, :date, :datetime].i
|
|
14
14
|
-%>
|
15
15
|
describe "<%= ns_table_name %>/new" do
|
16
16
|
before(:each) do
|
17
|
-
<%- AuthorizedRailsScaffolds
|
17
|
+
<%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
|
18
18
|
@<%= model.underscore %> = assign(:<%= model.underscore %>, FactoryGirl.build_stubbed(:<%= model.underscore %>))
|
19
19
|
<%- end -%>
|
20
20
|
assign(:<%= var_name %>, FactoryGirl.build(:<%= var_name %><%= output_attributes.empty? ? '))' : ',' %>
|
@@ -5,7 +5,7 @@ require "spec_helper"
|
|
5
5
|
|
6
6
|
parts = ns_table_name.split('/')[0..-2] || []
|
7
7
|
|
8
|
-
AuthorizedRailsScaffolds
|
8
|
+
AuthorizedRailsScaffolds.parent_models.each_with_index do |model, model_index|
|
9
9
|
parts << model.underscore.pluralize
|
10
10
|
parts << model_index + 2
|
11
11
|
end
|
@@ -14,8 +14,8 @@ parts << ns_table_name.split('/')[-1]
|
|
14
14
|
request_path = parts.join('/')
|
15
15
|
|
16
16
|
extra_arguments = ''
|
17
|
-
if AuthorizedRailsScaffolds
|
18
|
-
AuthorizedRailsScaffolds
|
17
|
+
if AuthorizedRailsScaffolds.parent_models.any?
|
18
|
+
AuthorizedRailsScaffolds.parent_models.each_with_index do |model, model_index|
|
19
19
|
extra_arguments += ", :#{model.underscore}_id => \"#{model_index + 2}\""
|
20
20
|
end
|
21
21
|
end
|
@@ -13,7 +13,7 @@ references_attributes = attributes.reject{|attribute| ![:references].include? at
|
|
13
13
|
-%>
|
14
14
|
describe "<%= ns_table_name %>/show" do
|
15
15
|
before(:each) do
|
16
|
-
<%- AuthorizedRailsScaffolds
|
16
|
+
<%- AuthorizedRailsScaffolds.parent_models.each do |model| -%>
|
17
17
|
@<%= model.underscore %> = assign(:<%= model.underscore %>, FactoryGirl.build_stubbed(:<%= model.underscore %>))
|
18
18
|
<%- end -%>
|
19
19
|
@<%= var_name %> = FactoryGirl.build_stubbed(:<%= var_name %><%= output_attributes.empty? ? ')' : ',' %>
|
metadata
CHANGED
@@ -1,57 +1,49 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authorized_rails_scaffolds
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- bmorrall
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-03-26 00:00:00.
|
12
|
+
date: 2013-03-26 00:00:00.000000000Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: railties
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70121345852780 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ! '>='
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '3.1'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
|
-
version_requirements:
|
23
|
-
requirements:
|
24
|
-
- - ! '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '3.1'
|
24
|
+
version_requirements: *70121345852780
|
27
25
|
- !ruby/object:Gem::Dependency
|
28
26
|
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
27
|
+
requirement: &70121345852280 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
30
29
|
requirements:
|
31
30
|
- - ~>
|
32
31
|
- !ruby/object:Gem::Version
|
33
32
|
version: '1.3'
|
34
33
|
type: :development
|
35
34
|
prerelease: false
|
36
|
-
version_requirements:
|
37
|
-
requirements:
|
38
|
-
- - ~>
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.3'
|
35
|
+
version_requirements: *70121345852280
|
41
36
|
- !ruby/object:Gem::Dependency
|
42
37
|
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
38
|
+
requirement: &70121345851900 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
44
40
|
requirements:
|
45
41
|
- - ! '>='
|
46
42
|
- !ruby/object:Gem::Version
|
47
43
|
version: '0'
|
48
44
|
type: :development
|
49
45
|
prerelease: false
|
50
|
-
version_requirements:
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
46
|
+
version_requirements: *70121345851900
|
55
47
|
description: Creates scaffolds for Twitter Bootstrap with generated RSpec coverage
|
56
48
|
email:
|
57
49
|
- bemo56@hotmail.com
|
@@ -66,6 +58,7 @@ files:
|
|
66
58
|
- Rakefile
|
67
59
|
- authorized_rails_scaffolds.gemspec
|
68
60
|
- lib/authorized_rails_scaffolds.rb
|
61
|
+
- lib/authorized_rails_scaffolds/helper.rb
|
69
62
|
- lib/authorized_rails_scaffolds/version.rb
|
70
63
|
- lib/generators/authorized_rails_scaffolds/install_scaffold/USAGE
|
71
64
|
- lib/generators/authorized_rails_scaffolds/install_scaffold/install_scaffold_generator.rb
|
@@ -73,7 +66,6 @@ files:
|
|
73
66
|
- lib/generators/authorized_rails_scaffolds/install_scaffold/templates/controller.rb
|
74
67
|
- lib/generators/authorized_rails_scaffolds/install_scaffold/templates/edit.html.erb
|
75
68
|
- lib/generators/authorized_rails_scaffolds/install_scaffold/templates/index.html.erb
|
76
|
-
- lib/generators/authorized_rails_scaffolds/install_scaffold/templates/initializer.rb
|
77
69
|
- lib/generators/authorized_rails_scaffolds/install_scaffold/templates/new.html.erb
|
78
70
|
- lib/generators/authorized_rails_scaffolds/install_scaffold/templates/show.html.erb
|
79
71
|
- lib/generators/authorized_rails_scaffolds/install_spec/USAGE
|
@@ -90,26 +82,27 @@ files:
|
|
90
82
|
homepage: https://github.com/bmorrall/authorized_rails_scaffolds
|
91
83
|
licenses:
|
92
84
|
- MIT
|
93
|
-
metadata: {}
|
94
85
|
post_install_message:
|
95
86
|
rdoc_options: []
|
96
87
|
require_paths:
|
97
88
|
- lib
|
98
89
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
99
91
|
requirements:
|
100
92
|
- - ! '>='
|
101
93
|
- !ruby/object:Gem::Version
|
102
94
|
version: '0'
|
103
95
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
104
97
|
requirements:
|
105
98
|
- - ! '>='
|
106
99
|
- !ruby/object:Gem::Version
|
107
100
|
version: '0'
|
108
101
|
requirements: []
|
109
102
|
rubyforge_project:
|
110
|
-
rubygems_version:
|
103
|
+
rubygems_version: 1.8.10
|
111
104
|
signing_key:
|
112
|
-
specification_version:
|
105
|
+
specification_version: 3
|
113
106
|
summary: Replaces Rails and RSpec's default generators with templates taking full
|
114
107
|
advantage of Authentication (Devise), Authorization (CanCan) and Test Coverage (RSpec)
|
115
108
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 33e014ce5460fd00415ab744aa6c62218700e5aa
|
4
|
-
data.tar.gz: f7ef08d1c1d18a961e54f31fa092d459cae329dc
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 4991100484bf19211002bebdbb8340595485869ae127969985736212aa762df00fde165a505a7efaba9622cd8828dc1abf2caf617530da7c7d0f4ce164d2ac6f
|
7
|
-
data.tar.gz: 825dd5ab02b58a2cb5f8cf1e4f02151158a5b2324cbccb20d578c92922b0850ffc6b7cd413af28ab15dd9628e7304bef27361613ddb54175282408e43e8b002f
|