Commit 15a05be7 authored by Robert Speicher's avatar Robert Speicher
Browse files

Fix Style/Blocks cop violations

parent 88328392
......@@ -17,13 +17,13 @@
describe "POST create" do
render_views
before {
before do
post :create,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
branch_name: branch,
ref: ref
}
end
context "valid branch name, valid source" do
let(:branch) { "merge_branch" }
......
......@@ -12,7 +12,7 @@
before do
session[:oauth_request_token] = {}
end
it "updates access token" do
token = "asdasd12345"
secret = "sekrettt"
......@@ -57,20 +57,13 @@
describe "POST create" do
let(:bitbucket_username) { user.username }
let(:bitbucket_user) {
{
user: {
username: bitbucket_username
}
}.with_indifferent_access
}
let(:bitbucket_repo) {
{
slug: "vim",
owner: bitbucket_username
}.with_indifferent_access
}
let(:bitbucket_user) do
{ user: { username: bitbucket_username } }.with_indifferent_access
end
let(:bitbucket_repo) do
{ slug: "vim", owner: bitbucket_username }.with_indifferent_access
end
before do
allow(Gitlab::BitbucketImport::KeyAdder).
......
......@@ -57,14 +57,14 @@
describe "POST create" do
let(:github_username) { user.username }
let(:github_user) {
OpenStruct.new(login: github_username)
}
let(:github_repo) {
OpenStruct.new(name: 'vim', full_name: "#{github_username}/vim", owner: OpenStruct.new(login: github_username))
}
let(:github_user) { OpenStruct.new(login: github_username) }
let(:github_repo) do
OpenStruct.new(
name: 'vim',
full_name: "#{github_username}/vim",
owner: OpenStruct.new(login: github_username)
)
end
before do
controller.stub_chain(:client, :user).and_return(github_user)
......
......@@ -49,21 +49,17 @@
describe "POST create" do
let(:gitlab_username) { user.username }
let(:gitlab_user) {
{
username: gitlab_username
}.with_indifferent_access
}
let(:gitlab_repo) {
let(:gitlab_user) do
{ username: gitlab_username }.with_indifferent_access
end
let(:gitlab_repo) do
{
path: 'vim',
path_with_namespace: "#{gitlab_username}/vim",
owner: { name: gitlab_username },
namespace: { path: gitlab_username }
}.with_indifferent_access
}
end
before do
controller.stub_chain(:client, :user).and_return(gitlab_user)
......
......@@ -36,9 +36,7 @@
end
it 'does not change issue count' do
expect {
click_button 'Save changes'
}.to_not change { Issue.count }
expect { click_button 'Save changes' }.to_not change { Issue.count }
end
it 'should update issue fields' do
......
......@@ -4,10 +4,9 @@
describe 'flatten_tree' do
let(:project) { create(:project) }
before {
@repository = project.repository
@commit = project.commit("e56497bb")
}
before do
@repository = project.repository @commit = project.commit("e56497bb")
end
context "on a directory containing more than one file/directory" do
let(:tree_item) { double(name: "files", path: "files") }
......
......@@ -7,9 +7,7 @@
it 'should not send emails' do
allow(Gitlab.config.gitlab).to receive(:email_enabled).and_return(false)
expect {
deliver_mail
}.not_to change(ActionMailer::Base.deliveries, :count)
expect { deliver_mail }.not_to change(ActionMailer::Base.deliveries, :count)
end
after do
......
......@@ -22,8 +22,13 @@
end
describe 'options uses a symbol' do
let(:options) { { maximum: :test,
attributes: { attachment: attachment } } }
let(:options) do
{
maximum: :test,
attributes: { attachment: attachment }
}
end
before do
allow(note).to receive(:test) { 10 }
end
......
......@@ -6,13 +6,13 @@
let(:app) { lambda { |env| [200, {}, "Success!"] } }
let!(:auth) { Grack::Auth.new(app) }
let(:env) {
let(:env) do
{
"rack.input" => "",
"REQUEST_METHOD" => "GET",
"QUERY_STRING" => "service=git-upload-pack"
'rack.input' => '',
'REQUEST_METHOD' => 'GET',
'QUERY_STRING' => 'service=git-upload-pack'
}
}
end
let(:status) { auth.call(env).first }
describe "#call" do
......
......@@ -2,24 +2,26 @@
describe Gitlab::BitbucketImport::ProjectCreator do
let(:user) { create(:user, bitbucket_access_token: "asdffg", bitbucket_access_token_secret: "sekret") }
let(:repo) { {
name: 'Vim',
slug: 'vim',
is_private: true,
owner: "asd" }.with_indifferent_access
}
let(:repo) do
{
name: 'Vim',
slug: 'vim',
is_private: true,
owner: "asd"
}.with_indifferent_access
end
let(:namespace){ create(:group, owner: user) }
before do
namespace.add_owner(user)
end
it 'creates project' do
allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::BitbucketImport::ProjectCreator.new(repo, namespace, user)
project = project_creator.execute
expect(project.import_url).to eq("ssh://git@bitbucket.org/asd/vim.git")
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
......
......@@ -2,14 +2,16 @@
describe Gitlab::GithubImport::ProjectCreator do
let(:user) { create(:user, github_access_token: "asdffg") }
let(:repo) { OpenStruct.new(
login: 'vim',
name: 'vim',
private: true,
full_name: 'asd/vim',
clone_url: "https://gitlab.com/asd/vim.git",
owner: OpenStruct.new(login: "john"))
}
let(:repo) do
OpenStruct.new(
login: 'vim',
name: 'vim',
private: true,
full_name: 'asd/vim',
clone_url: "https://gitlab.com/asd/vim.git",
owner: OpenStruct.new(login: "john")
)
end
let(:namespace){ create(:group, owner: user) }
before do
......@@ -18,10 +20,10 @@
it 'creates project' do
allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::GithubImport::ProjectCreator.new(repo, namespace, user)
project = project_creator.execute
expect(project.import_url).to eq("https://asdffg@gitlab.com/asd/vim.git")
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
......
......@@ -2,14 +2,16 @@
describe Gitlab::GitlabImport::ProjectCreator do
let(:user) { create(:user, gitlab_access_token: "asdffg") }
let(:repo) { {
name: 'vim',
path: 'vim',
visibility_level: Gitlab::VisibilityLevel::PRIVATE,
path_with_namespace: 'asd/vim',
http_url_to_repo: "https://gitlab.com/asd/vim.git",
owner: { name: "john" } }.with_indifferent_access
}
let(:repo) do
{
name: 'vim',
path: 'vim',
visibility_level: Gitlab::VisibilityLevel::PRIVATE,
path_with_namespace: 'asd/vim',
http_url_to_repo: "https://gitlab.com/asd/vim.git",
owner: { name: "john" }
}.with_indifferent_access
end
let(:namespace){ create(:group, owner: user) }
before do
......@@ -18,10 +20,10 @@
it 'creates project' do
allow_any_instance_of(Project).to receive(:add_import_job)
project_creator = Gitlab::GitlabImport::ProjectCreator.new(repo, namespace, user)
project = project_creator.execute
expect(project.import_url).to eq("https://oauth2:asdffg@gitlab.com/asd/vim.git")
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PRIVATE)
end
......
......@@ -4,16 +4,15 @@
let(:mapped_user) { create(:user, username: "thilo123") }
let(:raw_data) { JSON.parse(File.read(Rails.root.join("spec/fixtures/GoogleCodeProjectHosting.json"))) }
let(:client) { Gitlab::GoogleCodeImport::Client.new(raw_data) }
let(:import_data) {
let(:import_data) do
{
"repo" => client.repo("tint2").raw_data,
"user_map" => {
"thilo..." => "@#{mapped_user.username}"
}
}
}
'repo' => client.repo('tint2').raw_data,
'user_map' => { 'thilo...' => "@#{mapped_user.username}" }
}
end
let(:project) { create(:project) }
subject { described_class.new(project) }
subject { described_class.new(project) }
before do
project.create_import_data(data: import_data)
......
......@@ -2,13 +2,13 @@
describe Gitlab::GoogleCodeImport::ProjectCreator do
let(:user) { create(:user) }
let(:repo) {
let(:repo) do
Gitlab::GoogleCodeImport::Repository.new(
"name" => 'vim',
"summary" => 'VI Improved',
"repositoryUrls" => [ "https://vim.googlecode.com/git/" ]
"name" => 'vim',
"summary" => 'VI Improved',
"repositoryUrls" => ["https://vim.googlecode.com/git/"]
)
}
end
let(:namespace){ create(:group, owner: user) }
before do
......@@ -20,7 +20,7 @@
project_creator = Gitlab::GoogleCodeImport::ProjectCreator.new(repo, namespace, user)
project = project_creator.execute
expect(project.import_url).to eq("https://vim.googlecode.com/git/")
expect(project.visibility_level).to eq(Gitlab::VisibilityLevel::PUBLIC)
end
......
......@@ -11,9 +11,9 @@
)
end
let(:uid_raw) {
let(:uid_raw) do
"CN=Onur K\xC3\xBC\xC3\xA7\xC3\xBCk,OU=Test,DC=example,DC=net"
}
end
let(:email_raw) { "onur.k\xC3\xBC\xC3\xA7\xC3\xBCk@example.net" }
let(:nickname_raw) { "ok\xC3\xBC\xC3\xA7\xC3\xBCk" }
let(:first_name_raw) { 'Onur' }
......@@ -34,16 +34,16 @@
let(:nickname_utf8) { nickname_ascii.force_encoding(Encoding::UTF_8) }
let(:name_utf8) { name_ascii.force_encoding(Encoding::UTF_8) }
let(:info_hash) {
let(:info_hash) do
{
email: email_ascii,
email: email_ascii,
first_name: first_name_ascii,
last_name: last_name_ascii,
name: name_ascii,
nickname: nickname_ascii,
uid: uid_ascii
last_name: last_name_ascii,
name: name_ascii,
nickname: nickname_ascii,
uid: uid_ascii
}
}
end
context 'defaults' do
it { expect(auth_hash.provider).to eql provider_utf8 }
......
......@@ -33,10 +33,10 @@
#These must happen in the context of the satellite directory...
satellite_action = Gitlab::Satellite::Action.new(user, project)
project.satellite.lock {
project.satellite.lock do
#Now clean it up, use send to get around prepare_satellite! being protected
satellite_action.send(:prepare_satellite!, repo)
}
end
#verify it's clean
heads = repo.heads.map(&:name)
......
......@@ -82,23 +82,23 @@ def is_a_matching_diff(diff, diffs)
describe '#can_be_merged?' do
context 'on fork' do
it { expect(Gitlab::Satellite::MergeAction.new(
merge_request_fork.author,
merge_request_fork).can_be_merged?).to be_truthy }
it do
expect(Gitlab::Satellite::MergeAction.new(merge_request_fork.author, merge_request_fork).can_be_merged?).to be_truthy
end
it { expect(Gitlab::Satellite::MergeAction.new(
merge_request_fork_with_conflict.author,
merge_request_fork_with_conflict).can_be_merged?).to be_falsey }
it do
expect(Gitlab::Satellite::MergeAction.new(merge_request_fork_with_conflict.author, merge_request_fork_with_conflict).can_be_merged?).to be_falsey
end
end
context 'between branches' do
it { expect(Gitlab::Satellite::MergeAction.new(
merge_request.author,
merge_request).can_be_merged?).to be_truthy }
it do
expect(Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).can_be_merged?).to be_truthy
end
it { expect(Gitlab::Satellite::MergeAction.new(
merge_request_with_conflict.author,
merge_request_with_conflict).can_be_merged?).to be_falsey }
it do
expect(Gitlab::Satellite::MergeAction.new(merge_request_with_conflict.author, merge_request_with_conflict).can_be_merged?).to be_falsey
end
end
end
end
......@@ -418,9 +418,7 @@
describe 'project access changed' do
let(:project) { create(:project) }
let(:user) { create(:user) }
let(:project_member) { create(:project_member,
project: project,
user: user) }
let(:project_member) { create(:project_member, project: project, user: user) }
subject { Notify.project_access_granted_email(project_member.id) }
it_behaves_like 'an email sent from GitLab'
......
......@@ -44,9 +44,7 @@
it "destroys the deploy key" do
subject.destroy
expect {
deploy_key.reload
}.to raise_error(ActiveRecord::RecordNotFound)
expect { deploy_key.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
end
end
......
......@@ -50,9 +50,7 @@
it "catches exceptions" do
expect(WebHook).to receive(:post).and_raise("Some HTTP Post error")
expect {
@service_hook.execute(@data)
}.to raise_error
expect { @service_hook.execute(@data) }.to raise_error
end
end
end
......@@ -71,9 +71,7 @@
it "catches exceptions" do
expect(WebHook).to receive(:post).and_raise("Some HTTP Post error")
expect {
@project_hook.execute(@data, 'push_hooks')
}.to raise_error
expect { @project_hook.execute(@data, 'push_hooks') }.to raise_error
end
end
end
......@@ -3,7 +3,7 @@
describe SlackService::IssueMessage do
subject { SlackService::IssueMessage.new(args) }
let(:args) {
let(:args) do
{
user: {
name: 'Test User',
......@@ -23,7 +23,7 @@
description: 'issue description'
}
}
}
end
let(:color) { '#345' }
......
......@@ -3,7 +3,7 @@
describe SlackService::MergeMessage do
subject { SlackService::MergeMessage.new(args) }
let(:args) {
let(:args) do
{
user: {
name: 'Test User',
......@@ -24,7 +24,7 @@
target_branch: 'target_branch',
}
}
}
end
let(:color) { '#345' }
......
......@@ -3,7 +3,7 @@
describe SlackService::PushMessage do
subject { SlackService::PushMessage.new(args) }
let(:args) {
let(:args) do
{
after: 'after',
before: 'before',
......@@ -12,7 +12,7 @@
user_name: 'user_name',
project_url: 'url'
}
}
end
let(:color) { '#345' }
......@@ -40,16 +40,16 @@
end
context 'tag push' do
let(:args) {
let(:args) do
{
after: 'after',
before: Gitlab::Git::BLANK_SHA,
project_name: 'project_name',
ref: 'refs/tags/new_tag',
user_name: 'user_name',
project_url: 'url'
after: 'after',
before: Gitlab::Git::BLANK_SHA,
project_name: 'project_name',
ref: 'refs/tags/new_tag',
user_name: 'user_name',
project_url: 'url'
}
}
end
it 'returns a message regarding pushes' do
expect(subject.pretext).to eq('user_name pushed new tag ' \
......
......@@ -68,9 +68,16 @@
describe "Template" do
describe "for pushover service" do
let(:service_template) {
PushoverService.create(template: true, properties: { device: 'MyDevice', sound: 'mic', priority: 4, api_key: '123456789' })
}
let(:service_template) do
PushoverService.create(
template: true,
properties: {
device: 'MyDevice',
sound: 'mic',
priority: 4,
api_key: '123456789'
})
end
let(:project) { create(:project) }
describe 'should be prefilled for projects pushover service' do
......
......@@ -39,14 +39,14 @@
end
describe "POST /projects/:id/repository/files" do
let(:valid_params) {
let(:valid_params) do
{
file_path: 'newfile.rb',