hot-glue 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,8 +5,8 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
5
5
  helper :hot_glue
6
6
  include HotGlue::ControllerHelper
7
7
 
8
- <% unless @auth_identifier == '' || @god %>before_action :<%= auth_root %><% end %>
9
- <% if any_nested? %><% nest_chain = [] %> <% @nested_set.each { |arg|
8
+ <% unless @auth_identifier == '' || @god %>before_action :<%= auth_root %><% end %><% if any_nested? %>
9
+ <% nest_chain = [] %> <% @nested_set.each { |arg|
10
10
 
11
11
  if auth_identifier == arg[:singular]
12
12
  this_scope = auth_object
@@ -17,13 +17,10 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
17
17
  end
18
18
 
19
19
  nest_chain << arg %>
20
- before_action :<%= arg[:singular] %><%= ", if: -> { params.include?(:#{arg[:singular]}_id) }" if arg[:optional] %>
21
-
22
- <% } %><% end %>
20
+ before_action :<%= arg[:singular] %><%= ", if: -> { params.include?(:#{arg[:singular]}_id) }" if arg[:optional] %><% } %><% end %>
23
21
  before_action :load_<%= singular_name %>, only: [:show, :edit, :update, :destroy]
24
- after_action -> { flash.discard }, if: -> { request.format.symbol == :turbo_stream }
25
- <% if @nested_set.any? %>
26
- def <%= @nested_set[0][:singular] %><% if @god
22
+ after_action -> { flash.discard }, if: -> { request.format.symbol == :turbo_stream }
23
+ <% if @nested_set.any? %>def <%= @nested_set[0][:singular] %><% if @god
27
24
  next_object = nil
