inline_forms_installer 8.1.6 → 8.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8780337213fbfb45e061f0f5309c9cb73826461aacca4dd4cc1662214b8654f4
4
- data.tar.gz: c355bf659cc460fa83ca210a712c91b466dc4d7e30c0c8477906b2d867770674
3
+ metadata.gz: 1db2a592daf12e0ddf1b93c67469f400540e58a81b8ca96ee516dccb7a03dc20
4
+ data.tar.gz: 4e5abd3355753c8f09d79e16431007a0b268066e1106330c4251649262f92fe2
5
5
  SHA512:
6
- metadata.gz: 1e663a9f2bfdf0ad9e8bab1a93cb397a12374d7918a7f08d069c10b84ca3e635c95cd702c87e1164fb78173f6992cd99191930c1814ffdddc7d996273303c5c5
7
- data.tar.gz: 210aef3002d3c58c01f226c5f29e6f0a7e548c8b273cb3eca3f08e524beb407f16b75d4cd3ec46abcac4e4a65b21d05c3d2132e79d347cac5a528b54119ac5a4
6
+ metadata.gz: 92c4c50ca28769e76767bcc11fc74c742520386cddf55c4559133b95251161dd71d28e2a9e8d3fbddde62b95d9adf6e72f5666b7893ae9f94374132d66af37b6
7
+ data.tar.gz: d71c002620d3959812057383f6714eb01f9863370351d4436cf419e4b7a2ece6f78a2848ca057209fe6b68956fe42e04bdcd1f75731d6880c06d06b960f358b2
@@ -105,6 +105,13 @@ gem 'jquery-ui-rails', '4.0.3'
105
105
  # Foundation Icons SCSS + fonts are vendored in the inline_forms engine (Dart Sass;
106
106
  # foundation-icons-sass-rails depended on sass-rails).
107
107
  gem 'mini_magick'
108
+ # money-rails powers the `money_field` Tier 1 helper:
109
+ # * adds the `humanized_money_with_symbol` view helper used by
110
+ # money_field_show
111
+ # * exposes `monetize :foo_cents` so an integer `_cents` column is
112
+ # read/written as a Money instance through `obj.foo`
113
+ # Used by FormElementShowcase#amount in the --example app.
114
+ gem 'money-rails', '~> 3.0'
108
115
  gem 'mysql2'
109
116
  gem 'paper_trail', '~> 17.0'
110
117
  gem 'rails-i18n', '~> 8.1'
@@ -1049,7 +1056,7 @@ if ENV['install_example'] == 'true'
1049
1056
  # ---------------------------------------------------------------------
1050
1057
  say "- Generating FormElementShowcase (one resource per kept Tier 1 form_element)..."
1051
1058
  sleep 1
1052
- run %q{bundle exec rails g inline_forms FormElementShowcase title:string body_plain_area:plain_text_area count:integer_field price:decimal_field meeting_date:date_select meeting_time:time_select birth_month:month_select start_month:month_year_picker is_active:check_box gender:radio_button rating_int:dropdown_with_integers priority:dropdown_with_values priority2:dropdown_with_values stars:dropdown_with_values_with_stars attachment:file_field jingle:audio_field cover:image_field description:rich_text roles:has_and_belongs_to_many _enabled:yes _list_order:title _list_search:title _presentation:'#{title}'}
1059
+ run %q{bundle exec rails g inline_forms FormElementShowcase title:string body_plain_area:plain_text_area count:integer_field price:decimal_field amount:money_field meeting_date:date_select meeting_time:time_select birth_month:month_select start_month:month_year_picker is_active:check_box gender:radio_button rating_int:dropdown_with_integers priority:dropdown_with_values priority2:dropdown_with_values stars:dropdown_with_values_with_stars scale_int:scale_with_integers scale_val:scale_with_values attachment:file_field jingle:audio_field cover:image_field description:rich_text roles:has_and_belongs_to_many _enabled:yes _list_order:title _list_search:title _presentation:'#{title}'}
1053
1060
 
1054
1061
  say "- Generating Attachment + Jingle uploaders (Cover reuses ImageUploader)..."
1055
1062
  run "bundle exec rails generate uploader Attachment"
@@ -1063,12 +1070,39 @@ if ENV['install_example'] == 'true'
1063
1070
  "mount_uploader :cover, CoverUploader",
1064
1071
  "mount_uploader :cover, ImageUploader"
1065
1072
 
1073
+ # money-rails wiring for the `amount:money_field` showcase column.
1074
+ #
1075
+ # * The inline_forms generator emits a plain `t.integer :amount`
1076
+ # (FormElementRegistry maps `:money_field` to `:integer`), but
1077
+ # money-rails' `monetize` reader/writer convention is `_cents`-
1078
+ # suffixed: declare `monetize :amount_cents`, store cents in
1079
+ # `amount_cents`, and money-rails defines `obj.amount`/`obj.amount=`
1080
+ # returning/parsing Money objects. That keeps the inline_forms
1081
+ # attribute list entry `[:amount, :money_field]` semantically
1082
+ # correct (`obj.amount` => Money) without a custom helper.
1083
+ # * Rename the column in the generated create-table migration from
1084
+ # `:amount` to `:amount_cents` *before* `rake db:migrate` runs.
1085
+ # * Add a small initializer pinning the default currency so the
1086
+ # showcase renders predictably under any host locale.
1087
+ showcase_migration = Dir.glob("db/migrate/*_inline_forms_create_form_element_showcases.rb").first
1088
+ if showcase_migration
1089
+ gsub_file showcase_migration, /t\.integer :amount\b/, "t.integer :amount_cents, default: 0, null: false"
1090
+ end
1091
+
1092
+ create_file "config/initializers/money.rb", <<-MONEY_INIT.strip_heredoc
1093
+ # Generated by inline_forms (money-rails defaults for the
1094
+ # FormElementShowcase `amount:money_field` demo column).
1095
+ MoneyRails.configure do |config|
1096
+ config.default_currency = :usd
1097
+ end
1098
+ MONEY_INIT
1099
+
1066
1100
  # First field-level validation in the example app. `allow_blank: true`
1067
1101
  # keeps PaperTrail revert paths (and the seeded second row, which leaves
1068
1102
  # count nil) valid. The integration test covers the explicit error
1069
1103
  # path by POSTing `count: "abc"` to /form_element_showcases.
1070
1104
  inject_into_file "app/models/form_element_showcase.rb",
1071
- "\n validates :count, numericality: { only_integer: true }, allow_blank: true\n mount_uploader :attachment, AttachmentUploader\n",
1105
+ "\n validates :count, numericality: { only_integer: true }, allow_blank: true\n mount_uploader :attachment, AttachmentUploader\n monetize :amount_cents\n",
1072
1106
  after: "class FormElementShowcase < ApplicationRecord\n"
1073
1107
 
1074
1108
  # Value-bearing rows for every form_element that needs a values hash
@@ -1082,6 +1116,8 @@ if ENV['install_example'] == 'true'
1082
1116
  "[ :priority, :dropdown_with_values ]" => "[ :priority, :dropdown_with_values, { 1 => 'low', 2 => 'mid', 3 => 'high' } ]",
1083
1117
  "[ :priority2, :dropdown_with_values ]" => "[ :priority2, :dropdown_with_values, { 1 => 'low', 2 => 'mid', 3 => 'high' }, [ 2 ] ]",
1084
1118
  "[ :stars, :dropdown_with_values_with_stars ]" => "[ :stars, :dropdown_with_values_with_stars, { 1 => '1stars', 2 => '2stars', 3 => '3stars', 4 => '4stars', 5 => '5stars' } ]",
1119
+ "[ :scale_int, :scale_with_integers ]" => "[ :scale_int, :scale_with_integers, { 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five' } ]",
1120
+ "[ :scale_val, :scale_with_values ]" => "[ :scale_val, :scale_with_values, { 1 => 'red', 2 => 'green', 3 => 'blue' } ]",
1085
1121
  }
1086
1122
  showcase_value_rows.each do |from, to|
1087
1123
  gsub_file "app/models/form_element_showcase.rb", from, to
@@ -1130,6 +1166,7 @@ if ENV['install_example'] == 'true'
1130
1166
  body_plain_area: Plain text area
1131
1167
  count: Count
1132
1168
  price: Price
1169
+ amount: Amount
1133
1170
  meeting_date: Meeting date
1134
1171
  meeting_time: Meeting time
1135
1172
  birth_month: Birth month
@@ -1140,6 +1177,8 @@ if ENV['install_example'] == 'true'
1140
1177
  priority: Priority
1141
1178
  priority2: Priority (with disabled option)
1142
1179
  stars: Stars
1180
+ scale_int: Scale (integers)
1181
+ scale_val: Scale (values)
1143
1182
  attachment: Attachment
1144
1183
  jingle: Jingle
1145
1184
  cover: Cover
@@ -1195,6 +1234,7 @@ if ENV['install_example'] == 'true'
1195
1234
  s.body_plain_area = "A short plain-text paragraph."
1196
1235
  s.count = 7
1197
1236
  s.price = "12.34"
1237
+ s.amount = Money.from_amount(99.95, "USD") if s.respond_to?(:amount=)
1198
1238
  s.meeting_date = Date.new(2026, 6, 1)
1199
1239
  s.meeting_time = Time.utc(2000, 1, 1, 14, 30)
1200
1240
  s.birth_month = 7
@@ -1205,6 +1245,8 @@ if ENV['install_example'] == 'true'
1205
1245
  s.priority = 2
1206
1246
  s.priority2 = 3
1207
1247
  s.stars = 4
1248
+ s.scale_int = 3
1249
+ s.scale_val = 2
1208
1250
  s.description = "<p>A rich-text paragraph for the showcase.</p>"
1209
1251
  end
1210
1252
  if defined?(Role) && Role.exists?(1) && full.roles.empty?
@@ -1222,6 +1264,8 @@ if ENV['install_example'] == 'true'
1222
1264
  s.priority = 1
1223
1265
  s.priority2 = 1
1224
1266
  s.stars = 1
1267
+ s.scale_int = 1
1268
+ s.scale_val = 1
1225
1269
  end
1226
1270
  end
1227
1271
 
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineFormsInstaller
3
- VERSION = "8.1.6"
3
+ VERSION = "8.1.8"
4
4
 
5
5
  # Written into generated apps' `.ruby-version` (must match gemspec `required_ruby_version`).
6
6
  TARGET_RUBY_VERSION = "ruby-4.0.4"
@@ -2,14 +2,14 @@
2
2
 
3
3
  require_relative "../example_app/example_integration_test_case"
4
4
 
5
- # Choice helpers on FormElementShowcase:
5
+ # Choice/scale helpers on FormElementShowcase:
6
6
  # check_box (is_active, 0|1)
7
7
  # radio_button (gender, hash)
8
8
  # dropdown_with_integers (rating_int)
9
9
  # dropdown_with_values (priority normal + priority2 options_disabled)
10
10
  # dropdown_with_values_with_stars (stars)
11
- # (scale_with_integers / scale_with_values are dropped from the showcase
12
- # until their runtime show helpers are repaired; see CHANGELOG 8.1.6.)
11
+ # scale_with_integers (scale_int)
12
+ # scale_with_values (scale_val)
13
13
  class ExampleAppShowcaseChoiceScaleFieldsTest < ExampleAppIntegrationTestCase
14
14
  setup do
15
15
  @showcase = FormElementShowcase.find_or_create_by!(title: "Choice/scale demo")
@@ -123,4 +123,30 @@ class ExampleAppShowcaseChoiceScaleFieldsTest < ExampleAppIntegrationTestCase
123
123
  assert_equal 5, @showcase.reload.stars
124
124
  end
125
125
 
126
+ test "scale_with_integers scale_int round-trips" do
127
+ frame = field_frame(:scale_int)
128
+ put form_element_showcase_path(
129
+ @showcase,
130
+ attribute: "scale_int",
131
+ form_element: "scale_with_integers",
132
+ update: frame
133
+ ), params: { underscored_param_root => { scale_int: 4 } }, headers: field_headers(:scale_int)
134
+
135
+ assert_response :success
136
+ assert_equal 4, @showcase.reload.scale_int
137
+ end
138
+
139
+ test "scale_with_values scale_val round-trips" do
140
+ frame = field_frame(:scale_val)
141
+ put form_element_showcase_path(
142
+ @showcase,
143
+ attribute: "scale_val",
144
+ form_element: "scale_with_values",
145
+ update: frame
146
+ ), params: { underscored_param_root => { scale_val: 3 } }, headers: field_headers(:scale_val)
147
+
148
+ assert_response :success
149
+ assert_equal 3, @showcase.reload.scale_val
150
+ end
151
+
126
152
  end
@@ -5,9 +5,7 @@ require_relative "../example_app/example_integration_test_case"
5
5
  # Numeric Tier 1 helpers on FormElementShowcase:
6
6
  # integer_field (count) + numericality validation regression
7
7
  # decimal_field (price)
8
- # (money_field is dropped from the showcase; the runtime helper depends on
9
- # money-rails' `humanized_money_with_symbol`, which is not in the installer
10
- # Gemfile. See CHANGELOG 8.1.6 "Dropped" section.)
8
+ # money_field (amount, money-rails `monetize :amount_cents`)
11
9
  class ExampleAppShowcaseNumericFieldsTest < ExampleAppIntegrationTestCase
12
10
  setup do
13
11
  @showcase = FormElementShowcase.find_or_create_by!(title: "Numeric demo")
@@ -49,24 +47,46 @@ class ExampleAppShowcaseNumericFieldsTest < ExampleAppIntegrationTestCase
49
47
  assert_equal "99.95", @showcase.reload.price
50
48
  end
51
49
 
50
+ test "money_field amount round-trips through monetize :amount_cents" do
51
+ skip "money-rails monetize not configured" unless FormElementShowcase.respond_to?(:monetized_attributes) &&
52
+ FormElementShowcase.monetized_attributes.key?("amount")
53
+
54
+ frame = "form_element_showcase_#{@showcase.id}_amount"
55
+ headers = { "Turbo-Frame" => frame, "Accept" => "text/html" }
56
+
57
+ put form_element_showcase_path(
58
+ @showcase,
59
+ attribute: "amount",
60
+ form_element: "money_field",
61
+ update: frame
62
+ ), params: { amount: "12.34" }, headers: headers
63
+
64
+ assert_response :success
65
+ assert_includes @response.body, %(<turbo-frame id="#{frame}">)
66
+ reloaded = @showcase.reload
67
+ assert_equal 1234, reloaded.amount_cents,
68
+ "expected monetize to parse '12.34' into 1234 cents, got #{reloaded.amount_cents.inspect}"
69
+ end
70
+
52
71
  test "integer_field count rejects non-integer via top-level create" do
53
72
  # The controller's create iterates every attribute and calls each
54
- # form_element's update method. Several helpers crash on nil params:
55
- # - month_year_picker_update -> Date.parse("") raises
56
- # - dropdown_with_integers_update / dropdown_with_values{_with_stars}_update
57
- # -> params[:_form_element_showcase][:attr] dereferences nil
58
- # We supply just enough to let the create walk reach the validation step.
73
+ # form_element's update method. Several helpers used to crash on nil
74
+ # params (month_year_picker_update, scale_*_update, dropdown_*_update)
75
+ # so we supply just enough to let the create walk reach validation.
59
76
  assert_no_difference "FormElementShowcase.count" do
60
77
  post form_element_showcases_path(update: @list_frame),
61
78
  params: {
62
79
  title: "Bad Count",
63
80
  count: "abc",
81
+ amount: "0.00",
64
82
  start_month: "September 2026",
65
83
  _form_element_showcase: {
66
84
  rating_int: 1,
67
85
  priority: 1,
68
86
  priority2: 1,
69
87
  stars: 1,
88
+ scale_int: 1,
89
+ scale_val: 1,
70
90
  },
71
91
  },
72
92
  headers: @list_headers
@@ -13,6 +13,7 @@ class ExampleAppShowcasePageRenderTest < ExampleAppIntegrationTestCase
13
13
  body_plain_area
14
14
  count
15
15
  price
16
+ amount
16
17
  meeting_date
17
18
  meeting_time
18
19
  birth_month
@@ -23,6 +24,8 @@ class ExampleAppShowcasePageRenderTest < ExampleAppIntegrationTestCase
23
24
  priority
24
25
  priority2
25
26
  stars
27
+ scale_int
28
+ scale_val
26
29
  attachment
27
30
  jingle
28
31
  cover
@@ -60,6 +63,9 @@ class ExampleAppShowcasePageRenderTest < ExampleAppIntegrationTestCase
60
63
  s.priority = 2
61
64
  s.priority2 = 3
62
65
  s.stars = 4
66
+ s.scale_int = 3
67
+ s.scale_val = 2
68
+ s.amount = Money.from_amount(99.95, "USD") if s.respond_to?(:amount=) && defined?(Money)
63
69
  s.description = "<p>A rich-text body.</p>"
64
70
  end
65
71
  @full.roles << @role unless @full.roles.where(id: @role.id).exists?
@@ -73,6 +79,8 @@ class ExampleAppShowcasePageRenderTest < ExampleAppIntegrationTestCase
73
79
  s.priority = 1
74
80
  s.priority2 = 1
75
81
  s.stars = 1
82
+ s.scale_int = 1
83
+ s.scale_val = 1
76
84
  end
77
85
  end
78
86
 
@@ -15,6 +15,7 @@ class ExampleAppFormElementShowcaseTest < ActiveSupport::TestCase
15
15
  header_numbers
16
16
  count
17
17
  price
18
+ amount
18
19
  header_dates
19
20
  meeting_date
20
21
  meeting_time
@@ -27,6 +28,8 @@ class ExampleAppFormElementShowcaseTest < ActiveSupport::TestCase
27
28
  priority
28
29
  priority2
29
30
  stars
31
+ scale_int
32
+ scale_val
30
33
  header_files
31
34
  attachment
32
35
  jingle
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inline_forms_installer
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.6
4
+ version: 8.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares