Skip to content

Instantly share code, notes, and snippets.

@lmarburger
Created June 25, 2009 10:35
Show Gist options
  • Save lmarburger/135781 to your computer and use it in GitHub Desktop.
Save lmarburger/135781 to your computer and use it in GitHub Desktop.
class Video < ActiveRecord::Base
default_scope :order => 'id DESC'
named_scope :processed, :conditions => { :processed => true }
named_scope :unprocessed, :conditions => { :processed => false }
end
context 'Given videos' do
setup do
# Add some processed and unprocessed videos to the database.
[ :uploaded_video, :processed_video ].each do |factory_type|
3.times { Factory(factory_type) }
end
end
should 'sort newest videos first' do
Video.all.should == Video.all(:order => 'id DESC')
end
should 'retrieve processed videos' do
Video.processed.should == Video.all(:conditions => { :processed => true })
end
should 'retrieve unprocessed videos' do
Video.unprocessed.should == Video.all(:conditions => { :processed => false })
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment