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

Fix Style/AlignHash cop violations

parent 871bb2f1
......@@ -18,8 +18,10 @@
render_views
before do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: id)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
end
context "valid branch, valid file" do
......@@ -42,8 +44,10 @@
render_views
before do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: id)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
controller.instance_variable_set(:@blob, nil)
end
......
......@@ -13,8 +13,11 @@
describe "#show" do
shared_examples "export as" do |format|
it "should generally work" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: commit.id, format: format)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id,
format: format)
expect(response).to be_success
end
......@@ -22,13 +25,17 @@
it "should generate it" do
expect_any_instance_of(Commit).to receive(:"to_#{format}")
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: commit.id, format: format)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id, format: format)
end
it "should render it" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: commit.id, format: format)
get(:show,
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}"))
end
......@@ -37,8 +44,10 @@
allow_any_instance_of(Commit).to receive(:"to_#{format}").
and_return('HTML entities &<>" ')
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: commit.id, format: format)
get(:show,
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('&gt;')
......@@ -52,8 +61,11 @@
let(:format) { :diff }
it "should really only be a git diff" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: commit.id, format: format)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id,
format: format)
expect(response.body).to start_with("diff --git")
end
......@@ -64,15 +76,21 @@
let(:format) { :patch }
it "should really be a git email patch" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: commit.id, format: format)
get(:show,
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}")
end
it "should contain a git diff" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: commit.id, format: format)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id,
format: format)
expect(response.body).to match(/^diff --git/)
end
......@@ -81,8 +99,10 @@
describe "#branches" do
it "contains branch and tags information" do
get(:branches, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: commit.id)
get(:branches,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: commit.id)
expect(assigns(:branches)).to include("master", "feature_conflict")
expect(assigns(:tags)).to include("v1.1.0")
......
......@@ -12,8 +12,11 @@
describe "GET show" do
context "as atom feed" do
it "should render as atom" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: "master", format: "atom")
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: "master",
format: "atom")
expect(response).to be_success
expect(response.content_type).to eq('application/atom+xml')
end
......
......@@ -35,8 +35,10 @@
context 'for image formats' do
context 'when requested file exists' do
it 'renders the raw file' do
get :show, category: 'workflow/protected_branches',
file: 'protected_branches1', format: :png
get :show,
category: 'workflow/protected_branches',
file: 'protected_branches1',
format: :png
expect(response).to be_success
expect(response.content_type).to eq 'image/png'
expect(response.headers['Content-Disposition']).to match(/^inline;/)
......@@ -45,7 +47,10 @@
context 'when requested file is missing' 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
end
end
......@@ -53,7 +58,10 @@
context 'for other formats' 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
end
end
......
......@@ -12,8 +12,11 @@
end
it 'compare should show some diffs' do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, from: ref_from, to: ref_to)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
from: ref_from,
to: ref_to)
expect(response).to be_success
expect(assigns(:diffs).length).to be >= 1
......
......@@ -13,8 +13,11 @@
describe "#show" do
shared_examples "export merge as" do |format|
it "should generally work" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: merge_request.iid, format: format)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
expect(response).to be_success
end
......@@ -22,13 +25,19 @@
it "should generate it" do
expect_any_instance_of(MergeRequest).to receive(:"to_#{format}")
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: merge_request.iid, format: format)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
end
it "should render it" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: merge_request.iid, format: format)
get(:show,
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)
end
......@@ -37,8 +46,11 @@
allow_any_instance_of(MergeRequest).to receive(:"to_#{format}").
and_return('HTML entities &<>" ')
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: merge_request.iid, format: format)
get(:show,
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('&gt;')
......@@ -52,8 +64,11 @@
let(:format) { :diff }
it "should really only be a git diff" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: merge_request.iid, format: format)
get(:show,
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")
end
......@@ -64,15 +79,20 @@
let(:format) { :patch }
it "should really be a git email patch with commit" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: merge_request.iid, format: format)
get(:show,
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}")
end
it "should contain git diffs" do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: merge_request.iid, format: format)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format)
expect(response.body).to match(/^diff --git/)
end
......@@ -81,8 +101,11 @@
describe 'GET diffs' do
def go(format: 'html')
get :diffs, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: merge_request.iid, format: format
get :diffs,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format
end
context 'as html' do
......@@ -126,8 +149,11 @@ def go(format: 'html')
describe 'GET commits' do
def go(format: 'html')
get :commits, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: merge_request.iid, format: format
get :commits,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: merge_request.iid,
format: format
end
context 'as html' do
......
......@@ -11,15 +11,20 @@
describe 'GET #logs_tree' do
def default_get(format = :html)
get :logs_tree, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: 'master',
path: 'foo/bar/baz.html', format: format
get :logs_tree,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: 'master',
path: 'foo/bar/baz.html',
format: format
end
def xhr_get(format = :html)
xhr :get, :logs_tree, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: 'master',
path: 'foo/bar/baz.html', format: format
xhr :get,
:logs_tree,
namespace_id: project.namespace.to_param,
project_id: project.to_param, id: 'master',
path: 'foo/bar/baz.html', format: format
end
it 'never throws MissingTemplate' do
......
......@@ -16,30 +16,34 @@
get :show, "go-get" => "1", namespace_id: "bogus_namespace", id: "bogus_project"
expect(response.body).to include("name='go-import'")
content = "localhost/bogus_namespace/bogus_project git http://localhost/bogus_namespace/bogus_project.git"
expect(response.body).to include("content='#{content}'")
end
end
end
describe "POST #toggle_star" do
it "toggles star if user is signed in" do
sign_in(user)
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)
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)
expect(user.starred?(public_project)).to be_falsey
end
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)
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)
expect(user.starred?(public_project)).to be_falsey
end
......
......@@ -19,8 +19,10 @@
render_views
before do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: id)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
end
context "valid branch, no path" do
......@@ -48,8 +50,10 @@
render_views
before do
get(:show, namespace_id: project.namespace.to_param,
project_id: project.to_param, id: id)
get(:show,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
id: id)
end
context 'redirect to blob' do
......
......@@ -14,17 +14,24 @@
context 'feed content' do
let(:project) { create(:project) }
let(:issue) do
create(:issue, project: project,
author: user, description: "Houston, we have a bug!\n\n***\n\nI guess.")
create(:issue,
project: project,
author: user,
description: "Houston, we have a bug!\n\n***\n\nI guess.")
end
let(:note) do
create(:note, noteable: issue, author: user,
note: 'Bug confirmed :+1:', project: project)
create(:note,
noteable: issue,
author: user,
note: 'Bug confirmed :+1:',
project: project)
end
let(:merge_request) do
create(:merge_request,
title: 'Fix bug', author: user,
source_project: project, target_project: project,
title: 'Fix bug',
author: user,
source_project: project,
target_project: project,
description: "Here is the fix: ![an image](image.png)")
end
......
......@@ -11,8 +11,11 @@ module Gitlab
context "without project" do
it "should convert the input using Asciidoctor and default options" do
expected_asciidoc_opts = { safe: :secure, backend: :html5,
attributes: described_class::DEFAULT_ADOC_ATTRS }
expected_asciidoc_opts = {
safe: :secure,
backend: :html5,
attributes: described_class::DEFAULT_ADOC_ATTRS
}
expect(Asciidoctor).to receive(:convert)
.with(input, expected_asciidoc_opts).and_return(html)
......@@ -25,8 +28,11 @@ module Gitlab
let(:asciidoc_opts) { { safe: :safe, attributes: ['foo'] } }
it "should merge the options with default ones" do
expected_asciidoc_opts = { safe: :safe, backend: :html5,
attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo'] }
expected_asciidoc_opts = {
safe: :safe,
backend: :html5,
attributes: described_class::DEFAULT_ADOC_ATTRS + ['foo']
}
expect(Asciidoctor).to receive(:convert)
.with(input, expected_asciidoc_opts).and_return(html)
......
......@@ -179,7 +179,10 @@
def add_note(text, author = issue.author)
created_at = Time.now - 1.hour + Note.count.seconds
issue.notes << create(:note, note: text, project: issue.project,
author_id: author.id, created_at: created_at)
issue.notes << create(:note,
note: text,
project: issue.project,
author_id: author.id,
created_at: created_at)
end
end
......@@ -63,8 +63,9 @@
end
it "should return a 201 status if user is already project member" 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
expect do
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER
end.not_to change { ProjectMember.count }
......
......@@ -13,12 +13,14 @@
@project = create(:project, namespace: group)
@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',
target_branch: 'feature',
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',
target_branch: 'feature',
target_project: @project)
......
......@@ -5,8 +5,10 @@
before do
@from_namespace = create(:namespace)
@from_user = create(:user, namespace: @from_namespace )
@from_project = create(:project, creator_id: @from_user.id,
namespace: @from_namespace, star_count: 107,
@from_project = create(:project,
creator_id: @from_user.id,
namespace: @from_namespace,
star_count: 107,
description: 'wow such project')
@to_namespace = create(: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