summaryrefslogtreecommitdiff
path: root/spec/requests/api/projects_spec.rb
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2015-09-08 07:39:09 +0000
committerValery Sizov <valery@gitlab.com>2015-09-08 07:39:09 +0000
commitfd6be573ee87416c103b361d5a8843600e59903e (patch)
tree9ed3124d255d4432d3acbc4265d6fc1496041380 /spec/requests/api/projects_spec.rb
parent305d9e20cc048a83bd4799942357cd690dacdef3 (diff)
parent77053a6c217e06770a348ac989992afbd41697f6 (diff)
downloadgitlab-ci-fd6be573ee87416c103b361d5a8843600e59903e.tar.gz
Merge branch 'rs-rspec3' into 'master'
RSpec 3 Updates CI's specs to be a bit more like CE's to make that transition a little easier. See merge request !246
Diffstat (limited to 'spec/requests/api/projects_spec.rb')
-rw-r--r--spec/requests/api/projects_spec.rb80
1 files changed, 40 insertions, 40 deletions
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 014a9ef..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 == 200
- json_response.count.should == 2
- json_response.first["id"].should == project1.id
- json_response.last["id"].should == 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 == 200
- json_response.count.should == 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 == 201
- json_response["url"].should == 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 == 404
+ expect(response.status).to eq 404
end
it "non-manager is not authorized" do
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
post api("/projects/#{project.id}/webhooks"), options
- response.status.should == 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 == 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 == 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 == 200
- json_response['id'].should == 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 == 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 == 200
- json_response["name"].should == 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 == 404
+ expect(response.status).to eq 404
end
it "non-manager is not authorized" do
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
put api("/projects/#{project.id}"), options
- response.status.should == 401
+ expect(response.status).to eq 401
end
end
@@ -145,20 +145,20 @@ describe API::API do
it "should delete a specific project" do
delete api("/projects/#{project.id}"), options
- response.status.should == 200
+ expect(response.status).to eq 200
- expect { project.reload }.to raise_error
+ expect { project.reload }.to raise_error(ActiveRecord::RecordNotFound)
end
it "non-manager is not authorized" do
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ allow_any_instance_of(User).to receive(:can_manage_project?).and_return(false)
delete api("/projects/#{project.id}"), options
- response.status.should == 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 == 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 == 201
- json_response['name'].should == 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 == 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 == 201
+ expect(response.status).to eq 201
project.reload
- project.runners.first.id.should == 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 == 404
+ expect(response.status).to eq 404
post api("/projects/non-existing/runners/#{runner.id}"), options
- response.status.should == 404
+ expect(response.status).to eq 404
end
it "non-manager is not authorized" do
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ 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 == 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 == 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
- User.any_instance.stub(:can_manage_project?).and_return(false)
+ 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 == 401
+ expect(response.status).to eq 401
end
end
end