Skip to content

Commit

Permalink
support future date
Browse files Browse the repository at this point in the history
  • Loading branch information
guilhermesilveira committed Dec 20, 2009
1 parent 5191008 commit 3564bdf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/restfulie/server/atom_media_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def to_atom
def updated_at
last = Time.now
each do |item|
last = item.updated_at if item.respond_to? :updated_at && item.updated_at > last
last = item.updated_at if item.respond_to?(:updated_at) && item.updated_at > last
end
last
end
Expand Down
26 changes: 23 additions & 3 deletions spec/server/atom_media_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,31 @@ class City
end

context "while checking the last modified date from an array" do

class Item
def initialize(time)
@updated_at = time
end
attr_reader :updated_at
end

before do
@now = Time.now
Time.should_receive(:now).and_return(@now)
end

it "should return now if there are no items" do
now = Time.now
Time.should_receive(:now).and_return(now)
[].updated_at.should eql(now)
[].updated_at.should eql(@now)
end

it "should return now if the items dont answer to updated_at" do
["first", "second"].updated_at.should eql(@now)
end

it "should return a date in the future if an item has such date" do
[Item.new(@now + 100)].updated_at.should eql(@now+100)
end

end

end

0 comments on commit 3564bdf

Please sign in to comment.