Skip to content

Commit 820af0b

Browse files
sethherrclaude
andcommitted
Require the claim message in the browser
A claim carries no evidence without one. Client-side only - neither the model nor impound_claims#update turns an empty claim away, which the spec says out loud. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent fc363c8 commit 820af0b

3 files changed

Lines changed: 15 additions & 3 deletions

File tree

app/components/registrations/show/current_alerts/claim_impound/component.html.erb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@
66
<% if impound_claim.present? %>
77
<% if impound_claim.unsubmitted? %>
88
<%= form_with(model: impound_claim, url: impound_claim_path(impound_claim), builder: BikeIndexFormBuilder, data: {controller: "csrf-refresh"}) do |form| %>
9+
<%#
10+
Required in the browser only - a claim carries no evidence without it, but nothing
11+
server-side turns one away for being empty
12+
%>
13+
914
<%= render(UI::Forms::Group::Component.new(form_builder: form, attribute: :message, kind: :text_area,
10-
label_text: translation(".prove_its_yours", bike_type: impound_claim.bike_type), html_options: {rows: 4})) %>
15+
label_text: translation(".prove_its_yours", bike_type: impound_claim.bike_type), required: true,
16+
html_options: {rows: 4})) %>
1117

1218
<%= render(UI::Button::Component.new(text: translation(".save_message"), color: :secondary, kind: :submit)) %>
1319
<% end %>

app/components/registrations/show/wrapper/component.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Wrapper
88
class Component < ApplicationComponent
99
# Digest of the markup inside the cache block — the cached_markup_digest spec
1010
# keeps it current, following what this tree renders out into UI:: and elsewhere
11-
MARKUP_DIGEST = "5762e9b41c69"
11+
MARKUP_DIGEST = "fb4cbfb189d9"
1212

1313
def initialize(bike:, current_user:, view:, available_views:, bike_sticker: nil, current_alerts: {})
1414
@bike = bike

spec/components/registrations/show/current_alerts/claim_impound/component_system_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,15 @@
5353
it "offers the message form, then carries the outcome once it's answered" do
5454
visit "#{preview_path}/unsubmitted"
5555

56-
expect(page).to have_field("Verify your ownership")
56+
# Required in the browser, so an empty box won't save - though nothing server-side
57+
# turns an empty claim away
58+
expect(page).to have_field("Verify your ownership", type: "textarea", valid: false)
5759
expect(page).to have_button("Save message")
5860
expect(page).to have_button("Submit claim")
61+
62+
fill_in "Verify your ownership", with: "it still has my sticker under the seat"
63+
64+
expect(page).to have_field("Verify your ownership", valid: true)
5965
# The card is the claim now, rather than an invitation to open one
6066
expect(page).to have_no_button("Claim found bike")
6167
expect_axe_clean

0 commit comments

Comments
 (0)