spamtrap 0.3.4 → 0.3.5

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: f1f9fa53d08c869e9952416e63376c31ed74f74584e9cf1e59f7439364c370d5
4
- data.tar.gz: 4ecae5a00af343aa3c8856a3f2bcf04999bd37a0112d067d3d907e5b85b75e2a
3
+ metadata.gz: 7fe29ab4e860e6ec50177f3726bee89e12d1e04ad26f1690937134e2fd3bb3ec
4
+ data.tar.gz: ccb09fadb403aa131c826422d774f9ec0d72929ca9d3f8f737a9ddb84795ecfd
5
5
  SHA512:
6
- metadata.gz: 825936fb38cb3095ecf504c42aff353081a8352539a535beff67d85ef2423fc4e7bac328c107d48d5d0ed092ea1b508be6bb06e7490c33cceb2f230a0c89e45a
7
- data.tar.gz: c35648761da54aab75b8b8d587f24d4ccfbfb03210d23ed930fbdbea2743876de9a795d19980acac9bac45b92e7bbe94621f8419440031d2e15412b6876e041a
6
+ metadata.gz: '09de714c88709d90859cb25c8f129bb88efeba1a2c697519bca1aaa8df816894e3c442e37598c423fa8740832123af86c85b204ae5eec6eeb3115566a7fe74d4'
7
+ data.tar.gz: 65bda092b52a6bc5b0a58c61c5b08ad3e2f7723c1daf6418071582691eabfa0897998bf33bd7b473aae91708621cc9f0e368d1bf8e780bf14feb761c2a8f6f23
@@ -50,6 +50,10 @@ module Spamtrap
50
50
  # 2. activerecord.attributes.Model.field (ActiveRecord models)
51
51
  # 3. helpers.label.object_name.field (plain objects / form_with)
52
52
  # 4. humanize fallback
53
+ # Discard any explicit nil that a subclass may have passed through
54
+ # (e.g. `super(method, nil, options)`) so it does not survive as a
55
+ # spurious positional argument in the final super call.
56
+ args.compact!
53
57
  unless args.first.is_a?(String)
54
58
  human_text =
55
59
  if object.respond_to?(:to_model)
@@ -1,5 +1,5 @@
1
1
  module Spamtrap
2
2
 
3
- VERSION = '0.3.4'
3
+ VERSION = '0.3.5'
4
4
 
5
5
  end
@@ -133,6 +133,38 @@ class FormBuilderMutationTest < ActionView::TestCase
133
133
  assert_match(/selected.*CA|CA.*selected/, html)
134
134
  end
135
135
 
136
+ # --- label ---
137
+
138
+ def test_label_does_not_raise_when_mutate_is_true
139
+ msg = Message.new('Alice', 'alice@example.com', 'Hello')
140
+ f = build_form_builder(msg)
141
+ f.spamtrap(:trap, mutate: true)
142
+
143
+ assert_nothing_raised { f.label(:name) }
144
+ end
145
+
146
+ def test_label_with_explicit_nil_text_does_not_raise
147
+ # Regression: a subclass that calls super(method, nil, options) used to
148
+ # produce "wrong number of arguments (given 4, expected 1..3)" because the
149
+ # nil survived as a positional argument alongside the auto-generated text.
150
+ msg = Message.new('Alice', 'alice@example.com', 'Hello')
151
+ base = build_form_builder(msg)
152
+ base.spamtrap(:trap, mutate: true)
153
+
154
+ # Simulate what a subclass does: call label with nil text explicitly.
155
+ assert_nothing_raised { base.label(:name, nil, class: 'my-label') }
156
+ end
157
+
158
+ def test_label_with_explicit_nil_text_uses_humanized_fallback
159
+ msg = Message.new('Alice', 'alice@example.com', 'Hello')
160
+ base = build_form_builder(msg)
161
+ base.spamtrap(:trap, mutate: true)
162
+
163
+ html = base.label(:name, nil, class: 'my-label')
164
+
165
+ assert_includes html, 'Name'
166
+ end
167
+
136
168
  private
137
169
 
138
170
  # ActionView::TestCase helpers expect a #request method; provide a stub.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spamtrap
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cedric Howe