fixes #1396, fix tests
This commit is contained in:
@@ -7,6 +7,7 @@ class Note < ActiveRecord::Base
|
||||
before_validation :initialize_updater
|
||||
before_validation :blank_body
|
||||
validates_presence_of :post_id, :creator_id, :updater_id, :x, :y, :width, :height
|
||||
validate :coordinates_in_range, :message => "must be inside the image"
|
||||
has_many :versions, :class_name => "NoteVersion", :order => "note_versions.id ASC"
|
||||
after_save :update_post
|
||||
after_save :create_version
|
||||
@@ -95,6 +96,13 @@ class Note < ActiveRecord::Base
|
||||
self.updater_ip_addr = CurrentUser.ip_addr
|
||||
end
|
||||
|
||||
def coordinates_in_range
|
||||
if x < 0 || y < 0 || (x > post.image_width) || (y > post.image_height)
|
||||
self.errors.add(:coordinates, "must be inside the image")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
def post_must_not_be_note_locked
|
||||
if is_locked?
|
||||
errors.add :post, "is note locked"
|
||||
|
||||
@@ -104,11 +104,7 @@ class Tag < ActiveRecord::Base
|
||||
Post.raw_tag_match(name).find_each do |post|
|
||||
post.reload
|
||||
post.set_tag_counts
|
||||
post.update_column(:tag_count, post.tag_count)
|
||||
post.update_column(:tag_count_general, post.tag_count_general)
|
||||
post.update_column(:tag_count_artist, post.tag_count_artist)
|
||||
post.update_column(:tag_count_copyright, post.tag_count_copyright)
|
||||
post.update_column(:tag_count_character, post.tag_count_character)
|
||||
Post.update_all({:tag_count => post.tag_count, :tag_count_general => post.tag_count_general, :tag_count_artist => post.tag_count_artist, :tag_count_copyright => post.tag_count_copyright, :tag_count_character => post.tag_count_character}, {:id => post.id})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user