Skip to content

Commit

Permalink
skip Heart#validate_user validation when importing from vote_on_issue…
Browse files Browse the repository at this point in the history
…s plugin
  • Loading branch information
nishidayuya committed Nov 5, 2024
1 parent 1455710 commit a358fa4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/models/heart.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ class Heart < (defined?(ApplicationRecord) == 'constant' ? ApplicationRecord : A
belongs_to :heartable, :polymorphic => true
belongs_to :user

attribute :skip_validate_user, :boolean

validates_presence_of :user
validates_uniqueness_of :user_id, :scope => [:heartable_type, :heartable_id]
validate :validate_user
validate :validate_user, :unless => :skip_validate_user

def self.of_projects(*args)
projects = args.size > 0 ? args.shift : Project.none
Expand Down
1 change: 1 addition & 0 deletions lib/tasks/redmine_hearts.rake
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace :redmine_hearts do
:user => user,
:created_at => datetime,
:updated_at => datetime,
:skip_validate_user => true,
)
end
end
Expand Down

0 comments on commit a358fa4

Please sign in to comment.