inline_forms_installer 8.1.18 → 8.1.20

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: 8f04e2b37e58d0c6658da6ab3cc13ae2a44e22bb898fac9e8980960fd5d61378
4
- data.tar.gz: c6fe8cc0545e99c3671824b7858136ab6f36c696602c3db9ac5f0ea91c686c96
3
+ metadata.gz: e2acd92d33de3e1bcd824630a6a4e5166906d938ffb4baa18e8580cb9c8df63b
4
+ data.tar.gz: e26ce5fb20d87ac207540afa979ab716f2d5713663b3608eceb0b7185d1fab8f
5
5
  SHA512:
6
- metadata.gz: 2ec0b4161bf92dcaf7de326218c891dafaaf490c5a16f4850211bbc52672b75e96ab6f55291bdc79fae8a980c4c1cb6d93c036a07384c96e3a48801cd45167dc
7
- data.tar.gz: 83c865c2688e60ec6b06a0c811d7bccea25a9d252e1d2a70bf7328443dd869c438463a689f3127957c7563bc426f5434871993ea9eef8c53b46df3fbc3740456
6
+ metadata.gz: 40cd451d291f9920a74d09f4f7e2b61166438413b06e2c73d51463d84ddce674ac7ed88753f6276503953e0c99792761c9cfcdbd09a6290e64fcd18b47099084
7
+ data.tar.gz: 5a87788bf2d7c3878102d7e973f63565c12532de1677043e39c4bee61472c4ea710362ebbebc177b544242db56e9e9a0e5c8673c83a1fa9acd1216d8afcf31cd
@@ -1,6 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module InlineFormsInstaller
3
- VERSION = "8.1.18"
3
+ VERSION = "8.1.20"
4
4
 
5
5
  # Canonical bare Ruby version (must match gemspec `required_ruby_version`).
