inline_forms_installer 8.1.18 → 8.1.19
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 17d9be0ab02be059fbd012c30ab69203572d287491c925d1acbc1db978151b8a
|
|
4
|
+
data.tar.gz: 608a5beb0125c3fc5f7580a9eb5f6492933062f1cd5ed7e0d387e04d55f87f8e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8f34df16a70ce88353c41cb8608b4e7ebba5483b3a0431a4728fa18e6a04cf927f2b21a749799697063d26cb383217e24b19d866deeb05fb5961c5e621021147
|
|
7
|
+
data.tar.gz: 3a2b45d3f901cd11d0231052b17a442715ac50df9219127c2bfd175b1d65f979cfddaed25742483486eda6645fa661cf7aef7a10fce69c114fcc59c602f72b45
|
|
@@ -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
|
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.
|
|
4
|
+
version: 8.1.19
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ace Suares
|
|
@@ -95,6 +95,7 @@ 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
|