mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 16:11:08 +08:00
add tests for ListController.best_period_for
This commit is contained in:
@ -215,4 +215,31 @@ describe ListController do
|
||||
end
|
||||
end
|
||||
|
||||
describe "best_period_for" do
|
||||
|
||||
it "returns yearly for more than 180 days" do
|
||||
ListController.best_period_for(nil).should == :yearly
|
||||
ListController.best_period_for(180.days.ago).should == :yearly
|
||||
end
|
||||
|
||||
it "returns monthly when less than 180 days and more than 35 days" do
|
||||
(35...180).each do |date|
|
||||
ListController.best_period_for(date.days.ago).should == :monthly
|
||||
end
|
||||
end
|
||||
|
||||
it "returns weekly when less than 35 days and more than 8 days" do
|
||||
(8...35).each do |date|
|
||||
ListController.best_period_for(date.days.ago).should == :weekly
|
||||
end
|
||||
end
|
||||
|
||||
it "returns daily when less than 8 days" do
|
||||
(0...8).each do |date|
|
||||
ListController.best_period_for(date.days.ago).should == :daily
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user