Sha256: 1407f0b02f5b1effc09f4a1f746de329af24f19cbbc129c914fd8fab54557c39
Contents?: true
Size: 1.79 KB
Versions: 5
Compression:
Stored size: 1.79 KB
Contents
require 'spec_helper' describe ConnectionManager::ReplicationBuilder do context '#database_name' do it "should return the name of the database the model is using" do Fruit.database_name.should eql('spec/cm_test.sqlite3') end end context '#other_association_options' do it "should add :class_name options set to the replication subclass if :class_name is blank" do options = Fruit.replication_association_options(:has_one, :plant, 'Slave') options[:class_name].should eql("Plant::Slave") end it "should append :class_name with the replication subclass if :class_name is not bank" do options = Fruit.replication_association_options(:has_one, :plant, 'Slave', :class_name => 'Plant') options[:class_name].should eql("Plant::Slave") end context "has_one or has_many" do it "should add the :foreign_key if the :foreign_key options is not present" do options = Fruit.replication_association_options(:has_one, :plant, 'Slave') options[:foreign_key].should eql('fruit_id') options = Fruit.replication_association_options(:has_many, :plant, 'Slave') options[:foreign_key].should eql('fruit_id') end end end context '#replication_connection_classes' do it "should return the :using array with the array elements classified and append with Connection" do Fruit.replication_connection_classes({:using => ['slave_1_test_db','slave_2_test_db']}). should eql(["Slave1TestDbConnection", "Slave2TestDbConnection"]) end end context '#replicated' do it "should raise an exception if no replication_connection_classes are found" do Fruit.stubs(:replication_connection_classes).returns([]) lambda { Fruit.replicated }.should raise_error end end end
Version data entries
5 entries across 5 versions & 1 rubygems