Sha256: 70943ef548690522712e46b260312b6802e373ecc14cde6539e16dcc3aba7bf2
Contents?: true
Size: 1.38 KB
Versions: 2
Compression:
Stored size: 1.38 KB
Contents
require 'spec_helper' describe "ActiveRecord behaviors" do describe "a temporary ActiveRecord model created with with_model that has a named_scope" do before do class RegularModel < ActiveRecord::Base named_scope :title_is_foo, :conditions => {:title => 'foo'} end RegularModel.connection.drop_table(RegularModel.table_name) rescue nil RegularModel.connection.create_table(RegularModel.table_name) do |t| t.string 'title' t.text 'content' t.timestamps end end after do RegularModel.connection.drop_table(@model.table_name) rescue nil end with_model :blog_post do table do |t| t.string 'title' t.text 'content' t.timestamps end model do named_scope :title_is_foo, :conditions => {:title => 'foo'} end end describe "the named scope" do it "should work like a regular named scope" do included = RegularModel.create!(:title => 'foo', :content => "Include me!") excluded = RegularModel.create!(:title => 'bar', :content => "Include me!") RegularModel.title_is_foo.should == [included] included = BlogPost.create!(:title => 'foo', :content => "Include me!") excluded = BlogPost.create!(:title => 'bar', :content => "Include me!") BlogPost.title_is_foo.should == [included] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
with_model-0.1.1 | spec/active_record_behaviors_spec.rb |
with_model-0.1 | spec/active_record_behaviors_spec.rb |