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
8b089fa2
Commit
8b089fa2
authored
Jun 04, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce
parents
8645a0d3
b9219469
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
94 additions
and
8 deletions
+94
-8
CHANGELOG
CHANGELOG
+2
-0
app/models/user.rb
app/models/user.rb
+6
-0
app/views/notify/repository_push_email.html.haml
app/views/notify/repository_push_email.html.haml
+1
-1
app/views/projects/labels/index.html.haml
app/views/projects/labels/index.html.haml
+4
-1
doc/api/README.md
doc/api/README.md
+1
-0
doc/api/namespaces.md
doc/api/namespaces.md
+44
-0
lib/api/namespaces.rb
lib/api/namespaces.rb
+6
-5
spec/models/user_spec.rb
spec/models/user_spec.rb
+2
-0
spec/requests/api/namespaces_spec.rb
spec/requests/api/namespaces_spec.rb
+28
-1
No files found.
CHANGELOG
View file @
8b089fa2
...
...
@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 7.12.0 (unreleased)
- Don't notify users mentioned in code blocks or blockquotes.
- Omit link to generate labels if user does not have access to create them (Stan Hu)
- Disable changing of the source branch in merge request update API (Stan Hu)
- Shorten merge request WIP text.
- Add option to disallow users from registering any application to use GitLab as an OAuth provider
...
...
@@ -13,6 +14,7 @@ v 7.12.0 (unreleased)
- Add file attachment support in Milestone description (Stan Hu)
- Fix milestone "Browse Issues" button.
- Set milestone on new issue when creating issue from index with milestone filter active.
- Make namespace API available to all users (Stan Hu)
- Add web hook support for note events (Stan Hu)
- Disable "New Issue" and "New Merge Request" buttons when features are disabled in project settings (Stan Hu)
- Remove Rack Attack monkey patches and bump to version 4.3.0 (Stan Hu)
...
...
app/models/user.rb
View file @
8b089fa2
...
...
@@ -655,6 +655,12 @@ class User < ActiveRecord::Base
end
end
def
namespaces
namespace_ids
=
groups
.
pluck
(
:id
)
namespace_ids
.
push
(
namespace
.
id
)
Namespace
.
where
(
id:
namespace_ids
)
end
def
oauth_authorized_tokens
Doorkeeper
::
AccessToken
.
where
(
resource_owner_id:
self
.
id
,
revoked_at:
nil
)
end
...
...
app/views/notify/repository_push_email.html.haml
View file @
8b089fa2
...
...
@@ -35,7 +35,7 @@
=
diff
.
new_path
-
elsif
diff
.
new_file
%span
.new-file
&
plus
;
&
#43
;
=
diff
.
new_path
-
else
=
diff
.
new_path
...
...
app/views/projects/labels/index.html.haml
View file @
8b089fa2
...
...
@@ -13,4 +13,7 @@
=
paginate
@labels
,
theme:
'gitlab'
-
else
.light-well
-
if
can?
current_user
,
:admin_label
,
@project
.nothing-here-block
Create first label or
#{
link_to
'generate'
,
generate_namespace_project_labels_path
(
@project
.
namespace
,
@project
),
method: :post
}
default set of labels
-
else
.nothing-here-block
No labels created
doc/api/README.md
View file @
8b089fa2
...
...
@@ -19,6 +19,7 @@
-
[
Deploy Keys
](
deploy_keys.md
)
-
[
System Hooks
](
system_hooks.md
)
-
[
Groups
](
groups.md
)
-
[
Namespaces
](
namespaces.md
)
## Clients
...
...
doc/api/namespaces.md
0 → 100644
View file @
8b089fa2
# Namespaces
## List namespaces
Get a list of namespaces. (As user: my namespaces, as admin: all namespaces)
```
GET /namespaces
```
```
json
[
{
"id"
:
1
,
"path"
:
"user1"
,
"kind"
:
"user"
},
{
"id"
:
2
,
"path"
:
"group1"
,
"kind"
:
"group"
}
]
```
You can search for namespaces by name or path, see below.
## Search for namespace
Get all namespaces that match your string in their name or path.
```
GET /namespaces?search=foobar
```
```
json
[
{
"id"
:
1
,
"path"
:
"user1"
,
"kind"
:
"user"
}
]
```
lib/api/namespaces.rb
View file @
8b089fa2
module
API
# namespaces API
class
Namespaces
<
Grape
::
API
before
do
authenticate!
authenticated_as_admin!
end
before
{
authenticate!
}
resource
:namespaces
do
# Get a namespaces list
...
...
@@ -12,7 +9,11 @@ module API
# Example Request:
# GET /namespaces
get
do
@namespaces
=
Namespace
.
all
@namespaces
=
if
current_user
.
admin
Namespace
.
all
else
current_user
.
namespaces
end
@namespaces
=
@namespaces
.
search
(
params
[
:search
])
if
params
[
:search
].
present?
@namespaces
=
paginate
@namespaces
...
...
spec/models/user_spec.rb
View file @
8b089fa2
...
...
@@ -248,6 +248,7 @@ describe User do
it
{
expect
(
@user
.
several_namespaces?
).
to
be_truthy
}
it
{
expect
(
@user
.
authorized_groups
).
to
eq
([
@group
])
}
it
{
expect
(
@user
.
owned_groups
).
to
eq
([
@group
])
}
it
{
expect
(
@user
.
namespaces
).
to
match_array
([
@user
.
namespace
,
@group
])
}
end
describe
'group multiple owners'
do
...
...
@@ -270,6 +271,7 @@ describe User do
end
it
{
expect
(
@user
.
several_namespaces?
).
to
be_falsey
}
it
{
expect
(
@user
.
namespaces
).
to
eq
([
@user
.
namespace
])
}
end
describe
'blocking user'
do
...
...
spec/requests/api/namespaces_spec.rb
View file @
8b089fa2
...
...
@@ -3,6 +3,7 @@ require 'spec_helper'
describe
API
::
API
,
api:
true
do
include
ApiHelpers
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:user
)
{
create
(
:user
)
}
let!
(
:group1
)
{
create
(
:group
)
}
let!
(
:group2
)
{
create
(
:group
)
}
...
...
@@ -22,6 +23,32 @@ describe API::API, api: true do
expect
(
json_response
.
length
).
to
eq
(
Namespace
.
count
)
end
it
"admin: should return an array of matched namespaces"
do
get
api
(
"/namespaces?search=
#{
group1
.
name
}
"
,
admin
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
end
context
"when authenticated as a regular user"
do
it
"user: should return an array of namespaces"
do
get
api
(
"/namespaces"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
it
"admin: should return an array of matched namespaces"
do
get
api
(
"/namespaces?search=
#{
user
.
username
}
"
,
user
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
json_response
).
to
be_an
Array
expect
(
json_response
.
length
).
to
eq
(
1
)
end
end
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