mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Display distributor information on checkout address page
This commit is contained in:
@@ -17,7 +17,7 @@ module Spree
|
||||
|
||||
def initialize_country
|
||||
self.pickup_address ||= Address.new
|
||||
self.pickup_address.country = Country.find_by_id(Spree::Config[:default_country_id])
|
||||
self.pickup_address.country = Country.find_by_id(Spree::Config[:default_country_id]) if self.pickup_address.new_record?
|
||||
end
|
||||
|
||||
def set_unused_address_fields
|
||||
|
||||
@@ -14,7 +14,7 @@ module Spree
|
||||
|
||||
def initialize_country
|
||||
self.address ||= Address.new
|
||||
self.address.country = Country.find_by_id(Spree::Config[:default_country_id])
|
||||
self.address.country = Country.find_by_id(Spree::Config[:default_country_id]) if self.address.new_record?
|
||||
end
|
||||
|
||||
def set_unused_address_fields
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
Deface::Override.new(:virtual_path => "spree/checkout/_address",
|
||||
:replace => "[data-hook='shipping_fieldset_wrapper']",
|
||||
:partial => "spree/checkout/distributor",
|
||||
:name => "drop_off_point")
|
||||
|
||||
:name => "delivery_address")
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
%td= @distributor.email
|
||||
%tr
|
||||
%th Pickup address:
|
||||
%td= render 'spree/admin/shared/address', :address => @distributor.pickup_address
|
||||
%td= render 'spree/shared/address', :address => @distributor.pickup_address
|
||||
%tr
|
||||
%th Pickup times:
|
||||
%td= @distributor.pickup_times
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
%td= @supplier.description
|
||||
%tr
|
||||
%th Address:
|
||||
%td= render 'spree/admin/shared/address', :address => @supplier.address
|
||||
%td= render 'spree/shared/address', :address => @supplier.address
|
||||
%tr
|
||||
%th Email:
|
||||
%td= @supplier.email
|
||||
|
||||
@@ -1,5 +1,23 @@
|
||||
.columns.omega.six
|
||||
%fieldset{:id => 'shipping'}
|
||||
%legend Collection Point
|
||||
=form.collection_select("distributor_id", Spree::Distributor.all, :id, :name, {}, {:class => 'required'})
|
||||
%fieldset#shipping
|
||||
%legend Distributor
|
||||
%h2= @order.distributor.name
|
||||
%p
|
||||
%strong Address:
|
||||
%br/
|
||||
= render 'spree/shared/address', :address => @order.distributor.pickup_address
|
||||
%p
|
||||
%strong Pickup times:
|
||||
%br/
|
||||
= @order.distributor.pickup_times
|
||||
%p
|
||||
%strong Contact:
|
||||
%br/
|
||||
= @order.distributor.contact
|
||||
%br/
|
||||
= "Phone: #{@order.distributor.phone}"
|
||||
%br/
|
||||
= "Email: #{@order.distributor.email}"
|
||||
%p= @order.distributor.description
|
||||
%p= link_to @order.distributor.url, @order.distributor.url if @order.distributor.url
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ FactoryGirl.define do
|
||||
phone "1000100100"
|
||||
description 'The creator'
|
||||
email 'alan@somewhere.com'
|
||||
url 'http://example.com'
|
||||
pickup_times "Whenever you're free"
|
||||
pickup_address { Spree::Address.first || FactoryGirl.create(:address) }
|
||||
end
|
||||
|
||||
@@ -9,62 +9,66 @@ feature %q{
|
||||
include WebHelper
|
||||
|
||||
background do
|
||||
@distributor1 = create(:distributor, :name => 'Eaterprises')
|
||||
@distributor2 = create(:distributor, :name => 'Edible garden',
|
||||
:pickup_address => '12 Bungee Rd',
|
||||
:city => 'Carion',
|
||||
@distributor = create(:distributor, :name => 'Edible garden',
|
||||
:pickup_address => create(:address, :address1 => '12 Bungee Rd', :city => 'Carion'),
|
||||
:pickup_times => 'Tuesday, 4 PM')
|
||||
@product = create(:product, :name => 'Fuji apples')
|
||||
@product = create(:product, :name => 'Fuji apples', :distributors => [@distributor])
|
||||
|
||||
@zone = create(:zone)
|
||||
create(:zone_member, zone: @zone, zoneable: Spree::Country.find_by_name('Australia'))
|
||||
create(:shipping_method, zone: @zone)
|
||||
create(:payment_method)
|
||||
end
|
||||
|
||||
context "Given I am buying a product", :js => true do
|
||||
scenario "I should be able choose a distributor to pick up from", :skip => true do
|
||||
login_to_consumer_section
|
||||
|
||||
click_link 'Fuji apples'
|
||||
click_button 'Add To Cart'
|
||||
click_link 'Checkout'
|
||||
scenario "buying a product", :js => true do
|
||||
login_to_consumer_section
|
||||
|
||||
fill_in_fields('order_bill_address_attributes_firstname' => 'Joe',
|
||||
'order_bill_address_attributes_lastname' => 'Luck',
|
||||
'order_bill_address_attributes_address1' => '19 Sycamore Lane',
|
||||
'order_bill_address_attributes_city' => 'Horse Hill',
|
||||
'order_bill_address_attributes_zipcode' => '3213',
|
||||
'order_bill_address_attributes_phone' => '12999911111')
|
||||
click_link 'Fuji apples'
|
||||
click_button 'Add To Cart'
|
||||
click_link 'Checkout'
|
||||
|
||||
fill_in_fields('order_bill_address_attributes_firstname' => 'Joe',
|
||||
'order_bill_address_attributes_lastname' => 'Luck',
|
||||
'order_bill_address_attributes_address1' => '19 Sycamore Lane',
|
||||
'order_bill_address_attributes_city' => 'Horse Hill',
|
||||
'order_bill_address_attributes_zipcode' => '3213',
|
||||
'order_bill_address_attributes_phone' => '12999911111')
|
||||
|
||||
select('Australia', :from => 'order_bill_address_attributes_country_id')
|
||||
select('Victoria', :from => 'order_bill_address_attributes_state_id')
|
||||
select('Australia', :from => 'order_bill_address_attributes_country_id')
|
||||
select('Victoria', :from => 'order_bill_address_attributes_state_id')
|
||||
|
||||
select('Edible garden', :from => 'order_distributor_id')
|
||||
within('fieldset#shipping') do
|
||||
[@distributor.name,
|
||||
@distributor.pickup_address.address1,
|
||||
@distributor.pickup_address.city,
|
||||
@distributor.pickup_address.zipcode,
|
||||
@distributor.pickup_address.state_text,
|
||||
@distributor.pickup_address.country.name,
|
||||
@distributor.pickup_times,
|
||||
@distributor.contact,
|
||||
@distributor.phone,
|
||||
@distributor.email,
|
||||
@distributor.description,
|
||||
@distributor.url].each do |value|
|
||||
|
||||
# within('.distributor-details') do
|
||||
# page.should have_content('12 Bungee Rd')
|
||||
# page.should have_content('Carion')
|
||||
# page.should have_content('Tuesday, 4 PM')
|
||||
# end
|
||||
|
||||
click_button 'Save and Continue'
|
||||
#display delivery details?
|
||||
|
||||
click_button 'Save and Continue'
|
||||
fill_in 'card_number', :with => '4111111111111111'
|
||||
select('1', :from => 'payment_source_1_month')
|
||||
select("#{DateTime.now.year + 1}", :from => 'payment_source_1_year')
|
||||
fill_in 'card_code', :with => '234'
|
||||
|
||||
click_button 'Save and Continue'
|
||||
|
||||
page.should have_content('Your order has been processed successfully')
|
||||
# page.should have_content('Your order will be available on:')
|
||||
# page.should have_content('On Tuesday, 4 PM')
|
||||
# page.should have_content('12 Bungee Rd, Carion')
|
||||
page.should have_content value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
click_button 'Save and Continue'
|
||||
#display delivery details?
|
||||
|
||||
click_button 'Save and Continue'
|
||||
fill_in 'card_number', :with => '4111111111111111'
|
||||
select('1', :from => 'payment_source_1_month')
|
||||
select("#{DateTime.now.year + 1}", :from => 'payment_source_1_year')
|
||||
fill_in 'card_code', :with => '234'
|
||||
|
||||
click_button 'Save and Continue'
|
||||
|
||||
page.should have_content('Your order has been processed successfully')
|
||||
# page.should have_content('Your order will be available on:')
|
||||
# page.should have_content('On Tuesday, 4 PM')
|
||||
# page.should have_content('12 Bungee Rd, Carion')
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user