Commit 636db151 authored by Olaf Tomalka's avatar Olaf Tomalka

Higher code quality for fork to namespace API

parent 3aa40153
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.12.0 (unreleased) v 8.12.0 (unreleased)
- Add abillity to fork to a specific namespace using API. @ritave <olaf@tomalka.me> - Add ability to fork to a specific namespace using API. (ritave)
- Prepend blank line to `Closes` message on merge request linked to issue (lukehowell) - Prepend blank line to `Closes` message on merge request linked to issue (lukehowell)
- Filter tags by name !6121 - Filter tags by name !6121
- Make push events have equal vertical spacing. - Make push events have equal vertical spacing.
......
...@@ -204,7 +204,6 @@ module API ...@@ -204,7 +204,6 @@ module API
namespace = Namespace.find_by(id: namespace_id) || Namespace.find_by_path_or_name(namespace_id) namespace = Namespace.find_by(id: namespace_id) || Namespace.find_by_path_or_name(namespace_id)
not_found!('Target Namespace') unless namespace not_found!('Target Namespace') unless namespace
authorize! :create_projects, namespace
attrs[:namespace] = namespace attrs[:namespace] = namespace
end end
......
...@@ -3,10 +3,10 @@ require 'spec_helper' ...@@ -3,10 +3,10 @@ require 'spec_helper'
describe API::API, api: true do describe API::API, api: true do
include ApiHelpers include ApiHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user, username: 'user2_name') } let(:user2) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let(:group) { create(:group, name: 'group_name') } let(:group) { create(:group) }
let(:group2) do let(:group2) do
group = create(:group, name: 'group2_name') group = create(:group, name: 'group2_name')
group.add_owner(user2) group.add_owner(user2)
...@@ -94,7 +94,7 @@ describe API::API, api: true do ...@@ -94,7 +94,7 @@ describe API::API, api: true do
it 'fails if trying to fork to another user when not admin' do it 'fails if trying to fork to another user when not admin' do
post api("/projects/fork/#{project.id}", user2), namespace: admin.namespace.id post api("/projects/fork/#{project.id}", user2), namespace: admin.namespace.id
expect(response).to have_http_status(403) expect(response).to have_http_status(409)
end end
it 'fails if trying to fork to non-existent namespace' do it 'fails if trying to fork to non-existent namespace' do
...@@ -114,7 +114,7 @@ describe API::API, api: true do ...@@ -114,7 +114,7 @@ describe API::API, api: true do
it 'fails to fork to not owned group' do it 'fails to fork to not owned group' do
post api("/projects/fork/#{project.id}", user2), namespace: group.name post api("/projects/fork/#{project.id}", user2), namespace: group.name
expect(response).to have_http_status(403) expect(response).to have_http_status(409)
end end
it 'forks to not owned group when admin' do it 'forks to not owned group when admin' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment