670b2eb5c0
API: Share projects only with groups current_user can access
Aims to address the issues here: https://gitlab.com/gitlab-org/gitlab-ce/issues/23004
* Projects can be shared with non-existent groups
* Projects can be shared with groups that the current user does not have access to read
Concerns:
The new implementation of the API endpoint allows projects to be shared with a larger range of groups than can be done via the web UI.
The form for sharing a project with a group uses the following API endpoint to index the available groups: 494269fc92/lib/api/groups.rb (L17)
. The groups indexed in the web form will only be those groups that the user is currently a member of.
The new implementation allows projects to be shared with any group that the authenticated user has access to view. This widens the range of groups to those that are public and internal.
See merge request !2005
Signed-off-by: Rémy Coutable <remy@rymai.me>
17 lines
521 B
Ruby
17 lines
521 B
Ruby
require 'spec_helper'
|
|
|
|
describe ProjectGroupLink do
|
|
describe "Associations" do
|
|
it { should belong_to(:group) }
|
|
it { should belong_to(:project) }
|
|
end
|
|
|
|
describe "Validation" do
|
|
let!(:project_group_link) { create(:project_group_link) }
|
|
|
|
it { should validate_presence_of(:project_id) }
|
|
it { should validate_uniqueness_of(:group_id).scoped_to(:project_id).with_message(/already shared/) }
|
|
it { should validate_presence_of(:group) }
|
|
it { should validate_presence_of(:group_access) }
|
|
end
|
|
end
|