Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Spree Upgrade] Merging master into 2-0-stable (3rd run in Feb2019) #3524

Merged
merged 64 commits into from
Feb 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
8750310
Bump dalli from 2.7.2 to 2.7.9
dependabot-support Jan 29, 2019
dbfcbc6
Apply import defaults to variants of new products
mkllnk Feb 1, 2019
7c5b430
Test execution of BulkInvoiceService#start_pdf_job
mkllnk Feb 6, 2019
d97fa60
Remove code duplication and test PDF creation
mkllnk Feb 6, 2019
3aea16e
Cover alternative invoice template with specs
mkllnk Feb 6, 2019
4a3e5f1
Print supplier name on invoice
mkllnk Feb 6, 2019
2d0df7f
Update app/controllers/spree/admin/orders_controller_decorator.rb
luisramos0 Feb 6, 2019
5ee3dbf
Re-use renderer object
mkllnk Feb 6, 2019
492b1c9
Bump rspec-rails from 3.8.1 to 3.8.2
dependabot-support Feb 7, 2019
72cd053
Bump spinjs-rails from 1.3 to 1.4
dependabot-support Feb 7, 2019
5582160
Add localizeCurrency filter to admin and inject currencyConfig data
Matt-Yorkley Feb 7, 2019
f9ea939
Use localizeCurrency filter in subscriptions
Matt-Yorkley Feb 7, 2019
3dc75c8
Delete empty controller class eval and spec. Useless left overs from …
luisramos0 Feb 8, 2019
a876c2a
Address timing issues in enterprise roles specs
kristinalim Feb 11, 2019
0fc9ead
Bump i18n-js from 3.1.0 to 3.2.1
dependabot-support Feb 12, 2019
06ba518
Add flat rate calculator traits to related factories
kristinalim Jan 11, 2019
0212454
Refactor SQL result summarizer for report
kristinalim Jan 16, 2019
e550be9
Add test for using order-based exchange fees
kristinalim Jan 11, 2019
8f65bee
Clarify method name in report scope
kristinalim Jan 16, 2019
c4801aa
Fix Fee Calc on Transfer Through and Tax Category
kristinalim Jan 16, 2019
7a76355
Separate summarizing of SQL data by source
kristinalim Jan 22, 2019
373e3e1
Simplify name of SQL data summarizer class
kristinalim Jan 22, 2019
b9c144b
Prepare to change AssociatedEnterpriseFee to module
kristinalim Jan 23, 2019
664943a
Include UsingEnterpriseFee instead of inheriting
kristinalim Jan 23, 2019
bc95560
Add descriptions for data representation classes
kristinalim Jan 23, 2019
ddc788e
Move data representation translations to class
kristinalim Jan 23, 2019
5e8a336
Initialize data representation classes with data
kristinalim Jan 23, 2019
bda5eb1
Merge pull request #3337 from kristinalim/feature-enterprise_fees_rep…
sauloperez Feb 12, 2019
a36dc13
Add issue templates for tech debt
mkllnk Feb 13, 2019
612ea4c
Simplify spec of invoice creation
mkllnk Feb 13, 2019
5f5b0aa
Simplify specs with stripe factory
mkllnk Feb 13, 2019
87abfcd
Simplify shopping spec
mkllnk Feb 14, 2019
9058729
Merge pull request #3459 from openfoodfoundation/dependabot/bundler/r…
mkllnk Feb 14, 2019
71b24ba
Updating translations for config/locales/ca.yml
Transifex-Openfoodnetwork Feb 8, 2019
1956857
Updating translations for config/locales/es.yml
Transifex-Openfoodnetwork Feb 8, 2019
a71c89f
Updating translations for config/locales/en_GB.yml
Transifex-Openfoodnetwork Feb 8, 2019
0a885af
Merge pull request #3481 from mkllnk/simplify-stripe-creation-in-specs
sauloperez Feb 14, 2019
af95e38
Move check for table presence out of helper
kristinalim Feb 14, 2019
34020f7
Merge pull request #3377 from openfoodfoundation/dependabot/bundler/i…
sauloperez Feb 14, 2019
43fff8f
Merge pull request #3460 from openfoodfoundation/dependabot/bundler/s…
sauloperez Feb 14, 2019
6f2b894
Merge pull request #3403 from openfoodfoundation/dependabot/bundler/d…
sauloperez Feb 14, 2019
7c5e58d
Bump bugsnag from 4.1.0 to 5.5.0
dependabot-support Feb 14, 2019
0c5cc23
Fix hash merge for recording already created products by name
Matt-Yorkley Feb 3, 2019
d4589cc
Merge pull request #3444 from mkllnk/3437-supplier-name-on-invoice
mkllnk Feb 15, 2019
0a39178
Merge pull request #3470 from kristinalim/fix/3426-intermittent_spec_…
sauloperez Feb 15, 2019
93c6271
Merge pull request #3500 from openfoodfoundation/dependabot/bundler/b…
sauloperez Feb 15, 2019
9bf5531
Updating translations for config/locales/nb.yml
Transifex-Openfoodnetwork Feb 15, 2019
ed7015a
Bump selenium-webdriver from 3.12.0 to 3.141.0
dependabot-support Feb 15, 2019
f5df10f
Merge pull request #3507 from openfoodfoundation/dependabot/bundler/s…
sauloperez Feb 18, 2019
9705c24
Sanitize no-parsable BOM characters inserted by Excel
Matt-Yorkley Feb 15, 2019
ae4d36b
Merge pull request #3451 from Matt-Yorkley/subs/currency
mkllnk Feb 18, 2019
b7abb72
Merge pull request #3462 from luisramos0/delete-api-order-ctrl
mkllnk Feb 19, 2019
be59a8c
Merge pull request #3434 from Matt-Yorkley/pi/fix_hash_merge
mkllnk Feb 19, 2019
1b45033
Merge pull request #3506 from Matt-Yorkley/pi/parse_bom
mkllnk Feb 19, 2019
bb4d42e
Merge pull request #3464 from openfoodfoundation/transifex
mkllnk Feb 19, 2019
0a50a74
Updating translations for config/locales/en_US.yml
Transifex-Openfoodnetwork Feb 19, 2019
f0a6f5a
Merge pull request #3514 from openfoodfoundation/transifex
mkllnk Feb 19, 2019
9688fe7
Updating translations for config/locales/fr.yml
Transifex-Openfoodnetwork Feb 19, 2019
7e59132
Updating translations for config/locales/en_GB.yml
Transifex-Openfoodnetwork Feb 19, 2019
e7e2d1d
Merge pull request #3516 from openfoodfoundation/transifex
mkllnk Feb 19, 2019
aba4d74
Updating translations for config/locales/fr_CA.yml
Transifex-Openfoodnetwork Feb 20, 2019
ec26948
Merge pull request #3521 from openfoodfoundation/transifex
mkllnk Feb 20, 2019
34acaa4
Merge pull request #3425 from mkllnk/2783-product-importer-spec
luisramos0 Feb 20, 2019
5d51ad7
Merge branch 'master' into 2-0-stable-Feb20
luisramos0 Feb 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/ISSUE_TEMPLATE/tech-debt-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
name: Tech debt template
about: File a refactoring task that aids future development
title: ''
labels: tech debt
assignees: ''

---

### What we should change and why (this is tech debt)
<!-- The use of X changed and part y is now redundant. We can remove it and... -->



### Context
<!-- This came up in PR #3451#issuecomment-461616636. -->



### Impact and timeline
<!-- Example: This simplifies the upgrade to Spree 3 and should be done after upgrading to Spree 2. -->
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }
gem 'rails', '~> 3.2.22'
gem 'rails-i18n', '~> 3.0.0'
gem 'i18n', '~> 0.6.11'
gem 'i18n-js', '~> 3.1.0'
gem 'i18n-js', '~> 3.2.1'

# Patched version. See http://rubysec.com/advisories/CVE-2015-5312/.
gem 'nokogiri', '>= 1.6.7.1'
Expand Down
20 changes: 10 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ GEM
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
blockenspiel (0.5.0)
bugsnag (4.1.0)
bugsnag (5.5.0)
builder (3.0.4)
byebug (9.0.6)
cancan (1.6.10)
Expand Down Expand Up @@ -251,7 +251,7 @@ GEM
css_parser (1.6.0)
addressable
daemons (1.3.1)
dalli (2.7.2)
dalli (2.7.9)
database_cleaner (0.7.1)
db2fog (0.9.0)
activerecord (>= 3.2.0, < 5.0)
Expand Down Expand Up @@ -293,7 +293,7 @@ GEM
faraday (0.15.4)
multipart-post (>= 1.2, < 3)
ffaker (1.22.1)
ffi (1.9.25)
ffi (1.10.0)
figaro (1.1.1)
thor (~> 0.14)
fission (0.5.0)
Expand Down Expand Up @@ -489,8 +489,8 @@ GEM
httparty (0.16.2)
multi_xml (>= 0.5.2)
i18n (0.6.11)
i18n-js (3.1.0)
i18n (>= 0.6.6, < 2)
i18n-js (3.2.1)
i18n (>= 0.6.6)
immigrant (0.3.6)
activerecord (>= 3.0)
io-like (0.3.0)
Expand Down Expand Up @@ -660,7 +660,7 @@ GEM
rspec-mocks (3.8.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-rails (3.8.1)
rspec-rails (3.8.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
Expand Down Expand Up @@ -692,9 +692,9 @@ GEM
select2-rails (3.4.9)
sass-rails
thor (~> 0.14)
selenium-webdriver (3.12.0)
selenium-webdriver (3.141.0)
childprocess (~> 0.5)
rubyzip (~> 1.2)
rubyzip (~> 1.2, >= 1.2.2)
shellany (0.0.1)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
Expand All @@ -705,7 +705,7 @@ GEM
simplecov-html (0.10.2)
skylight (1.7.2)
activesupport (>= 3.0.0)
spinjs-rails (1.3)
spinjs-rails (1.4)
rails (>= 3.1)
spreadsheet (1.1.7)
ruby-ole (>= 1.0)
Expand Down Expand Up @@ -812,7 +812,7 @@ DEPENDENCIES
guard-rspec (~> 4.7.3)
haml
i18n (~> 0.6.11)
i18n-js (~> 3.1.0)
i18n-js (~> 3.2.1)
immigrant
jquery-migrate-rails
jquery-rails (= 3.0.0)
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
angular.module("admin.subscriptions", ['ngResource','admin.indexUtils','admin.dropdown'])
angular.module("admin.subscriptions", ['ngResource','admin.indexUtils','admin.dropdown', 'admin.utils'])
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
angular.module("admin.utils").filter "localizeCurrency", (currencyConfig)->
# Convert number to string currency using injected currency configuration.
(amount) ->
# Set country code (eg. "US").
currency_code = if currencyConfig.display_currency then " " + currencyConfig.currency else ""
# Set decimal points, 2 or 0 if hide_cents.
decimals = if currencyConfig.hide_cents == "true" then 0 else 2
# Set format if the currency symbol should come after the number, otherwise (default) use the locale setting.
format = if currencyConfig.symbol_position == "after" then "%n %u" else undefined
# We need to use parseFloat as the amount should come in as a string.
amount = parseFloat(amount)

# Build the final price string.
I18n.toCurrency(amount, {precision: decimals, unit: currencyConfig.symbol, format: format}) + currency_code
3 changes: 2 additions & 1 deletion app/controllers/admin/product_import_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ def save_uploaded_file(upload)
directory = 'tmp/product_import'
Dir.mkdir(directory) unless File.exist?(directory)
File.open(Rails.root.join(directory, filename + extension), 'wb') do |f|
f.write(upload.read)
data = UploadSanitizer.new(upload.read).call
f.write(data)
f.path
end
end
Expand Down
10 changes: 2 additions & 8 deletions app/controllers/spree/admin/orders_controller_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ def resend
end

def invoice
pdf = render_to_string pdf: "invoice-#{@order.number}.pdf",
template: invoice_template,
formats: [:html], encoding: "UTF-8"
pdf = InvoiceRenderer.new.render_to_string(@order)

Spree::OrderMailer.invoice_email(@order.id, pdf).deliver
flash[:success] = t('admin.orders.invoice_email_sent')
Expand All @@ -65,7 +63,7 @@ def invoice
end

def print
render pdf: "invoice-#{@order.number}", template: invoice_template, encoding: "UTF-8"
render InvoiceRenderer.new.args(@order)
end

def print_ticket
Expand All @@ -78,10 +76,6 @@ def update_distribution_charge

private

def invoice_template
Spree::Config.invoice_style2? ? "spree/admin/orders/invoice2" : "spree/admin/orders/invoice"
end

def require_distributor_abn
unless @order.distributor.abn.present?
flash[:error] = t(:must_have_valid_business_number, enterprise_name: @order.distributor.name)
Expand Down
7 changes: 0 additions & 7 deletions app/controllers/spree/api/orders_controller_decorator.rb

This file was deleted.

4 changes: 4 additions & 0 deletions app/helpers/admin/injection_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ def admin_inject_column_preferences(opts={})
admin_inject_json_ams_array opts[:module], "columns", column_preferences, Api::Admin::ColumnPreferenceSerializer
end

def admin_inject_currency_config
admin_inject_json_ams 'admin.utils', "currencyConfig", {}, Api::CurrencyConfigSerializer
end

def admin_inject_enterprise_permissions
permissions =
{can_manage_shipping_methods: can?(:manage_shipping_methods, @enterprise),
Expand Down
10 changes: 9 additions & 1 deletion app/models/product_import/entry_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def save_new_product(entry)
assign_errors product.errors.full_messages, entry.line_number
end

@already_created[entry.enterprise_id] = { entry.name => product.id }
@already_created.deep_merge! entry.enterprise_id => { entry.name => product.id }
end

def save_variant(entry)
Expand Down Expand Up @@ -212,12 +212,20 @@ def assign_defaults(object, entry)
case setting['mode']
when 'overwrite_all'
object.assign_attributes(attribute => setting['value'])
# In case of new products, some attributes are saved on the variant.
# We write them to the entry here to be copied to the variant later.
if entry.respond_to? "#{attribute}="
entry.public_send("#{attribute}=", setting['value'])
end
when 'overwrite_empty'
if object.public_send(attribute).blank? ||
((attribute == 'on_hand' || attribute == 'count_on_hand') &&
entry.on_hand_nil)

object.assign_attributes(attribute => setting['value'])
if entry.respond_to? "#{attribute}="
entry.public_send("#{attribute}=", setting['value'])
end
end
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/ insert_before "div#wrapper"

= admin_inject_currency_config
12 changes: 2 additions & 10 deletions app/services/bulk_invoice_service.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class BulkInvoiceService
include WickedPdf::PdfHelper
attr_reader :id

def initialize
Expand All @@ -11,10 +10,7 @@ def start_pdf_job(order_ids)
orders = Spree::Order.where(id: order_ids)

orders.each do |order|
invoice = renderer.render_to_string pdf: "invoice-#{order.number}.pdf",
template: invoice_template,
formats: [:html], encoding: "UTF-8",
locals: { :@order => order }
invoice = renderer.render_to_string(order)

pdf << CombinePDF.parse(invoice)
end
Expand Down Expand Up @@ -42,11 +38,7 @@ def directory
end

def renderer
ApplicationController.new
end

def invoice_template
Spree::Config.invoice_style2? ? "spree/admin/orders/invoice2" : "spree/admin/orders/invoice"
@renderer ||= InvoiceRenderer.new
end

def file_directory
Expand Down
29 changes: 29 additions & 0 deletions app/services/invoice_renderer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
class InvoiceRenderer
def render_to_string(order)
renderer.render_to_string(args(order))
end

def args(order)
{
pdf: "invoice-#{order.number}.pdf",
template: invoice_template,
formats: [:html],
encoding: "UTF-8",
locals: { :@order => order }
}
end

private

def renderer
ApplicationController.new
end

def invoice_template
if Spree::Config.invoice_style2?
"spree/admin/orders/invoice2"
else
"spree/admin/orders/invoice"
end
end
end
18 changes: 18 additions & 0 deletions app/services/upload_sanitizer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Formats uploaded files to UTF-8 encoding and strips unexpected BOM characters.
# Takes an open File object as input
class UploadSanitizer
def initialize(upload)
@data = upload
end

def call
@data.force_encoding('UTF-8')
strip_bom_character
end

private

def strip_bom_character
@data.gsub("\xEF\xBB\xBF".force_encoding("UTF-8"), '')
end
end
2 changes: 1 addition & 1 deletion app/views/admin/subscriptions/_orders_panel.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
%div{ ng: { bind: "::orderCycleCloses(proxyOrder.order_cycle_id)" } }
%td.text-center
%span.state{ ng: { class: "proxyOrder.state", bind: 'stateText(proxyOrder.state)' } }
%td.text-center{ ng: { bind: '(proxyOrder.total || subscription.estimatedTotal()) | currency' } }
%td.text-center{ ng: { bind: '(proxyOrder.total || subscription.estimatedTotal()) | localizeCurrency' } }
%td.actions
%a.edit-order.icon-edit.no-text{ href: '{{::proxyOrder.edit_path}}', target: '_blank', 'ofn-with-tip' => t(:edit_order), confirm_order_edit: true }
%a.cancel-order.icon-remove.no-text{ href: 'javascript:void(0)', ng: { hide: "proxyOrder.state == 'canceled'", click: "cancelOrder(proxyOrder)" }, 'ofn-with-tip' => t(:cancel_order) }
Expand Down
8 changes: 4 additions & 4 deletions app/views/admin/subscriptions/_review.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,24 @@
.description {{ item.description }}
.not-in-open-and-upcoming-order-cycles-warning{ ng: { if: '!item.in_open_and_upcoming_order_cycles' } }
= t(".no_open_or_upcoming_order_cycle")
%td.price.align-center {{ item.price_estimate | currency }}
%td.price.align-center {{ item.price_estimate | localizeCurrency }}
%td.quantity {{ item.quantity }}
%td.total.align-center {{ (item.price_estimate * item.quantity) | currency }}
%td.total.align-center {{ (item.price_estimate * item.quantity) | localizeCurrency }}
%tbody#subtotal.no-border-top{"data-hook" => "admin_order_form_subtotal"}
%tr#subtotal-row
%td{:colspan => "3"}
%b
= t(:subtotal)
\:
%td.total.align-center
%span {{ subscription.estimatedSubtotal() | currency }}
%span {{ subscription.estimatedSubtotal() | localizeCurrency }}
%tbody#order-total.grand-total.no-border-top{"data-hook" => "admin_order_form_total"}
%tr
%td{:colspan => "3"}
%b
= t(:order_total_price)
\:
%td.total.align-center
%span#order_form_total {{ subscription.estimatedTotal() | currency }}
%span#order_form_total {{ subscription.estimatedTotal() | localizeCurrency }}
%p.notice
= t "this_is_an_estimate", scope: 'admin.subscriptions.subscription_line_items'
10 changes: 5 additions & 5 deletions app/views/admin/subscriptions/_subscription_line_items.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
.description {{ item.description }}
.not-in-open-and-upcoming-order-cycles-warning{ ng: { if: '!item.in_open_and_upcoming_order_cycles' } }
= t(".not_in_open_and_upcoming_order_cycles_warning")
%td.price.align-center {{ item.price_estimate | currency }}
%td.price.align-center {{ item.price_estimate | localizeCurrency }}
%td.quantity
%input{ name: 'quantity', type: 'number', min: 0, ng: { model: 'item.quantity' } }
%td.total.align-center {{ (item.price_estimate * item.quantity) | currency }}
%td.total.align-center {{ (item.price_estimate * item.quantity) | localizeCurrency }}
%td.actions
%a.delete-item.icon-trash.no-text{ ng: { click: 'removeSubscriptionLineItem(item)'}, :href => "javascript:void(0)" }
%tbody#subtotal.no-border-top{"data-hook" => "admin_order_form_subtotal"}
Expand All @@ -32,7 +32,7 @@
= t(:subtotal)
\:
%td.total.align-center
%span#order_subtotal {{ subscription.estimatedSubtotal() | currency }}
%span#order_subtotal {{ subscription.estimatedSubtotal() | localizeCurrency }}
%td.actions
%tbody#fees.no-border-top{ ng: { show: "subscription.estimatedFees() > 0" } }
%tr#fees-row
Expand All @@ -41,7 +41,7 @@
= t(:fees)
\:
%td.total.align-center
%span#order_fees {{ subscription.estimatedFees() | currency }}
%span#order_fees {{ subscription.estimatedFees() | localizeCurrency }}
%td.actions
%tbody#order-total.grand-total.no-border-top{"data-hook" => "admin_order_form_total"}
%tr
Expand All @@ -50,7 +50,7 @@
= t(:order_total_price)
\:
%td.total.align-center
%span#order_form_total {{ subscription.estimatedTotal() | currency }}
%span#order_form_total {{ subscription.estimatedTotal() | localizeCurrency }}
%td.actions
%p.notice
= t ".this_is_an_estimate"
3 changes: 3 additions & 0 deletions app/views/spree/admin/orders/_invoice_table.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
%tr
%td
= render 'spree/shared/line_item_name', line_item: item
%br
%small
%em= raw(item.variant.product.supplier.name)
%td{:align => "right"}
= item.quantity
%td{:align => "right"}
Expand Down
3 changes: 3 additions & 0 deletions app/views/spree/admin/orders/_invoice_table2.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
%tr
%td
= render 'spree/shared/line_item_name', line_item: item
%br
%small
%em= raw(item.variant.product.supplier.name)
%td{:align => "right"}
= item.quantity
%td{:align => "right"}
Expand Down
Loading