Fixed some tests and snippet colorize
This commit is contained in:
parent
470aa7675e
commit
9304d049de
13 changed files with 64 additions and 68 deletions
|
@ -33,7 +33,7 @@ describe Gitlab::API do
|
|||
end
|
||||
|
||||
describe "POST /projects" do
|
||||
it "should create new project without code and path" do
|
||||
it "should create new project without path" do
|
||||
expect { post api("/projects", user), name: 'foo' }.to change {Project.count}.by(1)
|
||||
end
|
||||
|
||||
|
@ -53,8 +53,7 @@ describe Gitlab::API do
|
|||
|
||||
it "should assign attributes to project" do
|
||||
project = attributes_for(:project, {
|
||||
path: 'path',
|
||||
code: 'code',
|
||||
path: project.name.parameterize,
|
||||
description: Faker::Lorem.sentence,
|
||||
default_branch: 'stable',
|
||||
issues_enabled: false,
|
||||
|
@ -79,8 +78,8 @@ describe Gitlab::API do
|
|||
json_response['owner']['email'].should == user.email
|
||||
end
|
||||
|
||||
it "should return a project by code name" do
|
||||
get api("/projects/#{project.code}", user)
|
||||
it "should return a project by path name" do
|
||||
get api("/projects/#{project.path}", user)
|
||||
response.status.should == 200
|
||||
json_response['name'].should == project.name
|
||||
end
|
||||
|
@ -94,7 +93,7 @@ describe Gitlab::API do
|
|||
|
||||
describe "GET /projects/:id/repository/branches" do
|
||||
it "should return an array of project branches" do
|
||||
get api("/projects/#{project.code}/repository/branches", user)
|
||||
get api("/projects/#{project.path}/repository/branches", user)
|
||||
response.status.should == 200
|
||||
json_response.should be_an Array
|
||||
json_response.first['name'].should == project.repo.heads.sort_by(&:name).first.name
|
||||
|
@ -103,7 +102,7 @@ describe Gitlab::API do
|
|||
|
||||
describe "GET /projects/:id/repository/branches/:branch" do
|
||||
it "should return the branch information for a single branch" do
|
||||
get api("/projects/#{project.code}/repository/branches/new_design", user)
|
||||
get api("/projects/#{project.path}/repository/branches/new_design", user)
|
||||
response.status.should == 200
|
||||
|
||||
json_response['name'].should == 'new_design'
|
||||
|
@ -113,7 +112,7 @@ describe Gitlab::API do
|
|||
|
||||
describe "GET /projects/:id/members" do
|
||||
it "should return project team members" do
|
||||
get api("/projects/#{project.code}/members", user)
|
||||
get api("/projects/#{project.path}/members", user)
|
||||
response.status.should == 200
|
||||
json_response.should be_an Array
|
||||
json_response.count.should == 2
|
||||
|
@ -123,7 +122,7 @@ describe Gitlab::API do
|
|||
|
||||
describe "GET /projects/:id/members/:user_id" do
|
||||
it "should return project team member" do
|
||||
get api("/projects/#{project.code}/members/#{user.id}", user)
|
||||
get api("/projects/#{project.path}/members/#{user.id}", user)
|
||||
response.status.should == 200
|
||||
json_response['email'].should == user.email
|
||||
json_response['access_level'].should == UsersProject::MASTER
|
||||
|
@ -133,7 +132,7 @@ describe Gitlab::API do
|
|||
describe "POST /projects/:id/members" do
|
||||
it "should add user to project team" do
|
||||
expect {
|
||||
post api("/projects/#{project.code}/members", user), user_id: user2.id,
|
||||
post api("/projects/#{project.path}/members", user), user_id: user2.id,
|
||||
access_level: UsersProject::DEVELOPER
|
||||
}.to change { UsersProject.count }.by(1)
|
||||
|
||||
|
@ -145,7 +144,7 @@ describe Gitlab::API do
|
|||
|
||||
describe "PUT /projects/:id/members/:user_id" do
|
||||
it "should update project team member" do
|
||||
put api("/projects/#{project.code}/members/#{user3.id}", user), access_level: UsersProject::MASTER
|
||||
put api("/projects/#{project.path}/members/#{user3.id}", user), access_level: UsersProject::MASTER
|
||||
response.status.should == 200
|
||||
json_response['email'].should == user3.email
|
||||
json_response['access_level'].should == UsersProject::MASTER
|
||||
|
@ -155,14 +154,14 @@ describe Gitlab::API do
|
|||
describe "DELETE /projects/:id/members/:user_id" do
|
||||
it "should remove user from project team" do
|
||||
expect {
|
||||
delete api("/projects/#{project.code}/members/#{user3.id}", user)
|
||||
delete api("/projects/#{project.path}/members/#{user3.id}", user)
|
||||
}.to change { UsersProject.count }.by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /projects/:id/hooks" do
|
||||
it "should return project hooks" do
|
||||
get api("/projects/#{project.code}/hooks", user)
|
||||
get api("/projects/#{project.path}/hooks", user)
|
||||
|
||||
response.status.should == 200
|
||||
|
||||
|
@ -174,7 +173,7 @@ describe Gitlab::API do
|
|||
|
||||
describe "GET /projects/:id/hooks/:hook_id" do
|
||||
it "should return a project hook" do
|
||||
get api("/projects/#{project.code}/hooks/#{hook.id}", user)
|
||||
get api("/projects/#{project.path}/hooks/#{hook.id}", user)
|
||||
response.status.should == 200
|
||||
json_response['url'].should == hook.url
|
||||
end
|
||||
|
@ -183,7 +182,7 @@ describe Gitlab::API do
|
|||
describe "POST /projects/:id/hooks" do
|
||||
it "should add hook to project" do
|
||||
expect {
|
||||
post api("/projects/#{project.code}/hooks", user),
|
||||
post api("/projects/#{project.path}/hooks", user),
|
||||
"url" => "http://example.com"
|
||||
}.to change {project.hooks.count}.by(1)
|
||||
end
|
||||
|
@ -191,7 +190,7 @@ describe Gitlab::API do
|
|||
|
||||
describe "PUT /projects/:id/hooks/:hook_id" do
|
||||
it "should update an existing project hook" do
|
||||
put api("/projects/#{project.code}/hooks/#{hook.id}", user),
|
||||
put api("/projects/#{project.path}/hooks/#{hook.id}", user),
|
||||
url: 'http://example.org'
|
||||
response.status.should == 200
|
||||
json_response['url'].should == 'http://example.org'
|
||||
|
@ -202,7 +201,7 @@ describe Gitlab::API do
|
|||
describe "DELETE /projects/:id/hooks" do
|
||||
it "should delete hook from project" do
|
||||
expect {
|
||||
delete api("/projects/#{project.code}/hooks", user),
|
||||
delete api("/projects/#{project.path}/hooks", user),
|
||||
hook_id: hook.id
|
||||
}.to change {project.hooks.count}.by(-1)
|
||||
end
|
||||
|
@ -210,7 +209,7 @@ describe Gitlab::API do
|
|||
|
||||
describe "GET /projects/:id/repository/tags" do
|
||||
it "should return an array of project tags" do
|
||||
get api("/projects/#{project.code}/repository/tags", user)
|
||||
get api("/projects/#{project.path}/repository/tags", user)
|
||||
response.status.should == 200
|
||||
json_response.should be_an Array
|
||||
json_response.first['name'].should == project.repo.tags.sort_by(&:name).reverse.first.name
|
||||
|
@ -222,7 +221,7 @@ describe Gitlab::API do
|
|||
before { project.add_access(user2, :read) }
|
||||
|
||||
it "should return project commits" do
|
||||
get api("/projects/#{project.code}/repository/commits", user)
|
||||
get api("/projects/#{project.path}/repository/commits", user)
|
||||
response.status.should == 200
|
||||
|
||||
json_response.should be_an Array
|
||||
|
@ -232,7 +231,7 @@ describe Gitlab::API do
|
|||
|
||||
context "unauthorized user" do
|
||||
it "should not return project commits" do
|
||||
get api("/projects/#{project.code}/repository/commits")
|
||||
get api("/projects/#{project.path}/repository/commits")
|
||||
response.status.should == 401
|
||||
end
|
||||
end
|
||||
|
@ -240,7 +239,7 @@ describe Gitlab::API do
|
|||
|
||||
describe "GET /projects/:id/snippets" do
|
||||
it "should return an array of project snippets" do
|
||||
get api("/projects/#{project.code}/snippets", user)
|
||||
get api("/projects/#{project.path}/snippets", user)
|
||||
response.status.should == 200
|
||||
json_response.should be_an Array
|
||||
json_response.first['title'].should == snippet.title
|
||||
|
@ -249,7 +248,7 @@ describe Gitlab::API do
|
|||
|
||||
describe "GET /projects/:id/snippets/:snippet_id" do
|
||||
it "should return a project snippet" do
|
||||
get api("/projects/#{project.code}/snippets/#{snippet.id}", user)
|
||||
get api("/projects/#{project.path}/snippets/#{snippet.id}", user)
|
||||
response.status.should == 200
|
||||
json_response['title'].should == snippet.title
|
||||
end
|
||||
|
@ -257,8 +256,8 @@ describe Gitlab::API do
|
|||
|
||||
describe "POST /projects/:id/snippets" do
|
||||
it "should create a new project snippet" do
|
||||
post api("/projects/#{project.code}/snippets", user),
|
||||
title: 'api test', file_name: 'sample.rb', code: 'test'
|
||||
post api("/projects/#{project.path}/snippets", user),
|
||||
title: 'api test', file_name: 'sample.rb', path: 'test'
|
||||
response.status.should == 201
|
||||
json_response['title'].should == 'api test'
|
||||
end
|
||||
|
@ -266,42 +265,42 @@ describe Gitlab::API do
|
|||
|
||||
describe "PUT /projects/:id/snippets/:shippet_id" do
|
||||
it "should update an existing project snippet" do
|
||||
put api("/projects/#{project.code}/snippets/#{snippet.id}", user),
|
||||
code: 'updated code'
|
||||
put api("/projects/#{project.path}/snippets/#{snippet.id}", user),
|
||||
path: 'updated path'
|
||||
response.status.should == 200
|
||||
json_response['title'].should == 'example'
|
||||
snippet.reload.content.should == 'updated code'
|
||||
snippet.reload.content.should == 'updated path'
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE /projects/:id/snippets/:snippet_id" do
|
||||
it "should delete existing project snippet" do
|
||||
expect {
|
||||
delete api("/projects/#{project.code}/snippets/#{snippet.id}", user)
|
||||
delete api("/projects/#{project.path}/snippets/#{snippet.id}", user)
|
||||
}.to change { Snippet.count }.by(-1)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /projects/:id/snippets/:snippet_id/raw" do
|
||||
it "should get a raw project snippet" do
|
||||
get api("/projects/#{project.code}/snippets/#{snippet.id}/raw", user)
|
||||
get api("/projects/#{project.path}/snippets/#{snippet.id}/raw", user)
|
||||
response.status.should == 200
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /projects/:id/:sha/blob" do
|
||||
it "should get the raw file contents" do
|
||||
get api("/projects/#{project.code}/repository/commits/master/blob?filepath=README.md", user)
|
||||
get api("/projects/#{project.path}/repository/commits/master/blob?filepath=README.md", user)
|
||||
response.status.should == 200
|
||||
end
|
||||
|
||||
it "should return 404 for invalid branch_name" do
|
||||
get api("/projects/#{project.code}/repository/commits/invalid_branch_name/blob?filepath=README.md", user)
|
||||
get api("/projects/#{project.path}/repository/commits/invalid_branch_name/blob?filepath=README.md", user)
|
||||
response.status.should == 404
|
||||
end
|
||||
|
||||
it "should return 404 for invalid file" do
|
||||
get api("/projects/#{project.code}/repository/commits/master/blob?filepath=README.invalid", user)
|
||||
get api("/projects/#{project.path}/repository/commits/master/blob?filepath=README.invalid", user)
|
||||
response.status.should == 404
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue