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:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-04-11 16:34:49 +0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-04-11 16:34:49 +0300
commit9a44d6977ad27a443538b2b6c34b3fdd722e9bd6 (patch)
tree487aa6ad827b903aa2c78542d9252d056d9e1238 /spec/helpers
parent73fdd4b83d76998fef9770dbeaf05981d4500b8c (diff)
parent15cbbd09fbd05cfd2447dfb43d66d7a96a708f82 (diff)
Merge branch 'master' into decouple-member-notification
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/form_helper_spec.rb46
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb7
2 files changed, 46 insertions, 7 deletions
diff --git a/spec/helpers/form_helper_spec.rb b/spec/helpers/form_helper_spec.rb
new file mode 100644
index 00000000000..b20373a96fb
--- /dev/null
+++ b/spec/helpers/form_helper_spec.rb
@@ -0,0 +1,46 @@
+require 'rails_helper'
+
+describe FormHelper do
+ describe 'form_errors' do
+ it 'returns nil when model has no errors' do
+ model = double(errors: [])
+
+ expect(helper.form_errors(model)).to be_nil
+ end
+
+ it 'renders an alert div' do
+ model = double(errors: errors_stub('Error 1'))
+
+ expect(helper.form_errors(model)).
+ to include('<div class="alert alert-danger" id="error_explanation">')
+ end
+
+ it 'contains a summary message' do
+ single_error = double(errors: errors_stub('A'))
+ multi_errors = double(errors: errors_stub('A', 'B', 'C'))
+
+ expect(helper.form_errors(single_error)).
+ to include('<h4>The form contains the following error:')
+ expect(helper.form_errors(multi_errors)).
+ to include('<h4>The form contains the following errors:')
+ end
+
+ it 'renders each message' do
+ model = double(errors: errors_stub('Error 1', 'Error 2', 'Error 3'))
+
+ errors = helper.form_errors(model)
+
+ aggregate_failures do
+ expect(errors).to include('<li>Error 1</li>')
+ expect(errors).to include('<li>Error 2</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) }
+ end
+ end
+ end
+end
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index 9adcd916ced..13de88e2f21 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -150,13 +150,6 @@ describe GitlabMarkdownHelper do
end
end
- describe 'random_markdown_tip' do
- it 'returns a random Markdown tip' do
- stub_const("#{described_class}::MARKDOWN_TIPS", ['Random tip'])
- expect(random_markdown_tip).to eq 'Random tip'
- end
- end
-
describe '#first_line_in_markdown' do
let(:text) { "@#{user.username}, can you look at this?\nHello world\n"}