6
6
  # Written verbatim into generated apps' `.ruby-version` for rbenv/chruby/asdf/
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../example_app/example_integration_test_case"
4
+
5
+ # Regression for the inline attribute :update action.
6
+ #
7
+ # The bug: `update` ignored the return value of `@object.save` and always
8
+ # re-rendered `field_show` from the in-memory `@object`. money-rails rejects
9
+ # an unparseable amount like "99.ace99" (the monetized validator fails, so
10
+ # `save` returns false and `amount_cents` is never written), yet the user saw
11
+ # a "saved" show of the unsaved in-memory value. Re-opening the edit revealed
12
+ # the old value -- the success render was a lie.
13
+ #
14
+ # The fix branches on `@object.save`: on failure it re-renders the EDIT field
15
+ # (with the rejected raw input still visible) instead of a fake show.
16
+ class ExampleAppShowcaseMoneyUpdateTest < ExampleAppIntegrationTestCase
17
+ setup do
18
+ skip "money-rails monetize not configured" unless FormElementShowcase.respond_to?(:monetized_attributes) &&
19
+ FormElementShowcase.monetized_attributes.key?("amount")
20
+
21
+ # Mirror the seeded "Full demo" showcase ($99.95 == 9995 cents).
22
+ @showcase = FormElementShowcase.find_or_create_by!(title: "Full demo")
23
+ @showcase.update!(amount: Money.from_amount(99.95, "USD"))
24
+ assert_equal 9995, @showcase.reload.amount_cents
25
+
26
+ @frame = "form_element_showcase_#{@showcase.id}_amount"
27
+ @headers = { "Turbo-Frame" => @frame, "Accept" => "text/html" }
28
+ end
29
+
30
+ test "malformed money update does not persist and re-renders the edit field, not a fake show" do
31
+ put form_element_showcase_path(
32
+ @showcase,
33
+ attribute: "amount",
34
+ form_element: "money_field",
35
+ update: @frame
36
+ ), params: { amount: "99.ace99" }, headers: @headers
37
+
38
+ assert_response :success
39
+
40
+ # The DB value is untouched -- no silent mutation, no bad write.
41
+ assert_equal 9995, @showcase.reload.amount_cents,
42
+ "malformed '99.ace99' must not persist; amount_cents should stay 9995"
43
+ assert_equal Money.from_amount(99.95, "USD"), @showcase.reload.amount
44
+
45
+ body = @response.body
46
+
47
+ # The response is the EDIT state (text field), not a turbo field_show.
48
+ assert_includes body, %(<turbo-frame id="#{@frame}">)
49
+ assert_includes body, "input_money_field",
50
+ "expected the edit text field (input_money_field) to be re-rendered"
51
+ # The rejected raw input stays visible so the user can correct it.
52
+ assert_includes body, "99.ace99",
53
+ "expected the rejected raw input to remain in the edit field"
54
+
55
+ # It must NOT present a saved show of the in-memory 99.99 value.
56
+ refute_match(/\$\s*99\.99/, body,
57
+ "response must not present a fake '$99.99' saved show after a failed save")
58
+ end
59
+
60
+ test "valid money update persists and renders the show" do
61
+ put form_element_showcase_path(
62
+ @showcase,
63
+ attribute: "amount",
64
+ form_element: "money_field",
65
+ update: @frame
66
+ ), params: { amount: "12.34" }, headers: @headers
67
+
68
+ assert_response :success
69
+ assert_equal 1234, @showcase.reload.amount_cents,
70
+ "valid '12.34' must persist as 1234 cents"
71
+ assert_includes @response.body, %(<turbo-frame id="#{@frame}">)
72
+ assert_includes @response.body, "12.34"
73
+ # Show state renders the humanized money, not the edit text field.
74
+ refute_includes @response.body, "input_money_field",
75
+ "valid update should render the show, not the edit field"
76
+ end
77
+ end
@@ -0,0 +1,77 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../example_app/example_integration_test_case"
4
+
5
+ # Regression for the 8.1.20 validation-hint fixes on FormElementShowcase:
6
+ #
7
+ # * count (integer_field, `numericality: { only_integer: true }`)
8
+ # * price (decimal_field, bare `numericality: true`)
9
+ # * amount (money_field, money-rails `monetize :amount_cents`, which
10
+ # registers a MoneyValidator on `:amount`)
11
+ #
12
+ # Before 8.1.20 a bare `numericality: true` emitted ZERO hint messages
13
+ # (validation_hints dead-code bug), so `price` rendered an EMPTY
14
+ # `validation-hints-source` div, and `amount` had no i18n mapping for the
15
+ # money validator key. The show panel must now render a NON-EMPTY
16
+ # `<ul class="validation-hints-list">` for all three.
17
+ class ExampleAppShowcaseValidationHintsTest < ExampleAppIntegrationTestCase
18
+ setup do
19
+ @full = FormElementShowcase.find_or_create_by!(title: "Hints demo") do |s|
20
+ s.count = 7
21
+ s.price = "12.34"
22
+ s.amount = Money.from_amount(99.95, "USD") if s.respond_to?(:amount=) && defined?(Money)
23
+ end
24
+ @row_frame = "form_element_showcase_#{@full.id}"
25
+ @row_headers = { "Turbo-Frame" => @row_frame, "Accept" => "text/html" }
26
+ end
27
+
28
+ test "count label renders a non-empty validation-hints list" do
29
+ body = show_panel_body
30
+ assert_nonempty_hint(body, :count, "must be a number", "must be an integer")
31
+ end
32
+
33
+ test "price label renders a non-empty validation-hints list (bare numericality: true)" do
34
+ body = show_panel_body
35
+ assert_nonempty_hint(body, :price, "must be a number")
36
+ end
37
+
38
+ test "amount label renders a non-empty validation-hints list (money-rails validator)" do
39
+ skip "money-rails monetize not configured" unless FormElementShowcase.respond_to?(:monetized_attributes) &&
40
+ FormElementShowcase.monetized_attributes.key?("amount")
41
+
42
+ body = show_panel_body
43
+ assert_nonempty_hint(body, :amount, "must be a valid amount")
44
+ end
45
+
46
+ private
47
+
48
+ def show_panel_body
49
+ get form_element_showcase_path(@full, update: @row_frame), headers: @row_headers
50
+ assert_response :success
51
+ @response.body
52
+ end
53
+
54
+ # Asserts the hidden `validation-hints-source` div for +attribute+ exists
55
+ # AND contains a populated `<ul class="validation-hints-list">` with each
56
+ # expected message fragment — i.e. not the empty source div the pre-8.1.20
57
+ # bug produced.
58
+ def assert_nonempty_hint(body, attribute, *expected_messages)
59
+ hint_id = "validation_hints_form_element_showcase_#{@full.id}_#{attribute}"
60
+
61
+ assert_includes body, %(data-validation-hints-source="#{hint_id}"),
62
+ "expected has-tip trigger wired to #{hint_id}"
63
+
64
+ source = body[
65
+ %r{<div id="#{Regexp.escape(hint_id)}" class="validation-hints-source" hidden>(.*?)</div>}m,
66
+ 1
67
+ ]
68
+ refute_nil source, "expected a validation-hints-source div for #{attribute}"
69
+ assert_includes source, '<ul class="validation-hints-list">',
70
+ "expected a NON-EMPTY hints list for #{attribute}, got source: #{source.inspect}"
71
+
72
+ expected_messages.each do |message|
73
+ assert_includes source, message,
74
+ "expected #{attribute} hint list to include #{message.inspect}"
75
+ end
76
+ end
77
+ end
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.18
4
+ version: 8.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ace Suares
@@ -95,10 +95,12 @@ files:
95
95
  - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_choice_scale_fields_test.rb
96
96
  - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_date_time_fields_test.rb
97
97
  - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_locales_associations_test.rb
98
+ - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_money_update_test.rb
98
99
  - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_numeric_fields_test.rb
99
100
  - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_page_render_test.rb
100
101
  - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_row_turbo_test.rb
101
102
  - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_text_fields_test.rb
103
+ - lib/installer_templates/example_app_tests/test/integration/example_app_showcase_validation_hints_test.rb
102
104
  - lib/installer_templates/example_app_tests/test/integration/example_app_turbo_layout_test.rb
103
105
  - lib/installer_templates/example_app_tests/test/integration/example_app_validation_hints_test.rb
104
106
  - lib/installer_templates/example_app_tests/test/models/example_app_apartment_name_validation_test.rb