Commit 8aac79be authored by Marcel Amirault's avatar Marcel Amirault Committed by Rémy Coutable

Update time_helper.rb to fix output for exact minutes.

parent 7407efe1
...@@ -5,9 +5,13 @@ module TimeHelper ...@@ -5,9 +5,13 @@ module TimeHelper
seconds = interval_in_seconds - minutes * 60 seconds = interval_in_seconds - minutes * 60
if minutes >= 1 if minutes >= 1
"#{pluralize(minutes, "minute")} #{pluralize(seconds, "second")}" if seconds % 60 == 0
pluralize(minutes, "minute")
else else
"#{pluralize(seconds, "second")}" [pluralize(minutes, "minute"), pluralize(seconds, "second")].to_sentence
end
else
pluralize(seconds, "second")
end end
end end
......
...@@ -4,10 +4,12 @@ describe TimeHelper do ...@@ -4,10 +4,12 @@ describe TimeHelper do
describe "#time_interval_in_words" do describe "#time_interval_in_words" do
it "returns minutes and seconds" do it "returns minutes and seconds" do
intervals_in_words = { intervals_in_words = {
100 => "1 minute 40 seconds", 60 => "1 minute",
100.32 => "1 minute 40 seconds", 100 => "1 minute and 40 seconds",
121 => "2 minutes 1 second", 100.32 => "1 minute and 40 seconds",
3721 => "62 minutes 1 second", 120 => "2 minutes",
121 => "2 minutes and 1 second",
3721 => "62 minutes and 1 second",
0 => "0 seconds" 0 => "0 seconds"
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment