diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-01-05 10:43:29 +0100 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2016-01-05 10:43:29 +0100 |
commit | aa3c7219e3b82e815023f8e2b8fccaf600b41e2b (patch) | |
tree | 8d24e2c09a99290680ff274f47b39436cfc93b12 | |
parent | 7f2127ee4c9c276717ca04a1f43a9e7927b749ab (diff) | |
parent | 086cfc8685a6489ca032899307c77f828f515fbb (diff) | |
download | gitlab-ce-aa3c7219e3b82e815023f8e2b8fccaf600b41e2b.tar.gz |
Merge branch 'fix-api-lookup-with-usernames-with-dots' of https://gitlab.com/stanhu/gitlab-ce
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | lib/api/projects.rb | 2 | ||||
-rw-r--r-- | spec/requests/api/projects_spec.rb | 9 |
3 files changed, 11 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index e8eb5d568f5..47ef06bee54 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -17,6 +17,7 @@ v 8.4.0 (unreleased) - Add system hook messages for project rename and transfer (Steve Norman) - Fix version check image in Safari - Show 'All' tab by default in the builds page + - Fix API project lookups when querying with a namespace with dots (Stan Hu) v 8.3.3 (unreleased) - Fix project transfer e-mail sending incorrect paths in e-mail notification (Stan Hu) diff --git a/lib/api/projects.rb b/lib/api/projects.rb index a9e0960872a..0781236cf6d 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -3,7 +3,7 @@ module API class Projects < Grape::API before { authenticate! } - resource :projects do + resource :projects, requirements: { id: /[^\/]+/ } do helpers do def map_public_to_visibility_level(attrs) publik = attrs.delete(:public) diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index 7f0f9454b10..ab2530859ea 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -382,6 +382,15 @@ describe API::API, api: true do expect(response.status).to eq(404) end + it 'should handle users with dots' do + dot_user = create(:user, username: 'dot.user') + project = create(:project, creator_id: dot_user.id, namespace: dot_user.namespace) + + get api("/projects/#{dot_user.namespace.name}%2F#{project.path}", dot_user) + expect(response.status).to eq(200) + expect(json_response['name']).to eq(project.name) + end + describe 'permissions' do context 'all projects' do it 'Contains permission information' do |