summaryrefslogtreecommitdiff
path: root/spec/requests
diff options
context:
space:
mode:
Diffstat (limited to 'spec/requests')
-rw-r--r--spec/requests/api/builds_spec.rb26
-rw-r--r--spec/requests/api/commits_spec.rb16
-rw-r--r--spec/requests/api/forks_spec.rb6
-rw-r--r--spec/requests/api/projects_spec.rb68
-rw-r--r--spec/requests/api/runners_spec.rb30
-rw-r--r--spec/requests/api/triggers_spec.rb26
-rw-r--r--spec/requests/builds_spec.rb4
-rw-r--r--spec/requests/commits_spec.rb4
8 files changed, 90 insertions, 90 deletions
diff --git a/spec/requests/api/builds_spec.rb b/spec/requests/api/builds_spec.rb
index b579b36..4c01167 100644
--- a/spec/requests/api/builds_spec.rb
+++ b/spec/requests/api/builds_spec.rb
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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},
]
@@ -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},
@@ -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
diff --git a/spec/requests/api/commits_spec.rb b/spec/requests/api/commits_spec.rb
index 60763eb..99cdbc3 100644
--- a/spec/requests/api/commits_spec.rb
+++ b/spec/requests/api/commits_spec.rb
@@ -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
@@ -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
diff --git a/spec/requests/api/forks_spec.rb b/spec/requests/api/forks_spec.rb
index 1dd9c05..c884e4b 100644
--- a/spec/requests/api/forks_spec.rb
+++ b/spec/requests/api/forks_spec.rb
@@ -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
@@ -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
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 290d7cf..597f8dd 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
diff --git a/spec/requests/api/runners_spec.rb b/spec/requests/api/runners_spec.rb
index a6fc43c..f97afeb 100644
--- a/spec/requests/api/runners_spec.rb
+++ b/spec/requests/api/runners_spec.rb
@@ -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
@@ -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
@@ -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
diff --git a/spec/requests/api/triggers_spec.rb b/spec/requests/api/triggers_spec.rb
index fc7394c..e477a59 100644
--- a/spec/requests/api/triggers_spec.rb
+++ b/spec/requests/api/triggers_spec.rb
@@ -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
@@ -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
@@ -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
diff --git a/spec/requests/builds_spec.rb b/spec/requests/builds_spec.rb
index a245087..28dda2b 100644
--- a/spec/requests/builds_spec.rb
+++ b/spec/requests/builds_spec.rb
@@ -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
diff --git a/spec/requests/commits_spec.rb b/spec/requests/commits_spec.rb
index e257997..d992253 100644
--- a/spec/requests/commits_spec.rb
+++ b/spec/requests/commits_spec.rb
@@ -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