Commit ce5bc4f8 authored by Robert Speicher's avatar Robert Speicher

RSpec 3 updates for EE

parent 41e64d3c
......@@ -9,14 +9,14 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
end
step 'I should be redirected to admin appearance page' do
current_path.should == admin_appearances_path
page.should have_content 'Appearance settings'
expect(current_path).to eq admin_appearances_path
expect(page).to have_content 'Appearance settings'
end
step 'I should see newly created appearance' do
page.should have_field('appearance_title', with: 'MyCompany')
page.should have_field('appearance_description', with: 'dev server')
page.should have_content 'Last edit'
expect(page).to have_field('appearance_title', with: 'MyCompany')
expect(page).to have_field('appearance_description', with: 'dev server')
expect(page).to have_content 'Last edit'
end
step 'I click preview button' do
......@@ -28,8 +28,8 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
end
step 'I should see a customized appearance' do
page.should have_content appearance.title
page.should have_content appearance.description
expect(page).to have_content appearance.title
expect(page).to have_content appearance.description
end
step 'I attach a logo' do
......@@ -43,11 +43,11 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
end
step 'I should see a logo' do
page.should have_xpath('//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]')
expect(page).to have_xpath('//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]')
end
step 'I should see header logos' do
page.should have_xpath('//img[@src="/uploads/appearance/light_logo/1/header_logo_light.png"]')
expect(page).to have_xpath('//img[@src="/uploads/appearance/light_logo/1/header_logo_light.png"]')
end
step 'I remove the logo' do
......@@ -59,11 +59,11 @@ class Spinach::Features::AdminAppearance < Spinach::FeatureSteps
end
step 'I should see logo removed' do
page.should_not have_xpath('//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]')
expect(page).not_to have_xpath('//img[@src="/uploads/appearance/logo/1/gitlab_logo.png"]')
end
step 'I should see header logos removed' do
page.should_not have_xpath('//img[@src="/uploads/appearance/light_logo/1/header_logo_light.png"]')
expect(page).not_to have_xpath('//img[@src="/uploads/appearance/light_logo/1/header_logo_light.png"]')
end
def appearance
......
......@@ -50,7 +50,7 @@ class Spinach::Features::AdminEmail < Spinach::FeatureSteps
end
step 'I get redirected to the sign in path' do
current_path.should == root_path
expect(current_path).to eq root_path
end
step 'unsubscribed email is sent' do
......
......@@ -68,8 +68,8 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps
end
step 'I should see project shared with group' do
page.should have_content(shared_project.name_with_namespace)
page.should have_content "Projects shared with"
expect(page).to have_content(shared_project.name_with_namespace)
expect(page).to have_content "Projects shared with"
end
step 'we have user "John Doe" in group' do
......
......@@ -22,7 +22,7 @@ class Spinach::Features::AdminSettings < Spinach::FeatureSteps
end
step 'I should see the help text' do
page.should have_content help_text
expect(page).to have_content help_text
end
step 'I go to help page' do
......
......@@ -149,7 +149,7 @@ class Spinach::Features::AdminUsers < Spinach::FeatureSteps
step 'I should not see twitter details' do
expect(page).to have_content 'Pete'
expect(page).to_not have_content 'twitter'
expect(page).not_to have_content 'twitter'
end
step 'click on ssh keys tab' do
......
......@@ -28,7 +28,7 @@ class Spinach::Features::GroupHooks < Spinach::FeatureSteps
end
step 'I should see group hook' do
page.should have_content @hook.url
expect(page).to have_content @hook.url
end
step 'I submit new hook' do
......@@ -38,8 +38,8 @@ class Spinach::Features::GroupHooks < Spinach::FeatureSteps
end
step 'I should see newly created hook' do
current_path.should == group_hooks_path(@group)
page.should have_content(@url)
expect(current_path).to eq group_hooks_path(@group)
expect(page).to have_content(@url)
end
step 'I click test hook button' do
......@@ -53,18 +53,18 @@ class Spinach::Features::GroupHooks < Spinach::FeatureSteps
end
step 'hook should be triggered' do
current_path.should == group_hooks_path(@group)
page.should have_selector '.flash-notice',
expect(current_path).to eq group_hooks_path(@group)
expect(page).to have_selector '.flash-notice',
text: 'Hook successfully executed.'
end
step 'I should see hook error message' do
page.should have_selector '.flash-alert',
expect(page).to have_selector '.flash-alert',
text: 'Hook execution failed. Ensure the group has a project with commits.'
end
step 'I should see hook service down error message' do
page.should have_selector '.flash-alert',
expect(page).to have_selector '.flash-alert',
text: 'Hook execution failed. '\
'Ensure hook URL is correct and '\
'service is up.'
......
......@@ -119,11 +119,11 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
step 'I should see the audit event listed' do
within ('table#audits') do
page.should have_content 'Add user access as reporter'
page.should have_content 'Change access level from reporter to developer'
page.should have_content 'Remove user access'
page.should have_content('John Doe', count: 3)
page.should have_content('Mary Jane', count: 3)
expect(page).to have_content 'Add user access as reporter'
expect(page).to have_content 'Change access level from reporter to developer'
expect(page).to have_content 'Remove user access'
expect(page).to have_content('John Doe', count: 3)
expect(page).to have_content('Mary Jane', count: 3)
end
end
......@@ -143,7 +143,7 @@ class Spinach::Features::Groups < Spinach::FeatureSteps
end
Then 'I should be redirected to group page' do
current_path.should == group_path(Group.last)
expect(current_path).to eq group_path(Group.last)
end
And 'I change group name' do
......
......@@ -28,9 +28,9 @@ class Spinach::Features::GroupsManagement < Spinach::FeatureSteps
end
step 'I can control user membership' do
page.should have_button 'Add members'
page.should have_link 'Import members'
page.should have_selector '#project_member_access_level'
expect(page).to have_button 'Add members'
expect(page).to have_link 'Import members'
expect(page).to have_selector '#project_member_access_level'
end
step 'I reload "Open" project members page' do
......@@ -57,8 +57,8 @@ class Spinach::Features::GroupsManagement < Spinach::FeatureSteps
end
step 'I cannot control user membership from project page' do
page.should_not have_button 'Add members'
page.should_not have_link 'Import members'
page.should have_selector '#project_member_access_level'
expect(page).not_to have_button 'Add members'
expect(page).not_to have_link 'Import members'
expect(page).to have_selector '#project_member_access_level'
end
end
......@@ -18,10 +18,10 @@ class Spinach::Features::AuditEvent < Spinach::FeatureSteps
end
step 'I see remove deploy key event' do
page.should have_content("Remove deploy key")
expect(page).to have_content("Remove deploy key")
end
step 'I see deploy key event' do
page.should have_content("Add deploy key")
expect(page).to have_content("Add deploy key")
end
end
......@@ -10,9 +10,9 @@ class Spinach::Features::GitHooks < Spinach::FeatureSteps
step 'I should see git hook form' do
page.should have_selector('input#git_hook_commit_message_regex')
page.should have_content "Commit message"
page.should have_content "Commit author's email"
expect(page).to have_selector('input#git_hook_commit_message_regex')
expect(page).to have_content "Commit message"
expect(page).to have_content "Commit author's email"
end
......
......@@ -167,24 +167,24 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step 'I should see a discussion has started on diff' do
page.within(".notes .discussion") do
page.should have_content "#{current_user.name} started a discussion"
page.should have_content sample_commit.line_code_path
page.should have_content "Line is wrong"
expect(page).to have_content "#{current_user.name} started a discussion"
expect(page).to have_content sample_commit.line_code_path
expect(page).to have_content "Line is wrong"
end
end
step 'I should see a discussion has started on commit diff' do
page.within(".notes .discussion") do
page.should have_content "#{current_user.name} started a discussion on commit"
page.should have_content sample_commit.line_code_path
page.should have_content "Line is wrong"
expect(page).to have_content "#{current_user.name} started a discussion on commit"
expect(page).to have_content sample_commit.line_code_path
expect(page).to have_content "Line is wrong"
end
end
step 'I should see a discussion has started on commit' do
page.within(".notes .discussion") do
page.should have_content "#{current_user.name} started a discussion on commit"
page.should have_content "One comment to rule them all"
expect(page).to have_content "#{current_user.name} started a discussion on commit"
expect(page).to have_content "One comment to rule them all"
end
end
......@@ -203,9 +203,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
end
step 'I accept this merge request' do
Gitlab::Satellite::MergeAction.any_instance.stub(
merge!: true,
)
allow_any_instance_of(Gitlab::Satellite::MergeAction).to receive(:merge!).and_return(true)
page.within '.mr-state-widget' do
click_button "Accept Merge Request"
......@@ -299,7 +297,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
end
step 'I should see description field pre-filled' do
find_field('merge_request_description').value.should == 'This merge request should contain the following.'
expect(find_field('merge_request_description').value).to eq 'This merge request should contain the following.'
end
step 'I unfold diff' do
......@@ -356,13 +354,13 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step 'I should not see merge button' do
within '.mr-state-widget' do
page.should_not have_button("Accept Merge Request")
expect(page).not_to have_button("Accept Merge Request")
end
end
step 'I should see approved merge request "Bug NS-04"' do
within '.mr-state-widget' do
page.should have_button("Accept Merge Request")
expect(page).to have_button("Accept Merge Request")
end
end
......
......@@ -9,7 +9,7 @@ class Spinach::Features::ProjectNetworkGraph < Spinach::FeatureSteps
When 'I visit project "Shop" network page' do
# Stub Graph max_size to speed up test (10 commits vs. 650)
Network::Graph.stub(max_count: 10)
allow(Network::Graph).to receive(:max_count).and_return(10)
project = Project.find_by(name: "Shop")
visit namespace_project_network_path(project.namespace, project, "master")
......
......@@ -15,7 +15,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
step 'I should see project with new settings' do
expect(find_field('project_name').value).to eq 'NewName'
expect(find('#project_issues_enabled')).to_not be_checked
expect(find('#project_issues_enabled')).not_to be_checked
expect(find('#project_merge_requests_enabled')).to be_checked
end
......@@ -74,12 +74,12 @@ class Spinach::Features::Project < Spinach::FeatureSteps
end
step 'I should see project with merge request template saved' do
find_field('project_merge_requests_template').value.should == 'This merge request should contain the following.'
expect(find_field('project_merge_requests_template').value).to eq 'This merge request should contain the following.'
end
step 'I should see project "Shop" README link' do
within '.project-side' do
page.should have_content "README.md"
expect(page).to have_content "README.md"
end
end
......@@ -149,9 +149,9 @@ class Spinach::Features::Project < Spinach::FeatureSteps
step 'I should see the audit event listed' do
within ('table#audits') do
page.should have_content "Change access level from developer to master"
page.should have_content(project.owner.name)
page.should have_content('Pete')
expect(page).to have_content "Change access level from developer to master"
expect(page).to have_content(project.owner.name)
expect(page).to have_content('Pete')
end
end
......
......@@ -6,13 +6,13 @@ class Spinach::Features::ProjectGroupLinks < Spinach::FeatureSteps
step 'I should see project already shared with group "Ops"' do
within '.enabled-groups' do
page.should have_content "Ops"
expect(page).to have_content "Ops"
end
end
step 'I should see project is not shared with group "Market"' do
within '.enabled-groups' do
page.should_not have_content "Market"
expect(page).not_to have_content "Market"
end
end
......@@ -25,7 +25,7 @@ class Spinach::Features::ProjectGroupLinks < Spinach::FeatureSteps
step 'I should see project is shared with group "Market"' do
within '.enabled-groups' do
page.should have_content "Market"
expect(page).to have_content "Market"
end
end
......
......@@ -17,7 +17,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
end
step 'I should see project "Community" home page' do
Gitlab.config.gitlab.should_receive(:host).and_return("www.example.com")
expect(Gitlab.config.gitlab).to receive(:host).and_return("www.example.com")
page.within '.navbar-gitlab .title' do
expect(page).to have_content 'Community'
end
......
......@@ -198,10 +198,10 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
end
step 'I should see jira service settings saved' do
find_field('Project url').value.should == 'http://jira.example'
find_field('Username').value.should == 'gitlab'
find_field('Password').value.should_not == 'gitlab'
find_field('Api version').value.should == '2'
expect(find_field('Project url').value).to eq 'http://jira.example'
expect(find_field('Username').value).to eq 'gitlab'
expect(find_field('Password').value).not_to eq 'gitlab'
expect(find_field('Api version').value).to eq '2'
end
step 'I click Atlassian Bamboo CI service link' do
......
......@@ -142,8 +142,8 @@ class Spinach::Features::ProjectTeamManagement < Spinach::FeatureSteps
end
step 'I should see "Opensource" group user listing' do
page.should have_content("Shared with OpenSource group, members with Master role (2)")
page.should have_content(@os_user1.name)
page.should have_content(@os_user2.name)
expect(page).to have_content("Shared with OpenSource group, members with Master role (2)")
expect(page).to have_content(@os_user1.name)
expect(page).to have_content(@os_user2.name)
end
end
......@@ -96,8 +96,8 @@ class Spinach::Features::ProjectWiki < Spinach::FeatureSteps
step 'I click on existing image link' do
file = Gollum::File.new(wiki.wiki)
Gollum::Wiki.any_instance.stub(:file).with("image.jpg", "master", true).and_return(file)
Gollum::File.any_instance.stub(:mime_type).and_return("image/jpeg")
allow_any_instance_of(Gollum::Wiki).to receive(:file).with("image.jpg", "master", true).and_return(file)
allow_any_instance_of(Gollum::File).to receive(:mime_type).and_return("image/jpeg")
expect(page).to have_link('image', href: "image.jpg")
click_on "image"
end
......
......@@ -53,7 +53,7 @@ class Spinach::Features::Search < Spinach::FeatureSteps
step 'I should see code results for project "Shop"' do
page.within('.results') do
page.should have_content 'Update capybara, rspec-rails, poltergeist to recent versions'
expect(page).to have_content 'Update capybara, rspec-rails, poltergeist to recent versions'
end
end
......@@ -74,7 +74,7 @@ class Spinach::Features::Search < Spinach::FeatureSteps
step 'I should see "Foo" link in the search results' do
page.within('.results') do
find(:css, '.search-results').should have_link 'Foo'
expect(find(:css, '.search-results')).to have_link 'Foo'
end
end
......@@ -84,7 +84,7 @@ class Spinach::Features::Search < Spinach::FeatureSteps
step 'I should see "test_wiki" link in the search results' do
page.within('.results') do
find(:css, '.search-results').should have_link 'test_wiki.md'
expect(find(:css, '.search-results')).to have_link 'test_wiki.md'
end
end
......
......@@ -242,7 +242,7 @@ module SharedPaths
step "I visit my project's network page" do
# Stub Graph max_size to speed up test (10 commits vs. 650)
Network::Graph.stub(max_count: 10)
allow(Network::Graph).to receive(:max_count).and_return(10)
visit namespace_project_network_path(@project.namespace, @project, root_ref)
end
......
......@@ -14,7 +14,7 @@ class Spinach::Features::User < Spinach::FeatureSteps
end
step 'I should see unsubscribe text and button' do
page.should have_content "Unsubscribe from Admin notifications Yes, I want to unsubscribe joh@doe.org from any further admin emails."
expect(page).to have_content "Unsubscribe from Admin notifications Yes, I want to unsubscribe joh@doe.org from any further admin emails."
end
step 'I press the unsubscribe button' do
......@@ -22,7 +22,7 @@ class Spinach::Features::User < Spinach::FeatureSteps
end
step 'I should be unsubscribed' do
current_path.should == root_path
expect(current_path).to eq root_path
end
step '"John Doe" has contributions' do
......
......@@ -36,7 +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' }.not_to change { Issue.count }
end
it 'should update issue fields' do
......
......@@ -7,16 +7,16 @@ describe MergeRequestsHelper do
let(:last_commit) { Commit.new({}, project) }
before do
merge_request.stub(:source_project) { project }
merge_request.stub(:last_commit) { last_commit }
project.stub(:ci_service) { ci_service }
last_commit.stub(:sha) { '12d65c' }
allow(merge_request).to receive(:source_project) { project }
allow(merge_request).to receive(:last_commit) { last_commit }
allow(project).to receive(:ci_service) { ci_service }
allow(last_commit).to receive(:sha) { '12d65c' }
end
describe 'ci_build_details_path' do
it 'does not include api credentials in a link' do
ci_service.stub(:build_page) { "http://secretuser:secretpass@jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c" }
expect(ci_build_details_path(merge_request)).to_not match("secret")
allow(ci_service).to receive(:build_page) { "http://secretuser:secretpass@jenkins.example.com:8888/job/test1/scm/bySHA1/12d65c" }
expect(ci_build_details_path(merge_request)).not_to match("secret")
end
end
......
......@@ -21,12 +21,12 @@ describe OauthHelper do
describe "kerberos_enabled?" do
it 'returns true' do
allow(helper).to receive(:enabled_oauth_providers) { [:twitter, :github, :kerberos] }
helper.kerberos_enabled?.should be_truthy
expect(helper).to be_kerberos_enabled
end
it 'returns false' do
allow(helper).to receive(:enabled_oauth_providers) { [:twitter, :ldapmain] }
helper.kerberos_enabled?.should be_falsey
expect(helper).not_to be_kerberos_enabled
end
end
end
......@@ -36,12 +36,14 @@ describe Gitlab::Auth do
end
context "with kerberos" do
before { Devise.stub(omniauth_providers: [:kerberos]) }
before do
allow(Devise).to receive_messages(omniauth_providers: [:kerberos])
end
it "finds user" do
Gitlab::Kerberos::Authentication.stub(valid?: true)
Gitlab::Kerberos::Authentication.stub(email: user.email)
allow(Gitlab::Kerberos::Authentication).to receive_messages(valid?: true)
allow(Gitlab::Kerberos::Authentication).to receive_messages(email: user.email)
expect( gl_auth.find(username, password) ).to eql user
end
end
......
......@@ -249,19 +249,19 @@ describe Gitlab::GitAccess do
describe "git_hook_check" do
describe "author email check" do
it 'returns true' do
access.git_hook_check(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab').should be_truthy
expect(access.git_hook_check(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab')).to be_truthy
end
it 'returns false' do
project.create_git_hook
project.git_hook.update(commit_message_regex: "@only.com")
access.git_hook_check(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab').allowed?.should be_falsey
expect(access.git_hook_check(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab')).not_to be_allowed
end
it 'returns true for tags' do
project.create_git_hook
project.git_hook.update(commit_message_regex: "@only.com")
access.git_hook_check(user, project, 'refs/tags/v1', '6f6d7e7ed', '570e7b2ab').allowed?.should be_truthy
expect(access.git_hook_check(user, project, 'refs/tags/v1', '6f6d7e7ed', '570e7b2ab')).to be_allowed
end
end
......@@ -272,12 +272,12 @@ describe Gitlab::GitAccess do
end
it 'returns false for non-member user' do
access.git_hook_check(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab').allowed?.should be_falsey
expect(access.git_hook_check(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab')).not_to be_allowed
end
it 'returns true if committer is a gitlab member' do
create(:user, email: 'dmitriy.zaporozhets@gmail.com')
access.git_hook_check(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab').allowed?.should be_truthy
expect(access.git_hook_check(user, project, 'refs/heads/master', '6f6d7e7ed', '570e7b2ab')).to be_allowed
end
end
......@@ -285,13 +285,13 @@ describe Gitlab::GitAccess do
it 'returns false when filename is prohibited' do
project.create_git_hook
project.git_hook.update(file_name_regex: "jpg$")
access.git_hook_check(user, project, 'refs/heads/master', '913c66a37', '33f3729a4').allowed?.should be_falsey
expect(access.git_hook_check(user, project, 'refs/heads/master', '913c66a37', '33f3729a4')).not_to be_allowed
end
it 'returns true if file name is allowed' do
project.create_git_hook
project.git_hook.update(file_name_regex: "exe$")
access.git_hook_check(user, project, 'refs/heads/master', '913c66a37', '33f3729a4').allowed?.should be_truthy
expect(access.git_hook_check(user, project, 'refs/heads/master', '913c66a37', '33f3729a4')).to be_allowed
end
end
......@@ -299,17 +299,17 @@ describe Gitlab::GitAccess do
before do
allow_any_instance_of(Gitlab::Git::Blob).to receive(:size).and_return(1.5.megabytes.to_i)
end
it "returns false when size is too large" do
project.create_git_hook
project.git_hook.update(max_file_size: 1)
access.git_hook_check(user, project, 'refs/heads/master', 'cfe32cf6', '913c66a37').allowed?.should be_falsey
expect(access.git_hook_check(user, project, 'refs/heads/master', 'cfe32cf6', '913c66a37')).not_to be_allowed
end
it "returns true when size is allowed" do
project.create_git_hook
project.git_hook.update(max_file_size: 2)
access.git_hook_check(user, project, 'refs/heads/master', 'cfe32cf6', '913c66a37').allowed?.should be_truthy
expect(access.git_hook_check(user, project, 'refs/heads/master', 'cfe32cf6', '913c66a37')).to be_allowed
end
end
end
......
......@@ -8,13 +8,12 @@ describe Gitlab::Kerberos::Authentication do
describe :login do
before do
Devise.stub(omniauth_providers: [:kerberos])
allow(Devise).to receive_messages(omniauth_providers: [:kerberos])
end
it "finds the user if authentication is successful" do
kerberos_realm = user.email.sub(/.*@/, '')
::Krb5Auth::Krb5.any_instance.stub(get_init_creds_password: true)
::Krb5Auth::Krb5.any_instance.stub(get_default_realm: kerberos_realm)
allow_any_instance_of(::Krb5Auth::Krb5).to receive_messages(get_init_creds_password: true, get_default_realm: kerberos_realm)
expect(klass.login('gitlab', password)).to be_truthy
end
......@@ -22,8 +21,7 @@ describe Gitlab::Kerberos::Authentication do
it "returns false if there is no such user in kerberos" do
kerberos_login = "some-login"
kerberos_realm = user.email.sub(/.*@/, '')
::Krb5Auth::Krb5.any_instance.stub(get_init_creds_password: true)
::Krb5Auth::Krb5.any_instance.stub(get_default_realm: kerberos_realm)
allow_any_instance_of(::Krb5Auth::Krb5).to receive_messages(get_init_creds_password: true, get_default_realm: kerberos_realm)
expect(klass.login(kerberos_login, password)).to be_falsy
end
......
......@@ -88,29 +88,28 @@ describe Gitlab::LDAP::Access do
subject { access.update_permissions }
it "syncs ssh keys if enabled by configuration" do
access.stub sync_ssh_keys?: 'sshpublickey'
allow(access).to receive_messages(sync_ssh_keys?: 'sshpublickey')
expect(access).to receive(:update_ssh_keys).once
subject
end
it "does update group permissions with a group base configured" do
access.stub group_base: 'my-group-base'
allow(access).to receive_messages(group_base: 'my-group-base')
expect(access).to receive(:update_ldap_group_links)
subject
end
it "does not update group permissions without a group base configured" do
access.stub group_base: ''
allow(access).to receive_messages(group_base: '')
expect(access).not_to receive(:update_ldap_group_links)
subject
end
it "does update admin group permissions if admin group is configured" do
access.stub admin_group: 'my-admin-group'
access.stub :update_ldap_group_links
allow(access).to receive_messages(admin_group: 'my-admin-group', update_ldap_group_links: nil)
expect(access).to receive(:update_admin_status)
subject
......@@ -125,18 +124,18 @@ describe Gitlab::LDAP::Access do
end
before do
Gitlab::LDAP::Config.any_instance.stub(sync_ssh_keys: ssh_key_attribute_name)
access.stub sync_ssh_keys?: true
allow_any_instance_of(Gitlab::LDAP::Config).to receive_messages(sync_ssh_keys: ssh_key_attribute_name)
allow(access).to receive_messages(sync_ssh_keys?: true)
end
it "should add a SSH key if it is in LDAP but not in gitlab" do
Gitlab::LDAP::Adapter.any_instance.stub(:user) { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
allow_any_instance_of(Gitlab::LDAP::Adapter).to receive(:user) { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
expect{ access.update_ssh_keys }.to change(user.keys, :count).from(0).to(1)
end
it "should add a SSH key and give it a proper name" do
Gitlab::LDAP::Adapter.any_instance.stub(:user) { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
allow_any_instance_of(Gitlab::LDAP::Adapter).to receive(:user) { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
access.update_ssh_keys
expect(user.keys.last.title).to match(/LDAP/)
......@@ -145,9 +144,9 @@ describe Gitlab::LDAP::Access do
it "should not add a SSH key if it is invalid" do
entry = Net::LDAP::Entry.from_single_ldif_string("dn: cn=foo, dc=bar, dc=com\n#{ssh_key_attribute_name}: I am not a valid key")
Gitlab::LDAP::Adapter.any_instance.stub(:user) { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
allow_any_instance_of(Gitlab::LDAP::Adapter).to receive(:user) { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
expect{ access.update_ssh_keys }.to_not change(user.keys, :count)
expect{ access.update_ssh_keys }.not_to change(user.keys, :count)
end
context 'user has at least one LDAPKey' do
......@@ -155,14 +154,14 @@ describe Gitlab::LDAP::Access do
it "should remove a SSH key if it is no longer in LDAP" do
entry = Net::LDAP::Entry.from_single_ldif_string("dn: cn=foo, dc=bar, dc=com\n#{ssh_key_attribute_name}:\n")
Gitlab::LDAP::Adapter.any_instance.stub(:user) { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
allow_any_instance_of(Gitlab::LDAP::Adapter).to receive(:user) { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
expect{ access.update_ssh_keys }.to change(user.keys, :count).from(1).to(0)
end
it "should remove a SSH key if the ldap attribute was removed" do
entry = Net::LDAP::Entry.from_single_ldif_string("dn: cn=foo, dc=bar, dc=com")
Gitlab::LDAP::Adapter.any_instance.stub(:user) { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
allow_any_instance_of(Gitlab::LDAP::Adapter).to receive(:user) { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
expect{ access.update_ssh_keys }.to change(user.keys, :count).from(1).to(0)
end
......@@ -173,21 +172,21 @@ describe Gitlab::LDAP::Access do
let(:entry) { Net::LDAP::Entry.new }
before do
access.stub ldap_user: Gitlab::LDAP::Person.new(entry, user.ldap_identity.provider)
allow(access).to receive_messages(ldap_user: Gitlab::LDAP::Person.new(entry, user.ldap_identity.provider))
end
it "should not update email if email attribute is not set" do
expect{ access.update_email }.to_not change(user, :email)
expect{ access.update_email }.not_to change(user, :email)
end
it "should not update the email if the user has the same email in GitLab and in LDAP" do
entry['mail'] = [user.email]
expect{ access.update_email }.to_not change(user, :email)
expect{ access.update_email }.not_to change(user, :email)
end
it "should not update the email if the user has the same email GitLab and in LDAP, but with upper case in LDAP" do
entry['mail'] = [user.email.upcase]
expect{ access.update_email }.to_not change(user, :email)
expect{ access.update_email }.not_to change(user, :email)
end
it "should update the email if the user email is different" do
......@@ -199,10 +198,10 @@ describe Gitlab::LDAP::Access do
describe :update_admin_status do
before do
access.stub(admin_group: "GLAdmins")
allow(access).to receive_messages(admin_group: "GLAdmins")
ldap_user_entry = Net::LDAP::Entry.new
Gitlab::LDAP::Adapter.any_instance.stub(:user) { Gitlab::LDAP::Person.new(ldap_user_entry, user.ldap_identity.provider) }
Gitlab::LDAP::Person.any_instance.stub(:uid) { 'admin2' }
allow_any_instance_of(Gitlab::LDAP::Adapter).to receive(:user) { Gitlab::LDAP::Person.new(ldap_user_entry, user.ldap_identity.provider) }
allow_any_instance_of(Gitlab::LDAP::Person).to receive(:uid) { 'admin2' }
end
it "should give admin privileges to an User" do
......@@ -217,7 +216,7 @@ memberuid: admin3
objectclass: top
objectclass: posixGroup
})
Gitlab::LDAP::Adapter.any_instance.stub(:group) { Gitlab::LDAP::Group.new(admin_group) }
allow_any_instance_of(Gitlab::LDAP::Adapter).to receive(:group) { Gitlab::LDAP::Group.new(admin_group) }
expect{ access.update_admin_status }.to change(user, :admin?).to(true)
end
......@@ -234,7 +233,7 @@ memberuid: admin3
objectclass: top
objectclass: posixGroup
})
Gitlab::LDAP::Adapter.any_instance.stub(:group) { Gitlab::LDAP::Group.new(admin_group) }
allow_any_instance_of(Gitlab::LDAP::Adapter).to receive(:group) { Gitlab::LDAP::Group.new(admin_group) }
expect{ access.update_admin_status }.to change(user, :admin?).to(false)
end
end
......@@ -246,7 +245,7 @@ objectclass: posixGroup
let(:gitlab_group_2) { create :group }
before do
access.stub(cns_with_access: cns_with_access)
allow(access).to receive_messages(cns_with_access: cns_with_access)
end
context "non existing access for group-1, allowed via ldap-group1 as MASTER" do
......@@ -291,7 +290,7 @@ objectclass: posixGroup
before do
gitlab_group_1.group_members.masters.create(user_id: user.id)
gitlab_group_1.ldap_group_links.create(cn: 'ldap-group1', group_access: Gitlab::Access::MASTER, provider: 'ldapmain')
access.stub(cns_with_access: ['ldap-group2'])
allow(access).to receive_messages(cns_with_access: ['ldap-group2'])
end
it "removes user from gitlab_group_1" do
......@@ -304,7 +303,7 @@ objectclass: posixGroup
before do
gitlab_group_1.group_members.owners.create(user_id: user.id)
gitlab_group_1.ldap_group_links.create(cn: 'ldap-group1', group_access: Gitlab::Access::OWNER, provider: 'ldapmain')
access.stub(cns_with_access: ['ldap-group2'])
allow(access).to receive_messages(cns_with_access: ['ldap-group2'])
end
it "does not remove the user from gitlab_group_1 since it's the last owner" do
......@@ -318,7 +317,7 @@ objectclass: posixGroup
owner2 = create(:user) # a 2nd owner
gitlab_group_1.group_members.owners.create([{ user_id: user.id }, { user_id: owner2.id }])
gitlab_group_1.ldap_group_links.create(cn: 'ldap-group1', group_access: Gitlab::Access::OWNER, provider: 'ldapmain')
access.stub(cns_with_access: ['ldap-group2'])
allow(access).to receive_messages(cns_with_access: ['ldap-group2'])
end
it "removes user from gitlab_group_1" do
......@@ -345,14 +344,14 @@ objectclass: posixGroup
it "returns an interator of LDAP Groups" do
::LdapGroupLink.create({
cn: 'example', group_access: Gitlab::Access::DEVELOPER, group_id: 42, provider: 'ldapmain' })
Gitlab::LDAP::Adapter.any_instance.stub(:group) { Gitlab::LDAP::Group.new(ldap_group_1) }
allow_any_instance_of(Gitlab::LDAP::Adapter).to receive(:group) { Gitlab::LDAP::Group.new(ldap_group_1) }
expect(access.ldap_groups.first).to be_a Gitlab::LDAP::Group
end
it "only returns found ldap groups" do
::LdapGroupLink.create cn: 'example', group_access: Gitlab::Access::DEVELOPER, group_id: 42
Gitlab::LDAP::Group.stub(find_by_cn: nil) # group not found
allow(Gitlab::LDAP::Group).to receive_messages(find_by_cn: nil) # group not found
expect(access.ldap_groups).to be_empty
end
......@@ -392,13 +391,13 @@ objectclass: posixGroup
let(:ldap_user) { Gitlab::LDAP::Person.new(Net::LDAP::Entry.new, user.ldap_identity.provider) }
before do
access.stub(ldap_user: ldap_user)
ldap_user.stub(:uid) { 'user1' }
ldap_user.stub(:dn) { 'uid=user1,ou=People,dc=example' }
allow(access).to receive_messages(ldap_user: ldap_user)
allow(ldap_user).to receive(:uid) { 'user1' }
allow(ldap_user).to receive(:dn) { 'uid=user1,ou=People,dc=example' }
end
it "only returns ldap cns to which the user has access" do
access.stub(ldap_groups: ldap_groups)
allow(access).to receive_messages(ldap_groups: ldap_groups)
expect(access.cns_with_access).to eql ['group1']
end
end
......
......@@ -13,7 +13,7 @@ describe Gitlab::LDAP::Person do
subject { Gitlab::LDAP::Person.new(entry, 'ldapmain') }
before do
Gitlab::LDAP::Config.any_instance.stub(sync_ssh_keys: ssh_key_attribute_name)
allow_any_instance_of(Gitlab::LDAP::Config).to receive_messages(sync_ssh_keys: ssh_key_attribute_name)
end
context "when the SSH key is literal" do
......
require 'spec_helper'
describe 'Gitlab::Satellite::MergeAction' do
describe Gitlab::Satellite::MergeAction do
include RepoHelpers
let(:project) { create(:project, namespace: create(:group)) }
......@@ -20,14 +20,14 @@ describe 'Gitlab::Satellite::MergeAction' do
context 'on fork' do
it 'should get proper commits between' do
commits = Gitlab::Satellite::MergeAction.new(merge_request_fork.author, merge_request_fork).commits_between
commits = described_class.new(merge_request_fork.author, merge_request_fork).commits_between
verify_commits(commits, sample_compare.commits.first, sample_compare.commits.last)
end
end
context 'between branches' do
it 'should raise exception -- not expected to be used by non forks' do
expect { Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).commits_between }.to raise_error(RuntimeError)
expect { described_class.new(merge_request.author, merge_request).commits_between }.to raise_error(RuntimeError)
end
end
end
......@@ -41,14 +41,14 @@ describe 'Gitlab::Satellite::MergeAction' do
context 'on fork' do
it 'should build a format patch' do
patch = Gitlab::Satellite::MergeAction.new(merge_request_fork.author, merge_request_fork).format_patch
patch = described_class.new(merge_request_fork.author, merge_request_fork).format_patch
verify_content(patch)
end
end
context 'between branches' do
it 'should build a format patch' do
patch = Gitlab::Satellite::MergeAction.new(merge_request_fork.author, merge_request).format_patch
patch = described_class.new(merge_request_fork.author, merge_request).format_patch
verify_content(patch)
end
end
......@@ -67,15 +67,15 @@ describe 'Gitlab::Satellite::MergeAction' do
context 'on fork' do
it 'should get proper diffs' do
diffs = Gitlab::Satellite::MergeAction.new(merge_request_fork.author, merge_request_fork).diffs_between_satellite
diff = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request_fork).diff_in_satellite
diffs = described_class.new(merge_request_fork.author, merge_request_fork).diffs_between_satellite
diff = described_class.new(merge_request.author, merge_request_fork).diff_in_satellite
is_a_matching_diff(diff, diffs)
end
end
context 'between branches' do
it 'should get proper diffs' do
expect{ Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite }.to raise_error(RuntimeError)
expect { described_class.new(merge_request.author, merge_request).diffs_between_satellite }.to raise_error(RuntimeError)
end
end
end
......@@ -83,21 +83,21 @@ describe 'Gitlab::Satellite::MergeAction' do
describe '#can_be_merged?' do
context 'on fork' do
it do
expect(Gitlab::Satellite::MergeAction.new(merge_request_fork.author, merge_request_fork).can_be_merged?).to be_truthy
expect(described_class.new(merge_request_fork.author, merge_request_fork).can_be_merged?).to be_truthy
end
it do
expect(Gitlab::Satellite::MergeAction.new(merge_request_fork_with_conflict.author, merge_request_fork_with_conflict).can_be_merged?).to be_falsey
expect(described_class.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 do
expect(Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).can_be_merged?).to be_truthy
expect(described_class.new(merge_request.author, merge_request).can_be_merged?).to be_truthy
end
it do
expect(Gitlab::Satellite::MergeAction.new(merge_request_with_conflict.author, merge_request_with_conflict).can_be_merged?).to be_falsey
expect(described_class.new(merge_request_with_conflict.author, merge_request_with_conflict).can_be_merged?).to be_falsey
end
end
end
......@@ -106,37 +106,33 @@ describe 'Gitlab::Satellite::MergeAction' do
describe '#can_be_rebased?' do
context 'on fork' do
before(:each) do
merge_request.stub(:should_rebase).and_return(true)
allow(merge_request).to receive(:should_rebase).and_return(true)
end
it do
Gitlab::Satellite::MergeAction.new(
merge_request_fork.author,
merge_request_fork).merge!.should be_truthy
result = described_class.new(merge_request_fork.author, merge_request_fork).merge!
expect(result).to be_truthy
end
it do
Gitlab::Satellite::MergeAction.new(
merge_request_fork_with_conflict.author,
merge_request_fork_with_conflict).merge!.should be_falsey
result = described_class.new(merge_request_fork_with_conflict.author, merge_request_fork_with_conflict).merge!
expect(result).to be_falsey
end
end
context 'between branches' do
before(:each) do
merge_request.stub(:should_rebase).and_return(true)
allow(merge_request).to receive(:should_rebase).and_return(true)
end
it do
Gitlab::Satellite::MergeAction.new(
merge_request.author,
merge_request).merge!.should be_truthy
result = described_class.new(merge_request.author, merge_request).merge!
expect(result).to be_truthy
end
it do
Gitlab::Satellite::MergeAction.new(
merge_request_with_conflict.author,
merge_request_with_conflict).merge!.should be_falsey
result = described_class.new(merge_request_with_conflict.author, merge_request_with_conflict).merge!
expect(result).to be_falsey
end
end
end
......
......@@ -808,8 +808,8 @@ describe Notify do
it 'is sent as the author' do
sender = subject.header[:from].addrs[0]
sender.display_name.should eq("GitLab")
sender.address.should eq(gitlab_sender)
expect(sender.display_name).to eq("GitLab")
expect(sender.address).to eq(gitlab_sender)
end
it 'is sent to recipient' do
......
......@@ -7,8 +7,8 @@ describe Mentionable do
let(:project) { create(:project) }
it 'excludes JIRA references' do
project.stub(jira_tracker?: true)
references(project, 'JIRA-123').should be_empty
allow(project).to receive_messages(jira_tracker?: true)
expect(references(project, 'JIRA-123')).to be_empty
end
end
end
......
......@@ -11,7 +11,7 @@ describe LdapGroupLink do
group_link = build(:ldap_group_link,
cn: 'group1', group_id: 1, provider: 'ldapmain')
expect(group_link).to_not be_valid
expect(group_link).not_to be_valid
group_link.group_id = 2
expect(group_link).to be_valid
......
......@@ -18,7 +18,7 @@ describe License do
end
it "is invalid" do
expect(license).to_not be_valid
expect(license).not_to be_valid
end
end
end
......@@ -41,7 +41,7 @@ describe License do
context "when the license started" do
it "is invalid" do
expect(license).to_not be_valid
expect(license).not_to be_valid
end
end
......@@ -57,7 +57,7 @@ describe License do
let(:date) { License.current.starts_at - 6.months }
it "is invalid" do
expect(license).to_not be_valid
expect(license).not_to be_valid
end
end
......@@ -94,7 +94,7 @@ describe License do
end
it "is valid" do
expect(license).to_not be_valid
expect(license).not_to be_valid
end
end
......@@ -197,7 +197,7 @@ describe License do
context "when valid license data is provided" do
it "returns the license" do
expect(license.license).to_not be_nil
expect(license.license).not_to be_nil
end
end
end
......
......@@ -142,9 +142,9 @@ describe MergeRequest do
let(:issue1) { JiraIssue.new('FOOBAR-4567', subject.project) }
it 'returns sorted JiraIssues' do
subject.project.stub(default_branch: subject.target_branch)
allow(subject.project).to receive_messages(default_branch: subject.target_branch)
subject.closes_issues.should eq([issue1, issue0])
expect(subject.closes_issues).to eq([issue1, issue0])
end
end
end
......
......@@ -28,7 +28,7 @@ describe JenkinsService do
describe 'commits methods' do
before do
@service = JenkinsService.new
@service.stub(
allow(@service).to receive_messages(
service_hook: true,
project_url: 'http://jenkins.gitlab.org/projects/2',
token: 'verySecret'
......
......@@ -34,7 +34,7 @@ describe JiraService do
before do
@jira_service = JiraService.new
@jira_service.stub(
allow(@jira_service).to receive_messages(
project_id: project.id,
project: project,
service_hook: true,
......@@ -52,7 +52,7 @@ describe JiraService do
it "should call JIRA API" do
@jira_service.execute(sample_commit, JiraIssue.new("JIRA-123", project))
WebMock.should have_requested(:post, @api_url).with(
expect(WebMock).to have_requested(:post, @api_url).with(
body: /Issue solved with/
).once
end
......@@ -60,7 +60,7 @@ describe JiraService do
it "calls the api with jira_issue_transition_id" do
@jira_service.jira_issue_transition_id = 'this-is-a-custom-id'
@jira_service.execute(sample_commit, JiraIssue.new("JIRA-123", project))
WebMock.should have_requested(:post, @api_url).with(
expect(WebMock).to have_requested(:post, @api_url).with(
body: /this-is-a-custom-id/
).once
end
......
......@@ -185,8 +185,8 @@ describe User do
create :omniauth_user, provider: "gitlub"
users = User.non_ldap
users.count.should == 2
users.detect{ |user| user.username == ldap_user.username }.should be_nil
expect(users.count).to eq 2
expect(users.detect { |user| user.username == ldap_user.username }).to be_nil
end
end
......
......@@ -23,7 +23,7 @@ describe API::API, api: true do
context "when unauthenticated" do
it "should return authentication error" do
post api("/groups/#{group_with_ldap_links.id}/ldap_group_links")
response.status.should == 401
expect(response.status).to eq 401
end
end
......@@ -89,7 +89,7 @@ describe API::API, api: true do
context "when unauthenticated" do
it "should return authentication error" do
delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap-group1")
response.status.should == 401
expect(response.status).to eq 401
end
end
......@@ -126,7 +126,7 @@ describe API::API, api: true do
context "when unauthenticated" do
it "should return authentication error" do
delete api("/groups/#{group_with_ldap_links.id}/ldap_group_links/ldap2/ldap-group2")
response.status.should == 401
expect(response.status).to eq 401
end
end
......
......@@ -10,26 +10,24 @@ describe API::API do
OpenStruct.new(cn: 'students')
]
Gitlab::LDAP::Adapter.any_instance.stub(
groups: groups
)
allow_any_instance_of(Gitlab::LDAP::Adapter).to receive_messages(groups: groups)
end
describe "GET /ldap/groups" do
context "when unauthenticated" do
it "should return authentication error" do
get api("/ldap/groups")
response.status.should == 401
expect(response.status).to eq 401
end
end
context "when authenticated as user" do
it "should return an array of ldap groups" do
get api("/ldap/groups", user)
response.status.should == 200
json_response.should be_an Array
json_response.length.should == 2
json_response.first['cn'].should == 'developers'
expect(response.status).to eq 200
expect(json_response).to be_an Array
expect(json_response.length).to eq 2
expect(json_response.first['cn']).to eq 'developers'
end
end
end
......@@ -38,17 +36,17 @@ describe API::API do
context "when unauthenticated" do
it "should return authentication error" do
get api("/ldap/ldapmain/groups")
response.status.should == 401
expect(response.status).to eq 401
end
end
context "when authenticated as user" do
it "should return an array of ldap groups" do
get api("/ldap/ldapmain/groups", user)
response.status.should == 200
json_response.should be_an Array
json_response.length.should == 2
json_response.first['cn'].should == 'developers'
expect(response.status).to eq 200
expect(json_response).to be_an Array
expect(json_response.length).to eq 2
expect(json_response.first['cn']).to eq 'developers'
end
end
end
......
......@@ -19,17 +19,17 @@ describe API::API, 'ProjectGitHook', api: true do
context "authorized user" do
it "should return project git hook" do
get api("/projects/#{project.id}/git_hook", user)
response.status.should eq(200)
expect(response.status).to eq(200)
json_response.should be_an Hash
json_response['project_id'].should eq(project.id)
expect(json_response).to be_an Hash
expect(json_response['project_id']).to eq(project.id)
end
end
context "unauthorized user" do
it "should not access project git hooks" do
get api("/projects/#{project.id}/git_hook", user3)
response.status.should eq(403)
expect(response.status).to eq(403)
end
end
end
......@@ -40,11 +40,11 @@ describe API::API, 'ProjectGitHook', api: true do
it "should add git hook to project" do
post api("/projects/#{project.id}/git_hook", user),
deny_delete_tag: true
response.status.should eq(201)
expect(response.status).to eq(201)
json_response.should be_an Hash
json_response['project_id'].should eq(project.id)
json_response['deny_delete_tag'].should eq(true)
expect(json_response).to be_an Hash
expect(json_response['project_id']).to eq(project.id)
expect(json_response['deny_delete_tag']).to eq(true)
end
end
......@@ -52,7 +52,7 @@ describe API::API, 'ProjectGitHook', api: true do
it "should not add git hook to project" do
post api("/projects/#{project.id}/git_hook", user3),
deny_delete_tag: true
response.status.should eq(403)
expect(response.status).to eq(403)
end
end
end
......@@ -66,7 +66,7 @@ describe API::API, 'ProjectGitHook', api: true do
it "should not add git hook to project" do
post api("/projects/#{project.id}/git_hook", user),
deny_delete_tag: true
response.status.should eq(422)
expect(response.status).to eq(422)
end
end
end
......@@ -79,10 +79,10 @@ describe API::API, 'ProjectGitHook', api: true do
it "should update an existing project git hook" do
put api("/projects/#{project.id}/git_hook", user),
deny_delete_tag: false, commit_message_regex: 'Fixes \d+\..*'
response.status.should eq(200)
expect(response.status).to eq(200)
json_response['deny_delete_tag'].should eq(false)
json_response['commit_message_regex'].should eq('Fixes \d+\..*')
expect(json_response['deny_delete_tag']).to eq(false)
expect(json_response['commit_message_regex']).to eq('Fixes \d+\..*')
end
end
......@@ -90,13 +90,13 @@ describe API::API, 'ProjectGitHook', api: true do
it "should error on non existing project git hook" do
put api("/projects/#{project.id}/git_hook", user),
deny_delete_tag: false, commit_message_regex: 'Fixes \d+\..*'
response.status.should eq(404)
expect(response.status).to eq(404)
end
it "should not update git hook for unauthorized user" do
post api("/projects/#{project.id}/git_hook", user3),
deny_delete_tag: true
response.status.should eq(403)
expect(response.status).to eq(403)
end
end
......@@ -108,16 +108,16 @@ describe API::API, 'ProjectGitHook', api: true do
context "authorized user" do
it "should delete git hook from project" do
delete api("/projects/#{project.id}/git_hook", user)
response.status.should eq(200)
expect(response.status).to eq(200)
json_response.should be_an Hash
expect(json_response).to be_an Hash
end
end
context "unauthorized user" do
it "should return a 403 error" do
delete api("/projects/#{project.id}/git_hook", user3)
response.status.should eq(403)
expect(response.status).to eq(403)
end
end
end
......@@ -126,15 +126,15 @@ describe API::API, 'ProjectGitHook', api: true do
context "for non existing git hook" do
it "should delete git hook from project" do
delete api("/projects/#{project.id}/git_hook", user)
response.status.should eq(404)
expect(response.status).to eq(404)
json_response.should be_an Hash
json_response['message'].should eq("404 Not Found")
expect(json_response).to be_an Hash
expect(json_response['message']).to eq("404 Not Found")
end
it "should return a 403 error if not authorized" do
delete api("/projects/#{project.id}/git_hook", user3)
response.status.should eq(403)
expect(response.status).to eq(403)
end
end
end
......
......@@ -98,7 +98,7 @@ describe API::API, api: true do
end
it 'should return a 405 method not allowed error when group membership lock is enabled' do
response.status.should == 405
expect(response.status).to eq 405
end
end
end
......@@ -143,7 +143,7 @@ describe API::API, api: true do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
expect do
delete api("/projects/#{project.id}/members/#{user3.id}", user)
end.to_not change { ProjectMember.count }
end.not_to change { ProjectMember.count }
end
it "should return 200 if team member already removed" do
......
......@@ -642,25 +642,25 @@ describe API::API, api: true do
post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: Gitlab::Access::DEVELOPER
end.to change { ProjectGroupLink.count }.by(1)
response.status.should == 201
json_response['group_id'].should == group.id
json_response['group_access'].should == Gitlab::Access::DEVELOPER
expect(response.status).to eq 201
expect(json_response['group_id']).to eq group.id
expect(json_response['group_access']).to eq Gitlab::Access::DEVELOPER
end
it "should return a 400 error when group id is not given" do
post api("/projects/#{project.id}/share", user), group_access: Gitlab::Access::DEVELOPER
response.status.should == 400
expect(response.status).to eq 400
end
it "should return a 400 error when access level is not given" do
post api("/projects/#{project.id}/share", user), group_id: group.id
response.status.should == 400
expect(response.status).to eq 400
end
it "should return a 409 error when wrong params passed" do
post api("/projects/#{project.id}/share", user), group_id: group.id, group_access: 1234
response.status.should == 409
json_response['message'].should == 'Group access is not included in the list'
expect(response.status).to eq 409
expect(json_response['message']).to eq 'Group access is not included in the list'
end
end
......
......@@ -49,7 +49,7 @@ describe API::API, api: true do
it "should not create new hook without url" do
expect do
post api("/hooks", admin)
end.to_not change { SystemHook.count }
end.not_to change { SystemHook.count }
end
end
......
......@@ -44,10 +44,10 @@ describe API::API, api: true do
User.delete_all
create :omniauth_user, provider: "ldapserver1"
get api("/users", user), skip_ldap: "true"
response.status.should == 200
json_response.should be_an Array
expect(response.status).to eq 200
expect(json_response).to be_an Array
username = user.username
json_response.first["username"].should == username
expect(json_response.first["username"]).to eq username
end
end
end
......
......@@ -265,14 +265,14 @@ describe GitPushService do
WebMock.stub_request(:get, jira_api_comment_url).to_return(body: jira_issue_comments)
WebMock.stub_request(:get, jira_api_project_url)
closing_commit.stub({
allow(closing_commit).to receive_messages({
issue_closing_regex: Regexp.new(Gitlab.config.gitlab.issue_closing_pattern),
safe_message: "this is some work.\n\ncloses JIRA-1",
author_name: commit_author.name,
author_email: commit_author.email
})
project.repository.stub(commits_between: [closing_commit])
allow(project.repository).to receive_messages(commits_between: [closing_commit])
end
after do
......@@ -294,7 +294,7 @@ describe GitPushService do
}.to_json
service.execute(project, user, @oldrev, @newrev, @ref)
WebMock.should have_requested(:post, jira_api_transition_url).with(
expect(WebMock).to have_requested(:post, jira_api_transition_url).with(
body: message
).once
end
......@@ -302,7 +302,7 @@ describe GitPushService do
it "should initiate one api call to jira server to mention the issue" do
service.execute(project, user, @oldrev, @newrev, @ref)
WebMock.should have_requested(:post, jira_api_comment_url).with(
expect(WebMock).to have_requested(:post, jira_api_comment_url).with(
body: /mentioned this issue in/
).once
end
......
......@@ -18,9 +18,9 @@ describe LdapGroupResetService do
context 'initiated by ldap user' do
before { LdapGroupResetService.new.execute(group, ldap_user) }
it { member_access(ldap_user).should == Gitlab::Access::OWNER }
it { member_access(ldap_user_2).should == Gitlab::Access::GUEST }
it { member_access(user).should == Gitlab::Access::OWNER }
it { expect(member_access(ldap_user)).to eq Gitlab::Access::OWNER }
it { expect(member_access(ldap_user_2)).to eq Gitlab::Access::GUEST }
it { expect(member_access(user)).to eq Gitlab::Access::OWNER }
it { expect(ldap_user.reload.last_credential_check_at).to be_nil }
it { expect(ldap_user_2.reload.last_credential_check_at).to be_nil }
end
......@@ -28,9 +28,9 @@ describe LdapGroupResetService do
context 'initiated by regular user' do
before { LdapGroupResetService.new.execute(group, user) }
it { member_access(ldap_user).should == Gitlab::Access::GUEST }
it { member_access(ldap_user_2).should == Gitlab::Access::GUEST }
it { member_access(user).should == Gitlab::Access::OWNER }
it { expect(member_access(ldap_user)).to eq Gitlab::Access::GUEST }
it { expect(member_access(ldap_user_2)).to eq Gitlab::Access::GUEST }
it { expect(member_access(user)).to eq Gitlab::Access::OWNER }
it { expect(ldap_user.reload.last_credential_check_at).to be_nil }
it { expect(ldap_user_2.reload.last_credential_check_at).to be_nil }
end
......
......@@ -91,7 +91,7 @@ describe Projects::CreateService do
it "creates git hook from sample" do
git_hook = create_project(@user, @opts).git_hook
[:force_push_regex, :deny_delete_tag, :delete_branch_regex, :commit_message_regex].each do |attr_name|
git_hook.send(attr_name).should == @git_hook_sample.send(attr_name)
expect(git_hook.send(attr_name)).to eq @git_hook_sample.send(attr_name)
end
end
end
......
......@@ -414,7 +414,7 @@ describe SystemNoteService do
WebMock.stub_request(:get, jira_api_comment_url).to_return(body: jira_issue_comments)
end
subject { Note.create_cross_reference_note(jira_issue, commit, author) }
subject { described_class.cross_reference(jira_issue, commit, author) }
it { is_expected.to eq(jira_status_message) }
end
......@@ -425,7 +425,7 @@ describe SystemNoteService do
WebMock.stub_request(:get, jira_api_comment_url).to_return(body: "{\"comments\":[{\"body\":\"#{message}\"}]}")
end
subject { Note.create_cross_reference_note(jira_issue, commit, author) }
subject { described_class.cross_reference(jira_issue, commit, author) }
it { is_expected.not_to eq(jira_status_message) }
end
end
......@@ -442,7 +442,7 @@ describe SystemNoteService do
jira_tracker.destroy!
end
subject { Note.create_cross_reference_note(jira_issue, issue, author) }
subject { described_class.cross_reference(jira_issue, issue, author) }
it { is_expected.to eq(jira_status_message) }
end
......
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