Skip to content

Commit

Permalink
Revert to simple ' in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
lcreid committed Oct 2, 2023
1 parent c8bd151 commit 7a177a8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions test/bootstrap_form_group_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class BootstrapFormGroupTest < ActionView::TestCase
<span class="input-group-text">$</span>
<input required="required" class="form-control is-invalid" id="user_email" name="user[email]" type="text" />
<span class="input-group-text">.00</span>
<div class="invalid-feedback">cant be blank, is too short (minimum is 5 characters)</span>
<div class="invalid-feedback">can't be blank, is too short (minimum is 5 characters)</span>
</div>
</div>
</form>
Expand Down Expand Up @@ -404,7 +404,7 @@ class BootstrapFormGroupTest < ActionView::TestCase
expected = <<~HTML
<div class="mb-3">
<p class="form-control-plaintext">Bar</p>
<div class="invalid-feedback" style="display: block;">cant be blank, is too short (minimum is 5 characters)</div>
<div class="invalid-feedback" style="display: block;">can't be blank, is too short (minimum is 5 characters)</div>
</div>
HTML
assert_equivalent_html expected, output
Expand Down Expand Up @@ -466,7 +466,7 @@ class BootstrapFormGroupTest < ActionView::TestCase
<div class="field_with_errors">
<input required="required" class="form-control is-invalid" id="user_email" name="user[email]" type="email" />
</div>
<div class="invalid-feedback">cant be blank, is too short (minimum is 5 characters)</div>
<div class="invalid-feedback">can't be blank, is too short (minimum is 5 characters)</div>
</div>
HTML
output = @builder.email_field(:email, wrapper_class: "none-margin")
Expand All @@ -487,7 +487,7 @@ class BootstrapFormGroupTest < ActionView::TestCase
<div class="none-margin">
<label class="form-label required" for="user_email">Email</label>
<input required="required" class="form-control is-invalid" id="user_email" name="user[email]" type="text" />
<div class="invalid-feedback">cant be blank, is too short (minimum is 5 characters)</div>
<div class="invalid-feedback">can't be blank, is too short (minimum is 5 characters)</div>
<small class="form-text text-muted">This is required</small>
</div>
</form>
Expand Down
30 changes: 15 additions & 15 deletions test/bootstrap_form_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def warn(message, ...)
<form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
#{'<input name="utf8" type="hidden" value="&#x2713;"/>' unless ::Rails::VERSION::STRING >= '6'}
<div class="mb-3">
<label class="form-label required text-danger" for="user_email">Email cant be blank, is too short (minimum is 5 characters)</label>
<label class="form-label required text-danger" for="user_email">Email can't be blank, is too short (minimum is 5 characters)</label>
<input required="required" class="form-control is-invalid" id="user_email" name="user[email]" type="text" />
</div>
</form>
Expand All @@ -482,9 +482,9 @@ def warn(message, ...)
<form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
#{'<input name="utf8" type="hidden" value="&#x2713;"/>' unless ::Rails::VERSION::STRING >= '6'}
<div class="mb-3">
<label class="form-label required text-danger" for="user_email">Email cant be blank, is too short (minimum is 5 characters)</label>
<label class="form-label required text-danger" for="user_email">Email can't be blank, is too short (minimum is 5 characters)</label>
<input required="required" class="form-control is-invalid" id="user_email" name="user[email]" type="text" />
<div class="invalid-feedback">cant be blank, is too short (minimum is 5 characters)</span>
<div class="invalid-feedback">can't be blank, is too short (minimum is 5 characters)</span>
</div>
</form>
HTML
Expand All @@ -501,9 +501,9 @@ def warn(message, ...)
<form accept-charset="UTF-8" action="/users" class="new_user" id="new_user" method="post">
#{'<input name="utf8" type="hidden" value="&#x2713;"/>' unless ::Rails::VERSION::STRING >= '6'}
<div class="mb-3">
<label class="form-label required text-danger" for="user_email">Your e-mail address cant be blank, is too short (minimum is 5 characters)</label>
<label class="form-label required text-danger" for="user_email">Your e-mail address can't be blank, is too short (minimum is 5 characters)</label>
<input required="required" class="form-control is-invalid" id="user_email" name="user[email]" type="text" />
<div class="invalid-feedback">cant be blank, is too short (minimum is 5 characters)</div>
<div class="invalid-feedback">can't be blank, is too short (minimum is 5 characters)</div>
</div>
</form>
HTML
Expand All @@ -520,7 +520,7 @@ def warn(message, ...)
<div class="alert alert-danger">
<p>Please fix the following errors:</p>
<ul class="rails-bootstrap-forms-error-summary">
<li>Email cant be blank</li>
<li>Email can't be blank</li>
<li>Email is too short (minimum is 5 characters)</li>
<li>Terms must be accepted</li>
</ul>
Expand All @@ -537,7 +537,7 @@ def warn(message, ...)
<div class="my-css-class">
<p>Please fix the following errors:</p>
<ul class="rails-bootstrap-forms-error-summary">
<li>Email cant be blank</li>
<li>Email can't be blank</li>
<li>Email is too short (minimum is 5 characters)</li>
<li>Terms must be accepted</li>
</ul>
Expand All @@ -560,7 +560,7 @@ def warn(message, ...)
<div class="alert alert-danger">
<p>Please fix the following errors:</p>
<ul class="rails-bootstrap-forms-error-summary">
<li>Email cant be blank</li>
<li>Email can't be blank</li>
<li>Email is too short (minimum is 5 characters)</li>
<li>Terms must be accepted</li>
</ul>
Expand Down Expand Up @@ -601,7 +601,7 @@ def warn(message, ...)
<div class="alert alert-danger">
<p>Please fix the following errors:</p>
<ul class="rails-bootstrap-forms-error-summary">
<li>Email cant be blank</li>
<li>Email can't be blank</li>
<li>Email is too short (minimum is 5 characters)</li>
<li>Terms must be accepted</li>
</ul>
Expand All @@ -617,7 +617,7 @@ def warn(message, ...)

expected = <<~HTML
<ul class="rails-bootstrap-forms-error-summary">
<li>Email cant be blank</li>
<li>Email can't be blank</li>
<li>Email is too short (minimum is 5 characters)</li>
<li>Terms must be accepted</li>
</ul>
Expand All @@ -637,7 +637,7 @@ def warn(message, ...)
assert @user.invalid?

expected = <<~HTML
<div class="invalid-feedback">Email cant be blank, Email is too short (minimum is 5 characters)</div>
<div class="invalid-feedback">Email can't be blank, Email is too short (minimum is 5 characters)</div>
HTML
assert_equivalent_html expected, @builder.errors_on(:email)
end
Expand Down Expand Up @@ -737,7 +737,7 @@ def warn(message, ...)
<div class="mb-3">
<label class="form-label required" for="user_email">Email</label>
<input required="required" class="form-control is-invalid" id="user_email" name="user[email]" type="text" />
<div class="invalid-feedback">cant be blank, is too short (minimum is 5 characters)</div>
<div class="invalid-feedback">can't be blank, is too short (minimum is 5 characters)</div>
<small class="form-text text-muted">This is required</small>
</div>
</form>
Expand All @@ -763,7 +763,7 @@ def warn(message, ...)
<div class="field_with_errors">
<input required="required" class="form-control is-invalid" id="user_email" name="user[email]" type="text" />
</div>
<div class="invalid-feedback">cant be blank, is too short (minimum is 5 characters)</div>
<div class="invalid-feedback">can't be blank, is too short (minimum is 5 characters)</div>
<small class="form-text text-muted">This is required</small>
</div>
</form>
Expand Down Expand Up @@ -829,7 +829,7 @@ def warn(message, ...)
@user.email = nil
assert @user.invalid?

expected = '<div class="invalid-feedback">cant be blank, is too short (minimum is 5 characters)</div>'
expected = '<div class="invalid-feedback">can\'t be blank, is too short (minimum is 5 characters)</div>'

assert_equivalent_html expected, @builder.errors_on(:email, hide_attribute_name: true)
end
Expand All @@ -838,7 +838,7 @@ def warn(message, ...)
@user.email = nil
assert @user.invalid?

expected = '<div class="custom-error-class">Email cant be blank, Email is too short (minimum is 5 characters)</div>'
expected = '<div class="custom-error-class">Email can\'t be blank, Email is too short (minimum is 5 characters)</div>'

assert_equivalent_html expected, @builder.errors_on(:email, custom_class: "custom-error-class")
end
Expand Down
2 changes: 1 addition & 1 deletion test/special_form_class_models_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def user_klass.model_name
<div class="field_with_errors">
<input class="form-control is-invalid" id="user_password" name="user[password]" required="required" type="text">
</div>
<div class="invalid-feedback">can#{Rails::VERSION::MAJOR < 7 ? "'" : '’'}t be blank</div>
<div class="invalid-feedback">can't be blank</div>
</div>
HTML
assert_equivalent_html expected, @builder.text_field(:password)
Expand Down

0 comments on commit 7a177a8

Please sign in to comment.