summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2015-02-12 19:53:23 +0100
committerJeroen van Baarsen <jeroenvanbaarsen@gmail.com>2015-02-12 21:00:55 +0100
commit026e988544f282c87afec9a85ff21a23877f6226 (patch)
tree91dde48a6b9afc7937b1c9b20815842be6c26408 /spec/helpers
parent5bb743efec0043d79ac508503c9e28bee5fae48f (diff)
downloadgitlab-ce-026e988544f282c87afec9a85ff21a23877f6226.tar.gz
Even more hound fixes
Signed-off-by: Jeroen van Baarsen <jeroenvanbaarsen@gmail.com>
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/application_helper_spec.rb30
-rw-r--r--spec/helpers/broadcast_messages_helper_spec.rb3
-rw-r--r--spec/helpers/diff_helper_spec.rb17
-rw-r--r--spec/helpers/gitlab_markdown_helper_spec.rb58
4 files changed, 69 insertions, 39 deletions
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
index 9c8c8ab4b0f..61d6c906ad0 100644
--- a/spec/helpers/application_helper_spec.rb
+++ b/spec/helpers/application_helper_spec.rb
@@ -46,7 +46,8 @@ describe ApplicationHelper do
group = create(:group)
group.avatar = File.open(avatar_file_path)
group.save!
- expect(group_icon(group.path).to_s).to match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
+ expect(group_icon(group.path).to_s).
+ to match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
end
it 'should give default avatar_icon when no avatar is present' do
@@ -86,7 +87,8 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
user.save!
- expect(avatar_icon(user.email).to_s).to match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
+ expect(avatar_icon(user.email).to_s).
+ to match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
it 'should return an url for the avatar with relative url' do
@@ -96,7 +98,8 @@ describe ApplicationHelper do
user = create(:user)
user.avatar = File.open(avatar_file_path)
user.save!
- expect(avatar_icon(user.email).to_s).to match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
+ expect(avatar_icon(user.email).to_s).
+ to match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
it 'should call gravatar_icon when no avatar is present' do
@@ -120,7 +123,8 @@ describe ApplicationHelper do
it 'should return default gravatar url' do
Gitlab.config.gitlab.stub(https: false)
- expect(gravatar_icon(user_email)).to match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
+ url = 'http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118'
+ expect(gravatar_icon(user_email)).to match(url)
end
it 'should use SSL when appropriate' do
@@ -130,8 +134,11 @@ describe ApplicationHelper do
it 'should return custom gravatar path when gravatar_url is set' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
- allow(Gitlab.config.gravatar).to receive(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
- expect(gravatar_icon(user_email, 20)).to eq('http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118')
+ allow(Gitlab.config.gravatar).
+ to receive(:plain_url).
+ and_return('http://example.local/?s=%{size}&hash=%{hash}')
+ url = 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
+ expect(gravatar_icon(user_email, 20)).to eq(url)
end
it 'should accept a custom size' do
@@ -146,7 +153,8 @@ describe ApplicationHelper do
it 'should be case insensitive' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
- expect(gravatar_icon(user_email)).to eq(gravatar_icon(user_email.upcase + ' '))
+ expect(gravatar_icon(user_email)).
+ to eq(gravatar_icon(user_email.upcase + ' '))
end
end
@@ -170,7 +178,7 @@ describe ApplicationHelper do
it 'includes a list of tag names' do
expect(options[1][0]).to eq('Tags')
- expect(options[1][1]).to include('v1.0.0','v1.1.0')
+ expect(options[1][1]).to include('v1.0.0', 'v1.1.0')
end
it 'includes a specific commit ref if defined' do
@@ -183,9 +191,11 @@ describe ApplicationHelper do
it 'sorts tags in a natural order' do
# Stub repository.tag_names to make sure we get some valid testing data
- expect(@project.repository).to receive(:tag_names).and_return(['v1.0.9', 'v1.0.10', 'v2.0', 'v3.1.4.2', 'v1.0.9a'])
+ expect(@project.repository).to receive(:tag_names).
+ and_return(['v1.0.9', 'v1.0.10', 'v2.0', 'v3.1.4.2', 'v1.0.9a'])
- expect(options[1][1]).to eq(['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9'])
+ expect(options[1][1]).
+ to eq(['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9'])
end
end
diff --git a/spec/helpers/broadcast_messages_helper_spec.rb b/spec/helpers/broadcast_messages_helper_spec.rb
index cf310b893e0..f6df12662bb 100644
--- a/spec/helpers/broadcast_messages_helper_spec.rb
+++ b/spec/helpers/broadcast_messages_helper_spec.rb
@@ -14,7 +14,8 @@ describe BroadcastMessagesHelper do
before { broadcast_message.stub(color: "#f2dede", font: "#b94a48") }
it "should have a customized style" do
- expect(broadcast_styling(broadcast_message)).to match('background-color:#f2dede;color:#b94a48')
+ expect(broadcast_styling(broadcast_message)).
+ to match('background-color:#f2dede;color:#b94a48')
end
end
end
diff --git a/spec/helpers/diff_helper_spec.rb b/spec/helpers/diff_helper_spec.rb
index 75da43a68a6..5bd09793b11 100644
--- a/spec/helpers/diff_helper_spec.rb
+++ b/spec/helpers/diff_helper_spec.rb
@@ -10,7 +10,7 @@ describe DiffHelper do
describe 'diff_hard_limit_enabled?' do
it 'should return true if param is provided' do
- allow(controller).to receive(:params) { { :force_show_diff => true } }
+ allow(controller).to receive(:params) { { force_show_diff: true } }
expect(diff_hard_limit_enabled?).to be_truthy
end
@@ -21,7 +21,7 @@ describe DiffHelper do
describe 'allowed_diff_size' do
it 'should return hard limit for a diff if force diff is true' do
- allow(controller).to receive(:params) { { :force_show_diff => true } }
+ allow(controller).to receive(:params) { { force_show_diff: true } }
expect(allowed_diff_size).to eq(1000)
end
@@ -32,13 +32,15 @@ describe DiffHelper do
describe 'parallel_diff' do
it 'should return an array of arrays containing the parsed diff' do
- expect(parallel_diff(diff_file, 0)).to match_array(parallel_diff_result_array)
+ expect(parallel_diff(diff_file, 0)).
+ to match_array(parallel_diff_result_array)
end
end
describe 'generate_line_code' do
it 'should generate correct line code' do
- expect(generate_line_code(diff_file.file_path, diff_file.diff_lines.first)).to eq('2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6')
+ expect(generate_line_code(diff_file.file_path, diff_file.diff_lines.first)).
+ to eq('2f6fcd96b88b36ce98c38da085c795a27d92a3dd_6_6')
end
end
@@ -55,12 +57,13 @@ describe DiffHelper do
describe 'diff_line_content' do
it 'should return non breaking space when line is empty' do
- expect(diff_line_content(nil)).to eq(" &nbsp;")
+ expect(diff_line_content(nil)).to eq(' &nbsp;')
end
it 'should return the line itself' do
- expect(diff_line_content(diff_file.diff_lines.first.text)).to eq("@@ -6,12 +6,18 @@ module Popen")
- expect(diff_line_content(diff_file.diff_lines.first.type)).to eq("match")
+ expect(diff_line_content(diff_file.diff_lines.first.text)).
+ to eq('@@ -6,12 +6,18 @@ module Popen')
+ expect(diff_line_content(diff_file.diff_lines.first.type)).to eq('match')
expect(diff_line_content(diff_file.diff_lines.first.new_pos)).to eq(6)
end
end
diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb
index 87d45faa207..317a559f83c 100644
--- a/spec/helpers/gitlab_markdown_helper_spec.rb
+++ b/spec/helpers/gitlab_markdown_helper_spec.rb
@@ -1,4 +1,4 @@
-require "spec_helper"
+require 'spec_helper'
describe GitlabMarkdownHelper do
include ApplicationHelper
@@ -42,7 +42,8 @@ describe GitlabMarkdownHelper do
end
it "should not touch HTML entities" do
- allow(@project.issues).to receive(:where).with(id: '39').and_return([issue])
+ allow(@project.issues).to receive(:where).
+ with(id: '39').and_return([issue])
actual = 'We&#39;ll accept good pull requests.'
expect(gfm(actual)).to eq("We'll accept good pull requests.")
end
@@ -156,7 +157,8 @@ describe GitlabMarkdownHelper do
expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
# Append some text to the end of the reference
- expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected)
+ expect(gfm(actual.gsub(reference, "#{reference}, right?"))).
+ to match(expected)
end
it "should keep whitespace intact" do
@@ -216,9 +218,8 @@ describe GitlabMarkdownHelper do
)
# Append some text to the end of the reference
- expect(gfm(actual.gsub(full_reference, "#{full_reference}, right?"))).to(
- match(expected)
- )
+ expect(gfm(actual.gsub(full_reference, "#{full_reference}, right?"))).
+ to(match(expected))
end
it 'should keep whitespace intact' do
@@ -315,7 +316,8 @@ describe GitlabMarkdownHelper do
expect(gfm(actual.gsub(reference, "(#{reference})"))).to match(expected)
# Append some text to the end of the reference
- expect(gfm(actual.gsub(reference, "#{reference}, right?"))).to match(expected)
+ expect(gfm(actual.gsub(reference, "#{reference}, right?"))).
+ to match(expected)
end
it "should keep whitespace intact" do
@@ -471,7 +473,8 @@ describe GitlabMarkdownHelper do
expect(groups[0]).to match(/This should finally fix $/)
# First issue link
- expect(groups[1]).to match(/href="#{project_issue_url(project, issues[0])}"/)
+ expect(groups[1]).
+ to match(/href="#{project_issue_url(project, issues[0])}"/)
expect(groups[1]).to match(/##{issues[0].iid}$/)
# Internal commit link
@@ -479,7 +482,8 @@ describe GitlabMarkdownHelper do
expect(groups[2]).to match(/ and /)
# Second issue link
- expect(groups[3]).to match(/href="#{project_issue_url(project, issues[1])}"/)
+ expect(groups[3]).
+ to match(/href="#{project_issue_url(project, issues[1])}"/)
expect(groups[3]).to match(/##{issues[1].iid}$/)
# Trailing commit link
@@ -494,7 +498,8 @@ describe GitlabMarkdownHelper do
it "escapes HTML passed in as the body" do
actual = "This is a <h1>test</h1> - see ##{issues[0].iid}"
- expect(link_to_gfm(actual, commit_path)).to match('&lt;h1&gt;test&lt;/h1&gt;')
+ expect(link_to_gfm(actual, commit_path)).
+ to match('&lt;h1&gt;test&lt;/h1&gt;')
end
end
@@ -508,16 +513,20 @@ describe GitlabMarkdownHelper do
it "should handle references in headers" do
actual = "\n# Working around ##{issue.iid}\n## Apply !#{merge_request.iid}"
- expect(markdown(actual, {no_header_anchors:true})).to match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
- expect(markdown(actual, {no_header_anchors:true})).to match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
+ expect(markdown(actual, no_header_anchors: true)).
+ to match(%r{<h1[^<]*>Working around <a.+>##{issue.iid}</a></h1>})
+ expect(markdown(actual, no_header_anchors: true)).
+ to match(%r{<h2[^<]*>Apply <a.+>!#{merge_request.iid}</a></h2>})
end
it "should add ids and links to headers" do
# Test every rule except nested tags.
text = '..Ab_c-d. e..'
id = 'ab_c-d-e'
- expect(markdown("# #{text}")).to match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>})
- expect(markdown("# #{text}", {no_header_anchors:true})).to eq("<h1>#{text}</h1>")
+ expect(markdown("# #{text}")).
+ to match(%r{<h1 id="#{id}">#{text}<a href="[^"]*##{id}"></a></h1>})
+ expect(markdown("# #{text}", {no_header_anchors:true})).
+ to eq("<h1>#{text}</h1>")
id = 'link-text'
expect(markdown("# [link text](url) ![img alt](url)")).to match(
@@ -530,13 +539,16 @@ describe GitlabMarkdownHelper do
actual = "\n* dark: ##{issue.iid}\n* light by @#{member.user.username}"
- expect(markdown(actual)).to match(%r{<li>dark: <a.+>##{issue.iid}</a></li>})
- expect(markdown(actual)).to match(%r{<li>light by <a.+>@#{member.user.username}</a></li>})
+ expect(markdown(actual)).
+ to match(%r{<li>dark: <a.+>##{issue.iid}</a></li>})
+ expect(markdown(actual)).
+ to match(%r{<li>light by <a.+>@#{member.user.username}</a></li>})
end
it "should not link the apostrophe to issue 39" do
project.team << [user, :master]
- allow(project.issues).to receive(:where).with(iid: '39').and_return([issue])
+ allow(project.issues).
+ to receive(:where).with(iid: '39').and_return([issue])
actual = "Yes, it is @#{member.user.username}'s task."
expected = /Yes, it is <a.+>@#{member.user.username}<\/a>'s task/
@@ -545,7 +557,8 @@ describe GitlabMarkdownHelper do
it "should not link the apostrophe to issue 39 in code blocks" do
project.team << [user, :master]
- allow(project.issues).to receive(:where).with(iid: '39').and_return([issue])
+ allow(project.issues).
+ to receive(:where).with(iid: '39').and_return([issue])
actual = "Yes, `it is @#{member.user.username}'s task.`"
expected = /Yes, <code>it is @gfm\'s task.<\/code>/
@@ -555,7 +568,8 @@ describe GitlabMarkdownHelper do
it "should handle references in <em>" do
actual = "Apply _!#{merge_request.iid}_ ASAP"
- expect(markdown(actual)).to match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>})
+ expect(markdown(actual)).
+ to match(%r{Apply <em><a.+>!#{merge_request.iid}</a></em>})
end
it "should handle tables" do
@@ -572,8 +586,10 @@ describe GitlabMarkdownHelper do
target_html = "<pre class=\"code highlight white plaintext\"><code>some code from $40\nhere too\n</code></pre>\n"
- expect(helper.markdown("\n some code from $#{snippet.id}\n here too\n")).to eq(target_html)
- expect(helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n")).to eq(target_html)
+ expect(helper.markdown("\n some code from $#{snippet.id}\n here too\n")).
+ to eq(target_html)
+ expect(helper.markdown("\n```\nsome code from $#{snippet.id}\nhere too\n```\n")).
+ to eq(target_html)
end
it "should leave inline code untouched" do