spree/spree — pull request #2793 by futhr (2013-03-31 08:45:08+00:00)
Title: Cleaner factories with build test.

**Simplification/refactor of the FactoryGirl factories:**

- Major clean up of all factories to more readable format.

- `:address` now has aliases `:bill_address` and `:ship_address` mostly intended for internal associations but can be used to improve readability for new specs.

- Added a simple test *(placed it in spec/models/ together with ability_spec.rb)* for factories build that revealed following before any changes was made:

```
1) FactoryGirl factories with factory for :line_item_adjustment
Failure/Error: subject { build(factory.name) }
ActiveRecord::RecordInvalid:
Validation failed: Calculator can't be blank
# ./spec/models/factory_spec.rb:6:in `block (4 levels) in '

2) FactoryGirl factories with factory for :tax_rate
Failure/Error: is_valid.should be_true, subject.errors.full_messages.join(',')
Calculator can't be blank
# ./spec/models/factory_spec.rb:10:in `block (4 levels) in '
```

- Fixed above by adding valid calculator build association based on `Spree::Calculator::DefaultTax`

- Factory `:custom_product` had `association :taxons` with error: `Factory not registered: taxons`. *I just commented it out instead of removing it*.

- Removed factory `:tax_category_with_rates` because it was not used in **any** tests and also triggered validation failure.

- Extracted all use of `Faker` to `factories.rb` as a common library, `Faker` its actually only used very few times now except from within `sample/db/samples`.

**Notes:**

- I tested with `bash ./build.sh` to make sure my changes pass all tests.

- The calculators builds needs further investigation -they pass now -but failed before.

- `match_none match_one match_all` are set to `nil` in the factory but they `boolean` in the model?. *But I didn't change this because it might be a reason for it.*