diff options
Diffstat (limited to 'app/services/projects/group_links')
-rw-r--r-- | app/services/projects/group_links/create_service.rb | 1 | ||||
-rw-r--r-- | app/services/projects/group_links/destroy_service.rb | 4 | ||||
-rw-r--r-- | app/services/projects/group_links/update_service.rb | 29 |
3 files changed, 33 insertions, 1 deletions
diff --git a/app/services/projects/group_links/create_service.rb b/app/services/projects/group_links/create_service.rb index 241948b335b..2ba3cd6694f 100644 --- a/app/services/projects/group_links/create_service.rb +++ b/app/services/projects/group_links/create_service.rb @@ -13,6 +13,7 @@ module Projects ) if link.save + group.refresh_members_authorized_projects success(link: link) else error(link.errors.full_messages.to_sentence, 409) diff --git a/app/services/projects/group_links/destroy_service.rb b/app/services/projects/group_links/destroy_service.rb index ea7d05551fd..229191e41f6 100644 --- a/app/services/projects/group_links/destroy_service.rb +++ b/app/services/projects/group_links/destroy_service.rb @@ -12,7 +12,9 @@ module Projects TodosDestroyer::ConfidentialIssueWorker.perform_in(Todo::WAIT_FOR_DELETE, nil, project.id) end - group_link.destroy + group_link.destroy.tap do |link| + link.group.refresh_members_authorized_projects + end end end end diff --git a/app/services/projects/group_links/update_service.rb b/app/services/projects/group_links/update_service.rb new file mode 100644 index 00000000000..7de4b7a211d --- /dev/null +++ b/app/services/projects/group_links/update_service.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true + +module Projects + module GroupLinks + class UpdateService < BaseService + def initialize(group_link, user = nil) + super(group_link.project, user) + + @group_link = group_link + end + + def execute(group_link_params) + group_link.update!(group_link_params) + + if requires_authorization_refresh?(group_link_params) + group_link.group.refresh_members_authorized_projects + end + end + + private + + attr_reader :group_link + + def requires_authorization_refresh?(params) + params.include?(:group_access) + end + end + end +end |