hot-glue 0.5.7 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 542376a38c918a449ff542925f226deccdc53df8c538d01044ac1c48ecd62943
4
- data.tar.gz: 53f6afd924df425bb32ccd61b9d592a3d21e32ad8af4a71842d8c14539fe6fd0
3
+ metadata.gz: 14d86dc6800770982fbc2775311698b33f0e21180a3f3e8e6b0d8078dc304629
4
+ data.tar.gz: 8682fffd425887c274e016b382c374f95fde00fc7607ada565d590139adabc9d
5
5
  SHA512:
6
- metadata.gz: 7a3d4402f80c44ec09955aa53a4f9fae2c02567957d0f3f5b174a829728af5e0e57ea6add91fe974c5752eef67826cea3c5d0e1bac42bab8a838a49979f27b8e
7
- data.tar.gz: da590a33b01a00f798c6db36e2f68289284a2b886e2e92e34eb0dbfe538b515423c95d63732bdabe19c404323d78c88491238c9f591591abbc758bc4f068879d
6
+ metadata.gz: f142e3f8e048193ae628d446826dc9628ac37db747f25dbee38259f9ec7aee41b6ee91ded483065a28e80d777468b949e72b7021146a6812ee6e8ae58b0034bf
7
+ data.tar.gz: cfe2f196c675d6d89105e153b79f8712cb5a9543a64900eac06976705e7bb39dff688db6b0db93e9bc2871be852101790856b5ad526088ff344fed0c9b8c854c
data/.github/FUNDING.yml CHANGED
@@ -1 +1 @@
1
- custom: ["https://heliosdev.shop/p/hot-glue/","https://jfbcodes.com/p/hot-glue-in-depth-tutorial?utm_source=github.com&utm_campaign=github_hot_glue_repo_funding_link"]
1
+ custom: ["https://twitter.com/HotGlueForRails", "https://school.jasonfleetwoodboldt.com/8188?utm_source=github.com&utm_campaign=github_hot_glue_repo_funding_link"]
data/LICENSE CHANGED
@@ -1,10 +1,17 @@
1
- © 2022 Jason Fleetwood-Boldt. All Rights Reserved
2
- This software is 'fauxpen source,' which means you can think of it like 'free' as in speech but not 'free' as in beer....
3
1
 
4
- It is definitely 'free' as in Britney.
2
+
3
+ Copyright © 2022 Jason Fleetwood-Boldt. All Rights Reserved
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10
+
11
+
5
12
 
6
13
  TO PURCHASE A COMMERCIAL USAGE LICENSE PLEASE VISIT
7
14
  https://heliosdev.shop/hot-glue-license
8
15
 
9
- OR PURCHASE THE TUTORIAL (all purchases come with lifetime license)
10
- https://jfbcodes.com/p/hot-glue-in-depth-tutorial
16
+ OR PURCHASE THE TUTORIALS AT
17
+ https://school.jasonfleetwoodboldt.com/8188/?utm_source=github.com
data/README.md CHANGED
@@ -38,10 +38,10 @@ Other than the opinionated differences and additional features, Hot Glue produce
38
38
 
39
39
  # Get Hot Glue
40
40
 
41
- ## [GET THE COURSE TODAY](https://jfbcodes.com/courses/hot-glue-in-depth-tutorial/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page) **only $60 USD!**
41
+ ## [GET THE COURSE TODAY](https://school.jasonfleetwoodboldt.com/8188/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page) **only $60 USD!**
42
42
 
43
43
 
44
- [![Hot Glue Course](https://user-images.githubusercontent.com/59002/189544503-6edbcd40-1728-4b13-ac9a-c7772ccb8284.jpg)](https://jfbcodes.com/courses/hot-glue-in-depth-tutorial/?utm_source=github.com&utm_campaign=github_hot_glue_readme_page)
44
+ [![Hot Glue Course](https://user-images.githubusercontent.com/59002/189544503-6edbcd40-1728-4b13-ac9a-c7772ccb8284.jpg)](https://school.jasonfleetwoodboldt.com/8188?utm_source=github.com&utm_campaign=github_hot_glue_readme_page)
45
45
 
46
46
  ---
47
47
  ---
@@ -580,7 +580,7 @@ The short form looks like this. It presumes there is a 'pets' association from `
580
580
 
581
581
  (The long form equivalent of this would be `--hawk=pet_id{current_user.pets}`)
582
582
 
583
- This is covered in [Example #3 in the Hot Glue Tutorial](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38584014)
583
+ This is covered in [Example #3 in the Hot Glue Tutorial](https://school.jasonfleetwoodboldt.com/8188)
584
584
 
585
585
  To hawk to a scope that is not the currently authenticated user, use the long form with `{...}`
586
586
  to specify the scope. Be sure to note to add the association name itself, like `users`:
@@ -590,7 +590,7 @@ to specify the scope. Be sure to note to add the association name itself, like `
590
590
  This would hawk the Appointment's `user_id` key to any users who are within the scope of the
591
591
  current_user's has_many association (so, for any other "my" family, would be `current_user.family.users`).
592
592
 
593
- This is covered in [Example #4 in the Hot Glue Tutorial](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38787505)
593
+ This is covered in [Example #4 in the Hot Glue Tutorial](https://school.jasonfleetwoodboldt.com/8188)
594
594
 
595
595
 
596
596
  ### `--plural=`
@@ -774,7 +774,7 @@ The bang (`!`) methods can respond in one of four ways:
774
774
 
775
775
  This means you can be a somewhat lazy about your bang methods, but keep in mind the truth operator compares boolean true NOT any object is truth. So your return object must either be actually true (boolean), or an object that is string or string-like (responds to .to_s). Want to just say it didn’t work? Return false. Want to just say it was OK? Return true. Want to say it was successful but provide a more detailed response? Return a string.
776
776
 
777
- Finally, you can raise an ActiveRecord error which will also get passed to the user, but in the flash alert area
777
+ Finally, you can raise an ActiveRecord error which will also get passed to the user in the flash alert area.
778
778
 
779
779
  For more information see Example 5 in the Tutorial
780
780
 
@@ -956,6 +956,21 @@ Omits the heading of column names that appears above the 1st row of data.
956
956
 
957
957
  ## Special Features
958
958
 
959
+ ### `--alt-lookup-foreign-keys`
960
+
961
+ Allows you to specify that a foreign key should act as a search field, allowing the user to input a unique value (like an email) to search for a related record.
962
+
963
+ Example:
964
+ ```
965
+ --alt-foreign-key-lookup='agent_id{email+}'
966
+ ```
967
+
968
+ First, assume the current able has a `belongs_to` association for `agent_id` to a foreign model, `Agent`
969
+
970
+ Here, we would build a scaffold that would treat the foreign key `agent_id` as an alt lookup, allowing the user to search for foreign records by email (the agent's email).
971
+
972
+ The `+` symbol indicates to automatically make a new `agent` record (without it, the agent_id will be set to nil if there is no associated agent record found -- this may cause the update to fail, unless `optional: true` is on the belongs_to association.)
973
+
959
974
 
960
975
  ### `--factory-creation={ ... }`
961
976
 
@@ -999,6 +1014,20 @@ end
999
1014
  ```
1000
1015
 
1001
1016
 
1017
+ If you are using factory creation along with with alt lookups, be sure your factory code creates a local variable that follows this name
1018
+
1019
+ **<downcase association name>**_factory.<downcase association name>
1020
+
1021
+ Thus, your factory object must have a method of the same name as the factory being created which returns the thing that got created.
1022
+ (It can do the creation either on instantiation or when calling that method)
1023
+
1024
+ For example, assuming the example from above, we are going to do the lookup ourselves inside of our own `AgentFactory` object.)
1025
+
1026
+ ```
1027
+ agent_factory = AgentFactory.new(find_or_create_by_email: agent_company_params[:__lookup_email])
1028
+ ```
1029
+
1030
+
1002
1031
 
1003
1032
 
1004
1033
 
@@ -1082,6 +1111,47 @@ Now, your labels will show up as defined in the `_labels` ("Is Pending", etc) in
1082
1111
 
1083
1112
 
1084
1113
  # VERSION HISTORY
1114
+ #### 2023-03-01 - v0.5.8
1115
+
1116
+ • Fixes spec assertions for enums to work with the enum `_label` field (when provided).
1117
+
1118
+ • Fixes `--form-label-position` (before/after) so that a carriage return is placed between the label & field correctly for either choice
1119
+
1120
+ • All spec files are now created in `spec/features/` folder (previously was `spec/system/` with `type: :feature`; they no longer have `type: :feature` as this is not necessary when they are in the `spec/features` folder)
1121
+
1122
+ • Corrects the hawk scope to only add the plural related entity when NOT using the shorthand `{ ... }`
1123
+
1124
+ • BEM (block element modifier)-style has been added list headings, show cells, edit cells. These class names will get added to the `<div>` tags for both the heading and cells.
1125
+
1126
+ The format is as follows:
1127
+
1128
+ For headings
1129
+ `heading--{singular}--{field name}-{field name}-{field name}`
1130
+
1131
+ For cells:
1132
+ `cell--{singular}--{field name}-{field name}-{field name}`
1133
+ use this to globally style different fields by object & field name
1134
+
1135
+ Note that if you have multiple fields inside one cell (for example, with specified grouping or smart layout), your fields names get concatinated using single-hyphens:
1136
+ For example, consider a customer scaffold with a first name & last name appearing in one cell. The cell itself will have a class of:
1137
+ `cell--customer--first_name-last_name`
1138
+
1139
+ If your cell contains only one field, for example, a phone number, it would look like this:
1140
+ `cell--customer--phone_number`
1141
+
1142
+ Tip: Use the _ends with_ and _starts with_ selectors, which can be used like this:.
1143
+
1144
+ ```
1145
+ div[class$="--phone_number"] {
1146
+ text-decoration: underline;
1147
+ }
1148
+ ```
1149
+
1150
+
1151
+ ```
1152
+
1153
+ ```
1154
+
1085
1155
 
1086
1156
  #### 2023-02-13 - v0.5.7 - factory-creation, alt lookups, update show only, fixes to Enums, support for Ruby 3.2
1087
1157
  • See `--factory-creation` section.
@@ -1147,8 +1217,8 @@ License check has been removed (Hot Glue is now free to use for hobbyists and in
1147
1217
  #### 2022-03-23 - v0.5.2 - Hawked Foreign Keys
1148
1218
 
1149
1219
  - You can now protect your foreign keys from malicious input and also restrict the scope of drop downs to show only records with the specified access control restriction.
1150
- - [Example #3](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38584014) in the Hot Glue Tutorial shows you how to use the hawk to limit the scope to the logged in user.
1151
- - [Example #4](https://jfb.teachable.com/courses/hot-glue-in-depth-tutorial/lectures/38787505) in the Hot Glue Tutorial shows how to hawk to a non-usual scope, the inverse of the current user's belongs_to (that is, hawk the scope to X where current_user `belongs_to :x`)
1220
+ - [Example #3](https://school.jasonfleetwoodboldt.com/8188) in the Hot Glue Tutorial shows you how to use the hawk to limit the scope to the logged in user.
1221
+ - [Example #4](https://school.jasonfleetwoodboldt.com/8188) in the Hot Glue Tutorial shows how to hawk to a non-usual scope, the inverse of the current user's belongs_to (that is, hawk the scope to X where current_user `belongs_to :x`)
1152
1222
 
1153
1223
 
1154
1224
  #### 2022-03-12 - v0.5.1 - Inline List Labels
@@ -62,7 +62,6 @@ module HotGlue
62
62
  if smart_layout
63
63
  # automatic control
64
64
  #
65
- layout_object[:columns][:button_columns] = 2
66
65
 
67
66
  if columns.size > available_columns
68
67
  if available_columns == 0
@@ -1,10 +1,19 @@
1
1
  class LayoutStrategy::Bootstrap < LayoutStrategy::Base
2
- def button_classes
2
+ def button_classes # column classes
3
3
  " " + "col-sm-#{builder.layout_object[:columns][:button_columns]}"
4
4
  end
5
5
 
6
+ def button_applied_classes
7
+ "btn btn-sm"
8
+ end
9
+
10
+ def magic_button_classes
11
+ "btn-secondary"
12
+ end
13
+
14
+
6
15
  def column_classes_for_button_column
7
- "col-md-#{builder.layout_object[:columns][:button_columns]}"
16
+ "col-md-#{builder.layout_object[:buttons][:size]}"
8
17
  end
9
18
 
10
19
 
@@ -17,7 +26,7 @@ class LayoutStrategy::Bootstrap < LayoutStrategy::Base
17
26
  end
18
27
 
19
28
  def container_name
20
- "container-fluid"
29
+ "container"
21
30
  end
22
31
 
23
32
  def column_classes_for_line_fields
@@ -18,30 +18,27 @@ module HotGlue
18
18
 
19
19
  def magic_button_output(path:, singular:, magic_buttons:, small_buttons: )
20
20
  magic_buttons.collect{ |button_name|
21
- "<%= form_with model: #{singular}, url: #{path}, html: {style: 'display: inline', data: {\"turbo-confirm\": 'Are you sure you want to #{button_name} this #{singular}?'}} do |f| %>
22
- <%= f.hidden_field :#{button_name}, value: \"#{button_name}\" %>
23
- <%= f.submit '#{button_name.titleize}'.html_safe, disabled: (#{singular}.respond_to?(:#{button_name}able?) && ! #{singular}.#{button_name}able? ), class: '#{singular}-button btn btn-primary #{"btn-sm" if small_buttons}' %>
24
- <% end %>"
21
+ "<%= form_with model: #{singular}, url: #{path}, html: {style: 'display: inline', data: {\"turbo-confirm\": 'Are you sure you want to #{button_name} this #{singular}?'}} do |f| %>" +
22
+ "<%= f.hidden_field :__#{button_name}, value: \"__#{button_name}\" %>" +
23
+ "<%= f.submit '#{button_name.titleize}'.html_safe, disabled: (#{singular}.respond_to?(:#{button_name}able?) && ! #{singular}.#{button_name}able? ), class: '#{singular}-button #{@layout_strategy.button_applied_classes} #{@layout_strategy.magic_button_classes}' %>" +
24
+ "<% end %>"
25
25
  }.join("\n")
26
26
  end
27
27
 
28
- def list_column_headings(*args)
29
- @columns = args[0][:columns]
30
- @column_width = args[0][:column_width]
31
- @col_identifier = args[0][:col_identifier]
32
-
28
+ def list_column_headings(col_identifier: , columns: , column_width:, singular: )
33
29
  col_style = @layout_strategy.column_headings_col_style
34
30
 
35
31
  result = columns.map{ |column|
36
- "<div class='#{col_identifier}'" + col_style + ">" + column.map(&:to_s).map{|col_name| "#{col_name.humanize}"}.join("<br />") + "</div>"
32
+ "<div class='#{col_identifier}' heading--#{singular}--#{column.join("-")} " + col_style + ">" +
33
+ column.map(&:to_s).map{|col_name| "#{col_name.humanize}"}.join("<br />") + "</div>"
37
34
  }.join("\n")
38
35
  return result
39
36
  end
40
37
 
41
38
 
42
39
  ################################################################
43
-
44
40
  # THE FORM
41
+ ################################################################
45
42
 
46
43
  def all_form_fields(*args)
47
44
 
@@ -62,7 +59,7 @@ module HotGlue
62
59
  singular = @singular
63
60
 
64
61
  result = columns.map{ |column|
65
- " <div class='#{column_classes}' >" +
62
+ " <div class='#{column_classes} cell--#{singular}--#{column.join("-")}' >" +
66
63
  column.map { |col|
67
64
  type = eval("#{singular_class}.columns_hash['#{col}']").type
68
65
  limit = eval("#{singular_class}.columns_hash['#{col}']").limit
@@ -223,12 +220,13 @@ module HotGlue
223
220
  end
224
221
 
225
222
  def boolean_result(col)
226
- " <br />" +
223
+ (form_labels_position == 'before' ? " <br />" : "") +
227
224
  " <%= f.radio_button(:#{col}, '0', checked: #{singular}.#{col} ? '' : 'checked') %>\n" +
228
225
  " <%= f.label(:#{col}, value: 'No', for: '#{singular}_#{col}_0') %>\n" +
229
226
  " <%= f.radio_button(:#{col}, '1', checked: #{singular}.#{col} ? 'checked' : '') %>\n" +
230
227
  " <%= f.label(:#{col}, value: 'Yes', for: '#{singular}_#{col}_1') %>\n" +
231
- ""
228
+ (form_labels_position == 'after' ? " <br />" : "")
229
+
232
230
  end
233
231
 
234
232
  def enum_result(col)
@@ -273,10 +271,13 @@ module HotGlue
273
271
  style_with_flex_basis = @layout_strategy.style_with_flex_basis(perc_width)
274
272
 
275
273
  result = columns.map{ |column|
276
- "<div class='#{col_identifier}'#{style_with_flex_basis}>" +
274
+ "<div class='#{col_identifier} #{singular}--#{column.join("-")}'#{style_with_flex_basis}> " +
277
275
 
278
276
 
279
277
  column.map { |col|
278
+ if eval("#{singular_class}.columns_hash['#{col}']").nil?
279
+ raise "Can't find column '#{col}' on #{singular_class}, are you sure that is the column name?"
280
+ end
280
281
  type = eval("#{singular_class}.columns_hash['#{col}']").type
281
282
  limit = eval("#{singular_class}.columns_hash['#{col}']").limit
282
283
  sql_type = eval("#{singular_class}.columns_hash['#{col}']").sql_type
@@ -480,16 +480,19 @@ module HotGlue
480
480
 
481
481
 
482
482
  def creation_syntax
483
+
484
+ merge_with = @alt_lookups.collect{ |key, data|
485
+ "#{data[:assoc].downcase}: #{data[:assoc].downcase}_factory.#{data[:assoc].downcase}"
486
+ }.join(", ")
487
+
483
488
  if @factory_creation == ''
484
489
  "@#{singular_name } = #{ class_name }.create(modified_params)"
485
490
  else
486
491
  "#{@factory_creation}\n" +
487
- " @#{singular_name } = #{ class_name }.create(modified_params)"
492
+ " @#{singular_name } = #{ class_name }.create(modified_params#{'.merge(' + merge_with + ')' if !merge_with.empty?})"
488
493
  end
489
494
  end
490
-
491
-
492
-
495
+
493
496
  def setup_hawk_keys
494
497
  @hawk_keys = {}
495
498
 
@@ -507,7 +510,7 @@ module HotGlue
507
510
 
508
511
  hawk_scope = key.gsub("_id", "").pluralize
509
512
  @hawk_keys[key.to_sym] = [hawk_to]
510
- use_shorthand = !hawk_scope.include?("{")
513
+ use_shorthand = !options["hawk"].include?("{")
511
514
 
512
515
  if use_shorthand # only include the hawk scope if using the shorthand
513
516
  @hawk_keys[key.to_sym] << hawk_scope
@@ -638,7 +641,7 @@ module HotGlue
638
641
  end
639
642
 
640
643
  unless @no_specs
641
- dest_file = File.join("#{'spec/dummy/' if Rails.env.test?}spec/system#{namespace_with_dash}", "#{plural}_behavior_spec.rb")
644
+ dest_file = File.join("#{'spec/dummy/' if Rails.env.test?}spec/features#{namespace_with_dash}", "#{plural}_behavior_spec.rb")
642
645
 
643
646
  if File.exist?(dest_file)
644
647
  existing_file = File.open(dest_file)
@@ -684,7 +687,8 @@ module HotGlue
684
687
  @template_builder.list_column_headings(
685
688
  columns: @layout_object[:columns][:container],
686
689
  col_identifier: @layout_strategy.column_classes_for_column_headings,
687
- column_width: @layout_strategy.column_width
690
+ column_width: @layout_strategy.column_width,
691
+ singular: @singular
688
692
  )
689
693
  end
690
694
 
@@ -1259,7 +1263,7 @@ module HotGlue
1259
1263
 
1260
1264
  def controller_update_params_tap_away_magic_buttons
1261
1265
  @magic_buttons.collect{ |magic_button|
1262
- ".tap{ |ary| ary.delete('#{magic_button}') }"
1266
+ ".tap{ |ary| ary.delete('__#{magic_button}') }"
1263
1267
  }.join("")
1264
1268
  end
1265
1269
 
@@ -104,7 +104,9 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
104
104
  <% if @alt_lookups.filter{|key,d| ! @update_show_only.include?(key.to_sym) }.any? %><%= @alt_lookups.filter{|key,d| ! @update_show_only.include?(key.to_sym) }.collect{|key, data|
105
105
  " #{data[:assoc].downcase} = #{data[:assoc]}.#{data[:with_create] ? "find_or_create_by" : "find_by"}(#{data[:lookup_as]}: #{ singular_name }_params[:__lookup_#{data[:lookup_as]}])\n"
106
106
  }.join("\n") %><% end %> <% merge_lookups = @alt_lookups.filter{|key,d| ! @update_show_only.include?(key.to_sym) }.collect{|key, data| "#{key.gsub("_id", "")}: #{key.gsub("_id", "")}" }.join(",") %>
107
- modified_params = modify_date_inputs_on_params(<%= singular_name %>_params.dup<% if @object_owner_sym && eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>.merge!(<% if @object_owner_optional && any_nested? %><%= @object_owner_name %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}<% else %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)<% end %>)<%= controller_update_params_tap_away_alt_lookups %><%= ".merge(#{merge_lookups})" if !merge_lookups.empty? %>
107
+ <% @magic_buttons.each { |button| %>@<%= singular_name %>.<%= button %>! if <%= singular_name %>_params[:__<%= button %>]
108
+ <% } %>
109
+ modified_params = modify_date_inputs_on_params(<%= singular_name %>_params.dup<% if @object_owner_sym && eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %>.merge!(<% if @object_owner_optional && any_nested? %><%= @object_owner_name %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}<% else %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)<% end %>)<%= controller_update_params_tap_away_alt_lookups %><%= controller_update_params_tap_away_magic_buttons %><%= ".merge(#{merge_lookups})" if !merge_lookups.empty? %>
108
110
 
109
111
  <% if @hawk_keys.any? %> modified_params = hawk_params({<%= hawk_to_ruby %>}, modified_params)<% end %>
110
112
  <% if @alt_lookups.any? %><%= @alt_lookups.collect{|key, data|
@@ -136,7 +138,7 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
136
138
  end<% end %>
137
139
 
138
140
  def <%=singular_name%>_params
139
- params.require(:<%= testing_name %>).permit(<%= (fields_filtered_for_email_lookups - @show_only) + @magic_buttons.collect(&:to_sym) %>)
141
+ params.require(:<%= testing_name %>).permit(<%= (fields_filtered_for_email_lookups - @show_only) + @magic_buttons.collect{|x| "__#{x}".to_sym }%>)
140
142
  end
141
143
 
142
144
  def namespace
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe 'interaction for <%= controller_class_name %>', type: :feature do
3
+ describe 'interaction for <%= controller_class_name %>' do
4
4
  include HotGlue::ControllerHelper
5
5
  include ActionView::RecordIdentifier
6
6
 
@@ -72,9 +72,13 @@ describe 'interaction for <%= controller_class_name %>', type: :feature do
72
72
  when :uuid
73
73
  assoc_name = col.to_s.gsub('_id','')
74
74
  association = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
75
-
76
-
77
75
  " " + ["expect(page).to have_content(#{singular}#{1}.#{assoc_name}.#{HotGlue.derrive_reference_name(association.class_name)})"].join("\n ")
76
+ when :enum
77
+ if(eval("#{singular_class}.respond_to?(:#{col}_labels)"))
78
+ " " + "expect(page).to have_content(#{singular_class}.#{col}_labels[#{singular}#{1}.#{col}])"
79
+ else
80
+ " " + "expect(page).to have_content(new_#{col})"
81
+ end
78
82
 
79
83
  when :boolean
80
84
  " " + ["expect(page).to have_content(#{singular}#{1}.#{col} ? 'YES' : 'NO')"].join("\n ")
@@ -115,7 +119,12 @@ describe 'interaction for <%= controller_class_name %>', type: :feature do
115
119
 
116
120
  when :boolean
117
121
  ["expect(page).to have_content(#{singular}#{1}.#{col} ? 'YES' : 'NO')"].join("\n ")
118
-
122
+ when :enum
123
+ if(eval("#{singular_class}.respond_to?(:#{col}_labels)"))
124
+ "expect(page).to have_content(#{singular_class}.#{col}_labels[new_#{col}])"
125
+ else
126
+ "expect(page).to have_content(new_#{col})"
127
+ end
119
128
  else
120
129
  "expect(page).to have_content(new_#{col})"
121
130
  end
@@ -146,9 +155,10 @@ describe 'interaction for <%= controller_class_name %>', type: :feature do
146
155
  elsif type == :boolean
147
156
  ' expect(page).to have_content(new_' + col.to_s + ' ? "YES" : "NO")'
148
157
 
158
+ elsif type == :enum && eval("#{singular_class}.respond_to?(:#{col}_labels)")
159
+ " expect(page).to have_content(#{singular_class}.#{col}_labels[new_#{col}])"
149
160
  else
150
161
  ' expect(page).to have_content(new_' + col.to_s + ')'
151
-
152
162
  end
153
163
  }.compact.join("\n")
154
164
  %>
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.5.7'
3
+ CURRENT = '0.5.8'
4
4
  end
5
5
  end
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.5.7
4
+ version: 0.5.8
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: 2023-02-13 00:00:00.000000000 Z
11
+ date: 2023-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails