Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
9304d049
Commit
9304d049
authored
Nov 23, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed some tests and snippet colorize
parent
470aa767
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
64 additions
and
68 deletions
+64
-68
app/controllers/admin/groups_controller.rb
app/controllers/admin/groups_controller.rb
+1
-1
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+1
-1
app/models/project.rb
app/models/project.rb
+4
-2
app/views/snippets/show.html.haml
app/views/snippets/show.html.haml
+6
-2
features/steps/admin/admin_groups.rb
features/steps/admin/admin_groups.rb
+1
-1
features/steps/project/create_project.rb
features/steps/project/create_project.rb
+0
-2
lib/api/projects.rb
lib/api/projects.rb
+1
-2
spec/requests/admin/admin_projects_spec.rb
spec/requests/admin/admin_projects_spec.rb
+2
-11
spec/requests/api/issues_spec.rb
spec/requests/api/issues_spec.rb
+5
-5
spec/requests/api/merge_requests_spec.rb
spec/requests/api/merge_requests_spec.rb
+6
-6
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+31
-32
spec/requests/projects_spec.rb
spec/requests/projects_spec.rb
+0
-3
spec/support/stubbed_repository.rb
spec/support/stubbed_repository.rb
+6
-0
No files found.
app/controllers/admin/groups_controller.rb
View file @
9304d049
...
@@ -74,6 +74,6 @@ class Admin::GroupsController < AdminController
...
@@ -74,6 +74,6 @@ class Admin::GroupsController < AdminController
private
private
def
group
def
group
@group
=
Group
.
find_by_
code
(
params
[
:id
])
@group
=
Group
.
find_by_
path
(
params
[
:id
])
end
end
end
end
app/controllers/groups_controller.rb
View file @
9304d049
...
@@ -50,7 +50,7 @@ class GroupsController < ApplicationController
...
@@ -50,7 +50,7 @@ class GroupsController < ApplicationController
protected
protected
def
group
def
group
@group
||=
Group
.
find_by_
code
(
params
[
:id
])
@group
||=
Group
.
find_by_
path
(
params
[
:id
])
end
end
def
projects
def
projects
...
...
app/models/project.rb
View file @
9304d049
...
@@ -86,7 +86,7 @@ class Project < ActiveRecord::Base
...
@@ -86,7 +86,7 @@ class Project < ActiveRecord::Base
def
create_by_user
(
params
,
user
)
def
create_by_user
(
params
,
user
)
namespace_id
=
params
.
delete
(
:namespace_id
)
namespace_id
=
params
.
delete
(
:namespace_id
)
namespace_id
||=
user
.
namespace
_id
namespace_id
||=
user
.
namespace
.
try
(
:id
)
project
=
Project
.
new
params
project
=
Project
.
new
params
...
@@ -222,6 +222,8 @@ class Project < ActiveRecord::Base
...
@@ -222,6 +222,8 @@ class Project < ActiveRecord::Base
end
end
end
end
def
move_repo
# For compatibility with old code
def
code
path
end
end
end
end
app/views/snippets/show.html.haml
View file @
9304d049
...
@@ -15,8 +15,12 @@
...
@@ -15,8 +15,12 @@
%span
.options
%span
.options
=
link_to
"raw"
,
raw_project_snippet_path
(
@project
,
@snippet
),
class:
"btn very_small"
,
target:
"_blank"
=
link_to
"raw"
,
raw_project_snippet_path
(
@project
,
@snippet
),
class:
"btn very_small"
,
target:
"_blank"
.file_content.code
.file_content.code
%div
{
class:
current_user
.
dark_scheme
?
"black"
:
""
}
-
unless
@snippet
.
content
.
empty?
=
raw
@snippet
.
colorize
(
options:
{
linenos:
'True'
})
%div
{
class:
current_user
.
dark_scheme
?
"black"
:
"white"
}
=
preserve
do
=
raw
Pygments
.
highlight
(
@snippet
.
content
,
formatter: :gitlab
)
-
else
%h4
.nothing_here_message
Empty file
%div
%div
...
...
features/steps/admin/admin_groups.rb
View file @
9304d049
...
@@ -9,7 +9,7 @@ class AdminGroups < Spinach::FeatureSteps
...
@@ -9,7 +9,7 @@ class AdminGroups < Spinach::FeatureSteps
And
'submit form with new group info'
do
And
'submit form with new group info'
do
fill_in
'group_name'
,
:with
=>
'gitlab'
fill_in
'group_name'
,
:with
=>
'gitlab'
fill_in
'group_
code
'
,
:with
=>
'gitlab'
fill_in
'group_
path
'
,
:with
=>
'gitlab'
click_button
"Save group"
click_button
"Save group"
end
end
...
...
features/steps/project/create_project.rb
View file @
9304d049
...
@@ -4,8 +4,6 @@ class CreateProject < Spinach::FeatureSteps
...
@@ -4,8 +4,6 @@ class CreateProject < Spinach::FeatureSteps
And
'fill project form with valid data'
do
And
'fill project form with valid data'
do
fill_in
'project_name'
,
:with
=>
'NewProject'
fill_in
'project_name'
,
:with
=>
'NewProject'
fill_in
'project_code'
,
:with
=>
'NPR'
fill_in
'project_path'
,
:with
=>
'newproject'
click_button
"Create project"
click_button
"Create project"
end
end
...
...
lib/api/projects.rb
View file @
9304d049
...
@@ -40,8 +40,7 @@ module Gitlab
...
@@ -40,8 +40,7 @@ module Gitlab
post
do
post
do
params
[
:code
]
||=
params
[
:name
]
params
[
:code
]
||=
params
[
:name
]
params
[
:path
]
||=
params
[
:name
]
params
[
:path
]
||=
params
[
:name
]
attrs
=
attributes_for_keys
[
:code
,
attrs
=
attributes_for_keys
[
:path
,
:path
,
:name
,
:name
,
:description
,
:description
,
:default_branch
,
:default_branch
,
...
...
spec/requests/admin/admin_projects_spec.rb
View file @
9304d049
...
@@ -2,9 +2,7 @@ require 'spec_helper'
...
@@ -2,9 +2,7 @@ require 'spec_helper'
describe
"Admin::Projects"
do
describe
"Admin::Projects"
do
before
do
before
do
@project
=
create
(
:project
,
@project
=
create
(
:project
)
name:
"LeGiT"
,
code:
"LGT"
)
login_as
:admin
login_as
:admin
end
end
...
@@ -29,7 +27,7 @@ describe "Admin::Projects" do
...
@@ -29,7 +27,7 @@ describe "Admin::Projects" do
end
end
it
"should have project info"
do
it
"should have project info"
do
page
.
should
have_content
(
@project
.
code
)
page
.
should
have_content
(
@project
.
path
)
page
.
should
have_content
(
@project
.
name
)
page
.
should
have_content
(
@project
.
name
)
end
end
end
end
...
@@ -48,19 +46,16 @@ describe "Admin::Projects" do
...
@@ -48,19 +46,16 @@ describe "Admin::Projects" do
describe
"Update project"
do
describe
"Update project"
do
before
do
before
do
fill_in
"project_name"
,
with:
"Big Bang"
fill_in
"project_name"
,
with:
"Big Bang"
fill_in
"project_code"
,
with:
"BB1"
click_button
"Save Project"
click_button
"Save Project"
@project
.
reload
@project
.
reload
end
end
it
"should show page with new data"
do
it
"should show page with new data"
do
page
.
should
have_content
(
"BB1"
)
page
.
should
have_content
(
"Big Bang"
)
page
.
should
have_content
(
"Big Bang"
)
end
end
it
"should change project entry"
do
it
"should change project entry"
do
@project
.
name
.
should
==
"Big Bang"
@project
.
name
.
should
==
"Big Bang"
@project
.
code
.
should
==
"BB1"
end
end
end
end
end
end
...
@@ -77,8 +72,6 @@ describe "Admin::Projects" do
...
@@ -77,8 +72,6 @@ describe "Admin::Projects" do
it
"should have labels for new project"
do
it
"should have labels for new project"
do
page
.
should
have_content
(
"Project name is"
)
page
.
should
have_content
(
"Project name is"
)
page
.
should
have_content
(
"Git Clone"
)
page
.
should
have_content
(
"URL"
)
end
end
end
end
...
@@ -86,8 +79,6 @@ describe "Admin::Projects" do
...
@@ -86,8 +79,6 @@ describe "Admin::Projects" do
before
do
before
do
visit
new_admin_project_path
visit
new_admin_project_path
fill_in
'project_name'
,
with:
'NewProject'
fill_in
'project_name'
,
with:
'NewProject'
fill_in
'project_code'
,
with:
'NPR'
fill_in
'project_path'
,
with:
'gitlabhq_1'
expect
{
click_button
"Create project"
}.
to
change
{
Project
.
count
}.
by
(
1
)
expect
{
click_button
"Create project"
}.
to
change
{
Project
.
count
}.
by
(
1
)
@project
=
Project
.
last
@project
=
Project
.
last
end
end
...
...
spec/requests/api/issues_spec.rb
View file @
9304d049
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/issues"
do
describe
"GET /projects/:id/issues"
do
it
"should return project issues"
do
it
"should return project issues"
do
get
api
(
"/projects/
#{
project
.
code
}
/issues"
,
user
)
get
api
(
"/projects/
#{
project
.
path
}
/issues"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
json_response
.
first
[
'title'
].
should
==
issue
.
title
json_response
.
first
[
'title'
].
should
==
issue
.
title
...
@@ -37,7 +37,7 @@ describe Gitlab::API do
...
@@ -37,7 +37,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/issues/:issue_id"
do
describe
"GET /projects/:id/issues/:issue_id"
do
it
"should return a project issue by id"
do
it
"should return a project issue by id"
do
get
api
(
"/projects/
#{
project
.
code
}
/issues/
#{
issue
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
path
}
/issues/
#{
issue
.
id
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
issue
.
title
json_response
[
'title'
].
should
==
issue
.
title
end
end
...
@@ -45,7 +45,7 @@ describe Gitlab::API do
...
@@ -45,7 +45,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/issues"
do
describe
"POST /projects/:id/issues"
do
it
"should create a new project issue"
do
it
"should create a new project issue"
do
post
api
(
"/projects/
#{
project
.
code
}
/issues"
,
user
),
post
api
(
"/projects/
#{
project
.
path
}
/issues"
,
user
),
title:
'new issue'
,
labels:
'label, label2'
title:
'new issue'
,
labels:
'label, label2'
response
.
status
.
should
==
201
response
.
status
.
should
==
201
json_response
[
'title'
].
should
==
'new issue'
json_response
[
'title'
].
should
==
'new issue'
...
@@ -56,7 +56,7 @@ describe Gitlab::API do
...
@@ -56,7 +56,7 @@ describe Gitlab::API do
describe
"PUT /projects/:id/issues/:issue_id"
do
describe
"PUT /projects/:id/issues/:issue_id"
do
it
"should update a project issue"
do
it
"should update a project issue"
do
put
api
(
"/projects/
#{
project
.
code
}
/issues/
#{
issue
.
id
}
"
,
user
),
put
api
(
"/projects/
#{
project
.
path
}
/issues/
#{
issue
.
id
}
"
,
user
),
title:
'updated title'
,
labels:
'label2'
,
closed:
1
title:
'updated title'
,
labels:
'label2'
,
closed:
1
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
'updated title'
json_response
[
'title'
].
should
==
'updated title'
...
@@ -67,7 +67,7 @@ describe Gitlab::API do
...
@@ -67,7 +67,7 @@ describe Gitlab::API do
describe
"DELETE /projects/:id/issues/:issue_id"
do
describe
"DELETE /projects/:id/issues/:issue_id"
do
it
"should delete a project issue"
do
it
"should delete a project issue"
do
delete
api
(
"/projects/
#{
project
.
code
}
/issues/
#{
issue
.
id
}
"
,
user
)
delete
api
(
"/projects/
#{
project
.
path
}
/issues/
#{
issue
.
id
}
"
,
user
)
response
.
status
.
should
==
405
response
.
status
.
should
==
405
end
end
end
end
...
...
spec/requests/api/merge_requests_spec.rb
View file @
9304d049
...
@@ -11,14 +11,14 @@ describe Gitlab::API do
...
@@ -11,14 +11,14 @@ describe Gitlab::API do
describe
"GET /projects/:id/merge_requests"
do
describe
"GET /projects/:id/merge_requests"
do
context
"when unauthenticated"
do
context
"when unauthenticated"
do
it
"should return authentication error"
do
it
"should return authentication error"
do
get
api
(
"/projects/
#{
project
.
code
}
/merge_requests"
)
get
api
(
"/projects/
#{
project
.
path
}
/merge_requests"
)
response
.
status
.
should
==
401
response
.
status
.
should
==
401
end
end
end
end
context
"when authenticated"
do
context
"when authenticated"
do
it
"should return an array of merge_requests"
do
it
"should return an array of merge_requests"
do
get
api
(
"/projects/
#{
project
.
code
}
/merge_requests"
,
user
)
get
api
(
"/projects/
#{
project
.
path
}
/merge_requests"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
json_response
.
first
[
'title'
].
should
==
merge_request
.
title
json_response
.
first
[
'title'
].
should
==
merge_request
.
title
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/merge_request/:merge_request_id"
do
describe
"GET /projects/:id/merge_request/:merge_request_id"
do
it
"should return merge_request"
do
it
"should return merge_request"
do
get
api
(
"/projects/
#{
project
.
code
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
path
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
merge_request
.
title
json_response
[
'title'
].
should
==
merge_request
.
title
end
end
...
@@ -36,7 +36,7 @@ describe Gitlab::API do
...
@@ -36,7 +36,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/merge_requests"
do
describe
"POST /projects/:id/merge_requests"
do
it
"should return merge_request"
do
it
"should return merge_request"
do
post
api
(
"/projects/
#{
project
.
code
}
/merge_requests"
,
user
),
post
api
(
"/projects/
#{
project
.
path
}
/merge_requests"
,
user
),
title:
'Test merge_request'
,
source_branch:
"stable"
,
target_branch:
"master"
,
author:
user
title:
'Test merge_request'
,
source_branch:
"stable"
,
target_branch:
"master"
,
author:
user
response
.
status
.
should
==
201
response
.
status
.
should
==
201
json_response
[
'title'
].
should
==
'Test merge_request'
json_response
[
'title'
].
should
==
'Test merge_request'
...
@@ -45,7 +45,7 @@ describe Gitlab::API do
...
@@ -45,7 +45,7 @@ describe Gitlab::API do
describe
"PUT /projects/:id/merge_request/:merge_request_id"
do
describe
"PUT /projects/:id/merge_request/:merge_request_id"
do
it
"should return merge_request"
do
it
"should return merge_request"
do
put
api
(
"/projects/
#{
project
.
code
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
),
title:
"New title"
put
api
(
"/projects/
#{
project
.
path
}
/merge_request/
#{
merge_request
.
id
}
"
,
user
),
title:
"New title"
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
'New title'
json_response
[
'title'
].
should
==
'New title'
end
end
...
@@ -53,7 +53,7 @@ describe Gitlab::API do
...
@@ -53,7 +53,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/merge_request/:merge_request_id/comments"
do
describe
"POST /projects/:id/merge_request/:merge_request_id/comments"
do
it
"should return comment"
do
it
"should return comment"
do
post
api
(
"/projects/
#{
project
.
code
}
/merge_request/
#{
merge_request
.
id
}
/comments"
,
user
),
note:
"My comment"
post
api
(
"/projects/
#{
project
.
path
}
/merge_request/
#{
merge_request
.
id
}
/comments"
,
user
),
note:
"My comment"
response
.
status
.
should
==
201
response
.
status
.
should
==
201
json_response
[
'note'
].
should
==
'My comment'
json_response
[
'note'
].
should
==
'My comment'
end
end
...
...
spec/requests/api/projects_spec.rb
View file @
9304d049
...
@@ -33,7 +33,7 @@ describe Gitlab::API do
...
@@ -33,7 +33,7 @@ describe Gitlab::API do
end
end
describe
"POST /projects"
do
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
)
expect
{
post
api
(
"/projects"
,
user
),
name:
'foo'
}.
to
change
{
Project
.
count
}.
by
(
1
)
end
end
...
@@ -53,8 +53,7 @@ describe Gitlab::API do
...
@@ -53,8 +53,7 @@ describe Gitlab::API do
it
"should assign attributes to project"
do
it
"should assign attributes to project"
do
project
=
attributes_for
(
:project
,
{
project
=
attributes_for
(
:project
,
{
path:
'path'
,
path:
project
.
name
.
parameterize
,
code:
'code'
,
description:
Faker
::
Lorem
.
sentence
,
description:
Faker
::
Lorem
.
sentence
,
default_branch:
'stable'
,
default_branch:
'stable'
,
issues_enabled:
false
,
issues_enabled:
false
,
...
@@ -79,8 +78,8 @@ describe Gitlab::API do
...
@@ -79,8 +78,8 @@ describe Gitlab::API do
json_response
[
'owner'
][
'email'
].
should
==
user
.
email
json_response
[
'owner'
][
'email'
].
should
==
user
.
email
end
end
it
"should return a project by
code
name"
do
it
"should return a project by
path
name"
do
get
api
(
"/projects/
#{
project
.
code
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
path
}
"
,
user
)
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'name'
].
should
==
project
.
name
json_response
[
'name'
].
should
==
project
.
name
end
end
...
@@ -94,7 +93,7 @@ describe Gitlab::API do
...
@@ -94,7 +93,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/repository/branches"
do
describe
"GET /projects/:id/repository/branches"
do
it
"should return an array of project 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
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
json_response
.
first
[
'name'
].
should
==
project
.
repo
.
heads
.
sort_by
(
&
:name
).
first
.
name
json_response
.
first
[
'name'
].
should
==
project
.
repo
.
heads
.
sort_by
(
&
:name
).
first
.
name
...
@@ -103,7 +102,7 @@ describe Gitlab::API do
...
@@ -103,7 +102,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/repository/branches/:branch"
do
describe
"GET /projects/:id/repository/branches/:branch"
do
it
"should return the branch information for a single 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
response
.
status
.
should
==
200
json_response
[
'name'
].
should
==
'new_design'
json_response
[
'name'
].
should
==
'new_design'
...
@@ -113,7 +112,7 @@ describe Gitlab::API do
...
@@ -113,7 +112,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/members"
do
describe
"GET /projects/:id/members"
do
it
"should return project team 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
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
json_response
.
count
.
should
==
2
json_response
.
count
.
should
==
2
...
@@ -123,7 +122,7 @@ describe Gitlab::API do
...
@@ -123,7 +122,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/members/:user_id"
do
describe
"GET /projects/:id/members/:user_id"
do
it
"should return project team member"
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
response
.
status
.
should
==
200
json_response
[
'email'
].
should
==
user
.
email
json_response
[
'email'
].
should
==
user
.
email
json_response
[
'access_level'
].
should
==
UsersProject
::
MASTER
json_response
[
'access_level'
].
should
==
UsersProject
::
MASTER
...
@@ -133,7 +132,7 @@ describe Gitlab::API do
...
@@ -133,7 +132,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/members"
do
describe
"POST /projects/:id/members"
do
it
"should add user to project team"
do
it
"should add user to project team"
do
expect
{
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
access_level:
UsersProject
::
DEVELOPER
}.
to
change
{
UsersProject
.
count
}.
by
(
1
)
}.
to
change
{
UsersProject
.
count
}.
by
(
1
)
...
@@ -145,7 +144,7 @@ describe Gitlab::API do
...
@@ -145,7 +144,7 @@ describe Gitlab::API do
describe
"PUT /projects/:id/members/:user_id"
do
describe
"PUT /projects/:id/members/:user_id"
do
it
"should update project team member"
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
response
.
status
.
should
==
200
json_response
[
'email'
].
should
==
user3
.
email
json_response
[
'email'
].
should
==
user3
.
email
json_response
[
'access_level'
].
should
==
UsersProject
::
MASTER
json_response
[
'access_level'
].
should
==
UsersProject
::
MASTER
...
@@ -155,14 +154,14 @@ describe Gitlab::API do
...
@@ -155,14 +154,14 @@ describe Gitlab::API do
describe
"DELETE /projects/:id/members/:user_id"
do
describe
"DELETE /projects/:id/members/:user_id"
do
it
"should remove user from project team"
do
it
"should remove user from project team"
do
expect
{
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
)
}.
to
change
{
UsersProject
.
count
}.
by
(
-
1
)
end
end
end
end
describe
"GET /projects/:id/hooks"
do
describe
"GET /projects/:id/hooks"
do
it
"should return project 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
response
.
status
.
should
==
200
...
@@ -174,7 +173,7 @@ describe Gitlab::API do
...
@@ -174,7 +173,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/hooks/:hook_id"
do
describe
"GET /projects/:id/hooks/:hook_id"
do
it
"should return a project hook"
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
response
.
status
.
should
==
200
json_response
[
'url'
].
should
==
hook
.
url
json_response
[
'url'
].
should
==
hook
.
url
end
end
...
@@ -183,7 +182,7 @@ describe Gitlab::API do
...
@@ -183,7 +182,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/hooks"
do
describe
"POST /projects/:id/hooks"
do
it
"should add hook to project"
do
it
"should add hook to project"
do
expect
{
expect
{
post
api
(
"/projects/
#{
project
.
code
}
/hooks"
,
user
),
post
api
(
"/projects/
#{
project
.
path
}
/hooks"
,
user
),
"url"
=>
"http://example.com"
"url"
=>
"http://example.com"
}.
to
change
{
project
.
hooks
.
count
}.
by
(
1
)
}.
to
change
{
project
.
hooks
.
count
}.
by
(
1
)
end
end
...
@@ -191,7 +190,7 @@ describe Gitlab::API do
...
@@ -191,7 +190,7 @@ describe Gitlab::API do
describe
"PUT /projects/:id/hooks/:hook_id"
do
describe
"PUT /projects/:id/hooks/:hook_id"
do
it
"should update an existing project hook"
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'
url:
'http://example.org'
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'url'
].
should
==
'http://example.org'
json_response
[
'url'
].
should
==
'http://example.org'
...
@@ -202,7 +201,7 @@ describe Gitlab::API do
...
@@ -202,7 +201,7 @@ describe Gitlab::API do
describe
"DELETE /projects/:id/hooks"
do
describe
"DELETE /projects/:id/hooks"
do
it
"should delete hook from project"
do
it
"should delete hook from project"
do
expect
{
expect
{
delete
api
(
"/projects/
#{
project
.
code
}
/hooks"
,
user
),
delete
api
(
"/projects/
#{
project
.
path
}
/hooks"
,
user
),
hook_id:
hook
.
id
hook_id:
hook
.
id
}.
to
change
{
project
.
hooks
.
count
}.
by
(
-
1
)
}.
to
change
{
project
.
hooks
.
count
}.
by
(
-
1
)
end
end
...
@@ -210,7 +209,7 @@ describe Gitlab::API do
...
@@ -210,7 +209,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/repository/tags"
do
describe
"GET /projects/:id/repository/tags"
do
it
"should return an array of project 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
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
json_response
.
first
[
'name'
].
should
==
project
.
repo
.
tags
.
sort_by
(
&
:name
).
reverse
.
first
.
name
json_response
.
first
[
'name'
].
should
==
project
.
repo
.
tags
.
sort_by
(
&
:name
).
reverse
.
first
.
name
...
@@ -222,7 +221,7 @@ describe Gitlab::API do
...
@@ -222,7 +221,7 @@ describe Gitlab::API do
before
{
project
.
add_access
(
user2
,
:read
)
}
before
{
project
.
add_access
(
user2
,
:read
)
}
it
"should return project commits"
do
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
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
...
@@ -232,7 +231,7 @@ describe Gitlab::API do
...
@@ -232,7 +231,7 @@ describe Gitlab::API do
context
"unauthorized user"
do
context
"unauthorized user"
do
it
"should not return project commits"
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
response
.
status
.
should
==
401
end
end
end
end
...
@@ -240,7 +239,7 @@ describe Gitlab::API do
...
@@ -240,7 +239,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/snippets"
do
describe
"GET /projects/:id/snippets"
do
it
"should return an array of project 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
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
should
be_an
Array
json_response
.
first
[
'title'
].
should
==
snippet
.
title
json_response
.
first
[
'title'
].
should
==
snippet
.
title
...
@@ -249,7 +248,7 @@ describe Gitlab::API do
...
@@ -249,7 +248,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/snippets/:snippet_id"
do
describe
"GET /projects/:id/snippets/:snippet_id"
do
it
"should return a project snippet"
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
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
snippet
.
title
json_response
[
'title'
].
should
==
snippet
.
title
end
end
...
@@ -257,8 +256,8 @@ describe Gitlab::API do
...
@@ -257,8 +256,8 @@ describe Gitlab::API do
describe
"POST /projects/:id/snippets"
do
describe
"POST /projects/:id/snippets"
do
it
"should create a new project snippet"
do
it
"should create a new project snippet"
do
post
api
(
"/projects/
#{
project
.
code
}
/snippets"
,
user
),
post
api
(
"/projects/
#{
project
.
path
}
/snippets"
,
user
),
title:
'api test'
,
file_name:
'sample.rb'
,
code
:
'test'
title:
'api test'
,
file_name:
'sample.rb'
,
path
:
'test'
response
.
status
.
should
==
201
response
.
status
.
should
==
201
json_response
[
'title'
].
should
==
'api test'
json_response
[
'title'
].
should
==
'api test'
end
end
...
@@ -266,42 +265,42 @@ describe Gitlab::API do
...
@@ -266,42 +265,42 @@ describe Gitlab::API do
describe
"PUT /projects/:id/snippets/:shippet_id"
do
describe
"PUT /projects/:id/snippets/:shippet_id"
do
it
"should update an existing project snippet"
do
it
"should update an existing project snippet"
do
put
api
(
"/projects/
#{
project
.
code
}
/snippets/
#{
snippet
.
id
}
"
,
user
),
put
api
(
"/projects/
#{
project
.
path
}
/snippets/
#{
snippet
.
id
}
"
,
user
),
code:
'updated code
'
path:
'updated path
'
response
.
status
.
should
==
200
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
'example'
json_response
[
'title'
].
should
==
'example'
snippet
.
reload
.
content
.
should
==
'updated
code
'
snippet
.
reload
.
content
.
should
==
'updated
path
'
end
end
end
end
describe
"DELETE /projects/:id/snippets/:snippet_id"
do
describe
"DELETE /projects/:id/snippets/:snippet_id"
do
it
"should delete existing project snippet"
do
it
"should delete existing project snippet"
do
expect
{
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
)
}.
to
change
{
Snippet
.
count
}.
by
(
-
1
)
end
end
end
end
describe
"GET /projects/:id/snippets/:snippet_id/raw"
do
describe
"GET /projects/:id/snippets/:snippet_id/raw"
do
it
"should get a raw project snippet"
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
response
.
status
.
should
==
200
end
end
end
end
describe
"GET /projects/:id/:sha/blob"
do
describe
"GET /projects/:id/:sha/blob"
do
it
"should get the raw file contents"
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
response
.
status
.
should
==
200
end
end
it
"should return 404 for invalid branch_name"
do
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
response
.
status
.
should
==
404
end
end
it
"should return 404 for invalid file"
do
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
response
.
status
.
should
==
404
end
end
end
end
...
...
spec/requests/projects_spec.rb
View file @
9304d049
...
@@ -8,8 +8,6 @@ describe "Projects" do
...
@@ -8,8 +8,6 @@ describe "Projects" do
visit
new_project_path
visit
new_project_path
fill_in
'project_name'
,
with:
'Awesome'
fill_in
'project_name'
,
with:
'Awesome'
find
(
"#project_path"
).
value
.
should
==
'awesome'
find
(
"#project_code"
).
value
.
should
==
'awesome'
end
end
end
end
...
@@ -53,7 +51,6 @@ describe "Projects" do
...
@@ -53,7 +51,6 @@ describe "Projects" do
visit
edit_project_path
(
@project
)
visit
edit_project_path
(
@project
)
fill_in
'project_name'
,
with:
'Awesome'
fill_in
'project_name'
,
with:
'Awesome'
fill_in
'project_code'
,
with:
'gitlabhq'
click_button
"Save"
click_button
"Save"
@project
=
@project
.
reload
@project
=
@project
.
reload
end
end
...
...
spec/support/stubbed_repository.rb
View file @
9304d049
...
@@ -28,4 +28,10 @@ module StubbedRepository
...
@@ -28,4 +28,10 @@ module StubbedRepository
end
end
end
end
class
Namespace
def
ensure_dir_exist
true
end
end
Project
.
send
(
:include
,
StubbedRepository
)
Project
.
send
(
:include
,
StubbedRepository
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment