FIX: use the new duration attribute in `set_or_create_timer` method.
New `duration` attribute is introduced for the `set_or_create_timer` method in the commit aad12822b7
for "based on last post" and "auto delete replies" topic timers.
This commit is contained in:
parent
22d5ba0f77
commit
f6d6f1701f
|
@ -257,10 +257,14 @@ class Topic < ActiveRecord::Base
|
|||
self.category.auto_close_hours &&
|
||||
!public_topic_timer&.execute_at
|
||||
|
||||
based_on_last_post = self.category.auto_close_based_on_last_post
|
||||
duration = based_on_last_post ? self.category.auto_close_hours : nil
|
||||
|
||||
self.set_or_create_timer(
|
||||
TopicTimer.types[:close],
|
||||
self.category.auto_close_hours,
|
||||
based_on_last_post: self.category.auto_close_based_on_last_post
|
||||
based_on_last_post: based_on_last_post,
|
||||
duration: duration
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -473,8 +473,9 @@ class PostCreator
|
|||
topic_timer.duration > 0
|
||||
|
||||
@topic.set_or_create_timer(TopicTimer.types[:close],
|
||||
topic_timer.duration,
|
||||
based_on_last_post: topic_timer.based_on_last_post
|
||||
nil,
|
||||
based_on_last_post: topic_timer.based_on_last_post,
|
||||
duration: topic_timer.duration
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -367,7 +367,8 @@ describe PostCreator do
|
|||
Fabricate(:topic_timer,
|
||||
based_on_last_post: true,
|
||||
execute_at: Time.zone.now - 12.hours,
|
||||
created_at: Time.zone.now - 24.hours
|
||||
created_at: Time.zone.now - 24.hours,
|
||||
duration: 12
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -1638,7 +1638,7 @@ describe Topic do
|
|||
|
||||
it 'can take a number of hours as a string and can handle based on last post' do
|
||||
freeze_time now
|
||||
topic.set_or_create_timer(TopicTimer.types[:close], '18', by_user: admin, based_on_last_post: true)
|
||||
topic.set_or_create_timer(TopicTimer.types[:close], nil, by_user: admin, based_on_last_post: true, duration: 18)
|
||||
expect(topic.topic_timers.first.execute_at).to eq_time(18.hours.from_now)
|
||||
end
|
||||
|
||||
|
@ -1750,7 +1750,7 @@ describe Topic do
|
|||
it "should be able to override category's default auto close" do
|
||||
Jobs.run_immediately!
|
||||
|
||||
expect(topic.topic_timers.first.duration).to eq(4)
|
||||
expect(topic.topic_timers.first.execute_at).to eq_time(topic.created_at + 4.hours)
|
||||
|
||||
topic.set_or_create_timer(TopicTimer.types[:close], 2, by_user: admin)
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ describe TopicStatusUpdater do
|
|||
Fabricate(:post, topic: topic)
|
||||
|
||||
topic.set_or_create_timer(
|
||||
TopicTimer.types[:close], '10', based_on_last_post: true
|
||||
TopicTimer.types[:close], nil, based_on_last_post: true, duration: 10
|
||||
)
|
||||
|
||||
TopicStatusUpdater.new(topic, admin).update!("autoclosed", true)
|
||||
|
|
Loading…
Reference in New Issue