Fix Style/Blocks cop violations
This commit is contained in:
parent
8832839291
commit
15a05be70d
34 changed files with 196 additions and 212 deletions
|
@ -17,13 +17,13 @@ describe Projects::BranchesController do
|
|||
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 @@ describe Import::BitbucketController do
|
|||
before do
|
||||
session[:oauth_request_token] = {}
|
||||
end
|
||||
|
||||
|
||||
it "updates access token" do
|
||||
token = "asdasd12345"
|
||||
secret = "sekrettt"
|
||||
|
@ -57,20 +57,13 @@ describe Import::BitbucketController do
|
|||
describe "POST create" do
|
||||
let(:bitbucket_username) { user.username }
|
||||
|
||||
let(:bitbucket_user) {
|
||||
{
|
||||
user: {
|
||||
username: bitbucket_username
|
||||
}
|
||||
}.with_indifferent_access
|
||||
}
|
||||
let(:bitbucket_user) do
|
||||
{ user: { username: bitbucket_username } }.with_indifferent_access
|
||||
end
|
||||
|
||||
let(:bitbucket_repo) {
|
||||
{
|
||||
slug: "vim",
|
||||
owner: bitbucket_username
|
||||
}.with_indifferent_access
|
||||
}
|
||||
let(:bitbucket_repo) do
|
||||
{ slug: "vim", owner: bitbucket_username }.with_indifferent_access
|
||||
end
|
||||
|
||||
before do
|
||||
allow(Gitlab::BitbucketImport::KeyAdder).
|
||||
|
|
|
@ -57,14 +57,14 @@ describe Import::GithubController do
|
|||
|
||||
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 Import::GitlabController do
|
|||
|
||||
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 @@ describe 'Issues', feature: true do
|
|||
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 TreeHelper do
|
|||
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 @@ describe DisableEmailInterceptor do
|
|||
|
||||
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 @@ describe 'Gitlab::FileSizeValidatorSpec' do
|
|||
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 @@ describe Grack::Auth do
|
|||
|
||||
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 @@ require 'spec_helper'
|
|||
|
||||
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 @@ require 'spec_helper'
|
|||
|
||||
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 @@ describe Gitlab::GithubImport::ProjectCreator do
|
|||
|
||||
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 @@ require 'spec_helper'
|
|||
|
||||
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 @@ describe Gitlab::GitlabImport::ProjectCreator do
|
|||
|
||||
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 @@ describe Gitlab::GoogleCodeImport::Importer do
|
|||
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 @@ require 'spec_helper'
|
|||
|
||||
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 @@ describe Gitlab::GoogleCodeImport::ProjectCreator do
|
|||
|
||||
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 @@ describe Gitlab::OAuth::AuthHash do
|
|||
)
|
||||
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 @@ describe Gitlab::OAuth::AuthHash do
|
|||
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 @@ describe 'Gitlab::Satellite::Action' do
|
|||
|
||||
#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 @@ describe 'Gitlab::Satellite::MergeAction' do
|
|||
|
||||
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 Notify do
|
|||
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 @@ describe DeployKeysProject do
|
|||
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 @@ describe ServiceHook do
|
|||
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 @@ describe ProjectHook do
|
|||
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 @@ require 'spec_helper'
|
|||
describe SlackService::IssueMessage do
|
||||
subject { SlackService::IssueMessage.new(args) }
|
||||
|
||||
let(:args) {
|
||||
let(:args) do
|
||||
{
|
||||
user: {
|
||||
name: 'Test User',
|
||||
|
@ -23,7 +23,7 @@ describe SlackService::IssueMessage do
|
|||
description: 'issue description'
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
let(:color) { '#345' }
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe SlackService::MergeMessage do
|
||||
subject { SlackService::MergeMessage.new(args) }
|
||||
|
||||
let(:args) {
|
||||
let(:args) do
|
||||
{
|
||||
user: {
|
||||
name: 'Test User',
|
||||
|
@ -24,7 +24,7 @@ describe SlackService::MergeMessage do
|
|||
target_branch: 'target_branch',
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
let(:color) { '#345' }
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
describe SlackService::PushMessage do
|
||||
subject { SlackService::PushMessage.new(args) }
|
||||
|
||||
let(:args) {
|
||||
let(:args) do
|
||||
{
|
||||
after: 'after',
|
||||
before: 'before',
|
||||
|
@ -12,7 +12,7 @@ describe SlackService::PushMessage do
|
|||
user_name: 'user_name',
|
||||
project_url: 'url'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
let(:color) { '#345' }
|
||||
|
||||
|
@ -40,16 +40,16 @@ describe SlackService::PushMessage do
|
|||
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 Service do
|
|||
|
||||
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 @@ describe API::API, api: true do
|
|||
end
|
||||
|
||||
describe "POST /projects/:id/repository/files" do
|
||||
let(:valid_params) {
|
||||
let(:valid_params) do
|
||||
{
|
||||
file_path: 'newfile.rb',
|
||||
branch_name: 'master',
|
||||
content: 'puts 8',
|
||||
commit_message: 'Added newfile'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it "should create a new file in project repo" do
|
||||
post api("/projects/#{project.id}/repository/files", user), valid_params
|
||||
|
@ -70,14 +70,14 @@ describe API::API, api: true do
|
|||
end
|
||||
|
||||
describe "PUT /projects/:id/repository/files" do
|
||||
let(:valid_params) {
|
||||
let(:valid_params) do
|
||||
{
|
||||
file_path: file_path,
|
||||
branch_name: 'master',
|
||||
content: 'puts 8',
|
||||
commit_message: 'Changed file'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it "should update existing file in project repo" do
|
||||
put api("/projects/#{project.id}/repository/files", user), valid_params
|
||||
|
@ -92,13 +92,13 @@ describe API::API, api: true do
|
|||
end
|
||||
|
||||
describe "DELETE /projects/:id/repository/files" do
|
||||
let(:valid_params) {
|
||||
let(:valid_params) do
|
||||
{
|
||||
file_path: file_path,
|
||||
branch_name: 'master',
|
||||
commit_message: 'Changed file'
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
it "should delete existing file in project repo" do
|
||||
delete api("/projects/#{project.id}/repository/files", user), valid_params
|
||||
|
|
|
@ -6,15 +6,14 @@ describe API::API, api: true do
|
|||
let(:user2) { create(:user) }
|
||||
let(:user3) { create(:user) }
|
||||
let(:admin) { create(:admin) }
|
||||
let(:project) {
|
||||
create(:project, creator_id: user.id,
|
||||
namespace: user.namespace)
|
||||
}
|
||||
let(:project_user2) {
|
||||
create(:project_member, user: user2,
|
||||
project: project,
|
||||
access_level: ProjectMember::GUEST)
|
||||
}
|
||||
|
||||
let(:project) do
|
||||
create(:project, creator_id: user.id, namespace: user.namespace)
|
||||
end
|
||||
|
||||
let(:project_user2) do
|
||||
create(:project_member, user: user2, project: project, access_level: ProjectMember::GUEST)
|
||||
end
|
||||
|
||||
describe 'POST /projects/fork/:id' do
|
||||
before { project_user2 }
|
||||
|
|
|
@ -61,10 +61,9 @@ describe API::API, api: true do
|
|||
it "should return ok and add new member" do
|
||||
new_user = create(:user)
|
||||
|
||||
expect {
|
||||
post api("/groups/#{group_no_members.id}/members", owner),
|
||||
user_id: new_user.id, access_level: GroupMember::MASTER
|
||||
}.to change { group_no_members.members.count }.by(1)
|
||||
expect do
|
||||
post api("/groups/#{group_no_members.id}/members", owner), user_id: new_user.id, access_level: GroupMember::MASTER
|
||||
end.to change { group_no_members.members.count }.by(1)
|
||||
|
||||
expect(response.status).to eq(201)
|
||||
expect(json_response['name']).to eq(new_user.name)
|
||||
|
@ -74,10 +73,9 @@ describe API::API, api: true do
|
|||
it "should not allow guest to modify group members" do
|
||||
new_user = create(:user)
|
||||
|
||||
expect {
|
||||
post api("/groups/#{group_with_members.id}/members", guest),
|
||||
user_id: new_user.id, access_level: GroupMember::MASTER
|
||||
}.not_to change { group_with_members.members.count }
|
||||
expect do
|
||||
post api("/groups/#{group_with_members.id}/members", guest), user_id: new_user.id, access_level: GroupMember::MASTER
|
||||
end.not_to change { group_with_members.members.count }
|
||||
|
||||
expect(response.status).to eq(403)
|
||||
end
|
||||
|
@ -178,9 +176,9 @@ describe API::API, api: true do
|
|||
|
||||
context "when a member of the group" do
|
||||
it "should delete guest's membership of group" do
|
||||
expect {
|
||||
expect do
|
||||
delete api("/groups/#{group_with_members.id}/members/#{guest.id}", owner)
|
||||
}.to change { group_with_members.members.count }.by(-1)
|
||||
end.to change { group_with_members.members.count }.by(-1)
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
|
|
@ -8,9 +8,10 @@ describe API::API, api: true do
|
|||
let!(:merge_request_closed) { create(:merge_request, state: "closed", author: user, assignee: user, source_project: project, target_project: project, title: "Closed test") }
|
||||
let!(:merge_request_merged) { create(:merge_request, state: "merged", author: user, assignee: user, source_project: project, target_project: project, title: "Merged test") }
|
||||
let!(:note) { create(:note_on_merge_request, author: user, project: project, noteable: merge_request, note: "a comment on a MR") }
|
||||
before {
|
||||
|
||||
before do
|
||||
project.team << [user, :reporters]
|
||||
}
|
||||
end
|
||||
|
||||
describe "GET /projects/:id/merge_requests" do
|
||||
context "when unauthenticated" do
|
||||
|
|
|
@ -61,10 +61,9 @@ describe API::API, 'ProjectHooks', api: true do
|
|||
|
||||
describe "POST /projects/:id/hooks" do
|
||||
it "should add hook to project" do
|
||||
expect {
|
||||
post api("/projects/#{project.id}/hooks", user),
|
||||
url: "http://example.com", issues_events: true
|
||||
}.to change {project.hooks.count}.by(1)
|
||||
expect do
|
||||
post api("/projects/#{project.id}/hooks", user), url: "http://example.com", issues_events: true
|
||||
end.to change {project.hooks.count}.by(1)
|
||||
expect(response.status).to eq(201)
|
||||
end
|
||||
|
||||
|
@ -105,9 +104,9 @@ describe API::API, 'ProjectHooks', api: true do
|
|||
|
||||
describe "DELETE /projects/:id/hooks/:hook_id" do
|
||||
it "should delete hook from project" do
|
||||
expect {
|
||||
expect do
|
||||
delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
|
||||
}.to change {project.hooks.count}.by(-1)
|
||||
end.to change {project.hooks.count}.by(-1)
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
|
||||
|
|
|
@ -53,10 +53,9 @@ describe API::API, api: true do
|
|||
|
||||
describe "POST /projects/:id/members" do
|
||||
it "should add user to project team" do
|
||||
expect {
|
||||
post api("/projects/#{project.id}/members", user), user_id: user2.id,
|
||||
access_level: ProjectMember::DEVELOPER
|
||||
}.to change { ProjectMember.count }.by(1)
|
||||
expect do
|
||||
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER
|
||||
end.to change { ProjectMember.count }.by(1)
|
||||
|
||||
expect(response.status).to eq(201)
|
||||
expect(json_response['username']).to eq(user2.username)
|
||||
|
@ -66,10 +65,9 @@ describe API::API, api: true 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,
|
||||
access_level: ProjectMember::DEVELOPER
|
||||
expect {
|
||||
post api("/projects/#{project.id}/members", user), user_id: user2.id,
|
||||
access_level: ProjectMember::DEVELOPER
|
||||
}.not_to change { ProjectMember.count }
|
||||
expect do
|
||||
post api("/projects/#{project.id}/members", user), user_id: user2.id, access_level: ProjectMember::DEVELOPER
|
||||
end.not_to change { ProjectMember.count }
|
||||
|
||||
expect(response.status).to eq(201)
|
||||
expect(json_response['username']).to eq(user2.username)
|
||||
|
@ -123,16 +121,16 @@ describe API::API, api: true do
|
|||
before { project_member2 }
|
||||
|
||||
it "should remove user from project team" do
|
||||
expect {
|
||||
expect do
|
||||
delete api("/projects/#{project.id}/members/#{user3.id}", user)
|
||||
}.to change { ProjectMember.count }.by(-1)
|
||||
end.to change { ProjectMember.count }.by(-1)
|
||||
end
|
||||
|
||||
it "should return 200 if team member is not part of a project" do
|
||||
delete api("/projects/#{project.id}/members/#{user3.id}", user)
|
||||
expect {
|
||||
expect do
|
||||
delete api("/projects/#{project.id}/members/#{user3.id}", user)
|
||||
}.to_not change { ProjectMember.count }
|
||||
end.to_not change { ProjectMember.count }
|
||||
end
|
||||
|
||||
it "should return 200 if team member already removed" do
|
||||
|
@ -142,9 +140,9 @@ describe API::API, api: true do
|
|||
end
|
||||
|
||||
it "should return 200 OK when the user was not member" do
|
||||
expect {
|
||||
expect do
|
||||
delete api("/projects/#{project.id}/members/1000000", user)
|
||||
}.to change { ProjectMember.count }.by(0)
|
||||
end.to change { ProjectMember.count }.by(0)
|
||||
expect(response.status).to eq(200)
|
||||
expect(json_response['message']).to eq("Access revoked")
|
||||
expect(json_response['id']).to eq(1000000)
|
||||
|
|
|
@ -17,9 +17,7 @@ describe ArchiveRepositoryService do
|
|||
end
|
||||
|
||||
it "raises an error" do
|
||||
expect {
|
||||
subject.execute(timeout: 0.0)
|
||||
}.to raise_error
|
||||
expect { subject.execute(timeout: 0.0) }.to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -218,18 +218,18 @@ describe GitPushService do
|
|||
end
|
||||
|
||||
it "doesn't create cross-reference notes for a closing reference" do
|
||||
expect {
|
||||
expect do
|
||||
service.execute(project, user, @oldrev, @newrev, @ref)
|
||||
}.not_to change { Note.where(project_id: project.id, system: true, commit_id: closing_commit.id).count }
|
||||
end.not_to change { Note.where(project_id: project.id, system: true, commit_id: closing_commit.id).count }
|
||||
end
|
||||
|
||||
it "doesn't close issues when pushed to non-default branches" do
|
||||
project.stub(default_branch: 'durf')
|
||||
|
||||
# The push still shouldn't create cross-reference notes.
|
||||
expect {
|
||||
expect do
|
||||
service.execute(project, user, @oldrev, @newrev, 'refs/heads/hurf')
|
||||
}.not_to change { Note.where(project_id: project.id, system: true).count }
|
||||
end.not_to change { Note.where(project_id: project.id, system: true).count }
|
||||
|
||||
expect(Issue.find(issue.id)).to be_opened
|
||||
end
|
||||
|
@ -238,9 +238,9 @@ describe GitPushService do
|
|||
allow(project).to receive(:default_issues_tracker?).and_return(false)
|
||||
|
||||
# The push still shouldn't create cross-reference notes.
|
||||
expect {
|
||||
expect do
|
||||
service.execute(project, user, @oldrev, @newrev, 'refs/heads/hurf')
|
||||
}.not_to change { Note.where(project_id: project.id, system: true).count }
|
||||
end.not_to change { Note.where(project_id: project.id, system: true).count }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Issues::BulkUpdateService do
|
||||
let(:issue) {
|
||||
create(:issue, project: @project)
|
||||
}
|
||||
let(:issue) { create(:issue, project: @project) }
|
||||
|
||||
before do
|
||||
@user = create :user
|
||||
|
@ -26,14 +24,14 @@ describe Issues::BulkUpdateService do
|
|||
}
|
||||
end
|
||||
|
||||
it {
|
||||
it do
|
||||
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
|
||||
expect(result[:success]).to be_truthy
|
||||
expect(result[:count]).to eq(@issues.count)
|
||||
|
||||
expect(@project.issues.opened).to be_empty
|
||||
expect(@project.issues.closed).not_to be_empty
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -49,14 +47,14 @@ describe Issues::BulkUpdateService do
|
|||
}
|
||||
end
|
||||
|
||||
it {
|
||||
it do
|
||||
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
|
||||
expect(result[:success]).to be_truthy
|
||||
expect(result[:count]).to eq(@issues.count)
|
||||
|
||||
expect(@project.issues.closed).to be_empty
|
||||
expect(@project.issues.opened).not_to be_empty
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -70,13 +68,13 @@ describe Issues::BulkUpdateService do
|
|||
}
|
||||
end
|
||||
|
||||
it {
|
||||
it do
|
||||
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
|
||||
expect(result[:success]).to be_truthy
|
||||
expect(result[:count]).to eq(1)
|
||||
|
||||
expect(@project.issues.first.assignee).to eq(@new_assignee)
|
||||
}
|
||||
end
|
||||
|
||||
it 'allows mass-unassigning' do
|
||||
@project.issues.first.update_attribute(:assignee, @new_assignee)
|
||||
|
@ -109,13 +107,13 @@ describe Issues::BulkUpdateService do
|
|||
}
|
||||
end
|
||||
|
||||
it {
|
||||
it do
|
||||
result = Issues::BulkUpdateService.new(@project, @user, @params).execute
|
||||
expect(result[:success]).to be_truthy
|
||||
expect(result[:count]).to eq(1)
|
||||
|
||||
expect(@project.issues.first.milestone).to eq(@milestone)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue