fix tests

This commit is contained in:
Albert Yi
2018-05-09 11:56:01 -07:00
parent 81d94dbab9
commit 99012ff342
13 changed files with 33 additions and 12 deletions

View File

@@ -54,6 +54,6 @@ class BansController < ApplicationController
permitted_params = %i[reason duration expires_at]
permitted_params += %i[user_id user_name] if context == :create
params.require(:ban).permit(permitted_params)
params.fetch(:ban, {}).permit(permitted_params)
end
end

View File

@@ -1,7 +1,7 @@
module DelayedJobsHelper
def print_name(job)
case job.name
when "PostKeeperManager.check_and_update"
when "PostKeeperManager.check_and_assign"
"<strong>update post tagger</strong>"
when "Tag.increment_post_counts"
@@ -71,7 +71,7 @@ module DelayedJobsHelper
def print_handler(job)
case job.name
when "PostKeeperManager.check_and_update"
when "PostKeeperManager.check_and_assign"
""
when "Tag.increment_post_counts", "Tag.decrement_post_counts"

View File

@@ -15,6 +15,11 @@ class PostKeeperManager
end
def self.check_and_update(post, updater_id = nil, increment_tags = nil)
check_and_assign(post, updater_id, increment_tags)
post.update_column(:keeper_data, post.keeper_data)
end
def self.check_and_assign(post, updater_id = nil, increment_tags = nil)
post = Post.find(post) unless post.is_a?(Post)
keeper_id = check(post, updater_id, increment_tags)
post.keeper_data = {uid: keeper_id}

View File

@@ -255,8 +255,8 @@ class Dmail < ApplicationRecord
end
def mark_as_read!
update_column(:is_read, true)
owner.dmails.unread.count.tap do |unread_count|
update_column(:is_read, true)
owner.update(has_mail: (unread_count > 0), unread_dmail_count: unread_count)
end
end

View File

@@ -564,7 +564,7 @@ class Post < ApplicationRecord
if PostKeeperManager.enabled? && persisted?
# no need to do this check on the initial create
PostKeeperManager.check_and_update(self, CurrentUser.id, increment_tags)
PostKeeperManager.check_and_assign(self, CurrentUser.id, increment_tags)
# run this again async to check for race conditions
PostKeeperManager.queue_check(self, CurrentUser.id)