Skip to content

Commit

Permalink
Appease the rubocop gods
Browse files Browse the repository at this point in the history
  • Loading branch information
mereghost committed Dec 20, 2024
1 parent 88c037c commit cbf9b44
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion app/models/types/pattern_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

module Types
class PatternMapper
TOKEN_REGEX = /{{[0-9A-z_]+}}/
TOKEN_REGEX = /{{[0-9A-Za-z_]+}}/

MAPPING = {
type: ->(wp) { wp.type.name },
Expand Down
12 changes: 5 additions & 7 deletions app/services/work_packages/create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class WorkPackages::CreateService < BaseServices::BaseCallable
attr_reader :user, :contract_class

def initialize(user:, contract_class: WorkPackages::CreateContract)
super()
@user = user
@contract_class = contract_class
end
Expand All @@ -54,10 +55,8 @@ def create(attributes, work_package)
if result.success
work_package.attachments = work_package.attachments_replacements if work_package.attachments_replacements
work_package.save

set_templated_subject(work_package)
work_package.save
else
false
end

if result.success?
Expand All @@ -68,18 +67,17 @@ def create(attributes, work_package)
end

set_user_as_watcher(work_package)
else
result.success = false
end

result
end

def set_templated_subject(work_package)
return unless work_package.type&.replacement_patterns_defined?
return unless work_package.type.enabled_patterns[:subject]
return true unless work_package.type&.replacement_patterns_defined?
return true unless work_package.type.enabled_patterns[:subject]

work_package.subject = work_package.type.enabled_patterns[:subject].resolve(work_package)
work_package.save
end

def set_attributes(attributes, work_package)
Expand Down

0 comments on commit cbf9b44

Please sign in to comment.