hot-glue 0.3.9 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,19 +2,20 @@ 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
- <%= @columns.map { |col|
7
- type = eval("#{singular_class}.columns_hash['#{col}']").type
8
- case type
9
- when :integer
10
- if col.to_s.ends_with?("_id")
11
- assoc = "#{col.to_s.gsub('_id','')}"
12
- "let!(:#{assoc}1) {create(:#{assoc}, name: FFaker::Name.name)}"
13
- end
14
- else
7
+ <%= (@columns - @show_only).map { |col|
8
+ type = eval("#{singular_class}.columns_hash['#{col}']").type
9
+ case type
10
+ when :integer
11
+ if col.to_s.ends_with?("_id")
12
+ assoc = "#{col.to_s.gsub('_id','')}"
13
+ "let!(:#{assoc}1) {create(:#{assoc})}"
15
14
  end
16
- }.compact.join("\n")
17
- %>
15
+ else
16
+ end
17
+ }.compact.join("\n")
18
+ %>
18
19
  <% item1_addOns = ""
19
20
  if (eval(@singular_class).instance_methods.include?(display_class.to_s))
20
21
  item1_addOns << "#{display_class}: FFaker::Name.name"
@@ -24,7 +25,7 @@ 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
 
@@ -40,7 +41,7 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
40
41
  "#{col}: DateTime.current + rand(1000).seconds"
41
42
  when :integer
42
43
  if col.to_s.ends_with?("_id")
43
- # shoould the assoication be on here
44
+ "#{col.to_s.gsub('_id','')}: #{col.to_s.gsub('_id','')}1"
44
45
  else
45
46
  "#{col}: rand(100)"
46
47
  end
@@ -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")
@@ -79,9 +82,16 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
79
82
  expect(page).to have_selector(:xpath, './/h3[contains(., "New <%= singular.titlecase %>")]')
80
83
 
81
84
  <%=
82
- @columns.map { |col|
85
+ (@columns - @show_only).map { |col|
83
86
  type = eval("#{singular_class}.columns_hash['#{col}']").type
84
87
  case type
88
+ when :date
89
+ " " + "new_#{col} = Date.current + (rand(100).days) \n" +
90
+ ' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
91
+ when :time
92
+ # " " + "new_#{col} = DateTime.current + (rand(100).days) \n" +
93
+ # ' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
94
+
85
95
  when :datetime
86
96
  " " + "new_#{col} = DateTime.current + (rand(100).days) \n" +
87
97
  ' ' + "find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
@@ -106,9 +116,18 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
106
116
  when :boolean
107
117
  " new_#{col} = rand(2).floor \n" +
108
118
  " find(\"[name='#{singular}[#{col}]'][value='\#{new_" + col.to_s + "}']\").choose"
109
- else
119
+ when :string
120
+ if col.to_s.include?("email")
121
+ " " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
122
+ " find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
123
+
124
+ else
110
125
  " " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
111
126
  " find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
127
+ end
128
+ when :text
129
+ " " + "new_#{col} = FFaker::Lorem.paragraphs(1).join("") \n" +
130
+ " find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
112
131
  end
113
132
 
114
133
  }.join("\n")
@@ -116,17 +135,17 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
116
135
  %>
117
136
  click_button "Save"
118
137
  expect(page).to have_content("Successfully created")
138
+ <%=" " +
119
139
 
120
- <%=
121
- @columns.map { |col|
140
+ (@columns - @show_only).map { |col|
122
141
  type = eval("#{singular_class}.columns_hash['#{col}']").type
123
142
 
124
143
  case type
125
144
  when :datetime
126
- " expect(page).to have_content(new_#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y') + \" @ \" +
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))"
145
+ # " expect(page).to have_content(new_#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y') + \" @ \" +
146
+ # new_#{col}.in_time_zone(current_timezone).strftime('%l').strip + \":\" +
147
+ # new_#{col}.in_time_zone(current_timezone).strftime('%M %p').strip + \" \" +
148
+ # timezonize(current_timezone))"
130
149
  when :integer
131
150
  if col.to_s.ends_with?("_id")
132
151
  # shoould the assoication be on here
@@ -139,28 +158,29 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
139
158
 
140
159
  }.compact.join("\n ")
141
160
  %>
142
-
143
161
  end
144
162
  end<% end %>
145
163
 
146
-
164
+ <% unless @no_edit %>
147
165
  describe "edit & update" do
148
166
  it "should return an editable form" do
149
167
  visit <%= path_helper_plural %>
150
168
  find("a.edit-<%= singular %>-button[href='/<%= namespace_with_slash %><%= plural %>/#{<%= singular %>1.id}/edit']").click
151
169
 
152
- expect(page).to have_content("Editing #{<%= singular %>1.<%= @display_class %> || "(no name)"}")
170
+ expect(page).to have_content("Editing #{<%= singular %>1.<%= @display_class %>.squish || "(no name)"}")
153
171
  <%=
154
- @columns.map { |col|
172
+ (@columns - @show_only).map { |col|
155
173
  type = eval("#{singular_class}.columns_hash['#{col}']").type
156
174
  limit = eval("#{singular_class}.columns_hash['#{col}']").limit
157
175
  sql_type = eval("#{singular_class}.columns_hash['#{col}']").sql_type
158
176
  case type
159
177
  when :datetime
178
+ " new_#{col} = DateTime.current + 1.day \n" +
179
+ " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s})"
160
180
  when :integer
161
181
  if !col.to_s.ends_with?("_id")
162
- " new_#{col} = rand(10000).floor \n" +
163
- " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s})"
182
+ " new_#{col} = rand(10000).floor \n" +
183
+ " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s})"
164
184
  end
165
185
  when :text
166
186
  if sql_type == "text"
@@ -172,12 +192,17 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
172
192
  ' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
173
193
  end
174
194
  when :string
175
- if sql_type == "varchar"
176
- " " + "new_#{col.to_s} = FFaker::Name.name \n" +
177
- ' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
195
+
196
+ if col.to_s.include?("email")
197
+ " " + "new_#{col} = 'new_test-email@nowhere.com' \n" +
198
+ " find(\"[name='#{singular}[#{ col.to_s }]']\").fill_in(with: new_#{col.to_s})"
199
+
200
+ elsif sql_type == "varchar"
201
+ " " + "new_#{col.to_s} = FFaker::Name.name \n" +
202
+ ' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
178
203
  else
179
- " " + "new_#{col.to_s} = FFaker::Lorem.paragraphs(1).join \n" +
180
- ' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
204
+ " " + "new_#{col.to_s} = FFaker::Lorem.paragraphs(1).join \n" +
205
+ ' find("input[name=\'' + singular + '[' + col.to_s + ']\']").fill_in(with: new_' + col.to_s + ')'
181
206
  end
182
207
  when :boolean
183
208
  " new_#{col} = rand(2).floor \n" +
@@ -186,11 +211,15 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
186
211
  " new_#{col} = rand(1)*5000 \n" +
187
212
  " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s })"
188
213
  when :date
189
- " new_#{col} = Date.current + rand(100).days \n" +
190
- " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s })"
214
+ " new_#{col} = Date.current + rand(100).days \n" +
215
+ " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s })"
191
216
  when :time
192
217
  " new_#{col} = Time.current + rand(144).hours \n" +
193
218
  " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s })"
219
+ when :datetime
220
+ " new_#{col} = DateTime.current + rand(1000).minutes \n" +
221
+ " find(\"[name='#{singular}[#{col}]']\").fill_in(with: new_#{col.to_s })"
222
+
194
223
  when :enum
195
224
  " list_of_#{col.to_s} = #{singular_class}.defined_enums['#{col.to_s}'].keys \n" +
196
225
  " " + "new_#{col.to_s} = list_of_#{col.to_s}[rand(list_of_#{col.to_s}.length)].to_s \n" +
@@ -205,10 +234,8 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
205
234
  %>
206
235
  click_button "Save"
207
236
  within("turbo-frame#<%= singular %>__#{<%= singular %>1.id} ") do
208
-
209
-
210
237
  <%=
211
- @columns.map { |col|
238
+ (@columns - @show_only).map { |col|
212
239
  type = eval("#{singular_class}.columns_hash['#{col}']").type
213
240
  case type
214
241
  when :datetime
@@ -226,10 +253,9 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
226
253
  end
227
254
  }.compact.join("\n")
228
255
  %>
229
-
230
256
  end
231
257
  end
232
- end
258
+ end <% end %>
233
259
 
234
260
  <% unless @no_delete %> describe "destroy" do
235
261
  it "should destroy" do
@@ -237,8 +263,6 @@ describe "interaction for <%= controller_class_name %>", type: :feature do
237
263
  accept_alert do
238
264
  find("form[action='<%= namespace_with_dash %>/<%= plural %>/#{<%= singular %>1.id}'] > input.delete-<%= singular %>-button").click
239
265
  end
240
- # find("form[action='<%= namespace_with_dash %>/<%= plural %>/#{<%= singular %>1.id}'] > input.delete-<%= singular %>-button").click
241
-
242
266
  expect(page).to_not have_content(<%= singular %>1.<%= @display_class %>)
243
267
  expect(<%= singular_class %>.where(id: <%= singular %>1.id).count).to eq(0)
244
268
  end
@@ -1,3 +1,3 @@
1
1
  module HotGlue
2
- VERSION = '0.3.9'
2
+ VERSION = '0.4.3'
3
3
  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.3.9
4
+ version: 0.4.3
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 00:00:00.000000000 Z
11
+ date: 2022-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5.1'
20
20
  - - "<="
21
21
  - !ruby/object:Gem::Version
22
- version: 7.0.0
22
+ version: '7'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '5.1'
30
30
  - - "<="
31
31
  - !ruby/object:Gem::Version
32
- version: 7.0.0
32
+ version: '7'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: kaminari
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -44,20 +44,6 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '1.2'
47
- - !ruby/object:Gem::Dependency
48
- name: turbo-rails
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">"
52
- - !ruby/object:Gem::Version
53
- version: '0.5'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">"
59
- - !ruby/object:Gem::Version
60
- version: '0.5'
61
47
  - !ruby/object:Gem::Dependency
62
48
  name: sass-rails
63
49
  requirement: !ruby/object:Gem::Requirement
@@ -107,14 +93,11 @@ files:
107
93
  - app/views/layouts/_flash_notices.erb
108
94
  - bin/rails
109
95
  - config/database.yml
110
- - db/migrate/20210306212711_create_abcs.rb
111
- - db/migrate/20210306223300_create_defs.rb
112
- - db/migrate/20210306223305_create_ghis.rb
113
- - db/migrate/20210306223309_create_jkls.rb
114
- - db/migrate/20210306223701_devise_create_users.rb
115
- - db/migrate/20210306225506_create_xyzs.rb
96
+ - config/hot_glue.yml
116
97
  - db/schema.rb
98
+ - lib/generators/hot_glue/helpers.rb
117
99
  - lib/generators/hot_glue/install_generator.rb
100
+ - lib/generators/hot_glue/layout/builder.rb
118
101
  - lib/generators/hot_glue/markup_templates/base.rb
119
102
  - lib/generators/hot_glue/markup_templates/erb.rb
120
103
  - lib/generators/hot_glue/markup_templates/haml.rb
@@ -164,7 +147,7 @@ files:
164
147
  - lib/hotglue/version.rb
165
148
  homepage: https://jasonfleetwoodboldt.com/hot-glue/
166
149
  licenses:
167
- - Nonstandard
150
+ - Commercial with free option
168
151
  metadata:
169
152
  source_code_uri: https://github.com/jasonfb/hot-glue
170
153
  tutorial: https://jfbcodes.com/hot-glue-tutorial
@@ -1,11 +0,0 @@
1
- class CreateAbcs < ActiveRecord::Migration[6.1]
2
- def change
3
- create_table :abcs do |t|
4
- t.integer :xxx
5
- t.string :yyy
6
- t.integer :def_id
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- class CreateDefs < ActiveRecord::Migration[6.1]
2
- def change
3
- create_table :defs do |t|
4
- t.integer :user_id
5
- t.string :name
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class CreateGhis < ActiveRecord::Migration[6.1]
2
- def change
3
- create_table :ghis do |t|
4
- t.integer :def_id
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class CreateJkls < ActiveRecord::Migration[6.1]
2
- def change
3
- create_table :jkls do |t|
4
- t.integer :hgi_id
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class DeviseCreateUsers < ActiveRecord::Migration[6.1]
4
- def change
5
- create_table :users do |t|
6
- ## Database authenticatable
7
- t.string :email, null: false, default: ""
8
- t.string :encrypted_password, null: false, default: ""
9
-
10
- ## Recoverable
11
- t.string :reset_password_token
12
- t.datetime :reset_password_sent_at
13
-
14
- ## Rememberable
15
- t.datetime :remember_created_at
16
-
17
- ## Trackable
18
- # t.integer :sign_in_count, default: 0, null: false
19
- # t.datetime :current_sign_in_at
20
- # t.datetime :last_sign_in_at
21
- # t.string :current_sign_in_ip
22
- # t.string :last_sign_in_ip
23
-
24
- ## Confirmable
25
- # t.string :confirmation_token
26
- # t.datetime :confirmed_at
27
- # t.datetime :confirmation_sent_at
28
- # t.string :unconfirmed_email # Only if using reconfirmable
29
-
30
- ## Lockable
31
- # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
32
- # t.string :unlock_token # Only if unlock strategy is :email or :both
33
- # t.datetime :locked_at
34
-
35
-
36
- t.timestamps null: false
37
- end
38
-
39
- add_index :users, :email, unique: true
40
- add_index :users, :reset_password_token, unique: true
41
- # add_index :users, :confirmation_token, unique: true
42
- # add_index :users, :unlock_token, unique: true
43
- end
44
- end
@@ -1,9 +0,0 @@
1
- class CreateXyzs < ActiveRecord::Migration[6.1]
2
- def change
3
- create_table :xyzs do |t|
4
- t.integer :nothing_id
5
-
6
- t.timestamps
7
- end
8
- end
9
- end