Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-03-02 21:07:42 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-03-02 21:07:42 +0300
commit7b52c7cb634ef7047d30b0337fe477bcdcedf41d (patch)
tree374ca9e908204488422046f10e340d1500780362 /spec/helpers
parentb375c6c05fbd03aea33a9ee9f82e678bdaa8c3cc (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/form_helper_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb
index 68aa0137cd5..6698d8970e7 100644
--- a/spec/helpers/form_helper_spec.rb
+++ b/spec/helpers/form_helper_spec.rb
@@ -39,6 +39,25 @@ describe FormHelper do
end
end
+ it 'renders messages truncated if requested' do
+ model = double(errors: errors_stub('Error 1', 'Error 2'))
+ model.errors.add(:title, 'is truncated')
+ model.errors.add(:base, 'Error 3')
+
+ expect(model.class).to receive(:human_attribute_name) do |attribute|
+ attribute.to_s.capitalize
+ end
+
+ errors = helper.form_errors(model, truncate: :title)
+
+ aggregate_failures do
+ expect(errors).to include('<li>Error 1</li>')
+ expect(errors).to include('<li>Error 2</li>')
+ expect(errors).to include('<li><span class="str-truncated-100">Title is truncated</span></li>')
+ expect(errors).to include('<li>Error 3</li>')
+ end
+ end
+
def errors_stub(*messages)
ActiveModel::Errors.new(double).tap do |errors|
messages.each { |msg| errors.add(:base, msg) }