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
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1b3718ab
Commit
1b3718ab
authored
Mar 17, 2022
by
Doug Stull
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove unecessary group_link routes for creation
- no longer necessary since we moved to invite modal use.
parent
5cc00fb6
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
2 additions
and
311 deletions
+2
-311
app/controllers/groups/group_links_controller.rb
app/controllers/groups/group_links_controller.rb
+0
-22
app/controllers/projects/group_links_controller.rb
app/controllers/projects/group_links_controller.rb
+0
-21
config/routes/group.rb
config/routes/group.rb
+1
-1
config/routes/project.rb
config/routes/project.rb
+1
-1
ee/app/controllers/ee/projects/group_links_controller.rb
ee/app/controllers/ee/projects/group_links_controller.rb
+0
-19
locale/gitlab.pot
locale/gitlab.pot
+0
-3
spec/controllers/groups/group_links_controller_spec.rb
spec/controllers/groups/group_links_controller_spec.rb
+0
-114
spec/controllers/projects/group_links_controller_spec.rb
spec/controllers/projects/group_links_controller_spec.rb
+0
-130
No files found.
app/controllers/groups/group_links_controller.rb
View file @
1b3718ab
...
...
@@ -6,24 +6,6 @@ class Groups::GroupLinksController < Groups::ApplicationController
feature_category
:subgroups
def
create
shared_with_group
=
Group
.
find
(
params
[
:shared_with_group_id
])
if
params
[
:shared_with_group_id
].
present?
if
shared_with_group
result
=
Groups
::
GroupLinks
::
CreateService
.
new
(
group
,
shared_with_group
,
current_user
,
group_link_create_params
)
.
execute
return
render_404
if
result
[
:http_status
]
==
404
flash
[
:alert
]
=
result
[
:message
]
if
result
[
:status
]
==
:error
else
flash
[
:alert
]
=
_
(
'Please select a group.'
)
end
redirect_to
group_group_members_path
(
group
)
end
def
update
Groups
::
GroupLinks
::
UpdateService
.
new
(
@group_link
).
execute
(
group_link_params
)
...
...
@@ -54,10 +36,6 @@ class Groups::GroupLinksController < Groups::ApplicationController
@group_link
||=
group
.
shared_with_group_links
.
find
(
params
[
:id
])
end
def
group_link_create_params
params
.
permit
(
:shared_group_access
,
:expires_at
)
end
def
group_link_params
params
.
require
(
:group_link
).
permit
(
:group_access
,
:expires_at
)
end
...
...
app/controllers/projects/group_links_controller.rb
View file @
1b3718ab
...
...
@@ -7,21 +7,6 @@ class Projects::GroupLinksController < Projects::ApplicationController
feature_category
:subgroups
def
create
group
=
Group
.
find
(
params
[
:link_group_id
])
if
params
[
:link_group_id
].
present?
if
group
result
=
Projects
::
GroupLinks
::
CreateService
.
new
(
project
,
current_user
,
group_link_create_params
).
execute
(
group
)
return
render_404
if
result
[
:http_status
]
==
404
flash
[
:alert
]
=
result
[
:message
]
if
result
[
:http_status
]
==
409
else
flash
[
:alert
]
=
_
(
'Please select a group.'
)
end
redirect_to
project_project_members_path
(
project
)
end
def
update
group_link
=
@project
.
project_group_links
.
find
(
params
[
:id
])
Projects
::
GroupLinks
::
UpdateService
.
new
(
group_link
).
execute
(
group_link_params
)
...
...
@@ -54,10 +39,4 @@ class Projects::GroupLinksController < Projects::ApplicationController
def
group_link_params
params
.
require
(
:group_link
).
permit
(
:group_access
,
:expires_at
)
end
def
group_link_create_params
params
.
permit
(
:link_group_access
,
:expires_at
)
end
end
Projects
::
GroupLinksController
.
prepend_mod_with
(
'Projects::GroupLinksController'
)
config/routes/group.rb
View file @
1b3718ab
...
...
@@ -99,7 +99,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
delete
:leave
,
on: :collection
end
resources
:group_links
,
only:
[
:
create
,
:
update
,
:destroy
],
constraints:
{
id:
/\d+|:id/
}
resources
:group_links
,
only:
[
:update
,
:destroy
],
constraints:
{
id:
/\d+|:id/
}
resources
:uploads
,
only:
[
:create
]
do
collection
do
...
...
config/routes/project.rb
View file @
1b3718ab
...
...
@@ -247,7 +247,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources
:starrers
,
only:
[
:index
]
resources
:forks
,
only:
[
:index
,
:new
,
:create
]
resources
:group_links
,
only:
[
:
create
,
:
update
,
:destroy
],
constraints:
{
id:
/\d+|:id/
}
resources
:group_links
,
only:
[
:update
,
:destroy
],
constraints:
{
id:
/\d+|:id/
}
resource
:import
,
only:
[
:new
,
:create
,
:show
]
resource
:avatar
,
only:
[
:show
,
:destroy
]
...
...
ee/app/controllers/ee/projects/group_links_controller.rb
deleted
100644 → 0
View file @
5cc00fb6
# frozen_string_literal: true
module
EE
module
Projects
module
GroupLinksController
extend
ActiveSupport
::
Concern
prepended
do
before_action
:authorize_group_share!
,
only:
[
:create
]
end
protected
def
authorize_group_share!
access_denied!
unless
project
.
allowed_to_share_with_group?
end
end
end
end
locale/gitlab.pot
View file @
1b3718ab
...
...
@@ -27877,9 +27877,6 @@ msgstr ""
msgid "Please select a group"
msgstr ""
msgid "Please select a group."
msgstr ""
msgid "Please select a valid target branch"
msgstr ""
...
...
spec/controllers/groups/group_links_controller_spec.rb
View file @
1b3718ab
...
...
@@ -35,120 +35,6 @@ RSpec.describe Groups::GroupLinksController do
end
end
describe
'#create'
do
let
(
:shared_with_group_id
)
{
shared_with_group
.
id
}
let
(
:shared_group_access
)
{
GroupGroupLink
.
default_access
}
subject
do
post
(
:create
,
params:
{
group_id:
shared_group
,
shared_with_group_id:
shared_with_group_id
,
shared_group_access:
shared_group_access
})
end
shared_examples
'creates group group link'
do
it
'links group with selected group'
do
expect
{
subject
}.
to
change
{
shared_with_group
.
shared_groups
.
include?
(
shared_group
)
}.
from
(
false
).
to
(
true
)
end
it
'redirects to group links page'
do
subject
expect
(
response
).
to
(
redirect_to
(
group_group_members_path
(
shared_group
)))
end
it
'allows access for group member'
do
expect
{
subject
}.
to
(
change
{
group_member
.
can?
(
:read_group
,
shared_group
)
}.
from
(
false
).
to
(
true
))
end
end
context
'when user has correct access to both groups'
do
before
do
shared_with_group
.
add_developer
(
user
)
shared_group
.
add_owner
(
user
)
end
context
'when default access level is requested'
do
include_examples
'creates group group link'
end
context
'when owner access is requested'
do
let
(
:shared_group_access
)
{
Gitlab
::
Access
::
OWNER
}
before
do
shared_with_group
.
add_owner
(
group_member
)
end
include_examples
'creates group group link'
it
'allows admin access for group member'
do
expect
{
subject
}.
to
(
change
{
group_member
.
can?
(
:admin_group
,
shared_group
)
}.
from
(
false
).
to
(
true
))
end
end
it
'updates project permissions'
,
:sidekiq_inline
do
expect
{
subject
}.
to
change
{
group_member
.
can?
(
:read_project
,
project
)
}.
from
(
false
).
to
(
true
)
end
context
'when shared with group id is not present'
do
let
(
:shared_with_group_id
)
{
nil
}
it
'redirects to group links page'
do
subject
expect
(
response
).
to
(
redirect_to
(
group_group_members_path
(
shared_group
)))
expect
(
flash
[
:alert
]).
to
eq
(
'Please select a group.'
)
end
end
context
'when link is not persisted in the database'
do
before
do
allow
(
::
Groups
::
GroupLinks
::
CreateService
).
to
(
receive_message_chain
(
:new
,
:execute
)
.
and_return
({
status: :error
,
http_status:
409
,
message:
'error'
}))
end
it
'redirects to group links page'
do
subject
expect
(
response
).
to
(
redirect_to
(
group_group_members_path
(
shared_group
)))
expect
(
flash
[
:alert
]).
to
eq
(
'error'
)
end
end
end
context
'when user does not have access to the group'
do
before
do
shared_group
.
add_owner
(
user
)
end
it
'renders 404'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'when user does not have admin access to the shared group'
do
before
do
shared_with_group
.
add_developer
(
user
)
shared_group
.
add_developer
(
user
)
end
it
'renders 404'
do
subject
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
include_examples
'placeholder is passed as `id` parameter'
,
:create
end
describe
'#update'
do
let!
(
:link
)
do
create
(
:group_group_link
,
{
shared_group:
shared_group
,
...
...
spec/controllers/projects/group_links_controller_spec.rb
View file @
1b3718ab
...
...
@@ -18,136 +18,6 @@ RSpec.describe Projects::GroupLinksController do
travel_back
end
describe
'#create'
do
shared_context
'link project to group'
do
before
do
post
(
:create
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
link_group_id:
group
.
id
,
link_group_access:
ProjectGroupLink
.
default_access
})
end
end
context
'when project is not allowed to be shared with a group'
do
before
do
group
.
update!
(
share_with_group_lock:
false
)
end
include_context
'link project to group'
it
'responds with status 404'
do
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
end
context
'when user has access to group they want to link project to'
do
before
do
group
.
add_developer
(
user
)
end
include_context
'link project to group'
it
'links project with selected group'
do
expect
(
group
.
shared_projects
).
to
include
project
end
it
'redirects to project group links page'
do
expect
(
response
).
to
redirect_to
(
project_project_members_path
(
project
)
)
end
end
context
'when user doers not have access to group they want to link to'
do
include_context
'link project to group'
it
'renders 404'
do
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
it
'does not share project with that group'
do
expect
(
group
.
shared_projects
).
not_to
include
project
end
end
context
'when user does not have access to the public group'
do
let
(
:group
)
{
create
(
:group
,
:public
)
}
include_context
'link project to group'
it
'renders 404'
do
expect
(
response
).
to
have_gitlab_http_status
(
:not_found
)
end
it
'does not share project with that group'
do
expect
(
group
.
shared_projects
).
not_to
include
project
end
end
context
'when project group id equal link group id'
do
before
do
group2
.
add_developer
(
user
)
post
(
:create
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
link_group_id:
group2
.
id
,
link_group_access:
ProjectGroupLink
.
default_access
})
end
it
'does not share project with selected group'
do
expect
(
group2
.
shared_projects
).
not_to
include
project
end
it
'redirects to project group links page'
do
expect
(
response
).
to
redirect_to
(
project_project_members_path
(
project
)
)
end
end
context
'when link group id is not present'
do
before
do
post
(
:create
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
link_group_access:
ProjectGroupLink
.
default_access
})
end
it
'redirects to project group links page'
do
expect
(
response
).
to
redirect_to
(
project_project_members_path
(
project
)
)
expect
(
flash
[
:alert
]).
to
eq
(
'Please select a group.'
)
end
end
context
'when link is not persisted in the database'
do
before
do
allow
(
::
Projects
::
GroupLinks
::
CreateService
).
to
receive_message_chain
(
:new
,
:execute
)
.
and_return
({
status: :error
,
http_status:
409
,
message:
'error'
})
post
(
:create
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
link_group_id:
group
.
id
,
link_group_access:
ProjectGroupLink
.
default_access
})
end
it
'redirects to project group links page'
do
expect
(
response
).
to
redirect_to
(
project_project_members_path
(
project
)
)
expect
(
flash
[
:alert
]).
to
eq
(
'error'
)
end
end
end
describe
'#update'
do
let_it_be
(
:link
)
do
create
(
...
...
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