diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 11:18:50 +0000 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/services/resource_events/change_state_service.rb | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) | |
download | gitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/services/resource_events/change_state_service.rb')
-rw-r--r-- | app/services/resource_events/change_state_service.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/app/services/resource_events/change_state_service.rb b/app/services/resource_events/change_state_service.rb new file mode 100644 index 00000000000..8beb76d8aee --- /dev/null +++ b/app/services/resource_events/change_state_service.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +module ResourceEvents + class ChangeStateService + attr_reader :resource, :user + + def initialize(user:, resource:) + @user, @resource = user, resource + end + + def execute(state) + ResourceStateEvent.create( + user: user, + issue: issue, + merge_request: merge_request, + state: ResourceStateEvent.states[state], + created_at: Time.zone.now) + + resource.expire_note_etag_cache + end + + private + + def issue + return unless resource.is_a?(Issue) + + resource + end + + def merge_request + return unless resource.is_a?(MergeRequest) + + resource + end + end +end |