diff options
author | Francisco Javier López <fjlopez@gitlab.com> | 2017-11-01 17:08:18 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-11-01 17:08:18 +0300 |
commit | af1fb493235496cc676795f0e7d355bfb34f869b (patch) | |
tree | 5cd99f98938d3bba32b0994be3eef9e41d03af74 /app/controllers/projects/group_links_controller.rb | |
parent | 713052c7255c9c4fc33b74ca5d788644a30018ca (diff) |
Refactor/group links controller
Diffstat (limited to 'app/controllers/projects/group_links_controller.rb')
-rw-r--r-- | app/controllers/projects/group_links_controller.rb | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/app/controllers/projects/group_links_controller.rb b/app/controllers/projects/group_links_controller.rb index f59200d3b1f..dbc1c8bcc28 100644 --- a/app/controllers/projects/group_links_controller.rb +++ b/app/controllers/projects/group_links_controller.rb @@ -12,12 +12,7 @@ class Projects::GroupLinksController < Projects::ApplicationController if group return render_404 unless can?(current_user, :read_group, group) - - project.project_group_links.create( - group: group, - group_access: params[:link_group_access], - expires_at: params[:expires_at] - ) + Projects::GroupLinks::CreateService.new(project, current_user, group_link_create_params).execute(group) else flash[:alert] = 'Please select a group.' end @@ -32,7 +27,9 @@ class Projects::GroupLinksController < Projects::ApplicationController end def destroy - project.project_group_links.find(params[:id]).destroy + group_link = project.project_group_links.find(params[:id]) + + ::Projects::GroupLinks::DestroyService.new(project, current_user).execute(group_link) respond_to do |format| format.html do @@ -47,4 +44,8 @@ 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 |