Skip to content

Commit

Permalink
Add test to ensure it works with named_scopes.
Browse files Browse the repository at this point in the history
  • Loading branch information
radar committed Jul 1, 2009
1 parent db90ffb commit dcfc7c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions spec/by_star_spec.rb
Expand Up @@ -352,6 +352,12 @@ def size(*args)
end
end

describe "named_scopes" do
it "should be compatible" do
Event.private.by_year(nil, :field => "start_time").size.should eql(1)
end
end


describe "nested find" do

Expand Down
7 changes: 5 additions & 2 deletions spec/fixtures/models.rb
Expand Up @@ -12,7 +12,7 @@ class Tag < ActiveRecord::Base
end

class Event < ActiveRecord::Base

named_scope :private, :conditions => { :public => false }
end

## seed data:
Expand Down Expand Up @@ -63,5 +63,8 @@ class Event < ActiveRecord::Base
Event.create(:name => "Today", :start_time => Time.zone.now)
Event.create(:name => "Yesterday", :start_time => Time.zone.now - 1.day)
Event.create(:name => "Tomorrow", :start_time => Time.zone.now + 1.day)

# For by_weekend test
Event.create(:name => "1st of August", :start_time => "01-08-#{Time.zone.now.year}".to_time)
Event.create(:name => "1st of August", :start_time => "01-08-#{Time.zone.now.year}".to_time)

Event.create(:name => "FBI meeting", :start_time => "02-03-#{Time.zone.now.year}".to_time, :public => false)
1 change: 1 addition & 0 deletions spec/fixtures/schema.rb
Expand Up @@ -17,6 +17,7 @@
create_table :events, :force => true do |t|
t.datetime :start_time, :end_time
t.string :name
t.boolean :public, :default => true
end

end

0 comments on commit dcfc7c9

Please sign in to comment.