Commit 41e64d3c authored by Robert Speicher's avatar Robert Speicher

Fix Rubocop warnings

parent dd328184
...@@ -55,10 +55,10 @@ describe ProjectsFinder do ...@@ -55,10 +55,10 @@ describe ProjectsFinder do
end end
context 'authenticated, group member with project shared with group' do context 'authenticated, group member with project shared with group' do
before { before do
group.add_user(user, Gitlab::Access::DEVELOPER) group.add_user(user, Gitlab::Access::DEVELOPER)
project5.project_group_links.create group_access: Gitlab::Access::MASTER, group: group project5.project_group_links.create group_access: Gitlab::Access::MASTER, group: group
} end
subject { ProjectsFinder.new.execute(user, group: group2) } subject { ProjectsFinder.new.execute(user, group: group2) }
......
...@@ -120,8 +120,9 @@ describe Gitlab::LDAP::Access do ...@@ -120,8 +120,9 @@ describe Gitlab::LDAP::Access do
describe :update_ssh_keys do describe :update_ssh_keys do
let(:ssh_key) { "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrSQHff6a1rMqBdHFt+FwIbytMZ+hJKN3KLkTtOWtSvNIriGhnTdn4rs+tjD/w+z+revytyWnMDM9dS7J8vQi006B16+hc9Xf82crqRoPRDnBytgAFFQY1G/55ql2zdfsC5yvpDOFzuwIJq5dNGsojS82t6HNmmKPq130fzsenFnj5v1pl3OJvk513oduUyKiZBGTroWTn7H/eOPtu7s9MD7pAdEjqYKFLeaKmyidiLmLqQlCRj3Tl2U9oyFg4PYNc0bL5FZJ/Z6t0Ds3i/a2RanQiKxrvgu3GSnUKMx7WIX373baL4jeM7cprRGiOY/1NcS+1cAjfJ8oaxQF/1dYj" } let(:ssh_key) { "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrSQHff6a1rMqBdHFt+FwIbytMZ+hJKN3KLkTtOWtSvNIriGhnTdn4rs+tjD/w+z+revytyWnMDM9dS7J8vQi006B16+hc9Xf82crqRoPRDnBytgAFFQY1G/55ql2zdfsC5yvpDOFzuwIJq5dNGsojS82t6HNmmKPq130fzsenFnj5v1pl3OJvk513oduUyKiZBGTroWTn7H/eOPtu7s9MD7pAdEjqYKFLeaKmyidiLmLqQlCRj3Tl2U9oyFg4PYNc0bL5FZJ/Z6t0Ds3i/a2RanQiKxrvgu3GSnUKMx7WIX373baL4jeM7cprRGiOY/1NcS+1cAjfJ8oaxQF/1dYj" }
let(:ssh_key_attribute_name) { 'altSecurityIdentities' } let(:ssh_key_attribute_name) { 'altSecurityIdentities' }
let(:entry) { let(:entry) do
Net::LDAP::Entry.from_single_ldif_string("dn: cn=foo, dc=bar, dc=com\n#{ssh_key_attribute_name}: SSHKey:#{ssh_key}\n#{ssh_key_attribute_name}: KerberosKey:bogus") } Net::LDAP::Entry.from_single_ldif_string("dn: cn=foo, dc=bar, dc=com\n#{ssh_key_attribute_name}: SSHKey:#{ssh_key}\n#{ssh_key_attribute_name}: KerberosKey:bogus")
end
before do before do
Gitlab::LDAP::Config.any_instance.stub(sync_ssh_keys: ssh_key_attribute_name) Gitlab::LDAP::Config.any_instance.stub(sync_ssh_keys: ssh_key_attribute_name)
...@@ -289,8 +290,7 @@ objectclass: posixGroup ...@@ -289,8 +290,7 @@ objectclass: posixGroup
context "existing access as master for group-1, not allowed" do context "existing access as master for group-1, not allowed" do
before do before do
gitlab_group_1.group_members.masters.create(user_id: user.id) gitlab_group_1.group_members.masters.create(user_id: user.id)
gitlab_group_1.ldap_group_links.create({ gitlab_group_1.ldap_group_links.create(cn: 'ldap-group1', group_access: Gitlab::Access::MASTER, provider: 'ldapmain')
cn: 'ldap-group1', group_access: Gitlab::Access::MASTER, provider: 'ldapmain'})
access.stub(cns_with_access: ['ldap-group2']) access.stub(cns_with_access: ['ldap-group2'])
end end
...@@ -303,8 +303,7 @@ objectclass: posixGroup ...@@ -303,8 +303,7 @@ objectclass: posixGroup
context "existing access as owner for group-1 with no other owner, not allowed" do context "existing access as owner for group-1 with no other owner, not allowed" do
before do before do
gitlab_group_1.group_members.owners.create(user_id: user.id) gitlab_group_1.group_members.owners.create(user_id: user.id)
gitlab_group_1.ldap_group_links.create({ gitlab_group_1.ldap_group_links.create(cn: 'ldap-group1', group_access: Gitlab::Access::OWNER, provider: 'ldapmain')
cn: 'ldap-group1', group_access: Gitlab::Access::OWNER, provider: 'ldapmain'})
access.stub(cns_with_access: ['ldap-group2']) access.stub(cns_with_access: ['ldap-group2'])
end end
...@@ -317,9 +316,8 @@ objectclass: posixGroup ...@@ -317,9 +316,8 @@ objectclass: posixGroup
context "existing access as owner for group-1 while other owners present, not allowed" do context "existing access as owner for group-1 while other owners present, not allowed" do
before do before do
owner2 = create(:user) # a 2nd owner owner2 = create(:user) # a 2nd owner
gitlab_group_1.group_members.owners.create([ {user_id: user.id}, {user_id: owner2.id} ] ) gitlab_group_1.group_members.owners.create([{ user_id: user.id }, { user_id: owner2.id }])
gitlab_group_1.ldap_group_links.create({ gitlab_group_1.ldap_group_links.create(cn: 'ldap-group1', group_access: Gitlab::Access::OWNER, provider: 'ldapmain')
cn: 'ldap-group1', group_access: Gitlab::Access::OWNER, provider: 'ldapmain'})
access.stub(cns_with_access: ['ldap-group2']) access.stub(cns_with_access: ['ldap-group2'])
end end
......
...@@ -6,8 +6,9 @@ describe Gitlab::LDAP::Person do ...@@ -6,8 +6,9 @@ describe Gitlab::LDAP::Person do
let(:ssh_key) { "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrSQHff6a1rMqBdHFt+FwIbytMZ+hJKN3KLkTtOWtSvNIriGhnTdn4rs+tjD/w+z+revytyWnMDM9dS7J8vQi006B16+hc9Xf82crqRoPRDnBytgAFFQY1G/55ql2zdfsC5yvpDOFzuwIJq5dNGsojS82t6HNmmKPq130fzsenFnj5v1pl3OJvk513oduUyKiZBGTroWTn7H/eOPtu7s9MD7pAdEjqYKFLeaKmyidiLmLqQlCRj3Tl2U9oyFg4PYNc0bL5FZJ/Z6t0Ds3i/a2RanQiKxrvgu3GSnUKMx7WIX373baL4jeM7cprRGiOY/1NcS+1cAjfJ8oaxQF/1dYj" } let(:ssh_key) { "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCrSQHff6a1rMqBdHFt+FwIbytMZ+hJKN3KLkTtOWtSvNIriGhnTdn4rs+tjD/w+z+revytyWnMDM9dS7J8vQi006B16+hc9Xf82crqRoPRDnBytgAFFQY1G/55ql2zdfsC5yvpDOFzuwIJq5dNGsojS82t6HNmmKPq130fzsenFnj5v1pl3OJvk513oduUyKiZBGTroWTn7H/eOPtu7s9MD7pAdEjqYKFLeaKmyidiLmLqQlCRj3Tl2U9oyFg4PYNc0bL5FZJ/Z6t0Ds3i/a2RanQiKxrvgu3GSnUKMx7WIX373baL4jeM7cprRGiOY/1NcS+1cAjfJ8oaxQF/1dYj" }
let(:ssh_key_attribute_name) { 'altSecurityIdentities' } let(:ssh_key_attribute_name) { 'altSecurityIdentities' }
let(:entry) { let(:entry) do
Net::LDAP::Entry.from_single_ldif_string("dn: cn=foo, dc=bar, dc=com\n#{keys}") } Net::LDAP::Entry.from_single_ldif_string("dn: cn=foo, dc=bar, dc=com\n#{keys}")
end
subject { Gitlab::LDAP::Person.new(entry, 'ldapmain') } subject { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
......
...@@ -109,13 +109,17 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -109,13 +109,17 @@ describe 'Gitlab::Satellite::MergeAction' do
merge_request.stub(:should_rebase).and_return(true) merge_request.stub(:should_rebase).and_return(true)
end end
it { Gitlab::Satellite::MergeAction.new( it do
merge_request_fork.author, Gitlab::Satellite::MergeAction.new(
merge_request_fork).merge!.should be_truthy } merge_request_fork.author,
merge_request_fork).merge!.should be_truthy
end
it { Gitlab::Satellite::MergeAction.new( it do
merge_request_fork_with_conflict.author, Gitlab::Satellite::MergeAction.new(
merge_request_fork_with_conflict).merge!.should be_falsey } merge_request_fork_with_conflict.author,
merge_request_fork_with_conflict).merge!.should be_falsey
end
end end
context 'between branches' do context 'between branches' do
...@@ -123,14 +127,17 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -123,14 +127,17 @@ describe 'Gitlab::Satellite::MergeAction' do
merge_request.stub(:should_rebase).and_return(true) merge_request.stub(:should_rebase).and_return(true)
end end
it { Gitlab::Satellite::MergeAction.new( it do
merge_request.author, Gitlab::Satellite::MergeAction.new(
merge_request).merge!.should be_truthy } merge_request.author,
merge_request).merge!.should be_truthy
end
it { Gitlab::Satellite::MergeAction.new( it do
merge_request_with_conflict.author, Gitlab::Satellite::MergeAction.new(
merge_request_with_conflict).merge!.should be_falsey } merge_request_with_conflict.author,
merge_request_with_conflict).merge!.should be_falsey
end
end end
end end
end end
...@@ -33,4 +33,4 @@ describe LdapGroupLink do ...@@ -33,4 +33,4 @@ describe LdapGroupLink do
end end
end end
end end
end end
\ No newline at end of file
...@@ -136,9 +136,7 @@ describe API::API, api: true do ...@@ -136,9 +136,7 @@ describe API::API, api: true do
it "creates an ldap_group_link if ldap_cn and ldap_access are supplied" do it "creates an ldap_group_link if ldap_cn and ldap_access are supplied" do
group_attributes = attributes_for(:group, ldap_cn: 'ldap-group', ldap_access: Gitlab::Access::DEVELOPER) group_attributes = attributes_for(:group, ldap_cn: 'ldap-group', ldap_access: Gitlab::Access::DEVELOPER)
expect { expect { post api("/groups", admin), group_attributes }.to change{ LdapGroupLink.count }.by(1)
post api("/groups", admin), group_attributes
}.to change{ LdapGroupLink.count }.by(1)
end end
end end
end end
......
...@@ -29,10 +29,10 @@ describe API::API, api: true do ...@@ -29,10 +29,10 @@ describe API::API, api: true do
context "when a less priviledged user" do context "when a less priviledged user" do
it "should not allow less priviledged user to add LDAP group link" do it "should not allow less priviledged user to add LDAP group link" do
expect { expect do
post api("/groups/#{group_with_ldap_links.id}/ldap_group_links", user), post api("/groups/#{group_with_ldap_links.id}/ldap_group_links", user),
cn: 'ldap-group4', group_access: GroupMember::GUEST cn: 'ldap-group4', group_access: GroupMember::GUEST
}.not_to change { group_with_ldap_links.ldap_group_links.count } end.not_to change { group_with_ldap_links.ldap_group_links.count }
expect(response.status).to eq(403) expect(response.status).to eq(403)
end end
...@@ -40,10 +40,10 @@ describe API::API, api: true do ...@@ -40,10 +40,10 @@ describe API::API, api: true do
context "when owner of the group" do context "when owner of the group" do
it "should return ok and add ldap group link" do it "should return ok and add ldap group link" do
expect { expect do
post api("/groups/#{group_with_ldap_links.id}/ldap_group_links", owner), post api("/groups/#{group_with_ldap_links.id}/ldap_group_links", owner),
cn: 'ldap-group3', group_access: GroupMember::GUEST, provider: 'ldap3' cn: 'ldap-group3', group_access: GroupMember::GUEST, provider: 'ldap3'
}.to change { group_with_ldap_links.ldap_group_links.count }.by(1) end.to change { group_with_ldap_links.ldap_group_links.count }.by(1)
expect(response.status).to eq(201) expect(response.status).to eq(201)
expect(json_response['cn']).to eq('ldap-group3') expect(json_response['cn']).to eq('ldap-group3')
...@@ -52,10 +52,10 @@ describe API::API, api: true do ...@@ -52,10 +52,10 @@ describe API::API, api: true do
end end
it "should return ok and add ldap group link even if no provider specified" do it "should return ok and add ldap group link even if no provider specified" do
expect { expect do
post api("/groups/#{group_with_ldap_links.id}/ldap_group_links", owner), post api("/groups/#{group_with_ldap_links.id}/ldap_group_links", owner),
cn: 'ldap-group3', group_access: GroupMember::GUEST cn: 'ldap-group3', group_access: GroupMember::GUEST
}.to change { group_with_ldap_links.ldap_group_links.count }.by(1) end.to change { group_with_ldap_links.ldap_group_links.count }.by(1)
expect(response.status).to eq(201) expect(response.status).to eq(201)
expect(json_response['cn']).to eq('ldap-group3') expect(json_response['cn']).to eq('ldap-group3')
...@@ -95,9 +95,9 @@ describe API::API, api: true do ...@@ -95,9 +95,9 @@ describe API::API, api: true do
context "when a less priviledged user" do context "when a less priviledged user" do
it "should not remove the LDAP group link" do it "should not remove the LDAP group link" do
expect { expect do
delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap-group1", user) delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap-group1", user)
}.not_to change { group_with_ldap_links.ldap_group_links.count } end.not_to change { group_with_ldap_links.ldap_group_links.count }
expect(response.status).to eq(403) expect(response.status).to eq(403)
end end
...@@ -105,17 +105,17 @@ describe API::API, api: true do ...@@ -105,17 +105,17 @@ describe API::API, api: true do
context "when owner of the group" do context "when owner of the group" do
it "should remove ldap group link" do it "should remove ldap group link" do
expect { expect do
delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap-group1", owner) delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap-group1", owner)
}.to change { group_with_ldap_links.ldap_group_links.count }.by(-1) end.to change { group_with_ldap_links.ldap_group_links.count }.by(-1)
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
it "should return 404 if LDAP group cn not used for a LDAP group link" do it "should return 404 if LDAP group cn not used for a LDAP group link" do
expect { expect do
delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap-group1356", owner) delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap-group1356", owner)
}.not_to change { group_with_ldap_links.ldap_group_links.count } end.not_to change { group_with_ldap_links.ldap_group_links.count }
expect(response.status).to eq(404) expect(response.status).to eq(404)
end end
...@@ -132,9 +132,9 @@ describe API::API, api: true do ...@@ -132,9 +132,9 @@ describe API::API, api: true do
context "when a less priviledged user" do context "when a less priviledged user" do
it "should not remove the LDAP group link" do it "should not remove the LDAP group link" do
expect { expect do
delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap2/ldap-group2", user) delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap2/ldap-group2", user)
}.not_to change { group_with_ldap_links.ldap_group_links.count } end.not_to change { group_with_ldap_links.ldap_group_links.count }
expect(response.status).to eq(403) expect(response.status).to eq(403)
end end
...@@ -142,17 +142,17 @@ describe API::API, api: true do ...@@ -142,17 +142,17 @@ describe API::API, api: true do
context "when owner of the group" do context "when owner of the group" do
it "should return 404 if LDAP group cn not used for a LDAP group link for the specified provider" do it "should return 404 if LDAP group cn not used for a LDAP group link for the specified provider" do
expect { expect do
delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap1/ldap-group2", owner) delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap1/ldap-group2", owner)
}.not_to change { group_with_ldap_links.ldap_group_links.count } end.not_to change { group_with_ldap_links.ldap_group_links.count }
expect(response.status).to eq(404) expect(response.status).to eq(404)
end end
it "should remove ldap group link" do it "should remove ldap group link" do
expect { expect do
delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap2/ldap-group2", owner) delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap2/ldap-group2", owner)
}.to change { group_with_ldap_links.ldap_group_links.count }.by(-1) end.to change { group_with_ldap_links.ldap_group_links.count }.by(-1)
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
......
...@@ -638,10 +638,9 @@ describe API::API, api: true do ...@@ -638,10 +638,9 @@ describe API::API, api: true do
let(:group) { create(:group) } let(:group) { create(:group) }
it "should share project with group" do it "should share project with group" do
expect { expect do
post api("/projects/#{project.id}/share", user), group_id: group.id, post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER
group_access: Gitlab::Access::DEVELOPER end.to change { ProjectGroupLink.count }.by(1)
}.to change { ProjectGroupLink.count }.by(1)
response.status.should == 201 response.status.should == 201
json_response['group_id'].should == group.id json_response['group_id'].should == group.id
......
...@@ -262,8 +262,7 @@ describe GitPushService do ...@@ -262,8 +262,7 @@ describe GitPushService do
WebMock.stub_request(:post, jira_api_transition_url) WebMock.stub_request(:post, jira_api_transition_url)
WebMock.stub_request(:post, jira_api_comment_url) WebMock.stub_request(:post, jira_api_comment_url)
WebMock.stub_request(:get, jira_api_comment_url). WebMock.stub_request(:get, jira_api_comment_url).to_return(body: jira_issue_comments)
to_return(:body => jira_issue_comments)
WebMock.stub_request(:get, jira_api_project_url) WebMock.stub_request(:get, jira_api_project_url)
closing_commit.stub({ closing_commit.stub({
...@@ -281,7 +280,7 @@ describe GitPushService do ...@@ -281,7 +280,7 @@ describe GitPushService do
end end
it "should initiate one api call to jira server to close the issue" do it "should initiate one api call to jira server to close the issue" do
message = { message = {
update: { update: {
comment: [{ comment: [{
add: { add: {
......
...@@ -411,8 +411,7 @@ describe SystemNoteService do ...@@ -411,8 +411,7 @@ describe SystemNoteService do
describe "new reference" do describe "new reference" do
before do before do
WebMock.stub_request(:get, jira_api_comment_url). WebMock.stub_request(:get, jira_api_comment_url).to_return(body: jira_issue_comments)
to_return(:body => jira_issue_comments)
end end
subject { Note.create_cross_reference_note(jira_issue, commit, author) } subject { Note.create_cross_reference_note(jira_issue, commit, author) }
...@@ -423,8 +422,7 @@ describe SystemNoteService do ...@@ -423,8 +422,7 @@ describe SystemNoteService do
describe "existing reference" do describe "existing reference" do
before do before do
message = "[#{author.name}|http://localhost/u/#{author.username}] mentioned this issue in [a commit of #{project.path_with_namespace}|http://localhost/#{project.path_with_namespace}/commit/#{commit.id}]." message = "[#{author.name}|http://localhost/u/#{author.username}] mentioned this issue in [a commit of #{project.path_with_namespace}|http://localhost/#{project.path_with_namespace}/commit/#{commit.id}]."
WebMock.stub_request(:get, jira_api_comment_url). WebMock.stub_request(:get, jira_api_comment_url).to_return(body: "{\"comments\":[{\"body\":\"#{message}\"}]}")
to_return(:body => "{\"comments\":[{\"body\":\"#{message}\"}]}")
end end
subject { Note.create_cross_reference_note(jira_issue, commit, author) } subject { Note.create_cross_reference_note(jira_issue, commit, author) }
...@@ -437,8 +435,7 @@ describe SystemNoteService do ...@@ -437,8 +435,7 @@ describe SystemNoteService do
before do before do
jira_service_settings jira_service_settings
WebMock.stub_request(:post, jira_api_comment_url) WebMock.stub_request(:post, jira_api_comment_url)
WebMock.stub_request(:get, jira_api_comment_url). WebMock.stub_request(:get, jira_api_comment_url).to_return(body: jira_issue_comments)
to_return(:body => jira_issue_comments)
end end
after do after do
......
require 'spec_helper' require 'spec_helper'
describe TestHookService do describe TestHookService do
let (:user) { create :user } let(:user) { create :user }
let (:group) { create :group } let(:group) { create :group }
let (:project) { create :project, group: group } let(:project) { create :project, group: group }
let (:project_hook){ create :project_hook, project: project } let(:project_hook) { create :project_hook, project: project }
let (:group_hook) { create :group_hook, group: group } let(:group_hook) { create :group_hook, group: group }
describe :execute do describe :execute do
it "should successfully execute the project hook" do it "should successfully execute the project hook" do
......
...@@ -19,4 +19,4 @@ describe AdminEmailsWorker do ...@@ -19,4 +19,4 @@ describe AdminEmailsWorker do
expect(ActionMailer::Base.deliveries.count).to eql 2 expect(ActionMailer::Base.deliveries.count).to eql 2
end end
end end
end end
\ No newline at end of file
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