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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
0e1635a6
Commit
0e1635a6
authored
Nov 23, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing requests after namespaces. Fixed admin bug with access to project
parent
e92b563a
Changes
14
Show whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
35 additions
and
62 deletions
+35
-62
app/controllers/admin/projects_controller.rb
app/controllers/admin/projects_controller.rb
+10
-0
app/helpers/application_helper.rb
app/helpers/application_helper.rb
+1
-1
app/observers/user_observer.rb
app/observers/user_observer.rb
+2
-2
lib/api/projects.rb
lib/api/projects.rb
+1
-4
spec/controllers/commits_controller_spec.rb
spec/controllers/commits_controller_spec.rb
+1
-1
spec/factories.rb
spec/factories.rb
+1
-1
spec/mailers/notify_spec.rb
spec/mailers/notify_spec.rb
+1
-3
spec/observers/user_observer_spec.rb
spec/observers/user_observer_spec.rb
+6
-1
spec/observers/users_project_observer_spec.rb
spec/observers/users_project_observer_spec.rb
+1
-3
spec/requests/admin/admin_hooks_spec.rb
spec/requests/admin/admin_hooks_spec.rb
+1
-3
spec/requests/admin/admin_projects_spec.rb
spec/requests/admin/admin_projects_spec.rb
+2
-35
spec/requests/admin/admin_users_spec.rb
spec/requests/admin/admin_users_spec.rb
+1
-0
spec/requests/api/milestones_spec.rb
spec/requests/api/milestones_spec.rb
+4
-4
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+3
-4
No files found.
app/controllers/admin/projects_controller.rb
View file @
0e1635a6
...
...
@@ -42,4 +42,14 @@ class Admin::ProjectsController < AdminController
redirect_to
projects_url
,
notice:
'Project was successfully deleted.'
end
protected
def
project
id
=
params
[
:project_id
]
||
params
[
:id
]
id
=
id
.
split
(
"/"
)
if
id
.
include?
(
"/"
)
@project
||=
Project
.
find_by_path
(
id
)
@project
||
render_404
end
end
app/helpers/application_helper.rb
View file @
0e1635a6
...
...
@@ -88,7 +88,7 @@ module ApplicationHelper
[
"Users"
,
users
.
map
{
|
u
|
[
u
.
human_name
,
u
.
id
]}
]
]
if
selected
==
:current_user
if
selected
==
:current_user
&&
current_user
.
namespace
selected
=
current_user
.
namespace
.
id
end
...
...
app/observers/user_observer.rb
View file @
0e1635a6
class
UserObserver
<
ActiveRecord
::
Observer
def
after_create
(
user
)
user
.
create_namespace
(
code
:
user
.
username
,
name:
user
.
name
)
user
.
create_namespace
(
path
:
user
.
username
,
name:
user
.
name
)
log_info
(
"User
\"
#{
user
.
name
}
\"
(
#{
user
.
email
}
) was created"
)
...
...
@@ -13,7 +13,7 @@ class UserObserver < ActiveRecord::Observer
def
after_save
user
if
user
.
username_changed?
and
user
.
namespace
user
.
namespace
.
update_attributes
(
code
:
user
.
username
)
user
.
namespace
.
update_attributes
(
path
:
user
.
username
)
end
end
...
...
lib/api/projects.rb
View file @
0e1635a6
...
...
@@ -38,10 +38,7 @@ module Gitlab
# Example Request
# POST /projects
post
do
params
[
:code
]
||=
params
[
:name
]
params
[
:path
]
||=
params
[
:name
]
attrs
=
attributes_for_keys
[
:path
,
:name
,
attrs
=
attributes_for_keys
[
:name
,
:description
,
:default_branch
,
:issues_enabled
,
...
...
spec/controllers/commits_controller_spec.rb
View file @
0e1635a6
...
...
@@ -13,7 +13,7 @@ describe CommitsController do
describe
"GET show"
do
context
"as atom feed"
do
it
"should render as atom"
do
get
:show
,
project_id:
project
.
code
,
id:
"master.atom"
get
:show
,
project_id:
project
.
path
,
id:
"master.atom"
response
.
should
be_success
response
.
content_type
.
should
==
'application/atom+xml'
end
...
...
spec/factories.rb
View file @
0e1635a6
...
...
@@ -12,7 +12,7 @@ FactoryGirl.define do
factory
:user
,
aliases:
[
:author
,
:assignee
,
:owner
]
do
email
{
Faker
::
Internet
.
email
}
name
username
'john'
username
{
Faker
::
Internet
.
user_name
}
password
"123456"
password_confirmation
{
password
}
...
...
spec/mailers/notify_spec.rb
View file @
0e1635a6
...
...
@@ -169,9 +169,7 @@ describe Notify do
end
describe
'project access changed'
do
let
(
:project
)
{
create
(
:project
,
path:
"Fuu"
,
code:
"Fuu"
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:users_project
)
{
create
(
:users_project
,
project:
project
,
...
...
spec/observers/user_observer_spec.rb
View file @
0e1635a6
...
...
@@ -13,7 +13,12 @@ describe UserObserver do
end
context
'when a new user is created'
do
let
(
:user
)
{
double
(
:user
,
id:
42
,
password:
'P@ssword!'
,
name:
'John'
,
email:
'u@mail.local'
,
username:
'root'
)
}
let
(
:user
)
{
double
(
:user
,
id:
42
,
password:
'P@ssword!'
,
name:
'John'
,
email:
'u@mail.local'
,
username:
'root'
,
create_namespace:
true
)
}
let
(
:notification
)
{
double
:notification
}
it
'sends an email'
do
...
...
spec/observers/users_project_observer_spec.rb
View file @
0e1635a6
...
...
@@ -2,9 +2,7 @@ require 'spec_helper'
describe
UsersProjectObserver
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
code:
"Fuu"
,
path:
"Fuu"
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:users_project
)
{
create
(
:users_project
,
project:
project
,
user:
user
)}
...
...
spec/requests/admin/admin_hooks_spec.rb
View file @
0e1635a6
...
...
@@ -2,9 +2,7 @@ require 'spec_helper'
describe
"Admin::Hooks"
do
before
do
@project
=
create
(
:project
,
name:
"LeGiT"
,
code:
"LGT"
)
@project
=
create
(
:project
)
login_as
:admin
@system_hook
=
create
(
:system_hook
)
...
...
spec/requests/admin/admin_projects_spec.rb
View file @
0e1635a6
...
...
@@ -39,8 +39,8 @@ describe "Admin::Projects" do
end
it
"should have project edit page"
do
page
.
should
have_content
(
"
Project name
"
)
page
.
should
have_
content
(
"URL
"
)
page
.
should
have_content
(
"
Edit project
"
)
page
.
should
have_
button
(
"Save Project
"
)
end
describe
"Update project"
do
...
...
@@ -60,39 +60,6 @@ describe "Admin::Projects" do
end
end
describe
"GET /admin/projects/new"
do
before
do
visit
admin_projects_path
click_link
"New Project"
end
it
"should be correct path"
do
current_path
.
should
==
new_admin_project_path
end
it
"should have labels for new project"
do
page
.
should
have_content
(
"Project name is"
)
end
end
describe
"POST /admin/projects"
do
before
do
visit
new_admin_project_path
fill_in
'project_name'
,
with:
'NewProject'
expect
{
click_button
"Create project"
}.
to
change
{
Project
.
count
}.
by
(
1
)
@project
=
Project
.
last
end
it
"should be correct path"
do
current_path
.
should
==
admin_project_path
(
@project
)
end
it
"should show project"
do
page
.
should
have_content
(
@project
.
name
)
page
.
should
have_content
(
@project
.
path
)
end
end
describe
"Add new team member"
do
before
do
@new_user
=
create
(
:user
)
...
...
spec/requests/admin/admin_users_spec.rb
View file @
0e1635a6
...
...
@@ -23,6 +23,7 @@ describe "Admin::Users" do
@password
=
"123ABC"
visit
new_admin_user_path
fill_in
"user_name"
,
with:
"Big Bang"
fill_in
"user_username"
,
with:
"bang"
fill_in
"user_email"
,
with:
"bigbang@mail.com"
fill_in
"user_password"
,
with:
@password
fill_in
"user_password_confirmation"
,
with:
@password
...
...
spec/requests/api/milestones_spec.rb
View file @
0e1635a6
...
...
@@ -11,7 +11,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/milestones"
do
it
"should return project milestones"
do
get
api
(
"/projects/
#{
project
.
code
}
/milestones"
,
user
)
get
api
(
"/projects/
#{
project
.
path
}
/milestones"
,
user
)
response
.
status
.
should
==
200
json_response
.
should
be_an
Array
json_response
.
first
[
'title'
].
should
==
milestone
.
title
...
...
@@ -20,7 +20,7 @@ describe Gitlab::API do
describe
"GET /projects/:id/milestones/:milestone_id"
do
it
"should return a project milestone by id"
do
get
api
(
"/projects/
#{
project
.
code
}
/milestones/
#{
milestone
.
id
}
"
,
user
)
get
api
(
"/projects/
#{
project
.
path
}
/milestones/
#{
milestone
.
id
}
"
,
user
)
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
milestone
.
title
end
...
...
@@ -28,7 +28,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/milestones"
do
it
"should create a new project milestone"
do
post
api
(
"/projects/
#{
project
.
code
}
/milestones"
,
user
),
post
api
(
"/projects/
#{
project
.
path
}
/milestones"
,
user
),
title:
'new milestone'
response
.
status
.
should
==
201
json_response
[
'title'
].
should
==
'new milestone'
...
...
@@ -38,7 +38,7 @@ describe Gitlab::API do
describe
"PUT /projects/:id/milestones/:milestone_id"
do
it
"should update a project milestone"
do
put
api
(
"/projects/
#{
project
.
code
}
/milestones/
#{
milestone
.
id
}
"
,
user
),
put
api
(
"/projects/
#{
project
.
path
}
/milestones/
#{
milestone
.
id
}
"
,
user
),
title:
'updated title'
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
'updated title'
...
...
spec/requests/api/projects_spec.rb
View file @
0e1635a6
...
...
@@ -53,7 +53,6 @@ describe Gitlab::API do
it
"should assign attributes to project"
do
project
=
attributes_for
(
:project
,
{
path:
project
.
name
.
parameterize
,
description:
Faker
::
Lorem
.
sentence
,
default_branch:
'stable'
,
issues_enabled:
false
,
...
...
@@ -257,7 +256,7 @@ describe Gitlab::API do
describe
"POST /projects/:id/snippets"
do
it
"should create a new project snippet"
do
post
api
(
"/projects/
#{
project
.
path
}
/snippets"
,
user
),
title:
'api test'
,
file_name:
'sample.rb'
,
path
:
'test'
title:
'api test'
,
file_name:
'sample.rb'
,
code
:
'test'
response
.
status
.
should
==
201
json_response
[
'title'
].
should
==
'api test'
end
...
...
@@ -266,10 +265,10 @@ describe Gitlab::API do
describe
"PUT /projects/:id/snippets/:shippet_id"
do
it
"should update an existing project snippet"
do
put
api
(
"/projects/
#{
project
.
path
}
/snippets/
#{
snippet
.
id
}
"
,
user
),
path:
'updated path
'
code:
'updated code
'
response
.
status
.
should
==
200
json_response
[
'title'
].
should
==
'example'
snippet
.
reload
.
content
.
should
==
'updated
path
'
snippet
.
reload
.
content
.
should
==
'updated
code
'
end
end
...
...
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