diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/helpers/form_helper_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/helpers/form_helper_spec.rb')
-rw-r--r-- | spec/helpers/form_helper_spec.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb index 1797b0e32cd..7c8c59be409 100644 --- a/spec/helpers/form_helper_spec.rb +++ b/spec/helpers/form_helper_spec.rb @@ -162,6 +162,24 @@ RSpec.describe FormHelper do end end + it 'renders custom messages without the attribute name prefix' do + model = double(errors: errors_stub('Error 1')) + model.errors.add(:name, 'is already taken') + model.errors.add(:code_name, 'This code name is not allowed') + + allow(model.class).to receive(:human_attribute_name) do |attribute| + attribute.to_s.capitalize + end + + errors = helper.form_errors(model, custom_message: [:code_name]) + + aggregate_failures do + expect(errors).to include('<li>Error 1</li>') + expect(errors).to include('<li>Name is already taken</li>') + expect(errors).to include('<li>This code name is not allowed</li>') + end + end + it 'renders help page links' do stubbed_errors = ActiveModel::Errors.new(double).tap do |errors| errors.add(:base, 'No text.', help_page_url: 'http://localhost/doc/user/index.html') |