28
25
  collect_objects = @nested_set.reverse.collect {|x|
29
26
  if eval("#{next_object || class_name}.reflect_on_association(:#{x[:singular]})").nil?
@@ -39,9 +36,10 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
39
36
  root_object = @auth + "." + @nested_set[0][:plural]
40
37
  end
41
38
  end
42
- %>
43
- <% if !@god && @nested_set[0][:singular] == @auth_identifier %>@<%= @nested_set[0][:singular] %> ||= <%= root_object %>
44
- <% else %> @<%= @nested_set[0][:singular] %> ||= <%= root_object %>.find(params[:<%= @nested_set[0][:singular] %>_id])<%= " if params.include?(:#{@nested_set[0][:singular]}_id)" if @nested_set[0][:optional] %> <% end %>
39
+ %><% if !@god && @nested_set[0][:singular] == @auth_identifier %>
40
+ @<%= @nested_set[0][:singular] %> ||= <%= root_object %>
41
+ <% else %>
42
+ @<%= @nested_set[0][:singular] %> ||= <%= root_object %>.find(params[:<%= @nested_set[0][:singular] %>_id])<%= " if params.include?(:#{@nested_set[0][:singular]}_id)" if @nested_set[0][:optional] %> <% end %>
45
43
  end
46
44
  <% end %><% if any_nested? %><% nest_chain = [@nested_set[0][:singular]]; this_scope = @nested_set[0][:plural]; %>
47
45
  <% for index in 0..(@nested_set.count - 1) do
@@ -54,18 +52,18 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
54
52
  def <%= arg[:singular] %>
55
53
  @<%= arg[:singular] %> ||= (<%= this_scope %>.find(params[:<%= arg[:singular] %>_id])<%= " if params.include?(:#{last_arg[:singular]}_id)" if last_arg && @god && last_arg[:optional] %>)
56
54
  <% if @god && last_arg && (last_arg[:optional] ) %>@<%= arg[:singular] %> ||= (<%= collect_objects[index-1] %>.find(params[:<%= arg[:singular] %>_id]) if params.include?(:<%= arg[:singular] %>_id) ) <% end %>
57
- end<% end %>
58
- <% end %><% end %> <% if !@self_auth %>
55
+ end<% end %><% end %><% end %> <% if !@self_auth %>
59
56
  def load_<%= singular_name %>
60
- @<%= singular_name %> = (<%= object_scope.gsub("@",'') %>.find(params[:id])<%= " if params.include?(:#{@nested_set.last[:singular]}_id)" if @nested_set[0] && @nested_set[0][:optional] %>)<% if @nested_set[0] && @nested_set[0][:optional] %> || <%= class_name %>.find(params[:id])<% end %>
57
+ @<%= singular_name %> = <%= object_scope.gsub("@",'') %>.find(params[:id])<%= " if params.include?(:#{@nested_set.last[:singular]}_id)" if @nested_set[0] && @nested_set[0][:optional] %><% if @nested_set[0] && @nested_set[0][:optional] %> || <%= class_name %>.find(params[:id])<% end %>
61
58
  end
62
59
  <% else %>
63
60
  def load_<%= singular_name %>
64
61
  @<%= singular_name %> = (<%= auth_object.gsub("@",'') %><%= " if params.include?(:#{@nested_set[0][:singular]}_id)" if @nested_set.any? && @nested_set[0][:optional] %>)<% if @nested_set.any? && @nested_set[0][:optional] %> || <%= class_name %>.find(params[:id])<% end %>
65
62
  end<% end %>
66
63
 
67
- def load_all_<%= plural %> <% if !@self_auth %>
68
- @<%= plural_name %> = ( <%= object_scope.gsub("@",'') %>.page(params[:page])<%= n_plus_one_includes %><%= " if params.include?(:#{ @nested_set.last[:singular]}_id)" if @nested_set.any? && @nested_set[0] && @nested_set[0][:optional] %>) <% if @nested_set[0] && @nested_set[0][:optional] %> || <%= class_name %>.all<% end %> <% else %>
64
+ def load_all_<%= plural %><% if !@self_auth %>
65
+ @<%= plural_name %> = <%= object_scope.gsub("@",'') %>.page(params[:page])<%= n_plus_one_includes %><%= " if params.include?(:#{ @nested_set.last[:singular]}_id)" if @nested_set.any? && @nested_set[0] && @nested_set[0][:optional] %><% if @nested_set[0] && @nested_set[0][:optional] %>
66
+ @<%= plural_name %> = <%= class_name %>.all<% end %><% else %>
69
67
  @<%= plural_name %> = <%= class_name %>.where(id: <%= auth_object.gsub("@",'') %>.id)<%= n_plus_one_includes %> # returns iterable even though this <%= singular_name %> is only allowed access to themselves<% end %>
70
68
  end
71
69
 
@@ -73,19 +71,20 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
73
71
  load_all_<%= plural %>
74
72
  end
75
73
 
76
- <% if create_action %> def new <% if @object_owner_sym %>
77
- @<%= singular_name %> = <%= class_name %>.new(<% if eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>) <% elsif @object_owner_optional && any_nested? %>
78
- @<%= singular_name %> = <%= class_name %>.new({}.merge(<%= @nested_set.last[:singular] %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {})) <% else %>
74
+ <% if create_action %> def new<% if @object_owner_sym %>
75
+ @<%= singular_name %> = <%= class_name %>.new(<% if eval("#{class_name}.reflect_on_association(:#{@object_owner_sym})").class == ActiveRecord::Reflection::BelongsToReflection %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)<% elsif @object_owner_optional && any_nested? %>
76
+ @<%= singular_name %> = <%= class_name %>.new({}.merge(<%= @nested_set.last[:singular] %> ? {<%= @object_owner_sym %>: <%= @object_owner_eval %>} : {}))<% else %>
79
77
  @<%= singular_name %> = <%= class_name %>.new(<% if any_nested? %><%= @object_owner_sym %>: <%= @object_owner_eval %><% end %>)
80
78
  <% end %>
81
79
  end
82
80
 
83
81
  def create
84
- 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 %>)
85
- <% if @hawk_keys.any? %> modified_params = hawk_params( {<%= hawk_to_ruby %>}, modified_params)<% end %>
86
-
87
- @<%=singular_name %> = <%= class_name %>.create(modified_params)
88
-
82
+ <% if @alt_lookups.any? %><%= @alt_lookups.collect{|key, data|
83
+ " #{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"
84
+ }.join("/n") %><% end %> <% merge_lookups = @alt_lookups.collect{|key, data| "#{key.gsub("_id", "")}: #{key.gsub("_id", "")}" }.join(",") %>
85
+ modified_params = modify_date_inputs_on_params(<%= singular_name %>_params.dup<%= controller_update_params_tap_away_alt_lookups %><% 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 %>)<%= ".merge(#{merge_lookups})" if !merge_lookups.empty? %><% if @hawk_keys.any? %>
86
+ modified_params = hawk_params({<%= hawk_to_ruby %>}, modified_params)<% end %>
87
+ <%= creation_syntax %>
89
88
  if @<%= singular_name %>.save
90
89
  flash[:notice] = "Successfully created #{@<%= singular %>.<%= display_class %>}"
91
90
  load_all_<%= plural %>
@@ -102,9 +101,20 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
102
101
  end
103
102
 
104
103
  <% end %><% if @build_update_action %> def update
105
- modified_params = modify_date_inputs_on_params(<%= singular %>_params<%= @auth ? ', ' + @auth : '' %>)<%= controller_update_params_tap_away_magic_buttons %><% if @hawk_keys.any? %>
106
- modified_params = hawk_params( {<%= hawk_to_ruby %>}, modified_params)<% end %>
107
- <%= controller_magic_button_update_actions %>
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
+ " #{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
+ }.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? %>
108
+
109
+ <% if @hawk_keys.any? %> modified_params = hawk_params({<%= hawk_to_ruby %>}, modified_params)<% end %>
110
+ <% if @alt_lookups.any? %><%= @alt_lookups.collect{|key, data|
111
+ unless @factory_creation.include?("#{data[:assoc].downcase} = ")
112
+ " #{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"
113
+ end
114
+ }.join("/n") %><% end %><% if (@update_alt_lookups).any? %>
115
+ <%= @update_alt_lookups.collect{|key, data|
116
+ " @#{ singular_name }.#{key.gsub("_id", "")} = #{key.gsub("_id", "")}"
117
+ }.join("/n") %><% end %>
108
118
  if @<%= singular_name %>.update(modified_params)
109
119
  <% if @display_list_after_update %> load_all_<%= plural %><% end %>
110
120
  flash[:notice] = (flash[:notice] || "") << "Saved #{@<%= singular %>.<%= display_class %>}"
@@ -120,17 +130,17 @@ class <%= controller_class_name %> < <%= controller_descends_from %>
120
130
  begin
121
131
  @<%=singular_name%>.destroy
122
132
  rescue StandardError => e
123
- flash[:alert] = "<%= singular_name.titlecase %> could not be deleted."
133
+ flash[:alert] = '<%= singular_name.titlecase %> could not be deleted.'
124
134
  end
125
135
  load_all_<%= plural %>
126
136
  end<% end %>
127
137
 
128
138
  def <%=singular_name%>_params
129
- params.require(:<%= testing_name %>).permit( <%= (@columns - @show_only) + @magic_buttons.collect(&:to_sym) %> )
139
+ params.require(:<%= testing_name %>).permit(<%= (fields_filtered_for_email_lookups - @show_only) + @magic_buttons.collect(&:to_sym) %>)
130
140
  end
131
141
 
132
142
  def namespace
133
- <% if @namespace %>"<%= @namespace %>/" <% else %>""<% end %>
143
+ <% if @namespace %>'<%= @namespace %>/'<% else %><% end %>
134
144
  end
135
145
  end
136
146
 
@@ -1,7 +1,7 @@
1
1
  <div class="row">
2
- <%= all_form_fields %>
2
+ <%= form_fields_html %>
3
3
 
4
- <div class="<%= @layout_strategy.column_classes_for_form_fields %>">
4
+ <div class="<%= @layout_strategy.column_classes_for_button_column %>">
5
5
  <\%= link_to "Cancel", <%= path_helper_plural %>, {class: "btn btn-secondary"} %><% if @no_field_form %>
6
6
  <\%= f.hidden_field "_________" %><% end %>
7
7
  <\%= f.submit "Save", class: "btn btn-primary pull-right" %>
@@ -1,7 +1,7 @@
1
1
  <% if @turbo_streams %><\%= turbo_stream_from <%= singular %> %>
2
2
  <% end %><\%= turbo_frame_tag "<%= @namespace %>__#{ dom_id(<%= singular %>) }" do %>
3
3
  <div class='<%= @layout_strategy.row_classes %>' data-id='<\%= <%= singular %>.id %>' data-edit='false'>
4
- <\%= render partial: '<%= show_path_partial %>', locals: { <%= singular %>: <%= singular %> }<% @nested_set.each do |nest_arg| %>.merge(defined?(<%= nest_arg[:singular] %>) ? {<%= nest_arg[:singular] %>: <%= nest_arg[:singular] %>, nested_for: "<%= nest_arg[:singular] %>-#{<%= nest_arg[:singular] %>.id}"} : {})<% end %> %>
4
+ <\%= render partial: '<%= show_path_partial %>', locals: { <%= singular %>: <%= singular %> }<% @nested_set.each do |nest_arg| %>.merge(defined?(<%= nest_arg[:singular] %>) ? {<%= nest_arg[:singular] %>: <%= nest_arg[:singular] %>, nested_for: "<%= nest_arg[:singular] %>-#{<%= nest_arg[:singular] %>.id}"} : {})<% end %> %>
5
5
 
6
6
  </div>
7
7
  <\% end %>
@@ -1,5 +1,5 @@
1
1
  <\%= turbo_frame_tag "<%= @namespace %>__<%= singular %>-new" do %>
2
2
  <div>
3
- <\%= link_to "New <%= thing_label %>", <%= new_path_name %>, disable_with: "Loading...", class: "new-<%= singular %>-button btn btn-primary pull-right <%= 'btn-sm' if @nested_set.any? %> " %>
3
+ <\%= link_to "<%= @new_button_label %>", <%= new_path_name %>, disable_with: "Loading...", class: "new-<%= singular %>-button btn btn-primary pull-right <%= 'btn-sm' if @nested_set.any? %> " %>
4
4
  </div>
5
5
  <\% end %>
@@ -1,9 +1,9 @@
1
1
  <\%= turbo_frame_tag "<%= @namespace %>__<%= singular %>-new" do %>
2
- <h3>
3
- New <%= thing_label %>
2
+ <h3>
3
+ <%= @new_form_heading %>
4
4
  </h3>
5
5
  <\%= form_with model: <%= singular %>, url: <%= form_path_new_helper %>, method: :post do |f| \%>
6
6
  <\%= render partial: "<%= namespace_with_slash + @controller_build_folder %>/form",
7
- locals: { <%= singular %>: <%= singular %>, f: f}<%= @nested_set.collect{|arg| ".merge(defined?(#{arg[:singular]}) ? {#{arg[:singular]}: #{arg[:singular]}}: {})" }.join %> \%>
8
- <\% end %>
7
+ locals: { <%= singular %>: <%= singular %>, f: f}<%= @nested_set.collect{|arg| ".merge(defined?(#{arg[:singular]}) ? {#{arg[:singular]}: #{arg[:singular]}}: {})" }.join %> \%>
8
+ <\% end %>
9
9
  <\% end %>
@@ -10,7 +10,7 @@
10
10
  <% downnest_class = downnest_object.class_name %>
11
11
  <% downnest_object_name = eval("#{downnest_class}.table_name") %>
12
12
  <% downnest_style = @layout_strategy.downnest_style %>
13
- <div class="<%= " col-md-#{@layout_object[:portals][downnest][:size]}" if @layout == "bootstrap" %> scaffold-downnest" <%= downnest_style %> >
13
+ <div class="<%= @layout_strategy.downnest_portal_column_width(downnest) %> scaffold-downnest" <%= downnest_style %> >
14
14
  <\%= render partial: "<%= namespace_with_trailing_dash %><%= downnest_object_name %>/list", locals: {
15
15
  <%= @singular %>: <%= @singular %>,
16
16
  <%= downnest_object_name %>: <%= @singular %>.<%= downnest %>
@@ -23,7 +23,7 @@
23
23
  <% end %>
24
24
 
25
25
  <%= @layout_strategy.button_style %>
26
- <div class="<%= @col_identifier %> scaffold-line-buttons <%= @layout_strategy.button_classes %>" <%= @layout_strategy.button_style %>>
26
+ <div class=" scaffold-line-buttons <%= @layout_strategy.column_classes_for_button_column %>" <%= @layout_strategy.button_style %>>
27
27
  <%= magic_button_output %>
28
28
 
29
29
  <% if destroy_action %>
@@ -1,4 +1,4 @@
1
- <% if !@display_list_after_update %><\%= turbo_stream.replace "<%= namespace %>__#{dom_id(@<%= singular %>)}" do %>
1
+ <% if !@display_list_after_update %><\%= turbo_stream.replace "<%= @namespace %>__#{dom_id(@<%= singular %>)}" do %>
2
2
  <\%= render partial: 'line', locals: {<%= singular %>: @<%= singular %> }<%= @nested_set.collect{|arg| ".merge(@#{arg[:singular]} ? {#{arg[:singular]}: @#{arg[:singular]}} : {})" }.join %> \%>
3
3
  <\% end %><% else %><\%= turbo_stream.replace "<%= plural %>-list" do %>
4
4
  <\%= render partial: '<%= list_path_partial %>', locals: {<%= plural %>: @<%= plural %>}<%= @nested_set.collect{|arg| ".merge(@#{arg[:singular]} ? {#{arg[:singular]}: @#{arg[:singular]}} : {})" }.join %> \%>
@@ -1,5 +1,5 @@
1
1
  .row
2
- <%= all_form_fields %>
2
+ <%= form_fields_html %>
3
3
  .col
4
4
  = link_to "Cancel", <%= path_helper_plural %>, {class: "btn btn-secondary"}
5
5
  = f.submit "Save", class: "btn btn-primary pull-right"
@@ -1,23 +1,12 @@
1
1
  require 'rails_helper'
2
2
 
3
- describe "interaction for <%= controller_class_name %>", type: :feature do
3
+ describe 'interaction for <%= controller_class_name %>', type: :feature do
4
4
  include HotGlue::ControllerHelper
5
5
  include ActionView::RecordIdentifier
6
6
 
7
7
  <%= @existing_content %>
8
8
  <% unless @god %>let(:<%= @auth %>) {create(:<%= @auth.gsub('current_', '') %>)}<%end%>
9
- <%= (@columns - @show_only).map { |col|
10
- type = eval("#{singular_class}.columns_hash['#{col}']").type
11
- case type
12
- when :integer
13
- if col.to_s.ends_with?("_id")
14
- assoc = "#{col.to_s.gsub('_id','')}"
15
- " let!(:#{assoc}1) {create(:#{assoc}" + (@hawk_keys["#{assoc}_id".to_sym] ? ", #{@auth.gsub('current_', '')}: #{@auth}": "") + ")}"
16
- end
17
- else
18
- end
19
- }.compact.join("\n")
20
- %>
9
+ <%= spec_related_column_lets %>
21
10
  <% item1_addOns = ""
22
11
  if (eval(@singular_class).instance_methods.include?(display_class.to_s))
23
12
  item1_addOns << "#{display_class}: FFaker::Name.name"
@@ -27,7 +16,16 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
27
16
  type = eval("#{singular_class}.columns_hash['#{col}']").type
28
17
  case type
29
18
  when :string
30
- (col.to_s.include?('email') ? "#{col}: FFaker::Internet.email" : "#{col}: FFaker::Movie.title")
19
+ faker_string =
20
+ if col.to_s.include?('email')
21
+ "#{col}: FFaker::Internet.email"
22
+ elsif col.to_s.include?('domain')
23
+ "#{col}: FFaker::Internet.domain_name"
24
+ elsif col.to_s.include?('ip_address') || col.to_s.ends_with?('_ip')
25
+ "#{col}: FFaker::Internet.ip_v4_address"
26
+ else
27
+ "#{col}: FFaker::Movie.title"
28
+ end
31
29
  when :text
32
30
  "#{col}: FFaker::Lorem.paragraphs(10).join(" ")"
33
31
 
@@ -47,10 +45,12 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
47
45
  else
48
46
  "#{col}: rand(100)"
49
47
  end
48
+ when :uuid
49
+ "#{col.to_s.gsub('_id','')}: #{col.to_s.gsub('_id','')}1"
50
50
  end
51
51
  }.compact.join(", ")
52
52
  %>let!(:<%= singular %>1) {create(:<%= singular %><%= object_parent_mapping_as_argument_for_specs %> <%= item1_addOns %> )}
53
- <%= objest_nest_factory_setup %> <% unless @god %>
53
+ <%= objest_nest_factory_setup %> <% unless @god || @existing_content.include?("login_as")%>
54
54
  before do
55
55
  login_as(<%= @auth %>)
56
56
  end <% end %>
@@ -61,6 +61,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
61
61
  <%=
62
62
  @columns.map { |col|
63
63
  type = eval("#{singular_class}.columns_hash['#{col}']").type
64
+
64
65
  case type
65
66
  when :datetime
66
67
  " " + ["expect(page).to have_content(#{singular}#{1}.#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ').gsub(' ', ' ') + timezonize(current_timezone) )"].join("\n ")
@@ -68,6 +69,15 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
68
69
  if !col.ends_with?("_id")
69
70
  " " + ["expect(page).to have_content(#{singular}#{1}.#{col})"].join("\n ")
70
71
  end
72
+ when :uuid
73
+ assoc_name = col.to_s.gsub('_id','')
74
+ association = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
75
+
76
+
77
+ " " + ["expect(page).to have_content(#{singular}#{1}.#{assoc_name}.#{HotGlue.derrive_reference_name(association.class_name)})"].join("\n ")
78
+
79
+ when :boolean
80
+ " " + ["expect(page).to have_content(#{singular}#{1}.#{col} ? 'YES' : 'NO')"].join("\n ")
71
81
  else
72
82
  " " + ["expect(page).to have_content(#{singular}#{1}.#{col})"].join("\n ")
73
83
  end
@@ -80,9 +90,9 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
80
90
  <% unless @no_create %> describe "new & create" do
81
91
  it "should create a new <%= singular.titlecase %>" do
82
92
  visit <%= path_helper_plural %>
83
- click_link "New <%= thing_label %>"
84
- expect(page).to have_selector(:xpath, './/h3[contains(., "New <%= thing_label %>")]')
85
- <%= test_capybara_block %>
93
+ click_link "<%= @new_button_label %>"
94
+ expect(page).to have_selector(:xpath, './/h3[contains(., "<%= @new_button_label %>")]')
95
+ <%= test_capybara_block(:create) %>
86
96
  click_button "Save"
87
97
  expect(page).to have_content("Successfully created")
88
98
  <%=" " +
@@ -92,7 +102,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
92
102
 
93
103
  case type
94
104
  when :datetime
95
- # " expect(page).to have_content(new_#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y') + \" @ \" +
105
+ # " expect(page).to have_content(#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y') + \" @ \" +
96
106
  # new_#{col}.in_time_zone(current_timezone).strftime('%l').strip + \":\" +
97
107
  # new_#{col}.in_time_zone(current_timezone).strftime('%M %p').strip + \" \" +
98
108
  # timezonize(current_timezone))"
@@ -102,6 +112,10 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
102
112
  else
103
113
  "expect(page).to have_content(new_#{col})"
104
114
  end
115
+
116
+ when :boolean
117
+ ["expect(page).to have_content(#{singular}#{1}.#{col} ? 'YES' : 'NO')"].join("\n ")
118
+
105
119
  else
106
120
  "expect(page).to have_content(new_#{col})"
107
121
  end
@@ -118,25 +132,23 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
118
132
  find("a.edit-<%= singular %>-button[href='/<%= namespace_with_slash %><%= plural %>/#{<%= singular %>1.id}/edit']").click
119
133
 
120
134
  expect(page).to have_content("Editing #{<%= singular %>1.<%= @display_class %>.squish || "(no name)"}")
121
- <%= test_capybara_block %>
135
+ <%= test_capybara_block(:update) %>
122
136
  click_button "Save"
123
137
  within("turbo-frame#<%= @namespace %>__#{dom_id(<%= singular %>1)} ") do
124
- <%=
125
- (@columns - @show_only).map { |col|
138
+ <%= (@columns - @show_only).map { |col|
126
139
  type = eval("#{singular_class}.columns_hash['#{col}']").type
127
- case type
128
- when :datetime
129
- # TODO: implement me
130
- when :time
131
- # TODO: implement me
132
- when :date
133
- # TODO: implement me
134
- when :boolean
135
- # TODO: implement me
140
+
141
+ if type == :uuid || (type == :integer && col.to_s.ends_with?("_id"))
142
+ assoc = col.to_s.gsub('_id', '')
143
+ class_name = eval("#{@singular_class}.reflect_on_association(:#{assoc})").class_name
144
+ " expect(page).to have_content(#{assoc}1.#{HotGlue.derrive_reference_name(class_name)})"
145
+
146
+ elsif type == :boolean
147
+ ' expect(page).to have_content(new_' + col.to_s + ' ? "YES" : "NO")'
148
+
136
149
  else
137
- unless type==:integer && col.to_s.ends_with?("_id")
138
- ' expect(page).to have_content(new_' + col.to_s + ')'
139
- end
150
+ ' expect(page).to have_content(new_' + col.to_s + ')'
151
+
140
152
  end
141
153
  }.compact.join("\n")
142
154
  %>
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.5.6'
3
+ CURRENT = '0.5.7'
4
4
  end
5
5
  end
@@ -5,6 +5,9 @@ rm dummy/app/controllers/dfgs_controller.rb
5
5
  rm dummy/app/controllers/cantelopes_controller.rb
6
6
  rm dummy/app/controllers/jkls_controller.rb
7
7
  rm dummy/app/controllers/users_controller.rb
8
+ rm dummy/app/controllers/humans_controller.rb
9
+ rm dummy/app/controllers/pets_controller.rb
10
+
8
11
 
9
12
  rm -rf dummy/app/views/cantelopes/*
10
13
  rm -rf dummy/app/views/jkls/*
@@ -12,6 +15,8 @@ rm -rf dummy/app/views/ghis/*
12
15
  rm -rf dummy/app/views/abcs/*
13
16
  rm -rf dummy/app/views/dfgs/*
14
17
  rm -rf dummy/app/views/users/*
18
+ rm -rf dummy/app/views/humans/*
19
+ rm -rf dummy/app/views/pets/*
15
20
 
16
21
  /bin/rm -rf dummy/spec/system/
17
22
 
data/script/test CHANGED
@@ -31,13 +31,21 @@ rails generate hot_glue:scaffold Dfg --auth=current_user
31
31
 
32
32
  rails generate hot_glue:scaffold Fruits::Cantelope --gd
33
33
 
34
+ rails generate hot_glue:scaffold Pet --gd
35
+
36
+ rails generate hot_glue:scaffold Human --gd
37
+
34
38
  #rails generate hot_glue:scaffold User --no-create --self-auth
35
39
  #rails generate hot_glue:scaffold Jkl --gd
36
- #rails generate hot_glue:scaffold Pet --gd
37
40
  #rails generate hot_glue:scaffold Appointment --hawk=pets --gd
38
- #rails generate hot_glue:scaffold Humen --gd
39
41
  #rails generate hot_glue:scaffold Family --gd
40
42
 
43
+ # TODO: test these
44
+ # --update-show-only
45
+ # --alt-lookup-foreign-keys
46
+ # --factory-creation
47
+
48
+
41
49
 
42
50
  rspec spec || exit
43
51
 
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.6
4
+ version: 0.5.7
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-01-02 00:00:00.000000000 Z
11
+ date: 2023-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails