Commit 359ed486 authored by Stan Hu's avatar Stan Hu

Fix Style/AlignHash cop violations

parent 871bb2f1
...@@ -18,8 +18,10 @@ describe Projects::BlobController do ...@@ -18,8 +18,10 @@ describe Projects::BlobController do
render_views render_views
before do before do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: id) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
end end
context "valid branch, valid file" do context "valid branch, valid file" do
...@@ -42,8 +44,10 @@ describe Projects::BlobController do ...@@ -42,8 +44,10 @@ describe Projects::BlobController do
render_views render_views
before do before do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: id) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
controller.instance_variable_set(:@blob, nil) controller.instance_variable_set(:@blob, nil)
end end
......
...@@ -13,8 +13,11 @@ describe Projects::CommitController do ...@@ -13,8 +13,11 @@ describe Projects::CommitController do
describe "#show" do describe "#show" do
shared_examples "export as" do |format| shared_examples "export as" do |format|
it "should generally work" do it "should generally work" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id,
format: format)
expect(response).to be_success expect(response).to be_success
end end
...@@ -22,13 +25,17 @@ describe Projects::CommitController do ...@@ -22,13 +25,17 @@ describe Projects::CommitController do
it "should generate it" do it "should generate it" do
expect_any_instance_of(Commit).to receive(:"to_#{format}") expect_any_instance_of(Commit).to receive(:"to_#{format}")
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id, format: format)
end end
it "should render it" do it "should render it" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id, format: format)
expect(response.body).to eq(commit.send(:"to_#{format}")) expect(response.body).to eq(commit.send(:"to_#{format}"))
end end
...@@ -37,8 +44,10 @@ describe Projects::CommitController do ...@@ -37,8 +44,10 @@ describe Projects::CommitController do
allow_any_instance_of(Commit).to receive(:"to_#{format}"). allow_any_instance_of(Commit).to receive(:"to_#{format}").
and_return('HTML entities &<>" ') and_return('HTML entities &<>" ')
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id, format: format)
expect(response.body).to_not include('&amp;') expect(response.body).to_not include('&amp;')
expect(response.body).to_not include('&gt;') expect(response.body).to_not include('&gt;')
...@@ -52,8 +61,11 @@ describe Projects::CommitController do ...@@ -52,8 +61,11 @@ describe Projects::CommitController do
let(:format) { :diff } let(:format) { :diff }
it "should really only be a git diff" do it "should really only be a git diff" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id,
format: format)
expect(response.body).to start_with("diff --git") expect(response.body).to start_with("diff --git")
end end
...@@ -64,15 +76,21 @@ describe Projects::CommitController do ...@@ -64,15 +76,21 @@ describe Projects::CommitController do
let(:format) { :patch } let(:format) { :patch }
it "should really be a git email patch" do it "should really be a git email patch" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id,
format: format)
expect(response.body).to start_with("From #{commit.id}") expect(response.body).to start_with("From #{commit.id}")
end end
it "should contain a git diff" do it "should contain a git diff" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: commit.id, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id,
format: format)
expect(response.body).to match(/^diff --git/) expect(response.body).to match(/^diff --git/)
end end
...@@ -81,8 +99,10 @@ describe Projects::CommitController do ...@@ -81,8 +99,10 @@ describe Projects::CommitController do
describe "#branches" do describe "#branches" do
it "contains branch and tags information" do it "contains branch and tags information" do
get(:branches, namespace_id: project.namespace.to_param, get(:branches,
project_id: project.to_param, id: commit.id) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id)
expect(assigns(:branches)).to include("master", "feature_conflict") expect(assigns(:branches)).to include("master", "feature_conflict")
expect(assigns(:tags)).to include("v1.1.0") expect(assigns(:tags)).to include("v1.1.0")
......
...@@ -12,8 +12,11 @@ describe Projects::CommitsController do ...@@ -12,8 +12,11 @@ describe Projects::CommitsController do
describe "GET show" do describe "GET show" do
context "as atom feed" do context "as atom feed" do
it "should render as atom" do it "should render as atom" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: "master", format: "atom") namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: "master",
format: "atom")
expect(response).to be_success expect(response).to be_success
expect(response.content_type).to eq('application/atom+xml') expect(response.content_type).to eq('application/atom+xml')
end end
......
...@@ -35,8 +35,10 @@ describe HelpController do ...@@ -35,8 +35,10 @@ describe HelpController do
context 'for image formats' do context 'for image formats' do
context 'when requested file exists' do context 'when requested file exists' do
it 'renders the raw file' do it 'renders the raw file' do
get :show, category: 'workflow/protected_branches', get :show,
file: 'protected_branches1', format: :png category: 'workflow/protected_branches',
file: 'protected_branches1',
format: :png
expect(response).to be_success expect(response).to be_success
expect(response.content_type).to eq 'image/png' expect(response.content_type).to eq 'image/png'
expect(response.headers['Content-Disposition']).to match(/^inline;/) expect(response.headers['Content-Disposition']).to match(/^inline;/)
...@@ -45,7 +47,10 @@ describe HelpController do ...@@ -45,7 +47,10 @@ describe HelpController do
context 'when requested file is missing' do context 'when requested file is missing' do
it 'renders not found' do it 'renders not found' do
get :show, category: 'foo', file: 'bar', format: :png get :show,
category: 'foo',
file: 'bar',
format: :png
expect(response).to be_not_found expect(response).to be_not_found
end end
end end
...@@ -53,7 +58,10 @@ describe HelpController do ...@@ -53,7 +58,10 @@ describe HelpController do
context 'for other formats' do context 'for other formats' do
it 'always renders not found' do it 'always renders not found' do
get :show, category: 'ssh', file: 'README', format: :foo get :show,
category: 'ssh',
file: 'README',
format: :foo
expect(response).to be_not_found expect(response).to be_not_found
end end
end end
......
...@@ -12,8 +12,11 @@ describe Projects::CompareController do ...@@ -12,8 +12,11 @@ describe Projects::CompareController do
end end
it 'compare should show some diffs' do it 'compare should show some diffs' do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, from: ref_from, to: ref_to) namespace_id: project.namespace.to_param,
project_id: project.to_param,
from: ref_from,
to: ref_to)
expect(response).to be_success expect(response).to be_success
expect(assigns(:diffs).length).to be >= 1 expect(assigns(:diffs).length).to be >= 1
......
...@@ -13,8 +13,11 @@ describe Projects::MergeRequestsController do ...@@ -13,8 +13,11 @@ describe Projects::MergeRequestsController do
describe "#show" do describe "#show" do
shared_examples "export merge as" do |format| shared_examples "export merge as" do |format|
it "should generally work" do it "should generally work" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
expect(response).to be_success expect(response).to be_success
end end
...@@ -22,13 +25,19 @@ describe Projects::MergeRequestsController do ...@@ -22,13 +25,19 @@ describe Projects::MergeRequestsController do
it "should generate it" do it "should generate it" do
expect_any_instance_of(MergeRequest).to receive(:"to_#{format}") expect_any_instance_of(MergeRequest).to receive(:"to_#{format}")
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
end end
it "should render it" do it "should render it" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
expect(response.body).to eq((merge_request.send(:"to_#{format}",user)).to_s) expect(response.body).to eq((merge_request.send(:"to_#{format}",user)).to_s)
end end
...@@ -37,8 +46,11 @@ describe Projects::MergeRequestsController do ...@@ -37,8 +46,11 @@ describe Projects::MergeRequestsController do
allow_any_instance_of(MergeRequest).to receive(:"to_#{format}"). allow_any_instance_of(MergeRequest).to receive(:"to_#{format}").
and_return('HTML entities &<>" ') and_return('HTML entities &<>" ')
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
expect(response.body).to_not include('&amp;') expect(response.body).to_not include('&amp;')
expect(response.body).to_not include('&gt;') expect(response.body).to_not include('&gt;')
...@@ -52,8 +64,11 @@ describe Projects::MergeRequestsController do ...@@ -52,8 +64,11 @@ describe Projects::MergeRequestsController do
let(:format) { :diff } let(:format) { :diff }
it "should really only be a git diff" do it "should really only be a git diff" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
expect(response.body).to start_with("diff --git") expect(response.body).to start_with("diff --git")
end end
...@@ -64,15 +79,20 @@ describe Projects::MergeRequestsController do ...@@ -64,15 +79,20 @@ describe Projects::MergeRequestsController do
let(:format) { :patch } let(:format) { :patch }
it "should really be a git email patch with commit" do it "should really be a git email patch with commit" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid, format: format)
expect(response.body[0..100]).to start_with("From #{merge_request.commits.last.id}") expect(response.body[0..100]).to start_with("From #{merge_request.commits.last.id}")
end end
it "should contain git diffs" do it "should contain git diffs" do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: merge_request.iid, format: format) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
expect(response.body).to match(/^diff --git/) expect(response.body).to match(/^diff --git/)
end end
...@@ -81,8 +101,11 @@ describe Projects::MergeRequestsController do ...@@ -81,8 +101,11 @@ describe Projects::MergeRequestsController do
describe 'GET diffs' do describe 'GET diffs' do
def go(format: 'html') def go(format: 'html')
get :diffs, namespace_id: project.namespace.to_param, get :diffs,
project_id: project.to_param, id: merge_request.iid, format: format namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format
end end
context 'as html' do context 'as html' do
...@@ -126,8 +149,11 @@ describe Projects::MergeRequestsController do ...@@ -126,8 +149,11 @@ describe Projects::MergeRequestsController do
describe 'GET commits' do describe 'GET commits' do
def go(format: 'html') def go(format: 'html')
get :commits, namespace_id: project.namespace.to_param, get :commits,
project_id: project.to_param, id: merge_request.iid, format: format namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format
end end
context 'as html' do context 'as html' do
......
...@@ -11,13 +11,18 @@ describe Projects::RefsController do ...@@ -11,13 +11,18 @@ describe Projects::RefsController do
describe 'GET #logs_tree' do describe 'GET #logs_tree' do
def default_get(format = :html) def default_get(format = :html)
get :logs_tree, namespace_id: project.namespace.to_param, get :logs_tree,
project_id: project.to_param, id: 'master', namespace_id: project.namespace.to_param,
path: 'foo/bar/baz.html', format: format project_id: project.to_param,
id: 'master',
path: 'foo/bar/baz.html',
format: format
end end
def xhr_get(format = :html) def xhr_get(format = :html)
xhr :get, :logs_tree, namespace_id: project.namespace.to_param, xhr :get,
:logs_tree,
namespace_id: project.namespace.to_param,
project_id: project.to_param, id: 'master', project_id: project.to_param, id: 'master',
path: 'foo/bar/baz.html', format: format path: 'foo/bar/baz.html', format: format
end end
......
...@@ -27,19 +27,23 @@ describe ProjectsController do ...@@ -27,19 +27,23 @@ describe ProjectsController do
it "toggles star if user is signed in" do it "toggles star if user is signed in" do
sign_in(user) sign_in(user)
expect(user.starred?(public_project)).to be_falsey expect(user.starred?(public_project)).to be_falsey
post(:toggle_star, namespace_id: public_project.namespace.to_param, post(:toggle_star,
namespace_id: public_project.namespace.to_param,
id: public_project.to_param) id: public_project.to_param)
expect(user.starred?(public_project)).to be_truthy expect(user.starred?(public_project)).to be_truthy
post(:toggle_star, namespace_id: public_project.namespace.to_param, post(:toggle_star,
namespace_id: public_project.namespace.to_param,
id: public_project.to_param) id: public_project.to_param)
expect(user.starred?(public_project)).to be_falsey expect(user.starred?(public_project)).to be_falsey
end end
it "does nothing if user is not signed in" do it "does nothing if user is not signed in" do
post(:toggle_star, namespace_id: project.namespace.to_param, post(:toggle_star,
namespace_id: project.namespace.to_param,
id: public_project.to_param) id: public_project.to_param)
expect(user.starred?(public_project)).to be_falsey expect(user.starred?(public_project)).to be_falsey
post(:toggle_star, namespace_id: project.namespace.to_param, post(:toggle_star,
namespace_id: project.namespace.to_param,
id: public_project.to_param) id: public_project.to_param)
expect(user.starred?(public_project)).to be_falsey expect(user.starred?(public_project)).to be_falsey
end end
......
...@@ -19,8 +19,10 @@ describe Projects::TreeController do ...@@ -19,8 +19,10 @@ describe Projects::TreeController do
render_views render_views
before do before do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: id) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
end end
context "valid branch, no path" do context "valid branch, no path" do
...@@ -48,8 +50,10 @@ describe Projects::TreeController do ...@@ -48,8 +50,10 @@ describe Projects::TreeController do
render_views render_views
before do before do
get(:show, namespace_id: project.namespace.to_param, get(:show,
project_id: project.to_param, id: id) namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
end end
context 'redirect to blob' do context 'redirect to blob' do
......
...@@ -14,17 +14,24 @@ describe "User Feed", feature: true do ...@@ -14,17 +14,24 @@ describe "User Feed", feature: true do
context 'feed content' do context 'feed content' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:issue) do let(:issue) do
create(:issue, project: project, create(:issue,
author: user, description: "Houston, we have a bug!\n\n***\n\nI guess.") project: project,
author: user,
description: "Houston, we have a bug!\n\n***\n\nI guess.")
end end
let(:note) do let(:note) do
create(:note, noteable: issue, author: user, create(:note,
note: 'Bug confirmed :+1:', project: project) noteable: issue,
author: user,
note: 'Bug confirmed :+1:',
project: project)
end end
let(:merge_request) do let(:merge_request) do
create(:merge_request, create(:merge_request,
title: 'Fix bug', author: user, title: 'Fix bug',
source_project: project, target_project: project, author: user,
source_project: project,
target_project: project,
description: "Here is the fix: ![an image](image.png)") description: "Here is the fix: ![an image](image.png)")
end end
......
...@@ -11,8 +11,11 @@ module Gitlab ...@@ -11,8 +11,11 @@ module Gitlab
context "without project" do context "without project" do
it "should convert the input using Asciidoctor and default options" do it "should convert the input using Asciidoctor and default options" do
expected_asciidoc_opts = { safe: :secure, backend: :html5, expected_asciidoc_opts = {
attributes: described_class::DEFAULT_ADOC_ATTRS } safe: :secure,
backend: :html5,
attributes: described_class::DEFAULT_ADOC_ATTRS
}
expect(Asciidoctor).to receive(:convert) expect(Asciidoctor).to receive(:convert)
.with(input, expected_asciidoc_opts).and_return(html) .with(input, expected_asciidoc_opts).and_return(html)
...@@ -25,8 +28,11 @@ module Gitlab ...@@ -25,8 +28,11 @@ module Gitlab
let(:asciidoc_opts) { { safe: :safe, attributes: ['foo'] } } let(:asciidoc_opts) { { safe: :safe, attributes: ['foo'] } }
it "should merge the options with default ones" do it "should merge the options with default ones" do
expected_asciidoc_opts = { safe: :safe, backend: :html5, expected_asciidoc_opts = {
attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo'] } safe: :safe,
backend: :html5,
attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo']
}
expect(Asciidoctor).to receive(:convert) expect(Asciidoctor).to receive(:convert)
.with(input, expected_asciidoc_opts).and_return(html) .with(input, expected_asciidoc_opts).and_return(html)
......
...@@ -179,7 +179,10 @@ describe Issue, 'Votes' do ...@@ -179,7 +179,10 @@ describe Issue, 'Votes' do
def add_note(text, author = issue.author) def add_note(text, author = issue.author)
created_at = Time.now - 1.hour + Note.count.seconds created_at = Time.now - 1.hour + Note.count.seconds
issue.notes << create(:note, note: text, project: issue.project, issue.notes << create(:note,
author_id: author.id, created_at: created_at) note: text,
project: issue.project,
author_id: author.id,
created_at: created_at)
end end
end end
...@@ -63,7 +63,8 @@ describe API::API, api: true do ...@@ -63,7 +63,8 @@ describe API::API, api: true do
end end
it "should return a 201 status if user is already project member" do it "should return a 201 status if user is already project member" do
post api("/projects/#{project.id}/members", user), user_id: user2.id, post api("/projects/#{project.id}/members", user),
user_id: user2.id,
access_level: ProjectMember::DEVELOPER access_level: ProjectMember::DEVELOPER
expect do expect do
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER
......
...@@ -13,12 +13,14 @@ describe MergeRequests::RefreshService do ...@@ -13,12 +13,14 @@ describe MergeRequests::RefreshService do
@project = create(:project, namespace: group) @project = create(:project, namespace: group)
@fork_project = Projects::ForkService.new(@project, @user).execute @fork_project = Projects::ForkService.new(@project, @user).execute
@merge_request = create(:merge_request, source_project: @project, @merge_request = create(:merge_request,
source_project: @project,
source_branch: 'master', source_branch: 'master',
target_branch: 'feature', target_branch: 'feature',
target_project: @project) target_project: @project)
@fork_merge_request = create(:merge_request, source_project: @fork_project, @fork_merge_request = create(:merge_request,
source_project: @fork_project,
source_branch: 'master', source_branch: 'master',
target_branch: 'feature', target_branch: 'feature',
target_project: @project) target_project: @project)
......
...@@ -5,8 +5,10 @@ describe Projects::ForkService do ...@@ -5,8 +5,10 @@ describe Projects::ForkService do
before do before do
@from_namespace = create(:namespace) @from_namespace = create(:namespace)
@from_user = create(:user, namespace: @from_namespace ) @from_user = create(:user, namespace: @from_namespace )
@from_project = create(:project, creator_id: @from_user.id, @from_project = create(:project,
namespace: @from_namespace, star_count: 107, creator_id: @from_user.id,
namespace: @from_namespace,
star_count: 107,
description: 'wow such project') description: 'wow such project')
@to_namespace = create(:namespace) @to_namespace = create(:namespace)
@to_user = create(:user, namespace: @to_namespace) @to_user = create(:user, namespace: @to_namespace)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment