Created
October 24, 2011 14:34
-
-
Save HeroicEric/1309172 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Given /^the custom taxons and custom products exist$/ do | |
taxonomy = Taxonomy.find_by_name('Categories') | |
root = taxonomy.root | |
clothing_taxon = taxonomy.taxons.create(:name => 'Clothing', :parent_id => root.id) | |
bags_taxon = taxonomy.taxons.create(:name => 'Bags', :parent_id => root.id) | |
mugs_taxon = taxonomy.taxons.create(:name => 'Mugs', :parent_id => root.id) | |
taxonomy = Taxonomy.find_by_name('Brand') | |
root = taxonomy.root | |
taxon = taxonomy.taxons.create(:name => "Ruby on Rails", :parent_id => root.id) | |
products_to_be_made = [ | |
{ :name => "Ruby on Rails Ringer T-shirt", :price => "17.99" }, | |
{ :name => "Ruby on Rails Mug", :price => "13.99" }, | |
{ :name => "Ruby on Rails Tote", :price => "15.99" }, | |
{ :name => "Ruby on Rails Bag", :price => "22.99" }, | |
{ :name => "Ruby on Rails Baseball Jersey", :price => "19.99" }, | |
{ :name => "Ruby on Rails Stein", :price => "16.99" }, | |
{ :name => "Ruby on Rails Jr. Spaghetti", :price => "19.99" } | |
] | |
product_to_be_made.each do |product_attributes| | |
product = Factory( | |
:product, | |
:name => product_attributes["name"], | |
:price => product_attributes["price"] | |
) | |
product.taxons << taxon | |
product.taxons << clothing_taxon | |
end | |
taxon = taxonomy.taxons.create(:name => "Ruby", :parent_id => root.id) | |
product = Factory(:product, :name => "Ruby Baseball Jersey", :price => "19.99") | |
product.taxons << taxon | |
product.taxons << clothing_taxon | |
taxon = taxonomy.taxons.create(:name => "Apache", :parent_id => root.id) | |
product = Factory(:product, :name => "Apache Baseball Jersey", :price => "19.99") | |
product.taxons << taxon | |
product.taxons << clothing_taxon | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment