leonardo 1.9.0.beta1 → 1.9.0.beta2
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/CHANGELOG +5 -0
- data/lib/generators/erb/leosca/templates/_fields.html.erb +2 -2
- data/lib/generators/erb/leosca/templates/_form.html.erb +1 -2
- data/lib/generators/erb/leosca/templates/_form_multiple.html.erb +5 -4
- data/lib/generators/erb/leosca/templates/_list.erb +2 -2
- data/lib/generators/erb/leosca/templates/_row_index.html.erb +1 -2
- data/lib/generators/erb/leosca/templates/formtastic/_fields.html.erb +1 -1
- data/lib/generators/erb/leosca/templates/formtastic/_form.html.erb +1 -1
- data/lib/generators/erb/leosca/templates/formtastic/_form_multiple.html.erb +3 -2
- data/lib/generators/erb/leosca/templates/index.html.erb +1 -1
- data/lib/generators/leolay/templates/config/locales/en.yml +5 -6
- data/lib/generators/leolay/templates/config/locales/it.yml +5 -6
- data/lib/generators/leonardo.rb +41 -12
- data/lib/generators/rails/leosca/leosca_generator.rb +0 -1
- data/lib/generators/rails/leosca_controller/leosca_controller_generator.rb +13 -5
- data/lib/generators/rails/leosca_controller/templates/controller.rb +8 -2
- data/lib/generators/rspec/leointegration/templates/request_spec.rb +97 -9
- data/lib/generators/rspec/leosca/templates/controller_spec.rb +1 -1
- metadata +4 -4
data/CHANGELOG
CHANGED
@@ -1,7 +1,12 @@
|
|
1
|
+
1.9.0.beta2 (December 12th, 2011) Marco Mastrodonato
|
2
|
+
* Specs updated
|
3
|
+
* Little improvements
|
4
|
+
|
1
5
|
1.9.0.beta1 (November 30th, 2011) Marco Mastrodonato
|
2
6
|
* Lists: Added multiple selection to combine with massive operation
|
3
7
|
* Lists: Added copy operation to create new items from existing. It works for multiple rows as well.
|
4
8
|
* Data forms: fields moved into new partial to share with multiple operation
|
9
|
+
* Little improvements
|
5
10
|
|
6
11
|
TODO:
|
7
12
|
* Model: Create name attribute for every one that does not have
|
@@ -3,13 +3,13 @@
|
|
3
3
|
<%%= f.label :<%= attribute.name %>, t('attributes.<%= singular_table_name %>.<%= attribute.name %>') %><br />
|
4
4
|
<%- case attribute.type
|
5
5
|
when :references, :belongs_to -%>
|
6
|
-
<%% if
|
6
|
+
<%% if <%= singular_table_name %>.new_record? -%>
|
7
7
|
<%%= f.collection_select :<%= attribute.name %>_id, <%= attribute.name.classify %>.all, :id, :name, :prompt => true if can?(:manage, <%=class_name %>) %>
|
8
8
|
<%% else -%>
|
9
9
|
<%%= f.collection_select :<%= attribute.name %>_id, <%= attribute.name.classify %>.all, :id, :name, :prompt => true %>
|
10
10
|
<%% end -%>
|
11
11
|
<%- when :date -%>
|
12
|
-
<%%= f
|
12
|
+
<%%= f.text_field :<%= attribute.name %> <%=", :class => \"calendar\"" if jquery_ui?%> %>
|
13
13
|
<%- else -%>
|
14
14
|
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
15
15
|
<%- end -%>
|
@@ -2,7 +2,6 @@
|
|
2
2
|
<%% if @<%= singular_table_name %>.errors.any? %>
|
3
3
|
<div id="error_explanation">
|
4
4
|
<h2><%%= pluralize(@<%= singular_table_name %>.errors.count, "error") %> prohibited this <%= singular_table_name %> from being saved:</h2>
|
5
|
-
|
6
5
|
<ul>
|
7
6
|
<%% @<%= singular_table_name %>.errors.full_messages.each do |msg| %>
|
8
7
|
<li><%%= msg %></li>
|
@@ -11,7 +10,7 @@
|
|
11
10
|
</div>
|
12
11
|
<%% end %>
|
13
12
|
|
14
|
-
<%%= render 'fields', :f => f %>
|
13
|
+
<%%= render 'fields', :f => f, :<%= singular_table_name %> => @<%= singular_table_name %> %>
|
15
14
|
<div class="actions">
|
16
15
|
<%%= f.submit :class => 'button large' %>
|
17
16
|
</div>
|
@@ -1,9 +1,10 @@
|
|
1
1
|
<%%= form_for(:<%= plural_table_name %>, :url => path, :method => :put) do |f| %>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
<%% end %>
|
2
|
+
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| -%>
|
3
|
+
<%%= f.fields_for "#{<%= singular_table_name %>.id}", <%= singular_table_name %> do |ff| %>
|
4
|
+
<%%= render 'fields', :f => ff, :<%= singular_table_name %> => <%= singular_table_name %> %>
|
6
5
|
<%% end %>
|
6
|
+
<div class="separator"></div>
|
7
|
+
<%% end -%>
|
7
8
|
<div class="actions">
|
8
9
|
<%%= f.submit :class => 'button large' %>
|
9
10
|
</div>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%%= paginate @<%= plural_table_name %>, :remote => remote %>
|
3
3
|
<%end%>
|
4
4
|
<%%= page_entries_info @<%= plural_table_name %>, t('models.<%= singular_table_name %>'), t('models.<%= plural_table_name %>') %>
|
5
|
-
|
5
|
+
<%% if @<%= plural_table_name %>.any? -%>
|
6
6
|
<%%= form_for :select, :url => select_<%= plural_table_name %>_path, :remote => false, :html => { :method => :post, :id => "form_select" } do |f| %>
|
7
7
|
<table class='user' cellspacing='0'>
|
8
8
|
<thead>
|
@@ -55,7 +55,7 @@
|
|
55
55
|
</div>
|
56
56
|
<%% end -%>
|
57
57
|
<div class="separator"></div>
|
58
|
-
|
58
|
+
<%% end -%>
|
59
59
|
<%- if pagination? -%>
|
60
60
|
<%%= paginate @<%= plural_table_name %>, :remote => remote %>
|
61
61
|
<%- end -%>
|
@@ -1,12 +1,11 @@
|
|
1
1
|
<td>
|
2
2
|
<%%= check_box_tag "ids[]", <%= singular_table_name %>.id, false, {:id =>"check#{<%= singular_table_name %>.id}", :class => "selectable"} %>
|
3
|
-
<%%= number_with_delimiter
|
3
|
+
<%%= link_to number_with_delimiter(<%= singular_table_name %>.id), <%= show_resource_path %><%= ", :remote => remote" if jquery_ui? %> %>
|
4
4
|
</td>
|
5
5
|
<%- attributes.each do |attribute| -%>
|
6
6
|
<td><%= attribute_to_erb(attribute, singular_table_name) -%></td>
|
7
7
|
<%- end -%>
|
8
8
|
<!-- Manage section, do not remove this tag -->
|
9
|
-
<td><%%= link_to t(:show), <%= show_resource_path %><%= ", :remote => remote" if jquery_ui? %> %></td>
|
10
9
|
<%- if authorization? -%>
|
11
10
|
<%%- if can? :update, <%= singular_table_name %> -%>
|
12
11
|
<%- end -%>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
<%- attributes.each do |attribute| -%>
|
3
3
|
<%- case attribute.type
|
4
4
|
when :references, :belongs_to -%>
|
5
|
-
<%% if
|
5
|
+
<%% if <%= singular_table_name %>.new_record? -%>
|
6
6
|
<%%= f.input :<%= attribute.name %> if can?(:manage, <%=class_name %>) %>
|
7
7
|
<%% else -%>
|
8
8
|
<%%= f.input :<%= attribute.name %> %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%%= semantic_form_for(<%= form_resource_path %>) do |f| %>
|
2
|
-
<%%= render 'fields', :f => f %>
|
2
|
+
<%%= render 'fields', :f => f, :<%= singular_table_name %> => @<%= singular_table_name %> %>
|
3
3
|
<%%= f.buttons do %>
|
4
4
|
<%%= f.commit_button :button_html => { :class => "button large" } %>
|
5
5
|
<%% end %>
|
@@ -1,8 +1,9 @@
|
|
1
1
|
<%%= semantic_form_for(:<%= plural_table_name %>, :url => path, :method => :put) do |f| %>
|
2
2
|
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
3
|
-
<%%= f.semantic_fields_for "#{<%= singular_table_name %>.id}", <%= singular_table_name %> do |
|
4
|
-
<%%= render 'fields', :f =>
|
3
|
+
<%%= f.semantic_fields_for "#{<%= singular_table_name %>.id}", <%= singular_table_name %> do |ff| %>
|
4
|
+
<%%= render 'fields', :f => ff, :<%= singular_table_name %> => <%= singular_table_name %> %>
|
5
5
|
<%% end %>
|
6
|
+
<div class="separator"></div>
|
6
7
|
<%% end %>
|
7
8
|
<%%= f.buttons do %>
|
8
9
|
<%%= f.commit_button :button_html => { :class => "button large" } %>
|
@@ -30,7 +30,7 @@
|
|
30
30
|
<%- when :text -%>
|
31
31
|
<%%= f.text_field :<%= attribute.name %> %>
|
32
32
|
<%- when :date -%>
|
33
|
-
<%%= f.text_field :<%= attribute.name %>, :class => "autosubmit<%=" calendar" if jquery_ui? %>"
|
33
|
+
<%%= f.text_field :<%= attribute.name %>, :class => "autosubmit<%=" calendar" if jquery_ui? %>" %>
|
34
34
|
<%- else -%>
|
35
35
|
<%%= f.<%= attribute.field_type %> :<%= attribute.name %> %>
|
36
36
|
<%- end -%>
|
@@ -178,9 +178,9 @@ en:
|
|
178
178
|
# Default value for :prompt => true in FormOptionsHelper
|
179
179
|
prompt: "Please select"
|
180
180
|
# Default translation keys for submit FormHelper
|
181
|
-
submit:
|
181
|
+
submit: &actions
|
182
182
|
create: "Create %{model}"
|
183
|
-
update: "Update
|
183
|
+
update: "Update"
|
184
184
|
submit: "Proceed"
|
185
185
|
|
186
186
|
activerecord: &activerecord
|
@@ -196,10 +196,8 @@ en:
|
|
196
196
|
labels:
|
197
197
|
<<: *attributes
|
198
198
|
hints:
|
199
|
-
actions:
|
200
|
-
|
201
|
-
update: "Save changes"
|
202
|
-
submit: "Proceed"
|
199
|
+
actions:
|
200
|
+
<<: *actions
|
203
201
|
authentication:
|
204
202
|
sign_in: "Sign in"
|
205
203
|
sign_in_with: "Sign in with"
|
@@ -230,6 +228,7 @@ en:
|
|
230
228
|
updated_multiple: "%{model} were successfully updated."
|
231
229
|
updated_multiple_ko: "An error prohibited %{model} to be updated."
|
232
230
|
deleted: "%{model} was successfully deleted."
|
231
|
+
deleted_ko: "An error prohibited %{model} to be deleted."
|
233
232
|
deleted_multiple: "%{model} were successfully deleted."
|
234
233
|
deleted_multiple_ko: "An error prohibited %{model} to be deleted."
|
235
234
|
search_found: "%{found} found"
|
@@ -176,9 +176,9 @@ it:
|
|
176
176
|
# Default value for :prompt => true in FormOptionsHelper
|
177
177
|
prompt: "Seleziona ..."
|
178
178
|
# Default translation keys for submit FormHelper
|
179
|
-
submit:
|
179
|
+
submit: &actions
|
180
180
|
create: "Crea %{model}"
|
181
|
-
update: "Aggiorna
|
181
|
+
update: "Aggiorna"
|
182
182
|
submit: "Procedi"
|
183
183
|
|
184
184
|
activerecord: &activerecord
|
@@ -225,10 +225,8 @@ it:
|
|
225
225
|
labels:
|
226
226
|
<<: *attributes
|
227
227
|
hints:
|
228
|
-
actions:
|
229
|
-
|
230
|
-
update: "Aggiorna"
|
231
|
-
submit: "Procedi"
|
228
|
+
actions:
|
229
|
+
<<: *actions
|
232
230
|
authentication:
|
233
231
|
sign_in: "Accedi"
|
234
232
|
sign_in_with: "Accedi con"
|
@@ -260,6 +258,7 @@ it:
|
|
260
258
|
updated_multiple: "La modifica di %{model} è avvenuta con successo."
|
261
259
|
updated_multiple_ko: "Un errore ha impedito la modifica di %{model}."
|
262
260
|
deleted: "L'oggetto %{model} è stato eliminato."
|
261
|
+
updated_ko: "Un errore ha impedito l'eliminazione dell'oggetto %{model}."
|
263
262
|
deleted_multiple: "L'eliminazione di %{model} è avvenuta con successo."
|
264
263
|
deleted_multiple_ko: "Un errore ha impedito l'eliminazione di %{model}."
|
265
264
|
search_found: "La ricerca ha trovato %{found}"
|
data/lib/generators/leonardo.rb
CHANGED
@@ -59,14 +59,16 @@ module Leonardo
|
|
59
59
|
end
|
60
60
|
" #{name}#{value}"
|
61
61
|
end
|
62
|
-
def attribute_to_requests(attribute)
|
62
|
+
def attribute_to_requests(attribute, object_id=nil)
|
63
|
+
object_id ||= "#{singular_table_name}_#{attribute.name}"
|
64
|
+
object_id = object_id.gsub('#', "\#{#{singular_table_name}.id}")
|
63
65
|
case attribute.type
|
64
|
-
when :boolean then "check
|
65
|
-
when :references, :belongs_to then "select #{singular_table_name}.#{attribute.name}.name, :from =>
|
66
|
+
when :boolean then "check \"#{object_id}\" if #{singular_table_name}.#{attribute.name}"
|
67
|
+
when :references, :belongs_to then "select #{singular_table_name}.#{attribute.name}.name, :from => \"#{object_id}\""
|
66
68
|
when :datetime, :time, :timestamp
|
67
69
|
then ""
|
68
|
-
when :date then "fill_in
|
69
|
-
else "fill_in
|
70
|
+
when :date then "fill_in \"#{object_id}\", :with => #{singular_table_name}.#{attribute.name}.strftime('%d-%m-%Y')"
|
71
|
+
else "fill_in \"#{object_id}\", :with => #{singular_table_name}.#{attribute.name}"
|
70
72
|
end
|
71
73
|
end
|
72
74
|
def attribute_to_erb(attribute, object)
|
@@ -83,13 +85,17 @@ module Leonardo
|
|
83
85
|
end
|
84
86
|
end
|
85
87
|
def get_attr_to_match(view=:list)
|
86
|
-
attributes.each do |attribute|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end
|
88
|
+
#attributes.each do |attribute|
|
89
|
+
# case attribute.type
|
90
|
+
# when :string, :text then
|
91
|
+
# return "have_content(#{singular_table_name}.#{attribute.name})",
|
92
|
+
# "have_no_content(#{singular_table_name}.#{attribute.name})"
|
93
|
+
# end
|
94
|
+
#end
|
95
|
+
attr = get_attr_to_check(view)
|
96
|
+
return "have_content(#{singular_table_name}.#{attr})",
|
97
|
+
"have_no_content(#{singular_table_name}.#{attr})" if attr
|
98
|
+
|
93
99
|
#If there are not string or text attributes
|
94
100
|
case view
|
95
101
|
when :list
|
@@ -98,6 +104,29 @@ module Leonardo
|
|
98
104
|
return "have_xpath('//table/tbody/tr')", "have_no_xpath('//table/tbody/tr')"
|
99
105
|
end
|
100
106
|
end
|
107
|
+
def get_attr_to_check(view=:list)
|
108
|
+
attribute = nil
|
109
|
+
case view
|
110
|
+
when :something
|
111
|
+
else
|
112
|
+
attributes.each{|a| attribute = case a.type when :string, :text then a.name end}
|
113
|
+
attributes.each{|a| attribute = case a.type when :references, :belongs_to, :datetime then nil else a.name end} unless attribute
|
114
|
+
#attributes.each do |attribute|
|
115
|
+
# case attribute.type
|
116
|
+
# when :references, :belongs_to, :datetime
|
117
|
+
# else
|
118
|
+
# selected_attr = attribute.name
|
119
|
+
# break
|
120
|
+
# end
|
121
|
+
#end
|
122
|
+
end
|
123
|
+
attribute
|
124
|
+
end
|
125
|
+
def fill_form_with_values(object_id=nil)
|
126
|
+
items = []
|
127
|
+
attributes.each{|a|items << " #{attribute_to_requests(a, object_id)}"}
|
128
|
+
items
|
129
|
+
end
|
101
130
|
end
|
102
131
|
|
103
132
|
module Nested
|
@@ -19,6 +19,7 @@ module Rails
|
|
19
19
|
class_option :remote, :type => :boolean, :default => true, :desc => "Enable ajax. You can also do later set remote to true into index view."
|
20
20
|
class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "To nest a resource under another(s)"
|
21
21
|
class_option :leospace, :type => :string, :default => "", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
|
22
|
+
class_option :auth_class, :type => :boolean, :default => 'user', :desc => "Set the authentication class name"
|
22
23
|
|
23
24
|
#Override
|
24
25
|
def create_controller_files
|
@@ -92,18 +93,25 @@ module Rails
|
|
92
93
|
return unless File.exists?(file)
|
93
94
|
inject_into_file file, :before => " end\nend" do
|
94
95
|
<<-FILE.gsub(/^ /, '')
|
95
|
-
#can :read, #{class_name} if
|
96
|
-
can :read, #{class_name} if
|
97
|
-
if
|
96
|
+
#can :read, #{class_name} if #{options[:auth_class]}.new_record? #Guest
|
97
|
+
can :read, #{class_name} if #{options[:auth_class]}.role? :guest #Registered guest
|
98
|
+
if #{options[:auth_class]}.role? :user
|
98
99
|
can :read, #{class_name}
|
99
|
-
can :update, #{class_name}
|
100
100
|
can :create, #{class_name}
|
101
|
+
can [:update, :destroy, :select, :create_multiple, :update_multiple], #{class_name} do |#{singular_table_name}|
|
102
|
+
if defined?(#{singular_table_name}.#{options[:auth_class]}_id)
|
103
|
+
#{singular_table_name}.#{options[:auth_class]}_id == #{options[:auth_class]}.id
|
104
|
+
else
|
105
|
+
true
|
106
|
+
end
|
107
|
+
end
|
101
108
|
end
|
102
|
-
if
|
109
|
+
if #{options[:auth_class]}.role? :manager
|
103
110
|
can :read, #{class_name}
|
104
111
|
can :update, #{class_name}
|
105
112
|
can :create, #{class_name}
|
106
113
|
can :destroy, #{class_name}
|
114
|
+
can [:select, :create_multiple, :update_multiple], #{class_name}
|
107
115
|
end
|
108
116
|
|
109
117
|
FILE
|
@@ -132,7 +132,8 @@ end
|
|
132
132
|
def create_multiple
|
133
133
|
respond_to do |format|
|
134
134
|
if <%= class_name %>.create(params[:<%= plural_table_name %>].values)
|
135
|
-
|
135
|
+
num = params[:<%= plural_table_name %>].values.size
|
136
|
+
format.html { redirect_to <%= list_resources_path %>, :notice => (num == 1 ? I18n.t(:created, :model => I18n.t('models.<%= singular_table_name %>')) : I18n.t(:created_multiple, :model => "#{num} #{I18n.t('models.<%= plural_table_name %>')}") ) }
|
136
137
|
else
|
137
138
|
format.html { render :action => "copy" }
|
138
139
|
end
|
@@ -158,7 +159,8 @@ end
|
|
158
159
|
def update_multiple
|
159
160
|
respond_to do |format|
|
160
161
|
if <%= class_name %>.update(params[:<%= plural_table_name %>].keys, params[:<%= plural_table_name %>].values)
|
161
|
-
|
162
|
+
num = params[:<%= plural_table_name %>].values.size
|
163
|
+
format.html { redirect_to <%= list_resources_path %>, :notice => (num == 1 ? I18n.t(:updated, :model => I18n.t('models.<%= singular_table_name %>')) : I18n.t(:updated_multiple, :model => "#{num} #{I18n.t('models.<%= plural_table_name %>')}") ) }
|
162
164
|
else
|
163
165
|
format.html { render :action => "edit_multiple" }
|
164
166
|
end
|
@@ -209,8 +211,12 @@ end
|
|
209
211
|
respond_to do |format|
|
210
212
|
format.js
|
211
213
|
format.html do
|
214
|
+
num_ok = num_ko = 0
|
215
|
+
@results.each {|k, v| result, msg = v; result ? num_ok +=1 : num_ko +=1}
|
212
216
|
case @operation
|
213
217
|
when :destroy
|
218
|
+
flash[:notice] = (num_ok == 1 ? I18n.t(:deleted, :model => I18n.t('models.<%= singular_table_name %>')) : I18n.t(:deleted_multiple, :model => "#{num_ok} #{I18n.t('models.<%= plural_table_name %>')}") ) if num_ok > 0
|
219
|
+
flash[:error] = (num_ko == 1 ? I18n.t(:deleted_ko, :model => I18n.t('models.<%= singular_table_name %>')) : I18n.t(:deleted_multiple_ko, :model => "#{num_ko} #{I18n.t('models.<%= plural_table_name %>')}") ) if num_ko > 0
|
214
220
|
redirect_to <%= list_resources_path %> and return
|
215
221
|
when :edit
|
216
222
|
render :edit_multiple and return
|
@@ -1,11 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
<%-
|
3
|
-
items = []
|
4
|
-
attributes.each do |attribute|
|
5
|
-
items << " #{attribute_to_requests(attribute)}"
|
6
|
-
end
|
7
|
-
check_attr_to_have, check_attr_to_not_have = get_attr_to_match
|
8
|
-
-%>
|
2
|
+
<%- check_attr_to_have, check_attr_to_not_have = get_attr_to_match -%>
|
9
3
|
|
10
4
|
describe "<%= class_name.pluralize %>" do
|
11
5
|
describe "GET /<%= table_name %>" do
|
@@ -23,12 +17,106 @@ describe "<%= class_name.pluralize %>" do
|
|
23
17
|
<%= singular_table_name %> = Factory.build(:<%= singular_table_name %>)
|
24
18
|
visit <%= new_resource_path_test %>
|
25
19
|
<%= "login_view_as(:user_admin)" if authentication? %>
|
26
|
-
<%=
|
20
|
+
<%= fill_form_with_values.join(CRLF) %>
|
27
21
|
click_button "Create #{I18n.t('models.<%= singular_table_name %>')}"
|
28
22
|
#save_and_open_page #uncomment to debug
|
29
23
|
page.should have_content(I18n.t(:created, :model => I18n.t('models.<%= singular_table_name %>')))
|
30
24
|
page.should <%= check_attr_to_have %>
|
31
25
|
end
|
26
|
+
|
27
|
+
it "copy one <%= singular_table_name %>" do
|
28
|
+
<%= singular_table_name %> = Factory(:<%= singular_table_name %>)
|
29
|
+
visit <%= list_resources_path_test %>
|
30
|
+
<%= "login_view_as(:user_manager)" if authentication? -%>
|
31
|
+
#save_and_open_page #uncomment to debug
|
32
|
+
page.should <%= check_attr_to_have %>
|
33
|
+
assert page.find("#tr#{<%= singular_table_name %>.id}").visible?
|
34
|
+
check("check#{<%= singular_table_name %>.id}")
|
35
|
+
click_button I18n.t(:copy).upcase
|
36
|
+
page.should have_content(I18n.t('attributes.<%= singular_table_name %>.op_copy'))
|
37
|
+
<%= fill_form_with_values("#{plural_table_name}_#_name").join(CRLF) %>
|
38
|
+
click_button I18n.t(:submit)
|
39
|
+
page.should have_content(I18n.t(:created, :model => I18n.t('models.<%= singular_table_name %>')))
|
40
|
+
end
|
41
|
+
|
42
|
+
it "copy several <%= plural_table_name %>" do
|
43
|
+
<%= plural_table_name %> = FactoryGirl.create_list(:<%= singular_table_name %>, 2)
|
44
|
+
visit <%= list_resources_path_test %>
|
45
|
+
<%= "login_view_as(:user_manager)" if authentication? -%>
|
46
|
+
#save_and_open_page #uncomment to debug
|
47
|
+
<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
48
|
+
page.should <%= check_attr_to_have %>
|
49
|
+
assert page.find("#tr#{<%= singular_table_name %>.id}").visible?
|
50
|
+
check "check#{<%= singular_table_name %>.id}"
|
51
|
+
end
|
52
|
+
click_button I18n.t(:copy).upcase
|
53
|
+
page.should have_content(I18n.t('attributes.<%= singular_table_name %>.op_copy'))
|
54
|
+
<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
55
|
+
<%= fill_form_with_values("#{plural_table_name}_#_name").join(CRLF) %>
|
56
|
+
end
|
57
|
+
click_button I18n.t(:submit)
|
58
|
+
page.should have_content(I18n.t(:created_multiple, :model => "#{<%= plural_table_name %>.size} #{I18n.t('models.<%= plural_table_name %>')}"))
|
59
|
+
end
|
60
|
+
|
61
|
+
it "edit one <%= singular_table_name %>" do
|
62
|
+
<%= singular_table_name %> = Factory(:<%= singular_table_name %>)
|
63
|
+
visit <%= list_resources_path_test %>
|
64
|
+
<%= "login_view_as(:user_manager)" if authentication? -%>
|
65
|
+
#save_and_open_page #uncomment to debug
|
66
|
+
page.should <%= check_attr_to_have %>
|
67
|
+
assert page.find("#tr#{<%= singular_table_name %>.id}").visible?
|
68
|
+
check("check#{<%= singular_table_name %>.id}")
|
69
|
+
click_button I18n.t(:edit).upcase
|
70
|
+
page.should have_content(I18n.t('attributes.<%= singular_table_name %>.op_edit_multiple'))
|
71
|
+
<%= fill_form_with_values("#{plural_table_name}_#_name").join(CRLF) %>
|
72
|
+
click_button I18n.t(:submit)
|
73
|
+
page.should have_content(I18n.t(:updated, :model => I18n.t('models.<%= singular_table_name %>')))
|
74
|
+
end
|
75
|
+
|
76
|
+
it "edit several <%= plural_table_name %>" do
|
77
|
+
<%= plural_table_name %> = FactoryGirl.create_list(:<%= singular_table_name %>, 2)
|
78
|
+
visit <%= list_resources_path_test %>
|
79
|
+
<%= "login_view_as(:user_manager)" if authentication? -%>
|
80
|
+
#save_and_open_page #uncomment to debug
|
81
|
+
<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
82
|
+
page.should <%= check_attr_to_have %>
|
83
|
+
assert page.find("#tr#{<%= singular_table_name %>.id}").visible?
|
84
|
+
check "check#{<%= singular_table_name %>.id}"
|
85
|
+
end
|
86
|
+
click_button I18n.t(:edit).upcase
|
87
|
+
page.should have_content(I18n.t('attributes.<%= singular_table_name %>.op_edit_multiple'))
|
88
|
+
<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
89
|
+
<%= fill_form_with_values("#{plural_table_name}_#_name").join(CRLF) %>
|
90
|
+
end
|
91
|
+
click_button I18n.t(:submit)
|
92
|
+
page.should have_content(I18n.t(:updated_multiple, :model => "#{<%= plural_table_name %>.size} #{I18n.t('models.<%= plural_table_name %>')}"))
|
93
|
+
end
|
94
|
+
|
95
|
+
it "destroy one <%= singular_table_name %>" do
|
96
|
+
<%= singular_table_name %> = Factory(:<%= singular_table_name %>)
|
97
|
+
visit <%= list_resources_path_test %>
|
98
|
+
<%= "login_view_as(:user_manager)" if authentication? -%>
|
99
|
+
#save_and_open_page #uncomment to debug
|
100
|
+
page.should <%= check_attr_to_have %>
|
101
|
+
assert page.find("#tr#{<%= singular_table_name %>.id}").visible?
|
102
|
+
check("check#{<%= singular_table_name %>.id}")
|
103
|
+
click_button I18n.t(:destroy).upcase
|
104
|
+
page.should have_content(I18n.t(:deleted, :model => I18n.t('models.<%= singular_table_name %>')))
|
105
|
+
end
|
106
|
+
|
107
|
+
it "destroy several <%= plural_table_name %>" do
|
108
|
+
<%= plural_table_name %> = FactoryGirl.create_list(:<%= singular_table_name %>, 2)
|
109
|
+
visit <%= list_resources_path_test %>
|
110
|
+
<%= "login_view_as(:user_manager)" if authentication? -%>
|
111
|
+
#save_and_open_page #uncomment to debug
|
112
|
+
<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
113
|
+
page.should <%= check_attr_to_have %>
|
114
|
+
assert page.find("#tr#{<%= singular_table_name %>.id}").visible?
|
115
|
+
check "check#{<%= singular_table_name %>.id}"
|
116
|
+
end
|
117
|
+
click_button I18n.t(:destroy).upcase
|
118
|
+
page.should have_content(I18n.t(:deleted_multiple, :model => "#{<%= plural_table_name %>.size} #{I18n.t('models.<%= plural_table_name %>')}"))
|
119
|
+
end
|
32
120
|
end
|
33
121
|
|
34
122
|
describe "Check ajax /<%= plural_table_name %>" do
|
@@ -37,7 +125,7 @@ describe "<%= class_name.pluralize %>" do
|
|
37
125
|
visit <%= list_resources_path_test %>
|
38
126
|
<%= "login_view_as(:user_manager)" if authentication? %> #authentication
|
39
127
|
page.find("div#list").should <%= check_attr_to_have %>
|
40
|
-
click_link
|
128
|
+
click_link "#{<%= singular_table_name %>.id}"
|
41
129
|
page.find("div.ui-dialog").should <%= check_attr_to_have %> #checks if dialog is appeared
|
42
130
|
click_link "close" #close dialog
|
43
131
|
!page.find("div.ui-dialog").visible? #checks if dialog has been closed
|
@@ -168,7 +168,7 @@ describe <%= leospaced? ? (base_namespaces << controller_class_name).join('/').c
|
|
168
168
|
<%- if authorization? -%>
|
169
169
|
describe "without authorization" do
|
170
170
|
it "destroys the requested <%= ns_file_name %>" do
|
171
|
-
<%= "login_controller_as(:
|
171
|
+
<%= "login_controller_as(:user_guest)" if authentication? %>
|
172
172
|
<%= file_name %> = Factory(:<%= file_name %>)
|
173
173
|
expect {
|
174
174
|
delete :destroy, :id => <%= file_name %>.id.to_s<%= nested_params_http_request %>
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leonardo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 62196247
|
5
5
|
prerelease: 6
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 9
|
9
9
|
- 0
|
10
10
|
- beta
|
11
|
-
-
|
12
|
-
version: 1.9.0.
|
11
|
+
- 2
|
12
|
+
version: 1.9.0.beta2
|
13
13
|
platform: ruby
|
14
14
|
authors:
|
15
15
|
- Marco Mastrodonato
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2011-
|
20
|
+
date: 2011-12-09 00:00:00 Z
|
21
21
|
dependencies: []
|
22
22
|
|
23
23
|
description: A generator for creating Rails 3.1 applications ready to go. It generates the layout, the style, the internationalization and manage external gems for authentication, authorization and other. It also provides a customized scaffold to generates cool sites ajax ready in few minutes. If you find a bug please report to m.mastrodonato@gmail.com
|