spec/profitbricks/model_spec.rb in profitbricks-0.9.9 vs spec/profitbricks/model_spec.rb in profitbricks-1.0.0

- old
+ new

@@ -9,10 +9,14 @@ end class ModelBelongsToTest < Profitbricks::Model belongs_to :model_has_many_test end + + class ModelBelongsToWithClassNameTest < Profitbricks::Model + belongs_to :undefined_model, :class_name => :model_test + end end describe Profitbricks::Model do it "should define an attribute correclty" do mt = Profitbricks::ModelTest.new({:name => 'Test'}) @@ -41,28 +45,21 @@ mt = Profitbricks::ModelBelongsToTest.new( :model_has_many_test => {:name => 'One'} ) mt.model_has_many_test.class.should == Profitbricks::ModelHasManyTest mt.model_has_many_test.name.should == 'One' end + it "should create a belongs_to association with class_name correclty" do + mt = Profitbricks::ModelBelongsToWithClassNameTest.new( :undefined_model => {:name => 'One'} ) + mt.undefined_model.class.should == Profitbricks::ModelTest + mt.undefined_model.name.should == 'One' + end + it "should raise an LoadError exception" do lambda { module Profitbricks class Profitbricks::InvalidAssociation < Profitbricks::Model belongs_to :non_existant end end }.should raise_error(LoadError) - end - describe "get_xml_and_update_attributes" do - it "should execute update_attributes correclty" do - mt = Profitbricks::ModelTest.new({:name => 'Test', :camel_case => 'works'}) - xml = mt.get_xml_and_update_attributes({:name => 'Test2', :camel_case => 'fails?'}, [:name, :camel_case]) - xml.should == "<camelCase>fails?</camelCase><modelTestName>Test2</modelTestName>" - mt.name.should == 'Test2' - mt.camel_case.should == 'fails?' - end - it "should work as class method" do - xml = Profitbricks::ModelTest.get_xml_and_update_attributes({:name => 'Test2', :camel_case => 'fails?'}, [:name, :camel_case]) - xml.should == "<camelCase>fails?</camelCase><modelTestName>Test2</modelTestName>" - end end end \ No newline at end of file