Permalink
Browse files

added test for pings less than 30min in freq

  • Loading branch information...
sabman committed Aug 30, 2008
1 parent b2fb99d commit ab7f9d536a71f45ac25adcea30555858ba603aa6
Showing with 210 additions and 5 deletions.
  1. +186 −0 log/merb_test.log
  2. +24 −5 spec/models/resource_spec.rb
View
@@ -421,3 +421,189 @@ Wed, 27 Aug 2008 13:28:21 GMT ~ info ~ Logfile created
~ Connecting to database...
~ Compiling routes...
~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
+ ~ Loaded TEST Environment...
+ ~ loading gem 'merb_activerecord' ...
+ ~ loading gem 'activerecord' ...
+ ~ Connecting to database...
+ ~ Compiling routes...
+ ~ Using 'share-nothing' cookie sessions (4kb limit per client)
@@ -11,6 +11,16 @@ def valid_attributes
:tag => "blog"
}
end
+ def invalid_attributes
+ {
+ :name => "",
+ :url => "http:",
+ :changesURL => "htt.example.com/changes.xml",
+ :rssURL => "htt.com/feed",
+ :tag => "blog"
+ }
+ end
+
end
describe Resource do
@@ -31,24 +41,33 @@ def valid_attributes
Resource.count - count_before == 1
end
- it "should update a resource when pinged" do
+ it "should update a pinged resource that was last updated > 30min" do
res = Resource.create(valid_attributes)
last_updated_at = (Time.now - 1810)
- puts "last updated at: #{last_updated_at}" # check last updated at
+ puts "\nlast updated: #{last_updated_at}" # check last updated at
Resource.record_timestamps = false # don't forget to reset to true
res.update_attributes(:updated_at => last_updated_at)
- puts "before #{res.updated_at}" # check updated at was correctly set
+ puts "before ping: #{res.updated_at}" # check updated at was correctly set
Resource.record_timestamps = true
Resource.check_spam_from_json(valid_attributes)
res = Resource.find_by_url(valid_attributes[:url])
- res.updated_at > last_updated_at
- puts "after #{res.updated_at}" # check the new time stamp has a diff of atleast 30min
+ res.updated_at > (last_updated_at)
+ puts "after ping: #{res.updated_at}" # check the new time stamp has a diff of atleast 30min
end
+
+ it "should not update a pinged resource that was last updated < 30min ago" do
+ res = Resource.create(valid_attributes)
+ last_updated_at = res.updated_at
+ Resource.check_spam_from_json(valid_attributes)
+ res = Resource.find_by_url(valid_attributes[:url])
+ res.updated_at == (last_updated_at)
+ end
+
end
end

0 comments on commit ab7f9d5

Please sign in to comment.