hot-glue 0.5.6 → 0.5.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -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 %>' 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,19 @@ 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
+ " " + ["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
82
+
83
+ when :boolean
84
+ " " + ["expect(page).to have_content(#{singular}#{1}.#{col} ? 'YES' : 'NO')"].join("\n ")
71
85
  else
72
86
  " " + ["expect(page).to have_content(#{singular}#{1}.#{col})"].join("\n ")
73
87
  end
@@ -80,9 +94,9 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
80
94
  <% unless @no_create %> describe "new & create" do
81
95
  it "should create a new <%= singular.titlecase %>" do
82
96
  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 %>
97
+ click_link "<%= @new_button_label %>"
98
+ expect(page).to have_selector(:xpath, './/h3[contains(., "<%= @new_button_label %>")]')
99
+ <%= test_capybara_block(:create) %>
86
100
  click_button "Save"
87
101
  expect(page).to have_content("Successfully created")
88
102
  <%=" " +
@@ -92,7 +106,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
92
106
 
93
107
  case type
94
108
  when :datetime
95
- # " expect(page).to have_content(new_#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y') + \" @ \" +
109
+ # " expect(page).to have_content(#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y') + \" @ \" +
96
110
  # new_#{col}.in_time_zone(current_timezone).strftime('%l').strip + \":\" +
97
111
  # new_#{col}.in_time_zone(current_timezone).strftime('%M %p').strip + \" \" +
98
112
  # timezonize(current_timezone))"
@@ -102,6 +116,15 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
102
116
  else
103
117
  "expect(page).to have_content(new_#{col})"
104
118
  end
119
+
120
+ when :boolean
121
+ ["expect(page).to have_content(#{singular}#{1}.#{col} ? 'YES' : 'NO')"].join("\n ")
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
105
128
  else
106
129
  "expect(page).to have_content(new_#{col})"
107
130
  end
@@ -118,25 +141,24 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
118
141
  find("a.edit-<%= singular %>-button[href='/<%= namespace_with_slash %><%= plural %>/#{<%= singular %>1.id}/edit']").click
119
142
 
120
143
  expect(page).to have_content("Editing #{<%= singular %>1.<%= @display_class %>.squish || "(no name)"}")
121
- <%= test_capybara_block %>
144
+ <%= test_capybara_block(:update) %>
122
145
  click_button "Save"
123
146
  within("turbo-frame#<%= @namespace %>__#{dom_id(<%= singular %>1)} ") do
124
- <%=
125
- (@columns - @show_only).map { |col|
147
+ <%= (@columns - @show_only).map { |col|
126
148
  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
149
+
150
+ if type == :uuid || (type == :integer && col.to_s.ends_with?("_id"))
151
+ assoc = col.to_s.gsub('_id', '')
152
+ class_name = eval("#{@singular_class}.reflect_on_association(:#{assoc})").class_name
153
+ " expect(page).to have_content(#{assoc}1.#{HotGlue.derrive_reference_name(class_name)})"
154
+
155
+ elsif type == :boolean
156
+ ' expect(page).to have_content(new_' + col.to_s + ' ? "YES" : "NO")'
157
+
158
+ elsif type == :enum && eval("#{singular_class}.respond_to?(:#{col}_labels)")
159
+ " expect(page).to have_content(#{singular_class}.#{col}_labels[new_#{col}])"
136
160
  else
137
- unless type==:integer && col.to_s.ends_with?("_id")
138
- ' expect(page).to have_content(new_' + col.to_s + ')'
139
- end
161
+ ' expect(page).to have_content(new_' + col.to_s + ')'
140
162
  end
141
163
  }.compact.join("\n")
142
164
  %>
@@ -1,5 +1,5 @@
1
1
  module HotGlue
2
2
  class Version
3
- CURRENT = '0.5.6'
3
+ CURRENT = '0.5.8'
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.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-01-02 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