Set shipping address from distributor, fix zone init in checkout spec

This commit is contained in:
Rohan Mitchell
2012-06-27 09:06:18 +10:00
parent 340259eb2a
commit c5270d6fa1
2 changed files with 20 additions and 15 deletions

View File

@@ -17,20 +17,18 @@ Spree::Order.class_eval do
# before_validation :shipping_address_from_distributor
before_validation :shipping_address_from_distributor
private
# def shipping_address_from_distributor
# if distributor
# ship_address.firstname = bill_address.firstname
# ship_address.lastname = bill_address.lastname
# ship_address.phone = bill_address.phone
def shipping_address_from_distributor
if distributor
self.ship_address = distributor.pickup_address.clone
# ship_address.address1 = distributor.pickup_address
# ship_address.city = distributor.city
# ship_address.zipcode = distributor.post_code
# ship_address.state = distributor.state
# ship_address.country_id = distributor.country_id
# end
# end
if bill_address
self.ship_address.firstname = bill_address.firstname
self.ship_address.lastname = bill_address.lastname
self.ship_address.phone = bill_address.phone
end
end
end
end

View File

@@ -10,11 +10,18 @@ feature %q{
background do
@distributor = create(:distributor, :name => 'Edible garden',
:pickup_address => create(:address, :address1 => '12 Bungee Rd', :city => 'Carion'),
:pickup_times => 'Tuesday, 4 PM')
:pickup_address => create(:address,
:address1 => '12 Bungee Rd',
:city => 'Carion',
:zipcode => 3056,
:state => Spree::State.find_by_name('Victoria'),
:country => Spree::Country.find_by_name('Australia')),
:pickup_times => 'Tuesday, 4 PM')
@product = create(:product, :name => 'Fuji apples', :distributors => [@distributor])
@zone = create(:zone)
c = Spree::Country.find_by_name('Australia')
Spree::ZoneMember.create(:zoneable => c, :zone => @zone)
create(:shipping_method, zone: @zone)
create(:payment_method)
end