FIX: Category description topics shouldn't auto-close
This commit is contained in:
parent
df7b24b14a
commit
abed146cc7
|
@ -151,6 +151,7 @@ SQL
|
|||
def create_category_definition
|
||||
t = Topic.new(title: I18n.t("category.topic_prefix", category: name), user: user, pinned_at: Time.now, category_id: id)
|
||||
t.skip_callbacks = true
|
||||
t.auto_close_days = nil
|
||||
t.save!
|
||||
update_column(:topic_id, t.id)
|
||||
t.posts.create(raw: post_template, user: user)
|
||||
|
|
|
@ -605,7 +605,7 @@ class Topic < ActiveRecord::Base
|
|||
# TODO: change this method, along with category's auto_close_days. Use hours.
|
||||
def auto_close_days=(num_days)
|
||||
@ignore_category_auto_close = true
|
||||
set_auto_close(num_days * 24)
|
||||
set_auto_close( num_days ? num_days * 24 : nil)
|
||||
end
|
||||
|
||||
def self.auto_close
|
||||
|
|
|
@ -210,6 +210,11 @@ describe Category do
|
|||
@category.topic_url.should be_present
|
||||
end
|
||||
|
||||
it "should not set its description topic to auto-close" do
|
||||
category = Fabricate(:category, name: 'Closing Topics', auto_close_days: 1)
|
||||
category.topic.auto_close_at.should be_nil
|
||||
end
|
||||
|
||||
describe "creating a new category with the same slug" do
|
||||
it "should have a blank slug" do
|
||||
Fabricate(:category, name: "Amazing Categóry").slug.should be_blank
|
||||
|
|
|
@ -1067,6 +1067,22 @@ describe Topic do
|
|||
end
|
||||
end
|
||||
|
||||
describe "auto_close_days=" do
|
||||
subject(:topic) { Fabricate.build(:topic) }
|
||||
|
||||
it 'can take a number' do
|
||||
Timecop.freeze(Time.zone.now) do
|
||||
topic.auto_close_days = 2
|
||||
topic.auto_close_at.should be_within_one_second_of(2.days.from_now)
|
||||
end
|
||||
end
|
||||
|
||||
it 'can take nil' do
|
||||
topic.auto_close_days = nil
|
||||
topic.auto_close_at.should be_nil
|
||||
end
|
||||
end
|
||||
|
||||
describe 'set_auto_close' do
|
||||
let(:topic) { Fabricate.build(:topic) }
|
||||
let(:closing_topic) { Fabricate.build(:topic, auto_close_days: 5) }
|
||||
|
|
Loading…
Reference in New Issue