Fix invalid query syntax when `CategoryCustomField#value` is blank.
This commit is contained in:
parent
663d78414b
commit
7a2bf8e368
|
@ -388,9 +388,10 @@ class Category < ActiveRecord::Base
|
|||
|
||||
def self.auto_bump_topic!
|
||||
bumped = false
|
||||
|
||||
auto_bumps = CategoryCustomField
|
||||
.where(name: Category::NUM_AUTO_BUMP_DAILY)
|
||||
.where('value::int > 0')
|
||||
.where('NULLIF(value, \'\')::int > 0')
|
||||
.pluck(:category_id)
|
||||
|
||||
if (auto_bumps.length > 0)
|
||||
|
@ -399,6 +400,7 @@ class Category < ActiveRecord::Base
|
|||
break if bumped
|
||||
end
|
||||
end
|
||||
|
||||
bumped
|
||||
end
|
||||
|
||||
|
|
|
@ -734,6 +734,11 @@ describe Category do
|
|||
category.auto_bump_limiter.clear!
|
||||
expect(Category.auto_bump_topic!).to eq(true)
|
||||
expect(Topic.where(bumped_at: time).count).to eq(1)
|
||||
|
||||
category.num_auto_bump_daily = ""
|
||||
category.save!
|
||||
|
||||
expect(Category.auto_bump_topic!).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue