Skip to content

Instantly share code, notes, and snippets.

@robzolkos
Created May 19, 2011 02:17
Show Gist options
  • Save robzolkos/980044 to your computer and use it in GitHub Desktop.
Save robzolkos/980044 to your computer and use it in GitHub Desktop.
spec for organisations, categories, products
it "association test should work for organisations, categories, products" do
@orga = Factory.create(:organisation, :id=>1, :title=>"abc")
@orgb = Factory.create(:organisation, :id=>2, :title=>"abc")
@cata = Factory.create(:category, :title=>"design")
@catb = Factory.create(:category, :title=>"web design")
@catc = Factory.build(:category, :title=>"web")
@product1 = Factory.create(:product, :id=>1, :title=>"xxx", :categories=>[@cata, @catb], :organisation=>@orga)
@product2 = Factory.create(:product, :id=>2, :title=>"yyy", :categories=>[@catc, @cata], :organisation=>@orga)
@product3 = Factory.create(:product, :id=>3, :title=>"zzz", :categories=>[@catb], :organisation=>@orgb)
@cata.products.size.should == 2
@catb.products.size.should == 2
@product1.categories.should == [@cata, @catb]
@product2.categories.should == [@catc, @cata]
@orga.products.size.should == 2
@orga.categories.size.should == 3
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment