inline_forms_installer 8.1.19 → 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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e2acd92d33de3e1bcd824630a6a4e5166906d938ffb4baa18e8580cb9c8df63b
|
|
4
|
+
data.tar.gz: e26ce5fb20d87ac207540afa979ab716f2d5713663b3608eceb0b7185d1fab8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 40cd451d291f9920a74d09f4f7e2b61166438413b06e2c73d51463d84ddce674ac7ed88753f6276503953e0c99792761c9cfcdbd09a6290e64fcd18b47099084
|
|
7
|
+
data.tar.gz: 5a87788bf2d7c3878102d7e973f63565c12532de1677043e39c4bee61472c4ea710362ebbebc177b544242db56e9e9a0e5c8673c83a1fa9acd1216d8afcf31cd
|
|
@@ -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.
|
|
4
|
+
version: 8.1.20
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ace Suares
|
|
@@ -100,6 +100,7 @@ files:
|
|
|
100
100
|
- lib/installer_templates/example_app_tests/test/integration/example_app_showcase_page_render_test.rb
|
|
101
101
|
- lib/installer_templates/example_app_tests/test/integration/example_app_showcase_row_turbo_test.rb
|
|
102
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
|
|
103
104
|
- lib/installer_templates/example_app_tests/test/integration/example_app_turbo_layout_test.rb
|
|
104
105
|
- lib/installer_templates/example_app_tests/test/integration/example_app_validation_hints_test.rb
|
|
105
106
|
- lib/installer_templates/example_app_tests/test/models/example_app_apartment_name_validation_test.rb
|