Skip to content

Commit

Permalink
Merge pull request #771 from devton/bugs/fix_time_to_go-13594230
Browse files Browse the repository at this point in the history
use floor instead round to ignore when time_to_go calc return something ...
  • Loading branch information
diogob committed Jul 17, 2014
2 parents 195698a + 773c230 commit f80a84d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/decorators/project_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def time_to_go_for(unit)
time = 1.send(unit)

if source.expires_at.to_i >= time.from_now.to_i
time = ((source.expires_at - Time.zone.now).abs / time).round
time = ((source.expires_at - Time.zone.now).abs / time).floor
time_and_unit_attributes time, unit
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/decorators/project_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@

context "when there is more than 1 day to go" do
let(:expires_at){ Time.zone.now + 2.days }
it{ should == {time:2, unit:"dias"} }
it{ should == {time:1, unit:"dia"} }
end

context "when there is less than 1 day to go" do
let(:expires_at){ Time.zone.now + 13.hours }
it{ should == {time:13, unit:"horas"} }
it{ should == {time:12, unit:"horas"} }
end

context "when there is less than 1 hour to go" do
let(:expires_at){ Time.zone.now + 59.minutes }
it{ should == {time:59, unit:"minutos"} }
it{ should == {time:58, unit:"minutos"} }
end
end

Expand Down

0 comments on commit f80a84d

Please sign in to comment.