summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-02-14 15:34:36 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2017-02-14 15:34:36 +0200
commitc48539463ff2250058fbfa9d1811977f01313b7c (patch)
tree3acd43bf7142051dfd52a04d427fd61d2a77d53c
parentc867fbab24fcccc2a47ec518e30d8622f66dfa28 (diff)
downloadgitlab-ce-c48539463ff2250058fbfa9d1811977f01313b7c.tar.gz
Expose Namespace#full_path in namespaces API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
-rw-r--r--app/assets/javascripts/namespace_select.js4
-rw-r--r--app/views/admin/projects/index.html.haml2
-rw-r--r--doc/api/namespaces.md9
-rw-r--r--lib/api/entities.rb2
-rw-r--r--spec/requests/api/namespaces_spec.rb6
5 files changed, 16 insertions, 7 deletions
diff --git a/app/assets/javascripts/namespace_select.js b/app/assets/javascripts/namespace_select.js
index 514556ade0b..2ae5617206e 100644
--- a/app/assets/javascripts/namespace_select.js
+++ b/app/assets/javascripts/namespace_select.js
@@ -29,7 +29,7 @@
if (selected.id == null) {
return selected.text;
} else {
- return selected.kind + ": " + selected.path;
+ return selected.kind + ": " + selected.full_path;
}
},
data: function(term, dataCallback) {
@@ -50,7 +50,7 @@
if (namespace.id == null) {
return namespace.text;
} else {
- return namespace.kind + ": " + namespace.path;
+ return namespace.kind + ": " + namespace.full_path;
}
},
renderRow: this.renderRow,
diff --git a/app/views/admin/projects/index.html.haml b/app/views/admin/projects/index.html.haml
index cf8d438670b..cdef63daca9 100644
--- a/app/views/admin/projects/index.html.haml
+++ b/app/views/admin/projects/index.html.haml
@@ -30,7 +30,7 @@
- toggle_text = 'Namespace'
- if params[:namespace_id].present?
- namespace = Namespace.find(params[:namespace_id])
- - toggle_text = "#{namespace.kind}: #{namespace.path}"
+ - toggle_text = "#{namespace.kind}: #{namespace.full_path}"
= dropdown_toggle(toggle_text, { toggle: 'dropdown' }, { toggle_class: 'js-namespace-select large' })
.dropdown-menu.dropdown-select.dropdown-menu-align-right
= dropdown_title('Namespaces')
diff --git a/doc/api/namespaces.md b/doc/api/namespaces.md
index 88cd407d792..1d97b5de688 100644
--- a/doc/api/namespaces.md
+++ b/doc/api/namespaces.md
@@ -35,6 +35,12 @@ Example response:
"id": 2,
"path": "group1",
"kind": "group"
+ },
+ {
+ "id": 3,
+ "path": "bar",
+ "kind": "group",
+ "full_path": "foo/bar",
}
]
```
@@ -64,7 +70,8 @@ Example response:
{
"id": 4,
"path": "twitter",
- "kind": "group"
+ "kind": "group",
+ "full_path": "twitter",
}
]
```
diff --git a/lib/api/entities.rb b/lib/api/entities.rb
index 2a071e649fa..2fd88380d6b 100644
--- a/lib/api/entities.rb
+++ b/lib/api/entities.rb
@@ -414,7 +414,7 @@ module API
end
class Namespace < Grape::Entity
- expose :id, :name, :path, :kind
+ expose :id, :name, :path, :kind, :full_path
end
class MemberAccess < Grape::Entity
diff --git a/spec/requests/api/namespaces_spec.rb b/spec/requests/api/namespaces_spec.rb
index c1edf384d5c..a945d56f529 100644
--- a/spec/requests/api/namespaces_spec.rb
+++ b/spec/requests/api/namespaces_spec.rb
@@ -5,7 +5,7 @@ describe API::Namespaces, api: true do
let(:admin) { create(:admin) }
let(:user) { create(:user) }
let!(:group1) { create(:group) }
- let!(:group2) { create(:group) }
+ let!(:group2) { create(:group, :nested) }
describe "GET /namespaces" do
context "when unauthenticated" do
@@ -25,11 +25,13 @@ describe API::Namespaces, api: true do
end
it "admin: returns an array of matched namespaces" do
- get api("/namespaces?search=#{group1.name}", admin)
+ get api("/namespaces?search=#{group2.name}", admin)
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response.length).to eq(1)
+ expect(json_response.last['path']).to eq(group2.path)
+ expect(json_response.last['full_path']).to eq(group2.full_path)
end
end