spree/spree — pull request #5476 by BenMorganIO (2014-10-12 12:29:48+00:00)
Title: Add taxons to prototypes

This PR is a new feature inside of Spree: The ability to add taxons to prototypes.

This was done by create a HABTM association from the taxons to the prototypes. Then, I edited the admin interface to be able to include the creation of the taxons within the prototypes. When a new product is created,

A lot of time I was creating the taxons association to the prototypes via the properties model being my example. There was a method in there, `find_all_by_prototypes` that is broken. I have removed it completely as I was not able to get it working TDD wise.

The prototypes feature spec contained CRU, but no D. I added a D to give it the full CRUD.

The method for creating the associations within the prototypes for products was called `add_properties_and_option_types_from_prototype`. Since it now does taxons, it needed some renaming. It is now called `add_associations_from_prototype`. Much nicer.

Spree::Property and Spree::Prototype did _not_ have any model specs. I also needed to be able to test the `has_many_and_belongs_to` associations, so I hooked up shoulda and made this possible. It should allow the application to increase in the number of (mostly redundant, but definitely effective) tests for validations and associations.

I also noticed the `to_param` method had a comment that said `# For #2759`. I took the liberty to make a test for this method since it did require one. It was a bug fix and shouldn't be removed. I was originally going to use `alias_method`, but it appears it would call onto `self` (or rather `Spree::Taxon`) which was kinda weird.

If you're visual, here's the before:

![screen shot 2014-10-12 at 5 28 30 am](https://cloud.githubusercontent.com/assets/3117356/4606042/6aab9fca-520b-11e4-85f8-86217154e519.png)

And the after:

![screen shot 2014-10-12 at 5 29 07 am](https://cloud.githubusercontent.com/assets/3117356/4606044/73539498-520b-11e4-8404-06a90ed59399.png)