Skip to content
Snippets Groups Projects
Commit 77053a6c authored by Robert Speicher's avatar Robert Speicher
Browse files

Convert to RSpec3 syntax via transpec

Command:

    transpec -c 'bundle exec rspec spec -t ~feature' \
    -o should,oneliner,should_receive
parent 74b995d1
No related branches found
No related tags found
No related merge requests found
Showing
with 191 additions and 191 deletions
Loading
Loading
@@ -16,7 +16,7 @@ require 'spec_helper'
 
describe SlackService do
describe "Associations" do
it { should belong_to :project }
it { is_expected.to belong_to :project }
end
 
describe "Validations" do
Loading
Loading
@@ -25,7 +25,7 @@ describe SlackService do
subject.active = true
end
 
it { should validate_presence_of :webhook }
it { is_expected.to validate_presence_of :webhook }
end
end
 
Loading
Loading
@@ -52,7 +52,7 @@ describe SlackService do
slack.execute(build)
SlackNotifierWorker.drain
 
WebMock.should have_requested(:post, webhook_url).once
expect(WebMock).to have_requested(:post, webhook_url).once
end
end
end
Loading
Loading
@@ -30,21 +30,21 @@ require 'spec_helper'
describe Project do
subject { FactoryGirl.build :project }
 
it { should have_many(:commits) }
it { is_expected.to have_many(:commits) }
 
it { should validate_presence_of :name }
it { should validate_presence_of :timeout }
it { should validate_presence_of :default_ref }
it { is_expected.to validate_presence_of :name }
it { is_expected.to validate_presence_of :timeout }
it { is_expected.to validate_presence_of :default_ref }
 
describe 'before_validation' do
it 'should set an random token if none provided' do
project = FactoryGirl.create :project_without_token
project.token.should_not eq ""
expect(project.token).not_to eq ""
end
 
it 'should not set an random toke if one provided' do
project = FactoryGirl.create :project
project.token.should eq "iPWx6WM4lhHNedGfBpPJNP"
expect(project.token).to eq "iPWx6WM4lhHNedGfBpPJNP"
end
end
 
Loading
Loading
@@ -57,7 +57,7 @@ describe Project do
FactoryGirl.create :commit, committed_at: 1.hour.ago, project: newest_project
FactoryGirl.create :commit, committed_at: 2.hour.ago, project: oldest_project
 
described_class.ordered_by_last_commit_date.should eq [newest_project, oldest_project, project_without_commits]
expect(described_class.ordered_by_last_commit_date).to eq [newest_project, oldest_project, project_without_commits]
end
end
 
Loading
Loading
@@ -70,26 +70,26 @@ describe Project do
FactoryGirl.create(:build, commit: commit)
end
 
it { project.status.should eq 'pending' }
it { project.last_commit.should be_kind_of(Commit) }
it { project.human_status.should eq 'pending' }
it { expect(project.status).to eq 'pending' }
it { expect(project.last_commit).to be_kind_of(Commit) }
it { expect(project.human_status).to eq 'pending' }
end
end
 
describe '#email_notification?' do
it do
project = FactoryGirl.create :project, email_add_pusher: true
project.email_notification?.should eq true
expect(project.email_notification?).to eq true
end
 
it do
project = FactoryGirl.create :project, email_add_pusher: false, email_recipients: 'test tesft'
project.email_notification?.should eq true
expect(project.email_notification?).to eq true
end
 
it do
project = FactoryGirl.create :project, email_add_pusher: false, email_recipients: ''
project.email_notification?.should eq false
expect(project.email_notification?).to eq false
end
end
 
Loading
Loading
@@ -98,28 +98,28 @@ describe Project do
project = FactoryGirl.create :project, email_add_pusher: true
allow(project).to receive(:broken?).and_return(true)
allow(project).to receive(:success?).and_return(true)
project.broken_or_success?.should eq true
expect(project.broken_or_success?).to eq true
}
 
it {
project = FactoryGirl.create :project, email_add_pusher: true
allow(project).to receive(:broken?).and_return(true)
allow(project).to receive(:success?).and_return(false)
project.broken_or_success?.should eq true
expect(project.broken_or_success?).to eq true
}
 
it {
project = FactoryGirl.create :project, email_add_pusher: true
allow(project).to receive(:broken?).and_return(false)
allow(project).to receive(:success?).and_return(true)
project.broken_or_success?.should eq true
expect(project.broken_or_success?).to eq true
}
 
it {
project = FactoryGirl.create :project, email_add_pusher: true
allow(project).to receive(:broken?).and_return(false)
allow(project).to receive(:success?).and_return(false)
project.broken_or_success?.should eq false
expect(project.broken_or_success?).to eq false
}
end
 
Loading
Loading
@@ -128,14 +128,14 @@ describe Project do
let(:parsed_project) { described_class.parse(project_dump) }
 
it { parsed_project.should be_valid }
it { parsed_project.should be_kind_of(described_class) }
it { parsed_project.name.should eq("GitLab / api.gitlab.org") }
it { parsed_project.gitlab_id.should eq(189) }
it { parsed_project.gitlab_url.should eq("http://demo.gitlab.com/gitlab/api-gitlab-org") }
it { expect(parsed_project).to be_valid }
it { expect(parsed_project).to be_kind_of(described_class) }
it { expect(parsed_project.name).to eq("GitLab / api.gitlab.org") }
it { expect(parsed_project.gitlab_id).to eq(189) }
it { expect(parsed_project.gitlab_url).to eq("http://demo.gitlab.com/gitlab/api-gitlab-org") }
 
it "parses plain hash" do
described_class.parse(project_dump).name.should eq("GitLab / api.gitlab.org")
expect(described_class.parse(project_dump).name).to eq("GitLab / api.gitlab.org")
end
end
 
Loading
Loading
@@ -143,43 +143,43 @@ describe Project do
let(:project) { FactoryGirl.create :project }
subject { project.repo_url_with_auth }
 
it { should be_a(String) }
it { should end_with(".git") }
it { should start_with(project.gitlab_url[0..6]) }
it { should include(project.token) }
it { should include('gitlab-ci-token') }
it { should include(project.gitlab_url[7..-1]) }
it { is_expected.to be_a(String) }
it { is_expected.to end_with(".git") }
it { is_expected.to start_with(project.gitlab_url[0..6]) }
it { is_expected.to include(project.token) }
it { is_expected.to include('gitlab-ci-token') }
it { is_expected.to include(project.gitlab_url[7..-1]) }
end
 
describe '.search' do
let!(:project) { FactoryGirl.create(:project, name: "foo") }
 
it { described_class.search('fo').should include(project) }
it { described_class.search('bar').should be_empty }
it { expect(described_class.search('fo')).to include(project) }
it { expect(described_class.search('bar')).to be_empty }
end
 
describe '#any_runners' do
it "there are no runners available" do
project = FactoryGirl.create(:project)
project.any_runners?.should be_falsey
expect(project.any_runners?).to be_falsey
end
 
it "there is a specific runner" do
project = FactoryGirl.create(:project)
project.runners << FactoryGirl.create(:specific_runner)
project.any_runners?.should be_truthy
expect(project.any_runners?).to be_truthy
end
 
it "there is a shared runner" do
project = FactoryGirl.create(:project, shared_runners_enabled: true)
FactoryGirl.create(:shared_runner)
project.any_runners?.should be_truthy
expect(project.any_runners?).to be_truthy
end
 
it "there is a shared runner, but they are prohibited to use" do
project = FactoryGirl.create(:project)
FactoryGirl.create(:shared_runner)
project.any_runners?.should be_falsey
expect(project.any_runners?).to be_falsey
end
end
end
Loading
Loading
@@ -43,9 +43,9 @@ describe Runner do
 
before { shared_runner.assign_to(project) }
 
it { shared_runner.should be_specific }
it { shared_runner.projects.should eq [project] }
it { shared_runner.only_for?(project).should be_truthy }
it { expect(shared_runner).to be_specific }
it { expect(shared_runner.projects).to eq [project] }
it { expect(shared_runner.only_for?(project)).to be_truthy }
end
 
describe "belongs_to_one_project?" do
Loading
Loading
@@ -56,7 +56,7 @@ describe Runner do
project.runners << runner
project1.runners << runner
 
runner.belongs_to_one_project?.should be_falsey
expect(runner.belongs_to_one_project?).to be_falsey
end
 
it "returns true" do
Loading
Loading
@@ -64,7 +64,7 @@ describe Runner do
project = FactoryGirl.create(:project)
project.runners << runner
 
runner.belongs_to_one_project?.should be_truthy
expect(runner.belongs_to_one_project?).to be_truthy
end
end
end
Loading
Loading
@@ -17,7 +17,7 @@ require 'spec_helper'
describe Service do
 
describe "Associations" do
it { should belong_to :project }
it { is_expected.to belong_to :project }
end
 
describe "Mass assignment" do
Loading
Loading
@@ -40,7 +40,7 @@ describe Service do
end
 
describe '#can_test' do
it { @testable.should eq true }
it { expect(@testable).to eq true }
end
end
end
Loading
Loading
Loading
Loading
@@ -6,12 +6,12 @@ describe Trigger do
describe 'before_validation' do
it 'should set an random token if none provided' do
trigger = FactoryGirl.create :trigger_without_token, project: project
trigger.token.should_not be_nil
expect(trigger.token).not_to be_nil
end
 
it 'should not set an random token if one provided' do
trigger = FactoryGirl.create :trigger, project: project
trigger.token.should eq 'token'
expect(trigger.token).to eq 'token'
end
end
end
Loading
Loading
@@ -42,13 +42,13 @@ describe User do
it "returns false for reporter" do
allow(@user).to receive(:project_info).and_return(project_with_reporter_access)
 
@user.has_developer_access?(1).should be_falsey
expect(@user.has_developer_access?(1)).to be_falsey
end
 
it "returns true for owner" do
allow(@user).to receive(:project_info).and_return(project_with_owner_access)
 
@user.has_developer_access?(1).should be_truthy
expect(@user.has_developer_access?(1)).to be_truthy
end
end
 
Loading
Loading
@@ -66,13 +66,13 @@ describe User do
it "returns projects" do
allow_any_instance_of(described_class).to receive(:can_manage_project?).and_return(true)
 
user.authorized_projects.count.should eq 2
expect(user.authorized_projects.count).to eq 2
end
 
it "empty list if user miss manage permission" do
allow_any_instance_of(described_class).to receive(:can_manage_project?).and_return(false)
 
user.authorized_projects.count.should eq 0
expect(user.authorized_projects.count).to eq 0
end
end
 
Loading
Loading
@@ -93,8 +93,8 @@ describe User do
project.runners << runner
project1.runners << runner1
 
user.authorized_runners.should include(runner, runner1)
user.authorized_runners.should_not include(runner2)
expect(user.authorized_runners).to include(runner, runner1)
expect(user.authorized_runners).not_to include(runner2)
end
end
end
Loading
Loading
@@ -24,15 +24,15 @@ describe Variable do
 
describe '#value' do
it 'stores the encrypted value' do
subject.encrypted_value.should_not be_nil
expect(subject.encrypted_value).not_to be_nil
end
 
it 'stores an iv for value' do
subject.encrypted_value_iv.should_not be_nil
expect(subject.encrypted_value_iv).not_to be_nil
end
 
it 'stores a salt for value' do
subject.encrypted_value_salt.should_not be_nil
expect(subject.encrypted_value_salt).not_to be_nil
end
 
it 'fails to decrypt if iv is incorrect' do
Loading
Loading
Loading
Loading
@@ -13,22 +13,22 @@ require 'spec_helper'
 
describe WebHook do
describe "Associations" do
it { should belong_to :project }
it { is_expected.to belong_to :project }
end
 
describe "Validations" do
it { should validate_presence_of(:url) }
it { is_expected.to validate_presence_of(:url) }
 
context "url format" do
it { should allow_value("http://example.com").for(:url) }
it { should allow_value("https://excample.com").for(:url) }
it { should allow_value("http://test.com/api").for(:url) }
it { should allow_value("http://test.com/api?key=abc").for(:url) }
it { should allow_value("http://test.com/api?key=abc&type=def").for(:url) }
it { should_not allow_value("example.com").for(:url) }
it { should_not allow_value("ftp://example.com").for(:url) }
it { should_not allow_value("herp-and-derp").for(:url) }
it { is_expected.to allow_value("http://example.com").for(:url) }
it { is_expected.to allow_value("https://excample.com").for(:url) }
it { is_expected.to allow_value("http://test.com/api").for(:url) }
it { is_expected.to allow_value("http://test.com/api?key=abc").for(:url) }
it { is_expected.to allow_value("http://test.com/api?key=abc&type=def").for(:url) }
it { is_expected.not_to allow_value("example.com").for(:url) }
it { is_expected.not_to allow_value("ftp://example.com").for(:url) }
it { is_expected.not_to allow_value("herp-and-derp").for(:url) }
end
end
 
Loading
Loading
@@ -43,18 +43,18 @@ describe WebHook do
 
it "POSTs to the web hook URL" do
@web_hook.execute(@data)
WebMock.should have_requested(:post, @web_hook.url).once
expect(WebMock).to have_requested(:post, @web_hook.url).once
end
 
it "POSTs the data as JSON" do
json = @data.to_json
 
@web_hook.execute(@data)
WebMock.should have_requested(:post, @web_hook.url).with(body: json).once
expect(WebMock).to have_requested(:post, @web_hook.url).with(body: json).once
end
 
it "catches exceptions" do
described_class.should_receive(:post).and_raise("Some HTTP Post error")
expect(described_class).to receive(:post).and_raise("Some HTTP Post error")
 
expect { @web_hook.execute(@data) }.
to raise_error(RuntimeError, 'Some HTTP Post error')
Loading
Loading
Loading
Loading
@@ -22,15 +22,15 @@ describe API::API do
 
post api("/builds/register"), token: runner.token, info: {platform: :darwin}
 
response.status.should eq 201
json_response['sha'].should eq build.sha
runner.reload.platform.should eq "darwin"
expect(response.status).to eq 201
expect(json_response['sha']).to eq build.sha
expect(runner.reload.platform).to eq "darwin"
end
 
it "should return 404 error if no pending build found" do
post api("/builds/register"), token: runner.token
 
response.status.should eq 404
expect(response.status).to eq 404
end
 
it "should return 404 error if no builds for specific runner" do
Loading
Loading
@@ -39,7 +39,7 @@ describe API::API do
 
post api("/builds/register"), token: runner.token
 
response.status.should eq 404
expect(response.status).to eq 404
end
 
it "should return 404 error if no builds for shared runner" do
Loading
Loading
@@ -48,7 +48,7 @@ describe API::API do
 
post api("/builds/register"), token: shared_runner.token
 
response.status.should eq 404
expect(response.status).to eq 404
end
 
it "returns options" do
Loading
Loading
@@ -57,8 +57,8 @@ describe API::API do
 
post api("/builds/register"), token: runner.token, info: {platform: :darwin}
 
response.status.should eq 201
json_response["options"].should eq({"image" => "ruby:2.1", "services" => ["postgres"]})
expect(response.status).to eq 201
expect(json_response["options"]).to eq({"image" => "ruby:2.1", "services" => ["postgres"]})
end
 
it "returns variables" do
Loading
Loading
@@ -68,8 +68,8 @@ describe API::API do
 
post api("/builds/register"), token: runner.token, info: {platform: :darwin}
 
response.status.should eq 201
json_response["variables"].should eq [
expect(response.status).to eq 201
expect(json_response["variables"]).to eq [
{"key" => "DB_NAME", "value" => "postgres", "public" => true},
{"key" => "SECRET_KEY", "value" => "secret_value", "public" => false},
]
Loading
Loading
@@ -85,8 +85,8 @@ describe API::API do
 
post api("/builds/register"), token: runner.token, info: {platform: :darwin}
 
response.status.should eq 201
json_response["variables"].should eq [
expect(response.status).to eq 201
expect(json_response["variables"]).to eq [
{"key" => "DB_NAME", "value" => "postgres", "public" => true},
{"key" => "SECRET_KEY", "value" => "secret_value", "public" => false},
{"key" => "TRIGGER_KEY", "value" => "TRIGGER_VALUE", "public" => false},
Loading
Loading
@@ -101,7 +101,7 @@ describe API::API do
it "should update a running build" do
build.run!
put api("/builds/#{build.id}"), token: runner.token
response.status.should eq 200
expect(response.status).to eq 200
end
 
it 'Should not override trace information when no trace is given' do
Loading
Loading
Loading
Loading
@@ -19,10 +19,10 @@ describe API::API, 'Commits' do
it "should return commits per project" do
get api("/commits"), options
 
response.status.should eq 200
json_response.count.should eq 1
json_response.first["project_id"].should eq project.id
json_response.first["sha"].should eq commit.sha
expect(response.status).to eq 200
expect(json_response.count).to eq 1
expect(json_response.first["project_id"]).to eq project.id
expect(json_response.first["sha"]).to eq commit.sha
end
end
 
Loading
Loading
@@ -51,15 +51,15 @@ describe API::API, 'Commits' do
it "should create a build" do
post api("/commits"), options.merge(data: data)
 
response.status.should eq 201
json_response['sha'].should eq "da1560886d4f094c3e6c9ef40349f7d38b5d27d7"
expect(response.status).to eq 201
expect(json_response['sha']).to eq "da1560886d4f094c3e6c9ef40349f7d38b5d27d7"
end
 
it "should return 400 error if no data passed" do
post api("/commits"), options
 
response.status.should eq 400
json_response['message'].should eq "400 (Bad request) \"data\" not given"
expect(response.status).to eq 400
expect(json_response['message']).to eq "400 (Bad request) \"data\" not given"
end
end
end
Loading
Loading
@@ -41,8 +41,8 @@ describe API::API do
 
it "should create a project with valid data" do
post api("/forks"), options
response.status.should eq 201
json_response['name'].should eq "Gitlab.org / Underscore"
expect(response.status).to eq 201
expect(json_response['name']).to eq "Gitlab.org / Underscore"
end
end
 
Loading
Loading
@@ -53,7 +53,7 @@ describe API::API do
 
it "should error with invalid data" do
post api("/forks"), options
response.status.should eq 400
expect(response.status).to eq 400
end
end
end
Loading
Loading
Loading
Loading
@@ -25,10 +25,10 @@ describe API::API do
 
it "should return all projects on the CI instance" do
get api("/projects"), options
response.status.should eq 200
json_response.count.should eq 2
json_response.first["id"].should eq project1.id
json_response.last["id"].should eq project2.id
expect(response.status).to eq 200
expect(json_response.count).to eq 2
expect(json_response.first["id"]).to eq project1.id
expect(json_response.last["id"]).to eq project2.id
end
end
 
Loading
Loading
@@ -40,8 +40,8 @@ describe API::API do
it "should return all projects on the CI instance" do
get api("/projects/owned"), options
 
response.status.should eq 200
json_response.count.should eq 0
expect(response.status).to eq 200
expect(json_response.count).to eq 0
end
end
end
Loading
Loading
@@ -58,19 +58,19 @@ describe API::API do
 
it "should create webhook for specified project" do
post api("/projects/#{project.id}/webhooks"), options
response.status.should eq 201
json_response["url"].should eq webhook[:web_hook]
expect(response.status).to eq 201
expect(json_response["url"]).to eq webhook[:web_hook]
end
 
it "fails to create webhook for non existsing project" do
post api("/projects/non-existant-id/webhooks"), options
response.status.should eq 404
expect(response.status).to eq 404
end
 
it "non-manager is not authorized" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
post api("/projects/#{project.id}/webhooks"), options
response.status.should eq 401
expect(response.status).to eq 401
end
end
 
Loading
Loading
@@ -83,14 +83,14 @@ describe API::API do
 
it "fails to create webhook for not valid url" do
post api("/projects/#{project.id}/webhooks"), options
response.status.should eq 400
expect(response.status).to eq 400
end
end
 
context "Missed web_hook parameter" do
it "fails to create webhook for not provided url" do
post api("/projects/#{project.id}/webhooks"), options
response.status.should eq 400
expect(response.status).to eq 400
end
end
end
Loading
Loading
@@ -101,15 +101,15 @@ describe API::API do
context "with an existing project" do
it "should retrieve the project info" do
get api("/projects/#{project.id}"), options
response.status.should eq 200
json_response['id'].should eq project.id
expect(response.status).to eq 200
expect(json_response['id']).to eq project.id
end
end
 
context "with a non-existing project" do
it "should return 404 error if project not found" do
get api("/projects/non_existent_id"), options
response.status.should eq 404
expect(response.status).to eq 404
end
end
end
Loading
Loading
@@ -124,19 +124,19 @@ describe API::API do
 
it "should update a specific project's information" do
put api("/projects/#{project.id}"), options
response.status.should eq 200
json_response["name"].should eq project_info[:name]
expect(response.status).to eq 200
expect(json_response["name"]).to eq project_info[:name]
end
 
it "fails to update a non-existing project" do
put api("/projects/non-existant-id"), options
response.status.should eq 404
expect(response.status).to eq 404
end
 
it "non-manager is not authorized" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
put api("/projects/#{project.id}"), options
response.status.should eq 401
expect(response.status).to eq 401
end
end
 
Loading
Loading
@@ -145,7 +145,7 @@ describe API::API do
 
it "should delete a specific project" do
delete api("/projects/#{project.id}"), options
response.status.should eq 200
expect(response.status).to eq 200
 
expect { project.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
Loading
Loading
@@ -153,12 +153,12 @@ describe API::API do
it "non-manager is not authorized" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
delete api("/projects/#{project.id}"), options
response.status.should eq 401
expect(response.status).to eq 401
end
 
it "is getting not found error" do
delete api("/projects/not-existing_id"), options
response.status.should eq 404
expect(response.status).to eq 404
end
end
 
Loading
Loading
@@ -181,8 +181,8 @@ describe API::API do
 
it "should create a project with valid data" do
post api("/projects"), options
response.status.should eq 201
json_response['name'].should eq project_info[:name]
expect(response.status).to eq 201
expect(json_response['name']).to eq project_info[:name]
end
end
 
Loading
Loading
@@ -193,7 +193,7 @@ describe API::API do
 
it "should error with invalid data" do
post api("/projects"), options
response.status.should eq 400
expect(response.status).to eq 400
end
end
 
Loading
Loading
@@ -203,24 +203,24 @@ describe API::API do
 
it "should add the project to the runner" do
post api("/projects/#{project.id}/runners/#{runner.id}"), options
response.status.should eq 201
expect(response.status).to eq 201
 
project.reload
project.runners.first.id.should eq runner.id
expect(project.runners.first.id).to eq runner.id
end
 
it "should fail if it tries to link a non-existing project or runner" do
post api("/projects/#{project.id}/runners/non-existing"), options
response.status.should eq 404
expect(response.status).to eq 404
 
post api("/projects/non-existing/runners/#{runner.id}"), options
response.status.should eq 404
expect(response.status).to eq 404
end
 
it "non-manager is not authorized" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
post api("/projects/#{project.id}/runners/#{runner.id}"), options
response.status.should eq 401
expect(response.status).to eq 401
end
end
 
Loading
Loading
@@ -233,18 +233,18 @@ describe API::API do
end
 
it "should remove the project from the runner" do
project.runners.should be_present
expect(project.runners).to be_present
delete api("/projects/#{project.id}/runners/#{runner.id}"), options
response.status.should eq 200
expect(response.status).to eq 200
 
project.reload
project.runners.should be_empty
expect(project.runners).to be_empty
end
 
it "non-manager is not authorized" do
allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
post api("/projects/#{project.id}/runners/#{runner.id}"), options
response.status.should eq 401
expect(response.status).to eq 401
end
end
end
Loading
Loading
Loading
Loading
@@ -24,10 +24,10 @@ describe API::API do
 
it "should retrieve a list of all runners" do
get api("/runners"), options
response.status.should eq 200
json_response.count.should eq 5
json_response.last.should have_key("id")
json_response.last.should have_key("token")
expect(response.status).to eq 200
expect(json_response.count).to eq 5
expect(json_response.last).to have_key("id")
expect(json_response.last).to have_key("token")
end
end
 
Loading
Loading
@@ -35,41 +35,41 @@ describe API::API do
describe "should create a runner if token provided" do
before { post api("/runners/register"), token: GitlabCi::REGISTRATION_TOKEN }
 
it { response.status.should eq 201 }
it { expect(response.status).to eq 201 }
end
 
describe "should create a runner with description" do
before { post api("/runners/register"), token: GitlabCi::REGISTRATION_TOKEN, description: "server.hostname" }
 
it { response.status.should eq 201 }
it { Runner.first.description.should eq "server.hostname" }
it { expect(response.status).to eq 201 }
it { expect(Runner.first.description).to eq "server.hostname" }
end
 
describe "should create a runner with tags" do
before { post api("/runners/register"), token: GitlabCi::REGISTRATION_TOKEN, tag_list: "tag1, tag2" }
 
it { response.status.should eq 201 }
it { Runner.first.tag_list.sort.should eq ["tag1", "tag2"] }
it { expect(response.status).to eq 201 }
it { expect(Runner.first.tag_list.sort).to eq ["tag1", "tag2"] }
end
 
describe "should create a runner if project token provided" do
let(:project) { FactoryGirl.create(:project) }
before { post api("/runners/register"), token: project.token }
 
it { response.status.should eq 201 }
it { project.runners.size.should eq 1 }
it { expect(response.status).to eq 201 }
it { expect(project.runners.size).to eq 1 }
end
 
it "should return 403 error if token is invalid" do
post api("/runners/register"), token: 'invalid'
 
response.status.should eq 403
expect(response.status).to eq 403
end
 
it "should return 400 error if no token" do
post api("/runners/register")
 
response.status.should eq 400
expect(response.status).to eq 400
end
end
 
Loading
Loading
@@ -77,7 +77,7 @@ describe API::API do
let!(:runner) { FactoryGirl.create(:runner) }
before { delete api("/runners/delete"), token: runner.token }
 
it { response.status.should eq 200 }
it { Runner.count.should eq 0 }
it { expect(response.status).to eq 200 }
it { expect(Runner.count).to eq 0 }
end
end
Loading
Loading
@@ -17,17 +17,17 @@ describe API::API do
context 'Handles errors' do
it 'should return bad request if token is missing' do
post api("/projects/#{project.id}/refs/master/trigger")
response.status.should eq 400
expect(response.status).to eq 400
end
 
it 'should return not found if project is not found' do
post api('/projects/0/refs/master/trigger'), options
response.status.should eq 404
expect(response.status).to eq 404
end
 
it 'should return unauthorized if token is for different project' do
post api("/projects/#{project2.id}/refs/master/trigger"), options
response.status.should eq 401
expect(response.status).to eq 401
end
end
 
Loading
Loading
@@ -38,15 +38,15 @@ describe API::API do
 
it 'should create builds' do
post api("/projects/#{project.id}/refs/master/trigger"), options
response.status.should eq 201
expect(response.status).to eq 201
@commit.builds.reload
@commit.builds.size.should eq 2
expect(@commit.builds.size).to eq 2
end
 
it 'should return bad request with no builds created if there\'s no commit for that ref' do
post api("/projects/#{project.id}/refs/other-branch/trigger"), options
response.status.should eq 400
json_response['message'].should eq 'No builds created'
expect(response.status).to eq 400
expect(json_response['message']).to eq 'No builds created'
end
 
context 'Validates variables' do
Loading
Loading
@@ -56,21 +56,21 @@ describe API::API do
 
it 'should validate variables to be a hash' do
post api("/projects/#{project.id}/refs/master/trigger"), options.merge(variables: 'value')
response.status.should eq 400
json_response['message'].should eq 'variables needs to be a hash'
expect(response.status).to eq 400
expect(json_response['message']).to eq 'variables needs to be a hash'
end
 
it 'should validate variables needs to be a map of key-valued strings' do
post api("/projects/#{project.id}/refs/master/trigger"), options.merge(variables: {key: %w(1 2)})
response.status.should eq 400
json_response['message'].should eq 'variables needs to be a map of key-valued strings'
expect(response.status).to eq 400
expect(json_response['message']).to eq 'variables needs to be a map of key-valued strings'
end
 
it 'create trigger request with variables' do
post api("/projects/#{project.id}/refs/master/trigger"), options.merge(variables: variables)
response.status.should eq 201
expect(response.status).to eq 201
@commit.builds.reload
@commit.builds.first.trigger_request.variables.should eq variables
expect(@commit.builds.first.trigger_request.variables).to eq variables
end
end
end
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ describe "Builds" do
get status_project_build_path(@project, @build), format: :json
end
 
it { response.status.should eq 200 }
it { response.body.should include(@build.sha) }
it { expect(response.status).to eq 200 }
it { expect(response.body).to include(@build.sha) }
end
end
Loading
Loading
@@ -11,7 +11,7 @@ describe "Commits" do
get status_project_ref_commit_path(@project, @commit.ref, @commit.sha), format: :json
end
 
it { response.status.should eq 200 }
it { response.body.should include(@commit.sha) }
it { expect(response.status).to eq 200 }
it { expect(response.body).to include(@commit.sha) }
end
end
Loading
Loading
@@ -16,11 +16,11 @@ describe CreateCommitService do
)
end
 
it { commit.should be_kind_of(Commit) }
it { commit.should be_valid }
it { commit.should be_persisted }
it { commit.should eq project.commits.last }
it { commit.builds.first.should be_kind_of(Build) }
it { expect(commit).to be_kind_of(Commit) }
it { expect(commit).to be_valid }
it { expect(commit).to be_persisted }
it { expect(commit).to eq project.commits.last }
it { expect(commit.builds.first).to be_kind_of(Build) }
end
 
context "skip tag if there is no build for it" do
Loading
Loading
@@ -32,7 +32,7 @@ describe CreateCommitService do
ci_yaml_file: gitlab_ci_yaml,
commits: [ { message: "Message" } ]
)
result.should be_persisted
expect(result).to be_persisted
end
 
it "creates commit if there is no appropriate job but deploy job has right ref setting" do
Loading
Loading
@@ -45,7 +45,7 @@ describe CreateCommitService do
ci_yaml_file: config,
commits: [ { message: "Message" } ]
)
result.should be_persisted
expect(result).to be_persisted
end
end
 
Loading
Loading
@@ -59,8 +59,8 @@ describe CreateCommitService do
commits: commits,
ci_yaml_file: gitlab_ci_yaml
)
commit.builds.any?.should be_falsey
commit.status.should eq "skipped"
expect(commit.builds.any?).to be_falsey
expect(commit.status).to eq "skipped"
end
 
it "does not skips builds creation if there is no [ci skip] tag in commit message" do
Loading
Loading
@@ -74,7 +74,7 @@ describe CreateCommitService do
ci_yaml_file: gitlab_ci_yaml
)
commit.builds.first.name.should eq "staging"
expect(commit.builds.first.name).to eq "staging"
end
 
it "skips builds creation if there is [ci skip] tag in commit message and yaml is invalid" do
Loading
Loading
@@ -86,8 +86,8 @@ describe CreateCommitService do
commits: commits,
ci_yaml_file: "invalid: file"
)
commit.builds.any?.should be_falsey
commit.status.should eq "skipped"
expect(commit.builds.any?).to be_falsey
expect(commit.status).to eq "skipped"
end
end
 
Loading
Loading
@@ -100,7 +100,7 @@ describe CreateCommitService do
commits: commits,
ci_yaml_file: gitlab_ci_yaml
)
commit.builds.count(:all).should eq 2
expect(commit.builds.count(:all)).to eq 2
 
commit = service.execute(project,
ref: 'refs/heads/master',
Loading
Loading
@@ -109,7 +109,7 @@ describe CreateCommitService do
commits: commits,
ci_yaml_file: gitlab_ci_yaml
)
commit.builds.count(:all).should eq 2
expect(commit.builds.count(:all)).to eq 2
end
 
it "creates commit with failed status if yaml is invalid" do
Loading
Loading
@@ -123,8 +123,8 @@ describe CreateCommitService do
ci_yaml_file: "invalid: file"
)
 
commit.status.should eq "failed"
commit.builds.any?.should be_falsey
expect(commit.status).to eq "failed"
expect(commit.builds.any?).to be_falsey
end
end
end
Loading
Loading
@@ -11,8 +11,8 @@ describe CreateProjectService do
context 'valid params' do
let(:project) { service.execute(current_user, project_dump, 'http://localhost/projects/:project_id') }
 
it { project.should be_kind_of(Project) }
it { project.should be_persisted }
it { expect(project).to be_kind_of(Project) }
it { expect(project).to be_persisted }
end
 
context 'without project dump' do
Loading
Loading
@@ -32,9 +32,9 @@ describe CreateProjectService do
 
project = service.execute(current_user, project_dump, 'http://localhost/projects/:project_id', origin_project)
 
project.shared_runners_enabled.should be_truthy
project.public.should be_truthy
project.allow_git_fetch.should be_truthy
expect(project.shared_runners_enabled).to be_truthy
expect(project.public).to be_truthy
expect(project.allow_git_fetch).to be_truthy
end
end
end
Loading
Loading
Loading
Loading
@@ -13,14 +13,14 @@ describe CreateTriggerRequestService do
@commit = FactoryGirl.create :commit, project: project
end
 
it { subject.should be_kind_of(TriggerRequest) }
it { subject.commit.should eq @commit }
it { expect(subject).to be_kind_of(TriggerRequest) }
it { expect(subject.commit).to eq @commit }
end
 
context 'no commit for ref' do
subject { service.execute(project, trigger, 'other-branch') }
 
it { subject.should be_nil }
it { expect(subject).to be_nil }
end
 
context 'no builds created' do
Loading
Loading
@@ -30,7 +30,7 @@ describe CreateTriggerRequestService do
FactoryGirl.create :commit_without_jobs, project: project
end
 
it { subject.should be_nil }
it { expect(subject).to be_nil }
end
 
context 'for multiple commits' do
Loading
Loading
@@ -43,9 +43,9 @@ describe CreateTriggerRequestService do
end
 
context 'retries latest one' do
it { subject.should be_kind_of(TriggerRequest) }
it { subject.should be_persisted }
it { subject.commit.should eq @commit2 }
it { expect(subject).to be_kind_of(TriggerRequest) }
it { expect(subject).to be_persisted }
it { expect(subject.commit).to eq @commit2 }
end
end
end
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ describe EventService do
it "creates event" do
described_class.new.remove_project(user, project)
 
Event.admin.last.description.should eq "Project \"GitLab / gitlab-shell\" has been removed by root"
expect(Event.admin.last.description).to eq "Project \"GitLab / gitlab-shell\" has been removed by root"
end
end
 
Loading
Loading
@@ -20,7 +20,7 @@ describe EventService do
it "creates event" do
described_class.new.create_project(user, project)
 
Event.admin.last.description.should eq "Project \"GitLab / gitlab-shell\" has been created by root"
expect(Event.admin.last.description).to eq "Project \"GitLab / gitlab-shell\" has been created by root"
end
end
 
Loading
Loading
@@ -28,7 +28,7 @@ describe EventService do
it "creates event" do
described_class.new.change_project_settings(user, project)
 
Event.last.description.should eq "User \"root\" updated projects settings"
expect(Event.last.description).to eq "User \"root\" updated projects settings"
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment