diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/milestoneable.rb | 6 | ||||
-rw-r--r-- | app/models/issue.rb | 3 | ||||
-rw-r--r-- | app/models/issue_milestone.rb | 6 | ||||
-rw-r--r-- | app/models/merge_request.rb | 3 | ||||
-rw-r--r-- | app/models/merge_request_milestone.rb | 6 | ||||
-rw-r--r-- | app/models/milestone.rb | 3 | ||||
-rw-r--r-- | app/services/users/create_service.rb | 13 |
7 files changed, 10 insertions, 30 deletions
diff --git a/app/models/concerns/milestoneable.rb b/app/models/concerns/milestoneable.rb index 7fb3f95bf0a..7df6981a129 100644 --- a/app/models/concerns/milestoneable.rb +++ b/app/models/concerns/milestoneable.rb @@ -14,8 +14,6 @@ module Milestoneable validate :milestone_is_valid - after_save :write_to_new_milestone_relationship - scope :of_milestones, ->(ids) { where(milestone_id: ids) } scope :any_milestone, -> { where('milestone_id IS NOT NULL') } scope :with_milestone, ->(title) { left_joins_milestones.where(milestones: { title: title }) } @@ -41,10 +39,6 @@ module Milestoneable def milestone_is_valid errors.add(:milestone_id, message: "is invalid") if respond_to?(:milestone_id) && milestone_id.present? && !milestone_available? end - - def write_to_new_milestone_relationship - self.milestones = [milestone].compact if supports_milestone? && saved_change_to_milestone_id? - end end def milestone_available? diff --git a/app/models/issue.rb b/app/models/issue.rb index d01aa78a2c1..be702134ced 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -33,9 +33,6 @@ class Issue < ApplicationRecord has_internal_id :iid, scope: :project, track_if: -> { !importing? }, init: ->(s) { s&.project&.issues&.maximum(:iid) } - has_many :issue_milestones - has_many :milestones, through: :issue_milestones - has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent has_many :merge_requests_closing_issues, diff --git a/app/models/issue_milestone.rb b/app/models/issue_milestone.rb deleted file mode 100644 index da030077d87..00000000000 --- a/app/models/issue_milestone.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -class IssueMilestone < ApplicationRecord - belongs_to :milestone - belongs_to :issue -end diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 14aa6ac066e..6c32bdadfa8 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -38,9 +38,6 @@ class MergeRequest < ApplicationRecord has_many :merge_request_context_commits has_many :merge_request_context_commit_diff_files, through: :merge_request_context_commits, source: :diff_files - has_many :merge_request_milestones - has_many :milestones, through: :merge_request_milestones - has_one :merge_request_diff, -> { order('merge_request_diffs.id DESC') }, inverse_of: :merge_request diff --git a/app/models/merge_request_milestone.rb b/app/models/merge_request_milestone.rb deleted file mode 100644 index 4fa1d1dcb33..00000000000 --- a/app/models/merge_request_milestone.rb +++ /dev/null @@ -1,6 +0,0 @@ -# frozen_string_literal: true - -class MergeRequestMilestone < ApplicationRecord - belongs_to :milestone - belongs_to :merge_request -end diff --git a/app/models/milestone.rb b/app/models/milestone.rb index b3278f48aa9..29c621c54d0 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -39,9 +39,6 @@ class Milestone < ApplicationRecord has_many :merge_requests has_many :events, as: :target, dependent: :delete_all # rubocop:disable Cop/ActiveRecordDependent - has_many :issue_milestones - has_many :merge_request_milestones - scope :of_projects, ->(ids) { where(project_id: ids) } scope :of_groups, ->(ids) { where(group_id: ids) } scope :active, -> { with_state(:active) } diff --git a/app/services/users/create_service.rb b/app/services/users/create_service.rb index 2ac6dfd90fa..ec8b3cea664 100644 --- a/app/services/users/create_service.rb +++ b/app/services/users/create_service.rb @@ -11,12 +11,19 @@ module Users def execute(skip_authorization: false) user = Users::BuildService.new(current_user, params).execute(skip_authorization: skip_authorization) + reset_token = user.generate_reset_token if user.recently_sent_password_reset? - @reset_token = user.generate_reset_token if user.recently_sent_password_reset? - - notify_new_user(user, @reset_token) if user.save + after_create_hook(user, reset_token) if user.save user end + + private + + def after_create_hook(user, reset_token) + notify_new_user(user, reset_token) + end end end + +Users::CreateService.prepend_if_ee('EE::Users::CreateService') |