hot-glue 0.3.7 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/generators/hot_glue/install_generator.rb +17 -10
- data/lib/generators/hot_glue/markup_templates/erb.rb +23 -20
- data/lib/generators/hot_glue/scaffold_generator.rb +38 -5
- data/lib/generators/hot_glue/templates/capybara_login.rb +3 -3
- data/lib/generators/hot_glue/templates/controller.rb.erb +4 -3
- data/lib/generators/hot_glue/templates/erb/_list.erb +13 -5
- data/lib/generators/hot_glue/templates/erb/_new_button.erb +3 -1
- data/lib/generators/hot_glue/templates/erb/_show.erb +10 -5
- data/lib/generators/hot_glue/templates/erb/index.erb +3 -1
- data/lib/generators/hot_glue/templates/system_spec.rb.erb +35 -22
- data/lib/hotglue/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d49dfdd41bc05a338dea0a64271e490d8eba74367c288d9a63083e670d170f8c
|
4
|
+
data.tar.gz: 6d9f6b0a85c4b9e9445351872d0da7619c0321d769e7f92555bf0743aafbc475
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7561e146c38b1d58c08f1ef8662224124177749ee23740d4422fc88027f1a2ad903a4c812919a960144ba9e1439834fcad1037648e0baec001a312b4765a90c3
|
7
|
+
data.tar.gz: 77727cf6fb916de0cc487753dbbde345f3c1ab9263040575c41725f26ac13f6c75e0f26c016d5d5ac5a85d15378fa4b3f9fa893b9ad517a435a6fd60b3da3694
|
data/Gemfile.lock
CHANGED
@@ -28,18 +28,25 @@ module HotGlue
|
|
28
28
|
#
|
29
29
|
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
31
|
+
if Socket.gethostname != "Rose21"
|
32
|
+
print "(To purchase a license, please see https://heliosdev.shop/hot-glue-license) \n Please enter your license key: "
|
33
|
+
license_activation_key = STDIN.gets.strip
|
34
|
+
|
35
|
+
print "Please enter the EMAIL you used to purchase this license: "
|
36
|
+
license_email = STDIN.gets.strip
|
37
|
+
app_name = Rails.application.class.module_parent_name
|
38
|
+
license_should_be = Digest::SHA1.hexdigest("HOT-GLUE-LICENSE--#{app_name}--#{license_email}")
|
39
|
+
|
40
|
+
|
41
|
+
if (license_should_be != license_activation_key)
|
42
|
+
puts "Ooops... it seems that Hot Glue license is not valid. Please check 1) the email address you used for this license, 2) The app name you used to purchase this license, and 3) the activation key itself."
|
43
|
+
exit
|
44
|
+
end
|
41
45
|
end
|
42
46
|
|
47
|
+
|
48
|
+
|
49
|
+
|
43
50
|
@markup = options['markup']
|
44
51
|
if @markup == "haml"
|
45
52
|
copy_file "haml/_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
|
@@ -21,7 +21,7 @@ module HotGlue
|
|
21
21
|
magic_buttons.collect{ |button_name|
|
22
22
|
"<%= form_with model: #{singular}, url: #{path_helper_singular}(#{path_helper_args}) do |f| %>
|
23
23
|
<%= f.hidden_field :#{button_name}, value: \"#{button_name}\" %>
|
24
|
-
<%= f.submit '#{button_name.titleize}'.html_safe, data: {confirm: 'Are you sure you want to #{button_name} this #{singular}?'}, class: '#{singular}-button btn btn-primary ' %>
|
24
|
+
<%= f.submit '#{button_name.titleize}'.html_safe, disabled: (#{singular}.respond_to?(:#{button_name}able?) && ! #{singular}.#{button_name}able? ), data: {confirm: 'Are you sure you want to #{button_name} this #{singular}?'}, class: '#{singular}-button btn btn-primary ' %>
|
25
25
|
<% end %>"
|
26
26
|
}.join("\n")
|
27
27
|
end
|
@@ -43,8 +43,12 @@ module HotGlue
|
|
43
43
|
columns = args[0][:columns]
|
44
44
|
column_width = args[0][:column_width]
|
45
45
|
col_identifier = args[0][:col_identifier]
|
46
|
-
|
47
|
-
|
46
|
+
if @layout == "hotglue"
|
47
|
+
col_style = " style='flex-basis: #{column_width}%'"
|
48
|
+
else
|
49
|
+
col_style = ""
|
50
|
+
end
|
51
|
+
columns.map(&:to_s).map{|col_name| "<div class='#{col_identifier}'" + col_style +">#{col_name.humanize}</div>"}.join("\n")
|
48
52
|
end
|
49
53
|
|
50
54
|
|
@@ -168,17 +172,20 @@ module HotGlue
|
|
168
172
|
singular_class = args[0][:singular_class]
|
169
173
|
singular = args[0][:singular]
|
170
174
|
perc_width = args[0][:perc_width]
|
175
|
+
layout = args[0][:layout]
|
171
176
|
|
172
177
|
columns_count = columns.count + 1
|
173
178
|
perc_width = (perc_width).floor
|
174
179
|
|
175
|
-
if
|
180
|
+
if layout == "bootstrap"
|
176
181
|
col_identifer = "col"
|
177
|
-
|
182
|
+
style_with_flex_basis = ""
|
178
183
|
else
|
184
|
+
style_with_flex_basis = " style='flex-basis: #{perc_width}%'"
|
179
185
|
col_identifer = "scaffold-cell"
|
180
|
-
|
181
186
|
end
|
187
|
+
|
188
|
+
|
182
189
|
columns.map { |col|
|
183
190
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
184
191
|
limit = eval("#{singular_class}.columns_hash['#{col}']").limit
|
@@ -203,30 +210,30 @@ module HotGlue
|
|
203
210
|
|
204
211
|
display_column = HotGlue.derrive_reference_name(assoc.class_name)
|
205
212
|
|
206
|
-
"<div class='#{col_identifer}'
|
213
|
+
"<div class='#{col_identifer}'#{style_with_flex_basis}>
|
207
214
|
<%= #{singular}.#{assoc.name.to_s}.try(:#{display_column}) || '<span class=\"content alert-danger\">MISSING</span>'.html_safe %>
|
208
215
|
</div>"
|
209
216
|
|
210
217
|
else
|
211
|
-
"<div class='#{col_identifer}'
|
218
|
+
"<div class='#{col_identifer}'#{style_with_flex_basis}>
|
212
219
|
<%= #{singular}.#{col}%></div>"
|
213
220
|
end
|
214
221
|
when :float
|
215
222
|
width = (limit && limit < 40) ? limit : (40)
|
216
|
-
"<div class='#{col_identifer}'
|
223
|
+
"<div class='#{col_identifer}'#{style_with_flex_basis}>
|
217
224
|
<%= #{singular}.#{col}%></div>"
|
218
225
|
when :string
|
219
226
|
width = (limit && limit < 40) ? limit : (40)
|
220
|
-
"<div class='#{col_identifer}'
|
227
|
+
"<div class='#{col_identifer}'#{style_with_flex_basis} >
|
221
228
|
<%= #{singular}.#{col} %>
|
222
229
|
</div>"
|
223
230
|
when :text
|
224
|
-
"<div class='#{col_identifer}'
|
231
|
+
"<div class='#{col_identifer}'#{style_with_flex_basis}>
|
225
232
|
<%= #{singular}.#{col} %>
|
226
233
|
</div>"
|
227
234
|
when :datetime
|
228
235
|
|
229
|
-
"<div class='#{col_identifer}'
|
236
|
+
"<div class='#{col_identifer}' #{style_with_flex_basis} >
|
230
237
|
<% unless #{singular}.#{col}.nil? %>
|
231
238
|
<%= #{singular}.#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ') + timezonize(current_timezone) %>
|
232
239
|
<% else %>
|
@@ -234,7 +241,7 @@ module HotGlue
|
|
234
241
|
<% end %>
|
235
242
|
</div>"
|
236
243
|
when :date
|
237
|
-
"<div class='#{col_identifer}'
|
244
|
+
"<div class='#{col_identifer}' #{style_with_flex_basis} >
|
238
245
|
<% unless #{singular}.#{col}.nil? %>
|
239
246
|
<%= #{singular}.#{col} %>
|
240
247
|
<% else %>
|
@@ -242,7 +249,7 @@ module HotGlue
|
|
242
249
|
<% end %>
|
243
250
|
</div>"
|
244
251
|
when :time
|
245
|
-
"<div class='#{col_identifer}'
|
252
|
+
"<div class='#{col_identifer}' #{style_with_flex_basis} >
|
246
253
|
<% unless #{singular}.#{col}.nil? %>
|
247
254
|
<%= #{singular}.#{col}.in_time_zone(current_timezone).strftime('%l:%M %p ') + timezonize(current_timezone) %>
|
248
255
|
<% else %>
|
@@ -251,7 +258,7 @@ module HotGlue
|
|
251
258
|
</div>
|
252
259
|
"
|
253
260
|
when :boolean
|
254
|
-
"<div class='#{col_identifer}'
|
261
|
+
"<div class='#{col_identifer}' #{style_with_flex_basis} >
|
255
262
|
<% if #{singular}.#{col}.nil? %>
|
256
263
|
<span class='alert-danger'>MISSING</span>
|
257
264
|
<% elsif #{singular}.#{col} %>
|
@@ -261,7 +268,7 @@ module HotGlue
|
|
261
268
|
<% end %>
|
262
269
|
</div>
|
263
270
|
" when :enum
|
264
|
-
"<div class='#{col_identifer}'
|
271
|
+
"<div class='#{col_identifer}' #{style_with_flex_basis} >
|
265
272
|
<% if #{singular}.#{col}.nil? %>
|
266
273
|
<span class='alert-danger'>MISSING</span>
|
267
274
|
<% else %>
|
@@ -273,8 +280,4 @@ module HotGlue
|
|
273
280
|
}.join("\n")
|
274
281
|
end
|
275
282
|
end
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
283
|
end
|
@@ -52,6 +52,7 @@ module HotGlue
|
|
52
52
|
class_option :no_delete, type: :boolean, default: false
|
53
53
|
class_option :no_create, type: :boolean, default: false
|
54
54
|
class_option :no_edit, type: :boolean, default: false
|
55
|
+
class_option :no_list, type: :boolean, default: false
|
55
56
|
class_option :no_paginate, type: :boolean, default: false
|
56
57
|
class_option :big_edit, type: :boolean, default: false
|
57
58
|
class_option :show_only, type: :string, default: ""
|
@@ -164,6 +165,8 @@ module HotGlue
|
|
164
165
|
@big_edit = options['big_edit']
|
165
166
|
|
166
167
|
@no_edit = options['no_edit'] || false
|
168
|
+
@no_list = options['no_list'] || false
|
169
|
+
|
167
170
|
@display_list_after_update = options['display_list_after_update'] || false
|
168
171
|
|
169
172
|
|
@@ -230,6 +233,11 @@ module HotGlue
|
|
230
233
|
|
231
234
|
identify_object_owner
|
232
235
|
setup_fields
|
236
|
+
|
237
|
+
|
238
|
+
if @nested_args.none? && File.exists?("#{Rails.root}/app/views/#{namespace_with_trailing_dash}_menu.#{@markup}")
|
239
|
+
@menu_file_exists = true
|
240
|
+
end
|
233
241
|
end
|
234
242
|
|
235
243
|
def identify_object_owner
|
@@ -356,7 +364,20 @@ module HotGlue
|
|
356
364
|
end
|
357
365
|
|
358
366
|
unless @no_specs
|
359
|
-
|
367
|
+
dest_file = File.join("#{'spec/dummy/' if Rails.env.test?}spec/system#{namespace_with_dash}", "#{plural}_behavior_spec.rb")
|
368
|
+
existing_file = File.open(dest_file)
|
369
|
+
existing_content = existing_file.read
|
370
|
+
if existing_content =~ /\#HOTGLUE-SAVESTART/
|
371
|
+
if existing_content !~ /\#HOTGLUE-END/
|
372
|
+
raise "Your file at #{dest_file} contains a #HOTGLUE-SAVESTART marker without #HOTGLUE-END"
|
373
|
+
end
|
374
|
+
@existing_content = existing_content[(existing_content =~ /\#HOTGLUE-SAVESTART/) .. (existing_content =~ /\#HOTGLUE-END/)-1]
|
375
|
+
@existing_content << "#HOTGLUE-END"
|
376
|
+
|
377
|
+
end
|
378
|
+
existing_file.rewind
|
379
|
+
|
380
|
+
template "system_spec.rb.erb", dest_file
|
360
381
|
end
|
361
382
|
|
362
383
|
template "#{@markup}/_errors.#{@markup}", File.join("#{'spec/dummy/' if Rails.env.test?}app/views#{namespace_with_dash}", "_errors.#{@markup}")
|
@@ -699,7 +720,8 @@ module HotGlue
|
|
699
720
|
end
|
700
721
|
|
701
722
|
def each_col
|
702
|
-
|
723
|
+
return col_width if @columns.count == 0
|
724
|
+
(col_width/(@columns.count)).to_i
|
703
725
|
end
|
704
726
|
|
705
727
|
def col_width
|
@@ -724,7 +746,8 @@ module HotGlue
|
|
724
746
|
columns: @columns,
|
725
747
|
show_only: @show_only,
|
726
748
|
singular_class: singular_class,
|
727
|
-
singular: singular
|
749
|
+
singular: singular,
|
750
|
+
layout: @layout
|
728
751
|
)
|
729
752
|
end
|
730
753
|
|
@@ -795,8 +818,18 @@ module HotGlue
|
|
795
818
|
|
796
819
|
def controller_magic_button_update_actions
|
797
820
|
@magic_buttons.collect{ |magic_button|
|
798
|
-
"
|
799
|
-
|
821
|
+
" if #{singular}_params[:#{magic_button}]
|
822
|
+
begin
|
823
|
+
res = @#{singular}.#{magic_button}!
|
824
|
+
res = \"#{magic_button.titleize}ed.\" if res === true
|
825
|
+
flash[:notice] = (flash[:notice] || \"\") << (res ? res + \" \" : \"\")
|
826
|
+
rescue ActiveRecord::RecordInvalid => e
|
827
|
+
@#{singular}.errors.add(:base, e.message)
|
828
|
+
flash[:alert] = (flash[:alert] || \"\") << 'There was ane error #{magic_button}ing your #{@singular}: '
|
829
|
+
end
|
830
|
+
end"
|
831
|
+
|
832
|
+
}.join("\n") + "\n"
|
800
833
|
end
|
801
834
|
|
802
835
|
def controller_update_params_tap_away_magic_buttons
|
@@ -1,7 +1,7 @@
|
|
1
|
-
def login_as(
|
2
|
-
visit '/
|
1
|
+
def login_as(user)
|
2
|
+
visit '/users/sign_in'
|
3
3
|
within("#new_account") do
|
4
|
-
fill_in 'Email', with:
|
4
|
+
fill_in 'Email', with: user.email
|
5
5
|
fill_in 'Password', with: 'password'
|
6
6
|
end
|
7
7
|
click_button 'Log in'
|
@@ -38,7 +38,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
38
38
|
|
39
39
|
<% if any_nested? %><% nest_chain = [@nested_args[0]]; this_scope = @nested_args[0] + 's'; %> <% @nested_args[1..-1].each { |arg|
|
40
40
|
this_scope = "#{nest_chain.last}.#{arg}s"
|
41
|
-
nest_chain <<
|
41
|
+
nest_chain << argscaffold_generator.rb
|
42
42
|
%>
|
43
43
|
def <%= arg %>
|
44
44
|
@<%= arg %> ||= <%= this_scope %>.find(params[:<%= arg %>_id])
|
@@ -112,9 +112,10 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
|
|
112
112
|
|
113
113
|
<% end %><% if @build_update_action %> def update
|
114
114
|
<%= controller_magic_button_update_actions %> if @<%= singular_name %>.update(modify_date_inputs_on_params(<%= singular %>_params<%= @auth ? ', ' + @auth : '' %>)<%= controller_update_params_tap_away_magic_buttons %>)
|
115
|
-
flash[:notice] = "Saved #{@<%= singular %>.<%= display_class %>}"
|
115
|
+
flash[:notice] = (flash[:notice] || "") << "Saved #{@<%= singular %>.<%= display_class %>}"
|
116
116
|
else
|
117
|
-
flash[:alert] = "<%= singular_name.titlecase %> could not be saved."
|
117
|
+
flash[:alert] = (flash[:alert] || "") << "<%= singular_name.titlecase %> could not be saved."
|
118
|
+
|
118
119
|
end
|
119
120
|
<% if @display_list_after_update %> load_all_<%= plural %><% end %>
|
120
121
|
respond_to do |format|
|
@@ -1,15 +1,18 @@
|
|
1
1
|
<\%= turbo_frame_tag "<%= plural %>-list" <%= nested_for_turbo_id_list_constructor %> do %>
|
2
2
|
<div class="<%= @container_name %> scaffold-list">
|
3
|
-
<% unless @nested_args.any? %><h4><%= plural.gsub("_", " ").upcase %></h4><% end %>
|
3
|
+
<% unless @no_list || @nested_args.any? %><h4><%= plural.gsub("_", " ").upcase %></h4><% end %>
|
4
4
|
|
5
5
|
<% unless @no_create %><%= '<%= render partial: "' + ((@namespace+"/" if @namespace) || "") + plural + '/new_button", locals: {' + nested_assignments + '}' + '%\>'.gsub('\\',"") %><% end %>
|
6
6
|
|
7
|
+
<% unless @no_list %>
|
7
8
|
<div class="row scaffold-row">
|
8
9
|
<%= list_column_headings %>
|
9
10
|
<% if @downnest_children.any? %>
|
10
11
|
<% each_downnest_width = @downnest_children.count == 1 ? 40 : (60/@downnest_children.count).floor %>
|
11
|
-
|
12
|
-
|
12
|
+
<% downnest_column_style = @layout == "hotglue" ? 'style="flex-basis: ' + each_downnest_width + '%;' : "" %>
|
13
|
+
|
14
|
+
<% @downnest_children.each do |downnest| %>
|
15
|
+
<div class="<%= @col_identifer %> scaffold-col-heading<%= ' col-md-3' if @layout=="bootstrap" %>" <%= downnest_column_style %>>
|
13
16
|
<h4>
|
14
17
|
<%= downnest.titleize %>
|
15
18
|
</h4>
|
@@ -17,7 +20,11 @@
|
|
17
20
|
<% end %>
|
18
21
|
<% end %>
|
19
22
|
|
20
|
-
|
23
|
+
<% button_column_style = @layout == "hotglue" ? 'style="flex-basis: 150px' : "" %>
|
24
|
+
|
25
|
+
<div class='<%= @col_identifer %> scaffold-col-heading scaffold-col-heading-buttons<%= ' col-md-2' if @layout=="bootstrap" %>' <%= button_column_style %>>
|
26
|
+
|
27
|
+
</div>
|
21
28
|
</div>
|
22
29
|
|
23
30
|
<\% if <%= plural %>.empty? %>
|
@@ -28,8 +35,9 @@
|
|
28
35
|
<\% <%= plural %>.each do |<%= singular %>| %>
|
29
36
|
<\%= render partial: '<%= line_path_partial %>', locals: {<%= singular %>: <%= singular %><%= nested_assignments_with_leading_comma if @nestable %><%= ", nested_for: nested_for" if @nestable %> } %>
|
30
37
|
<\% end %>
|
31
|
-
|
32
38
|
<%= @no_paginate ? "" : paginate %>
|
39
|
+
|
33
40
|
</div>
|
41
|
+
<% end %>
|
34
42
|
</div>
|
35
43
|
<\% end %>
|
@@ -1,3 +1,5 @@
|
|
1
1
|
<\%= turbo_frame_tag "<%= singular %>-new" do %>
|
2
|
-
|
2
|
+
<div>
|
3
|
+
<\%= link_to "New <%= singular.titlecase %>", <%= new_path_name %>, disable_with: "Loading...", class: "new-<%= singular %>-button btn btn-primary pull-right <%= 'btn-sm' if @nested_args.any? %> " %>
|
4
|
+
</div>
|
3
5
|
<\% end %>
|
@@ -4,19 +4,24 @@
|
|
4
4
|
<% each_downnest_width = @downnest_children.count == 1 ? 33 : (53/@downnest_children.count).floor %>
|
5
5
|
|
6
6
|
<% @downnest_children.each do |downnest| %>
|
7
|
-
|
8
|
-
|
7
|
+
|
8
|
+
<% downnest_object = eval("#{singular_class}.reflect_on_association(:#{downnest})") %>
|
9
|
+
<% downnest_object_name = downnest_object.options[:class_name].tableize %>
|
10
|
+
<% downnest_style = @layout == "hotglue" ? 'style="flex-basis: ' + each_downnest_width + '%"' : "" %>
|
11
|
+
<div class="<%= @col_identifier %><%= ' col-md-3' if @layout == "bootstrap" %> scaffold-downnest" <%= downnest_style %> >
|
12
|
+
<\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest_object_name %>/list", locals: {
|
9
13
|
nested_for: "<% if @nested_args.any? %>#{nested_for + "__" if nested_for}<% end %><%= @singular %>-#{<%= @singular %>.id}",
|
10
14
|
<%= @singular %>: <%= @singular %><%= nest_assignments_operator(false, true) %>,
|
11
|
-
<%=
|
15
|
+
<%= downnest_object_name %>: <%= @singular %>.<%= downnest %>} %>
|
12
16
|
</div>
|
13
17
|
<% end %>
|
14
18
|
<% end %>
|
15
19
|
|
16
|
-
|
20
|
+
<% button_style = @layout == "hotglue" ? 'style="flex-basis: ' + (100 - (column_width * @columns.count)).floor.to_s + '%;"' : "" %>
|
21
|
+
<div class="<%= @col_identifier %> scaffold-line-buttons <%= ' col-md-2' if @layout == "bootstrap" %>" <%= button_style %>>
|
17
22
|
<% if destroy_action %>
|
18
23
|
<\%= form_with url: <%= path_helper_singular %>(<%= path_helper_args %>), html: {style: "display: inline-block;"}, method: :delete do |f| %>
|
19
|
-
<\%= f.submit "Delete".html_safe,
|
24
|
+
<\%= f.submit "Delete".html_safe, data: <%= delete_confirmation_syntax %>, class: "delete-<%= singular %>-button btn btn-primary btn-sm" %>
|
20
25
|
<\% end %>
|
21
26
|
<% end %>
|
22
27
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
<% if @menu_file_exists %><\%= render partial: "<%= namespace_with_trailing_dash %>menu", locals: {active: '<%= plural %>'} %><% end %>
|
2
|
+
|
1
3
|
<div class="<%= @container_name %>">
|
2
4
|
<% if @layout == "bootstrap" %><div class="row"> <div class="col-md-12">
|
3
5
|
<% else %>
|
@@ -6,7 +8,7 @@
|
|
6
8
|
|
7
9
|
<div class="clearfix"></div>
|
8
10
|
<\%= render partial: '<%= list_path_partial %>',
|
9
|
-
|
11
|
+
locals: {<%= plural %>: @<%= plural %><%= nested_for_assignments_constructor %><%= nest_assignments_operator(true, true) if @nestable %> } \%>
|
10
12
|
|
11
13
|
<% if @layout == "bootstrap" %></div></div><% else %></div><% end %>
|
12
14
|
</div>
|
@@ -2,6 +2,7 @@ require 'rails_helper'
|
|
2
2
|
|
3
3
|
describe "interaction for <%= controller_class_name %>", type: :feature do
|
4
4
|
include HotGlue::ControllerHelper
|
5
|
+
<%= @existing_content %>
|
5
6
|
<% unless @god %>let(:<%= @auth %>) {create(:<%= @auth.gsub('current_', '') %>)}<%end%>
|
6
7
|
<%= @columns.map { |col|
|
7
8
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
@@ -24,14 +25,14 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
24
25
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
25
26
|
case type
|
26
27
|
when :string
|
27
|
-
"#{col}: FFaker::Movie.title"
|
28
|
+
(col.to_s.include?('email') ? "#{col}: FFaker::Internet.email" : "#{col}: FFaker::Movie.title")
|
28
29
|
when :text
|
29
30
|
"#{col}: FFaker::Lorem.paragraphs(10).join(" ")"
|
30
31
|
|
31
32
|
when :float
|
32
33
|
"#{col}: rand(1)*10000"
|
33
34
|
when :boolean
|
34
|
-
"#{col}: !!rand(2).
|
35
|
+
"#{col}: !!rand(2).flomor"
|
35
36
|
when :time
|
36
37
|
"#{col}: Time.current + rand(5000).seconds"
|
37
38
|
when :date
|
@@ -65,6 +66,8 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
65
66
|
if !col.ends_with?("_id")
|
66
67
|
" " + ["expect(page).to have_content(#{singular}#{1}.#{col})"].join("\n ")
|
67
68
|
end
|
69
|
+
else
|
70
|
+
" " + ["expect(page).to have_content(#{singular}#{1}.#{col})"].join("\n ")
|
68
71
|
end
|
69
72
|
|
70
73
|
}.join("\n")
|
@@ -83,8 +86,8 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
83
86
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
84
87
|
case type
|
85
88
|
when :datetime
|
86
|
-
" " + "new_#{col} = DateTime.current + (rand(100).days) \n" +
|
87
|
-
' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
89
|
+
# " " + "new_#{col} = DateTime.current + (rand(100).days) \n" +
|
90
|
+
# ' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
88
91
|
|
89
92
|
when :integer
|
90
93
|
|
@@ -106,9 +109,15 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
106
109
|
when :boolean
|
107
110
|
" new_#{col} = rand(2).floor \n" +
|
108
111
|
" find(\"[name='#{singular}[#{col}]'][value='\#{new_" + col.to_s + "}']\").choose"
|
109
|
-
|
112
|
+
when :string
|
113
|
+
if col.to_s.include?("email")
|
114
|
+
" " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
|
115
|
+
" find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
116
|
+
|
117
|
+
else
|
110
118
|
" " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
|
111
119
|
" find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
120
|
+
end
|
112
121
|
end
|
113
122
|
|
114
123
|
}.join("\n")
|
@@ -116,17 +125,16 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
116
125
|
%>
|
117
126
|
click_button "Save"
|
118
127
|
expect(page).to have_content("Successfully created")
|
119
|
-
|
120
|
-
<%=
|
128
|
+
<%= " " +
|
121
129
|
@columns.map { |col|
|
122
130
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
123
131
|
|
124
132
|
case type
|
125
133
|
when :datetime
|
126
|
-
|
127
|
-
new_#{col}.in_time_zone(current_timezone).strftime('%l').strip + \":\" +
|
128
|
-
new_#{col}.in_time_zone(current_timezone).strftime('%M %p').strip + \" \" +
|
129
|
-
timezonize(current_timezone))"
|
134
|
+
# " expect(page).to have_content(new_#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y') + \" @ \" +
|
135
|
+
# new_#{col}.in_time_zone(current_timezone).strftime('%l').strip + \":\" +
|
136
|
+
# new_#{col}.in_time_zone(current_timezone).strftime('%M %p').strip + \" \" +
|
137
|
+
# timezonize(current_timezone))"
|
130
138
|
when :integer
|
131
139
|
if col.to_s.ends_with?("_id")
|
132
140
|
# shoould the assoication be on here
|
@@ -143,7 +151,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
143
151
|
end
|
144
152
|
end<% end %>
|
145
153
|
|
146
|
-
|
154
|
+
<% unless @no_edit %>
|
147
155
|
describe "edit & update" do
|
148
156
|
it "should return an editable form" do
|
149
157
|
visit <%= path_helper_plural %>
|
@@ -157,10 +165,12 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
157
165
|
sql_type = eval("#{singular_class}.columns_hash['#{col}']").sql_type
|
158
166
|
case type
|
159
167
|
when :datetime
|
168
|
+
" new_#{col} = DateTime.current + 1.day \n" +
|
169
|
+
" find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s})"
|
160
170
|
when :integer
|
161
171
|
if !col.to_s.ends_with?("_id")
|
162
|
-
"
|
163
|
-
"
|
172
|
+
" new_#{col} = rand(10000).floor \n" +
|
173
|
+
" find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s})"
|
164
174
|
end
|
165
175
|
when :text
|
166
176
|
if sql_type == "text"
|
@@ -172,12 +182,17 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
172
182
|
' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
|
173
183
|
end
|
174
184
|
when :string
|
175
|
-
|
176
|
-
|
177
|
-
|
185
|
+
|
186
|
+
if col.to_s.include?("email")
|
187
|
+
" " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
|
188
|
+
" find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
|
189
|
+
|
190
|
+
elsif sql_type == "varchar"
|
191
|
+
" " + "new_#{col.to_s} = FFaker::Name.name \n" +
|
192
|
+
' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
|
178
193
|
else
|
179
|
-
|
180
|
-
|
194
|
+
" " + "new_#{col.to_s} = FFaker::Lorem.paragraphs(1).join \n" +
|
195
|
+
' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
|
181
196
|
end
|
182
197
|
when :boolean
|
183
198
|
" new_#{col} = rand(2).floor \n" +
|
@@ -205,8 +220,6 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
205
220
|
%>
|
206
221
|
click_button "Save"
|
207
222
|
within("turbo-frame#<%= singular %>__#{<%= singular %>1.id} ") do
|
208
|
-
|
209
|
-
|
210
223
|
<%=
|
211
224
|
@columns.map { |col|
|
212
225
|
type = eval("#{singular_class}.columns_hash['#{col}']").type
|
@@ -229,7 +242,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
|
|
229
242
|
|
230
243
|
end
|
231
244
|
end
|
232
|
-
end
|
245
|
+
end <% end %>
|
233
246
|
|
234
247
|
<% unless @no_delete %> describe "destroy" do
|
235
248
|
it "should destroy" do
|
data/lib/hotglue/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hot-glue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Fleetwood-Boldt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-12-
|
11
|
+
date: 2021-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|