spec/octopus/model_spec.rb in ar-octopus-0.7.0 vs spec/octopus/model_spec.rb in ar-octopus-0.8.0

- old
+ new

@@ -235,21 +235,18 @@ it "should work with persisted objects" do u = User.using(:brazil).create(:name => "Mike") User.using(:brazil).find_by_name("Mike").should == u end - if Octopus.rails31? || Octopus.rails32? - # Rails <= 3.0 doesn't support equality checks on non-persisted objects - it "should check current_shard when determining equality" do - canada1.should_not == brazil1 - canada1.should == canada1_dup - end + it "should check current_shard when determining equality" do + canada1.should_not == brazil1 + canada1.should == canada1_dup + end - it "delegates equality check on scopes" do - u = User.using(:brazil).create!(:name => "Mike") - User.using(:brazil).where(:name => "Mike").should == [u] - end + it "delegates equality check on scopes" do + u = User.using(:brazil).create!(:name => "Mike") + User.using(:brazil).where(:name => "Mike").should == [u] end end end describe "using a postgresql shard" do @@ -373,27 +370,25 @@ @user.touch(:created_at) @user.reload.created_at.to_date.should eq(Date.today) end end - if Octopus.rails32? - describe "#pluck" do - before { User.using(:brazil).create!(:name => "User1") } + describe "#pluck" do + before { User.using(:brazil).create!(:name => "User1") } - it "should works from scope proxy" do - names = User.using(:brazil).pluck(:name) - names.should eq(["User1"]) - User.using(:master).pluck(:name).should eq([]) - end + it "should works from scope proxy" do + names = User.using(:brazil).pluck(:name) + names.should eq(["User1"]) + User.using(:master).pluck(:name).should eq([]) end + end - it "update_column" do - @user = User.using(:brazil).create!(:name => "User1") - @user2 = User.using(:brazil).find(@user.id) - @user2.update_column(:name, "Joaquim Shard Brazil") - User.using(:brazil).find_by_name("Joaquim Shard Brazil").should_not be_nil - end + it "update_column" do + @user = User.using(:brazil).create!(:name => "User1") + @user2 = User.using(:brazil).find(@user.id) + @user2.update_column(:name, "Joaquim Shard Brazil") + User.using(:brazil).find_by_name("Joaquim Shard Brazil").should_not be_nil end it "update_attributes" do @user = User.using(:brazil).create!(:name => "User1") @user2 = User.using(:brazil).find(@user.id) @@ -417,10 +412,21 @@ @user2 = User.using(:brazil).find(@user.id) @user2.update_attribute(:name, "Joaquim") User.using(:brazil).find_by_name("Joaquim").should_not be_nil end + it "as_json" do + ActiveRecord::Base.include_root_in_json = false + + Octopus.using(:brazil) do + User.create!(:name => "User1") + end + + user = User.using(:brazil).where(:name => "User1").first + user.as_json(:except => [:created_at, :updated_at, :id]).should eq({"admin"=>nil, "name"=>"User1", "number"=>nil}) + end + it "transaction" do u = User.create!(:name => "Thiago") User.using(:brazil).count.should == 0 User.using(:master).count.should == 1 @@ -480,14 +486,12 @@ it 'should work correctly with a block' do Cheese.using(:brazil).create!(:name => "YUMMMYYYY") end end - if Octopus.rails32? - describe "when using table_name=" do - it 'should work correctly' do - Ham.using(:brazil).create!(:name => "YUMMMYYYY") - end + describe "when using table_name=" do + it 'should work correctly' do + Ham.using(:brazil).create!(:name => "YUMMMYYYY") end end describe "when using a environment with a single adapter" do it 'should not clean the table name' do