Merge branch 'master' into 2-0-stable-Mar29

This commit is contained in:
luisramos0
2019-04-05 15:47:46 +01:00
12 changed files with 52 additions and 25 deletions

1
.gitignore vendored
View File

@@ -33,7 +33,6 @@ public/images
public/spree
config/abr.yml
config/initializers/feature_toggle.rb
config/initializers/db2fog.rb
NERD_tree*
coverage
libpeerconnection.log

View File

@@ -20,7 +20,6 @@ Layout/AlignArray:
Exclude:
- 'lib/open_food_network/bulk_coop_report.rb'
- 'lib/open_food_network/customers_report.rb'
- 'lib/open_food_network/order_and_distributor_report.rb'
- 'lib/open_food_network/orders_and_fulfillments_report.rb'
- 'lib/open_food_network/packing_report.rb'
- 'spec/lib/open_food_network/order_grouper_spec.rb'

View File

@@ -27,7 +27,7 @@ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-0-stable'
# - Pass customer email and phone number to PayPal (merged to upstream master)
# - Change type of password from string to password to hide it in the form
gem 'spree_paypal_express', github: "openfoodfoundation/better_spree_paypal_express", branch: "2-0-stable"
gem 'stripe', '~> 4.11.0'
gem 'stripe'
# We need at least this version to have Digicert's root certificate
# which is needed for Pin Payments (and possibly others).

View File

@@ -860,7 +860,7 @@ DEPENDENCIES
spree_paypal_express!
spring (= 1.7.2)
spring-commands-rspec
stripe (~> 4.11.0)
stripe
therubyracer (= 0.12.0)
timecop
truncate_html

View File

@@ -258,6 +258,7 @@ module ProductImport
new_product = Spree::Product.new
new_product.assign_attributes(entry.attributes.except('id'))
new_product.supplier_id = entry.producer_id
entry.on_hand = 0 if entry.on_hand.nil?
if new_product.valid?
entry.validates_as = 'new_product' unless entry.errors?

View File

@@ -1,15 +0,0 @@
# Depricated: this initializer contains an invalid bucket name.
# Users of DB2fog should be able to configure DB2fog without changing the code.
#
# Name your configuration file `db2fog.rb`. It will be ignored by git.
# And it will overwrite this depricated configuration.
#
# See: https://github.com/yob/db2fog
#
# TODO: Remove this file in a future release.
DB2Fog.config = {
:aws_access_key_id => Spree::Config[:s3_access_key],
:aws_secret_access_key => Spree::Config[:s3_secret],
:directory => "db-backup_#{Spree::Config[:s3_bucket]}",
:provider => 'AWS'
}

View File

@@ -0,0 +1,7 @@
# See: https://github.com/yob/db2fog
DB2Fog.config = {
:aws_access_key_id => Spree::Config[:s3_access_key],
:aws_secret_access_key => Spree::Config[:s3_secret],
:directory => Spree::Config[:s3_bucket],
:provider => 'AWS'
}

View File

@@ -2935,6 +2935,9 @@ See the %{link} to find out more about %{sitename}'s features and to start using
title: "Distribution"
distributor: "Distributor:"
order_cycle: "Order cycle:"
line_item_adjustments: "Line Item Adjustments"
order_adjustments: "Order Adjustments"
order_total: "Order Total"
overview:
products:
active_products:

View File

@@ -10,7 +10,8 @@ module OpenFoodNetwork
end
def header
[I18n.t(:report_header_order_date),
[
I18n.t(:report_header_order_date),
I18n.t(:report_header_order_id),
I18n.t(:report_header_customer_name),
I18n.t(:report_header_customer_email),
@@ -28,7 +29,9 @@ module OpenFoodNetwork
I18n.t(:report_header_distributor_address),
I18n.t(:report_header_distributor_city),
I18n.t(:report_header_distributor_postcode),
I18n.t(:report_header_shipping_instructions)]
I18n.t(:report_header_shipping_method),
I18n.t(:report_header_shipping_instructions)
]
end
def search
@@ -95,6 +98,7 @@ module OpenFoodNetwork
order.distributor.address.address1,
order.distributor.address.city,
order.distributor.address.zipcode,
order.shipping_method.name,
order.special_instructions
]
end

View File

@@ -11,15 +11,16 @@ module OpenFoodNetwork
'Customer Name', 'Customer Email', 'Customer Phone', 'Customer City',
'SKU', 'Item name', 'Variant', 'Quantity', 'Max Quantity', 'Cost', 'Shipping Cost',
'Payment Method',
'Distributor', 'Distributor address', 'Distributor city', 'Distributor postcode', 'Shipping instructions'])
'Distributor', 'Distributor address', 'Distributor city', 'Distributor postcode', 'Shipping Method', 'Shipping instructions'])
end
context 'with completed order' do
let(:bill_address) { create(:address) }
let(:distributor) { create(:distributor_enterprise) }
let(:product) { create(:product) }
let(:shipping_method) { create(:shipping_method) }
let(:shipping_instructions) { 'pick up on thursday please!' }
let(:order) { create(:order, state: 'complete', completed_at: Time.zone.now, distributor: distributor, bill_address: bill_address, special_instructions: shipping_instructions) }
let(:order) { create(:order, state: 'complete', completed_at: Time.zone.now, distributor: distributor, bill_address: bill_address, shipping_method: shipping_method, special_instructions: shipping_instructions) }
let(:payment_method) { create(:payment_method, distributors: [distributor]) }
let(:payment) { create(:payment, payment_method: payment_method, order: order) }
let(:line_item) { create(:line_item_with_shipment, product: product, order: order) }
@@ -53,6 +54,7 @@ module OpenFoodNetwork
distributor.address.address1,
distributor.address.city,
distributor.address.zipcode,
shipping_method.name,
shipping_instructions
])
end

View File

@@ -134,6 +134,32 @@ module OpenFoodNetwork
subject.stub(:params).and_return(distributor_id: distributor.id)
subject.filter(variants).should == [product2.variants.first]
end
it "ignores variant overrides without filter" do
distributor = create(:distributor_enterprise)
product = create(:simple_product, supplier: supplier, price: 5)
variant = product.variants.first
order_cycle = create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], variants: [product.variants.first])
create(:variant_override, hub: distributor, variant: variant, price: 2)
result = subject.filter(variants)
expect(result.first.price).to eq 5
end
it "considers variant overrides with distributor" do
distributor = create(:distributor_enterprise)
product = create(:simple_product, supplier: supplier, price: 5)
variant = product.variants.first
order_cycle = create(:simple_order_cycle, suppliers: [supplier], distributors: [distributor], variants: [product.variants.first])
create(:variant_override, hub: distributor, variant: variant, price: 2)
allow(subject).to receive(:params).and_return(distributor_id: distributor.id)
result = subject.filter(variants)
expect(result.first.price).to eq 2
end
it "filters to a specific order cycle" do
distributor = create(:distributor_enterprise)
product1 = create(:simple_product, supplier: supplier)

View File

@@ -52,7 +52,7 @@ describe ProductImport::ProductImporter do
csv << ["Potatoes", "User Enterprise", "Vegetables", "6", "6.50", "2", "kg", "", "", shipping_category_id_str]
csv << ["Pea Soup", "User Enterprise", "Vegetables", "8", "5.50", "750", "ml", "", "0", shipping_category_id_str]
csv << ["Salad", "User Enterprise", "Vegetables", "7", "4.50", "1", "", "bags", "", shipping_category_id_str]
csv << ["Hot Cross Buns", "User Enterprise", "Cake", "7", "3.50", "1", "", "buns", "1", shipping_category_id_str]
csv << ["Hot Cross Buns", "User Enterprise", "Cake", nil, "3.50", "1", "", "buns", "1", shipping_category_id_str]
end
File.write('/tmp/test-m.csv', csv_data)
file = File.new('/tmp/test-m.csv')
@@ -124,7 +124,8 @@ describe ProductImport::ProductImporter do
buns = Spree::Product.find_by_name('Hot Cross Buns')
expect(buns.supplier).to eq enterprise
# buns.on_hand).to eq Infinity
expect(buns.on_hand).to eq Float::INFINITY
expect(buns.count_on_hand).to eq 0
expect(buns.price).to eq 3.50
expect(buns.unit_value).to eq 1
expect(buns.variant_unit).to eq 'items'