diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 78cda1c170..72bef1c992 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -84,22 +84,6 @@ Layout/AlignParameters: - 'spec/lib/open_food_network/user_balance_calculator_spec.rb' - 'spec/support/request/authentication_workflow.rb' -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentOneStep, IndentationWidth. -# SupportedStyles: case, end -Layout/CaseIndentation: - Exclude: - - 'app/models/enterprise.rb' - - 'app/models/product_importer.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -Layout/ClosingParenthesisIndentation: - Exclude: - - 'app/overrides/add_capture_order_shortcut.rb' - - 'spec/serializers/variant_serializer_spec.rb' - # Offense count: 8 # Cop supports --auto-correct. Layout/CommentIndentation: @@ -261,16 +245,6 @@ Layout/EmptyLines: - 'spec/support/delayed_job_helper.rb' - 'spec/support/matchers/table_matchers.rb' -# Offense count: 6 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundAccessModifier: - Exclude: - - 'app/controllers/admin/order_cycles_controller.rb' - - 'app/controllers/spree/admin/shipping_methods_controller_decorator.rb' - - 'app/helpers/angular_form_builder.rb' - - 'spec/helpers/products_helper_spec.rb' - - 'spec/support/request/web_helper.rb' - # Offense count: 66 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -362,44 +336,6 @@ Layout/EmptyLinesAroundClassBody: - 'lib/open_food_network/rack_request_blocker.rb' - 'lib/open_food_network/reports/bulk_coop_report.rb' -# Offense count: 7 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundExceptionHandlingKeywords: - Exclude: - - 'app/controllers/checkout_controller.rb' - - 'app/controllers/enterprises_controller.rb' - - 'app/controllers/shop_controller.rb' - - 'app/models/spree/adjustment_decorator.rb' - - 'app/models/spree/tax_rate_decorator.rb' - - 'lib/tasks/users.rake' - - 'spec/features/admin/overview_spec.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundMethodBody: - Exclude: - - 'app/controllers/checkout_controller.rb' - - 'app/controllers/spree/admin/reports_controller_decorator.rb' - - 'app/serializers/api/product_serializer.rb' - - 'lib/open_food_network/orders_and_fulfillments_report.rb' - -# Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines -Layout/EmptyLinesAroundModuleBody: - Exclude: - - 'app/helpers/add_to_cart_helper.rb' - - 'app/helpers/groups_helper.rb' - - 'lib/open_food_network/column_preference_defaults.rb' - - 'lib/open_food_network/group_buy_report.rb' - - 'lib/open_food_network/order_cycle_form_applicator.rb' - - 'lib/open_food_network/order_grouper.rb' - - 'lib/open_food_network/variant_and_line_item_naming.rb' - - 'spec/models/spree/ability_spec.rb' - - 'spec/support/request/distribution_helper.rb' - - 'spec/support/request/ui_component_helper.rb' - # Offense count: 55 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. @@ -443,15 +379,6 @@ Layout/ExtraSpacing: - 'spec/spec_helper.rb' - 'spec/support/request/web_helper.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. -# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstParameterIndentation: - Exclude: - - 'lib/open_food_network/permissions.rb' - - 'spec/serializers/variant_serializer_spec.rb' - # Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: SupportedStyles, IndentationWidth. @@ -459,13 +386,6 @@ Layout/FirstParameterIndentation: Layout/IndentArray: EnforcedStyle: consistent -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -Layout/IndentAssignment: - Exclude: - - 'app/controllers/spree/admin/reports_controller_decorator.rb' - # Offense count: 52 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. @@ -489,14 +409,6 @@ Layout/IndentHash: - 'spec/lib/open_food_network/order_cycle_form_applicator_spec.rb' - 'spec/support/request/authentication_workflow.rb' -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent -Layout/IndentHeredoc: - Exclude: - - 'app/models/content_configuration.rb' - # Offense count: 21 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. @@ -566,19 +478,6 @@ Layout/LeadingCommentSpace: - 'spec/support/matchers/select2_matchers.rb' - 'spec/support/request/authentication_workflow.rb' -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineArrayBraceLayout: - Exclude: - - 'lib/open_food_network/customers_report.rb' - - 'lib/open_food_network/order_cycle_management_report.rb' - - 'lib/open_food_network/orders_and_fulfillments_report.rb' - - 'lib/open_food_network/packing_report.rb' - - 'lib/open_food_network/xero_invoices_report.rb' - - 'spec/archive/features/consumer/checkout_spec.rb' - # Offense count: 44 # Cop supports --auto-correct. Layout/MultilineBlockLayout: diff --git a/app/controllers/admin/order_cycles_controller.rb b/app/controllers/admin/order_cycles_controller.rb index d46aec20b3..445e268085 100644 --- a/app/controllers/admin/order_cycles_controller.rb +++ b/app/controllers/admin/order_cycles_controller.rb @@ -106,6 +106,7 @@ module Admin protected + def collection return Enterprise.where("1=0") unless json_request? return order_cycles_from_set if params[:order_cycle_set] @@ -130,6 +131,7 @@ module Admin end private + def load_data_for_index if json_request? # Split ransack params into all those that currently exist and new ones to limit returned ocs to recent or undated diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index 31933a5138..16b5134b11 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -84,7 +84,6 @@ class CheckoutController < Spree::CheckoutController customer_bill_address_id = @order.customer.bill_address.andand.id @order.customer.update_attributes(bill_address_attributes: new_bill_address.merge('id' => customer_bill_address_id)) end - end def set_default_ship_address @@ -133,7 +132,6 @@ class CheckoutController < Spree::CheckoutController def advance_order_state(order) tries ||= 3 order.next - rescue ActiveRecord::StaleObjectError retry unless (tries -= 1).zero? false diff --git a/app/controllers/enterprises_controller.rb b/app/controllers/enterprises_controller.rb index 451e60ceb4..2b2a639b87 100644 --- a/app/controllers/enterprises_controller.rb +++ b/app/controllers/enterprises_controller.rb @@ -33,7 +33,6 @@ class EnterprisesController < BaseController begin Rails.application.routes.recognize_path( "/#{ params[:permalink].to_s }" ) render text: params[:permalink], status: 409 - rescue ActionController::RoutingError render text: params[:permalink], status: 200 end diff --git a/app/controllers/shop_controller.rb b/app/controllers/shop_controller.rb index 4634536766..a32d5d0b85 100644 --- a/app/controllers/shop_controller.rb +++ b/app/controllers/shop_controller.rb @@ -18,7 +18,6 @@ class ShopController < BaseController products_json = filter(renderer.products_json) render json: products_json - rescue OpenFoodNetwork::CachedProductsRenderer::NoProducts render status: 404, json: '' end diff --git a/app/controllers/spree/admin/reports_controller_decorator.rb b/app/controllers/spree/admin/reports_controller_decorator.rb index 20379694a8..6c16031c0b 100644 --- a/app/controllers/spree/admin/reports_controller_decorator.rb +++ b/app/controllers/spree/admin/reports_controller_decorator.rb @@ -222,7 +222,6 @@ Spree::Admin::ReportsController.class_eval do csv_file_name = "#{params[:report_type]}_#{timestamp}.csv" render_report(@report.header, @table, params[:csv], csv_file_name) - end def products_and_inventory @@ -320,9 +319,9 @@ Spree::Admin::ReportsController.class_eval do reports[:order_cycle_management][:description] = render_to_string(partial: 'order_cycle_management_description', layout: false, locals: {report_types: report_types[:order_cycle_management]}).html_safe reports[:packing][:description] = - render_to_string(partial: 'packing_description', layout: false, locals: {report_types: report_types[:packing]}).html_safe + render_to_string(partial: 'packing_description', layout: false, locals: {report_types: report_types[:packing]}).html_safe reports[:sales_tax][:description] = - render_to_string(partial: 'sales_tax_description', layout: false, locals: {report_types: report_types[:sales_tax]}).html_safe + render_to_string(partial: 'sales_tax_description', layout: false, locals: {report_types: report_types[:sales_tax]}).html_safe # Return only reports the user is authorized to view. reports.select { |action| can? action, :report } diff --git a/app/controllers/spree/admin/shipping_methods_controller_decorator.rb b/app/controllers/spree/admin/shipping_methods_controller_decorator.rb index e6b7667f9f..9b2b03cf5e 100644 --- a/app/controllers/spree/admin/shipping_methods_controller_decorator.rb +++ b/app/controllers/spree/admin/shipping_methods_controller_decorator.rb @@ -44,6 +44,7 @@ module Spree end private + def load_hubs @hubs = Enterprise.managed_by(spree_current_user).is_distributor.sort_by!{ |d| [(@shipping_method.has_distributor? d) ? 0 : 1, d.name] } end diff --git a/app/helpers/add_to_cart_helper.rb b/app/helpers/add_to_cart_helper.rb index c8e657470d..6a1eec813f 100644 --- a/app/helpers/add_to_cart_helper.rb +++ b/app/helpers/add_to_cart_helper.rb @@ -18,5 +18,4 @@ module AddToCartHelper def available_order_cycles_for(order, product) DistributionChangeValidator.new(order).available_order_cycles_for(product) end - end diff --git a/app/helpers/angular_form_builder.rb b/app/helpers/angular_form_builder.rb index 4dff1f92e1..1f1ed29550 100644 --- a/app/helpers/angular_form_builder.rb +++ b/app/helpers/angular_form_builder.rb @@ -36,6 +36,7 @@ class AngularFormBuilder < ActionView::Helpers::FormBuilder end private + def angular_name(method) "#{@object_name}[#{@fields_for_record_name}_attributes][{{ $index }}][#{method}]" end diff --git a/app/helpers/groups_helper.rb b/app/helpers/groups_helper.rb index c5de5c1ca0..7a9b782a3e 100644 --- a/app/helpers/groups_helper.rb +++ b/app/helpers/groups_helper.rb @@ -1,5 +1,4 @@ module GroupsHelper - def link_to_service(baseurl, name, html_options = {}) return if name.blank? html_options = html_options.merge target: '_blank' @@ -19,5 +18,4 @@ module GroupsHelper def strip_url(url) url.andand.sub(/^https?:\/\//i, '') end - end diff --git a/app/models/content_configuration.rb b/app/models/content_configuration.rb index dbe6aa10fd..47038bcb9e 100644 --- a/app/models/content_configuration.rb +++ b/app/models/content_configuration.rb @@ -44,12 +44,12 @@ class ContentConfiguration < Spree::Preferences::FileConfiguration preference :footer_pinterest_url, :string, default: "" preference :footer_email, :string, default: "hello@openfoodnetwork.org" preference :community_forum_url, :string, default: "http://community.openfoodnetwork.org" - preference :footer_links_md, :text, default: <<-EOS -[Newsletter sign-up](/) + preference :footer_links_md, :text, default: <<-EOS.strip_heredoc + [Newsletter sign-up](/) -[News](/) + [News](/) -[Calendar](/) + [Calendar](/) EOS preference :footer_about_url, :string, default: "http://www.openfoodnetwork.org/ofn-local/open-food-network-australia/" diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 8b0f3fe385..82618e4e2e 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -289,18 +289,18 @@ class Enterprise < ActiveRecord::Base # Map backend cases to front end cases. case cat - when "producer_sells_any" - :producer_hub # Producer hub who sells own and others produce and supplies other hubs. - when "producer_sells_own" - :producer_shop # Producer with shopfront and supplies other hubs. - when "producer_sells_none" - :producer # Producer only supplies through others. - when "non_producer_sells_any" - :hub # Hub selling others products in order cycles. - when "non_producer_sells_own" - :hub # Wholesaler selling through own shopfront? Does this need a separate name? Should it exist? - when "non_producer_sells_none" - :hub_profile # Hub selling outside the system. + when "producer_sells_any" + :producer_hub # Producer hub who sells own and others produce and supplies other hubs. + when "producer_sells_own" + :producer_shop # Producer with shopfront and supplies other hubs. + when "producer_sells_none" + :producer # Producer only supplies through others. + when "non_producer_sells_any" + :hub # Hub selling others products in order cycles. + when "non_producer_sells_own" + :hub # Wholesaler selling through own shopfront? Does this need a separate name? Should it exist? + when "non_producer_sells_none" + :hub_profile # Hub selling outside the system. end end diff --git a/app/models/product_importer.rb b/app/models/product_importer.rb index d4b490f2c5..13fc0152da 100644 --- a/app/models/product_importer.rb +++ b/app/models/product_importer.rb @@ -364,12 +364,12 @@ class ProductImporter def assign_defaults(object, entry) @import_settings[entry['supplier_id'].to_s]['defaults'].each do |attribute, setting| case setting['mode'] - when 'overwrite_all' + when 'overwrite_all' + object.assign_attributes(attribute => setting['value']) + when 'overwrite_empty' + if object.send(attribute).blank? or (attribute == 'on_hand' and entry['on_hand_nil']) object.assign_attributes(attribute => setting['value']) - when 'overwrite_empty' - if object.send(attribute).blank? or (attribute == 'on_hand' and entry['on_hand_nil']) - object.assign_attributes(attribute => setting['value']) - end + end end end end diff --git a/app/models/spree/adjustment_decorator.rb b/app/models/spree/adjustment_decorator.rb index 4d0b8421e3..bca08752da 100644 --- a/app/models/spree/adjustment_decorator.rb +++ b/app/models/spree/adjustment_decorator.rb @@ -72,7 +72,6 @@ module Spree skip_callback :destroy, :after, :update_adjustable result = yield - ensure set_callback :save, :after, :update_adjustable set_callback :destroy, :after, :update_adjustable diff --git a/app/models/spree/tax_rate_decorator.rb b/app/models/spree/tax_rate_decorator.rb index 7126e8ac29..fd111084ce 100644 --- a/app/models/spree/tax_rate_decorator.rb +++ b/app/models/spree/tax_rate_decorator.rb @@ -51,7 +51,6 @@ module Spree calculator.calculable.included_in_price = true result = yield - ensure self.included_in_price = old_included_in_price calculator.calculable.included_in_price = old_included_in_price diff --git a/app/overrides/add_capture_order_shortcut.rb b/app/overrides/add_capture_order_shortcut.rb index b24744261e..db6947cf08 100644 --- a/app/overrides/add_capture_order_shortcut.rb +++ b/app/overrides/add_capture_order_shortcut.rb @@ -2,10 +2,10 @@ Deface::Override.new(:virtual_path => "spree/admin/orders/index", :name => "add_capture_order_shortcut", :insert_bottom => "[data-hook='admin_orders_index_row_actions']", :partial => 'spree/admin/orders/capture' - ) + ) # And align actions column (not spree standard, but looks better IMO) Deface::Override.new(:virtual_path => "spree/admin/orders/index", :name => "add_capture_order_shortcut_align", :set_attributes => "[data-hook='admin_orders_index_row_actions']", :attributes => {:class => "actions", :style => "text-align:left;"} #removes 'align-center' class - ) + ) diff --git a/app/serializers/api/product_serializer.rb b/app/serializers/api/product_serializer.rb index 1ccc46b15f..27ea6c5ed4 100644 --- a/app/serializers/api/product_serializer.rb +++ b/app/serializers/api/product_serializer.rb @@ -27,7 +27,6 @@ class Api::UncachedProductSerializer < ActiveModel::Serializer else object.master.price_with_fees(options[:current_distributor], options[:current_order_cycle]) end - end end diff --git a/lib/open_food_network/column_preference_defaults.rb b/lib/open_food_network/column_preference_defaults.rb index ec2953a823..ee28e4b2a5 100644 --- a/lib/open_food_network/column_preference_defaults.rb +++ b/lib/open_food_network/column_preference_defaults.rb @@ -1,6 +1,5 @@ module OpenFoodNetwork module ColumnPreferenceDefaults - private # NOTE: These methods define valid column names (via hash keys) diff --git a/lib/open_food_network/customers_report.rb b/lib/open_food_network/customers_report.rb index 20cbdd85e7..a84e1ce416 100644 --- a/lib/open_food_network/customers_report.rb +++ b/lib/open_food_network/customers_report.rb @@ -41,8 +41,7 @@ module OpenFoodNetwork ba.phone, order.distributor.andand.name, [da.andand.address1, da.andand.address2, da.andand.city].join(" "), - order.shipping_method.andand.name - ] + order.shipping_method.andand.name] end end end diff --git a/lib/open_food_network/group_buy_report.rb b/lib/open_food_network/group_buy_report.rb index 4a52929d77..bc3ef23d8d 100644 --- a/lib/open_food_network/group_buy_report.rb +++ b/lib/open_food_network/group_buy_report.rb @@ -1,5 +1,4 @@ module OpenFoodNetwork - GroupBuyVariantRow = Struct.new(:variant, :sum_quantities, :sum_max_quantities) do def to_row [variant.product.supplier.name, variant.product.name, I18n.t('admin.reports.unitsize'), variant.options_text, variant.weight, sum_quantities, sum_max_quantities] diff --git a/lib/open_food_network/order_cycle_form_applicator.rb b/lib/open_food_network/order_cycle_form_applicator.rb index d1aca3c55f..80e68881d4 100644 --- a/lib/open_food_network/order_cycle_form_applicator.rb +++ b/lib/open_food_network/order_cycle_form_applicator.rb @@ -1,7 +1,6 @@ require 'open_food_network/order_cycle_permissions' module OpenFoodNetwork - # There are two translator classes on the boundary between Angular and Rails: On the Angular side, # there is the OrderCycle#dataForSubmit method, and on the Rails side is this class. I think data # translation is more a responsibility of Angular, so I'd be inclined to refactor this class to move diff --git a/lib/open_food_network/order_cycle_management_report.rb b/lib/open_food_network/order_cycle_management_report.rb index d3d8842d27..53310e6fe1 100644 --- a/lib/open_food_network/order_cycle_management_report.rb +++ b/lib/open_food_network/order_cycle_management_report.rb @@ -74,8 +74,7 @@ module OpenFoodNetwork order.shipping_method.andand.name, order.payments.first.andand.payment_method.andand.name, order.payments.first.amount, - OpenFoodNetwork::UserBalanceCalculator.new(order.email, order.distributor).balance - ] + OpenFoodNetwork::UserBalanceCalculator.new(order.email, order.distributor).balance] end def delivery_row(order) @@ -92,8 +91,7 @@ module OpenFoodNetwork order.payments.first.amount, OpenFoodNetwork::UserBalanceCalculator.new(order.email, order.distributor).balance, has_temperature_controlled_items?(order), - order.special_instructions - ] + order.special_instructions] end def filter_to_payment_method(orders) diff --git a/lib/open_food_network/order_grouper.rb b/lib/open_food_network/order_grouper.rb index c24d1069b8..b63b994407 100644 --- a/lib/open_food_network/order_grouper.rb +++ b/lib/open_food_network/order_grouper.rb @@ -1,5 +1,4 @@ module OpenFoodNetwork - class OrderGrouper def initialize(rules, column_constructors) @rules = rules diff --git a/lib/open_food_network/orders_and_fulfillments_report.rb b/lib/open_food_network/orders_and_fulfillments_report.rb index 94fef9bea1..1de8c3ff40 100644 --- a/lib/open_food_network/orders_and_fulfillments_report.rb +++ b/lib/open_food_network/orders_and_fulfillments_report.rb @@ -36,14 +36,12 @@ module OpenFoodNetwork I18n.t(:report_header_ship_street), I18n.t(:report_header_ship_street_2), I18n.t(:report_header_ship_city), I18n.t(:report_header_ship_postcode), I18n.t(:report_header_ship_state), I18n.t(:report_header_comments), I18n.t(:report_header_sku), I18n.t(:report_header_order_cycle), I18n.t(:report_header_payment_method), I18n.t(:report_header_customer_code), I18n.t(:report_header_tags), - I18n.t(:report_header_billing_street), I18n.t(:report_header_billing_street_2), I18n.t(:report_header_billing_city), I18n.t(:report_header_billing_postcode), I18n.t(:report_header_billing_state), - ] + I18n.t(:report_header_billing_street), I18n.t(:report_header_billing_street_2), I18n.t(:report_header_billing_city), I18n.t(:report_header_billing_postcode), I18n.t(:report_header_billing_state),] else [I18n.t(:report_header_producer), I18n.t(:report_header_product), I18n.t(:report_header_variant), I18n.t(:report_header_amount), I18n.t(:report_header_curr_cost_per_unit), I18n.t(:report_header_total_cost), I18n.t(:report_header_status), I18n.t(:report_header_incoming_transport)] end - end def search @@ -247,7 +245,8 @@ module OpenFoodNetwork proc { |line_items| line_items.first.order.bill_address.andand.address2 }, proc { |line_items| line_items.first.order.bill_address.andand.city }, proc { |line_items| line_items.first.order.bill_address.andand.zipcode }, - proc { |line_items| line_items.first.order.bill_address.andand.state } ] + proc { |line_items| line_items.first.order.bill_address.andand.state } + ] else [ proc { |line_items| line_items.first.product.supplier.name }, proc { |line_items| line_items.first.product.name }, diff --git a/lib/open_food_network/packing_report.rb b/lib/open_food_network/packing_report.rb index f43f8d73dd..4c9eb783ec 100644 --- a/lib/open_food_network/packing_report.rb +++ b/lib/open_food_network/packing_report.rb @@ -81,7 +81,8 @@ module OpenFoodNetwork { group_by: proc { |line_item| line_item.product }, sort_by: proc { |product| product.name } }, { group_by: proc { |line_item| line_item.full_name }, - sort_by: proc { |full_name| full_name } } ] + sort_by: proc { |full_name| full_name } } + ] else # supplier_rows orders # table_items = supplier_rows orders @@ -118,8 +119,7 @@ module OpenFoodNetwork proc { |line_items| line_items.first.product.name }, proc { |line_items| line_items.first.full_name }, proc { |line_items| line_items.sum { |li| li.quantity } }, - proc { |line_items| is_temperature_controlled?(line_items.first) } - ] + proc { |line_items| is_temperature_controlled?(line_items.first) }] else [ proc { |line_items| line_items.first.order.distributor.name }, diff --git a/lib/open_food_network/permissions.rb b/lib/open_food_network/permissions.rb index b745ebb1f4..d303af5681 100644 --- a/lib/open_food_network/permissions.rb +++ b/lib/open_food_network/permissions.rb @@ -69,9 +69,9 @@ module OpenFoodNetwork granted_distributors = related_enterprises_granted(:add_to_order_cycle, by: managed_enterprises.is_primary_producer) produced = Spree::Order.with_line_items_variants_and_products_outer. where( - "spree_orders.distributor_id IN (?) AND spree_products.supplier_id IN (?)", - granted_distributors, - related_enterprises_granting(:add_to_order_cycle, to: granted_distributors).merge(managed_enterprises.is_primary_producer) + "spree_orders.distributor_id IN (?) AND spree_products.supplier_id IN (?)", + granted_distributors, + related_enterprises_granting(:add_to_order_cycle, to: granted_distributors).merge(managed_enterprises.is_primary_producer) ).pluck(:id) Spree::Order.where(id: editable | produced) diff --git a/lib/open_food_network/variant_and_line_item_naming.rb b/lib/open_food_network/variant_and_line_item_naming.rb index 42c78a80dc..148dadaf67 100644 --- a/lib/open_food_network/variant_and_line_item_naming.rb +++ b/lib/open_food_network/variant_and_line_item_naming.rb @@ -6,7 +6,6 @@ require 'open_food_network/option_value_namer' module OpenFoodNetwork module VariantAndLineItemNaming - # Copied and modified from Spree::Variant def options_text values = self.option_values.joins(:option_type).order("#{Spree::OptionType.table_name}.position asc") diff --git a/lib/open_food_network/xero_invoices_report.rb b/lib/open_food_network/xero_invoices_report.rb index b491f551b2..43f278c73e 100644 --- a/lib/open_food_network/xero_invoices_report.rb +++ b/lib/open_food_network/xero_invoices_report.rb @@ -152,8 +152,7 @@ module OpenFoodNetwork '', Spree::Config.currency, '', - order.paid? ? I18n.t(:y) : I18n.t(:n) - ] + order.paid? ? I18n.t(:y) : I18n.t(:n)] end def adjustments(order) diff --git a/lib/tasks/users.rake b/lib/tasks/users.rake index b668191328..0391c2d4ae 100644 --- a/lib/tasks/users.rake +++ b/lib/tasks/users.rake @@ -75,7 +75,6 @@ namespace :openfoodnetwork do ba_country = Spree::Country.find_by_name row[43] ba = Spree::Address.create!({firstname: row[35], lastname: row[36], address1: row[37], address2: row[38], city: row[39], zipcode: row[40], phone: row[41], state: ba_state, country: ba_country, created_at: row[44], updated_at: row[45], company: row[46]}, without_protection: true) user.update_column :bill_address_id, ba.id - rescue ActiveRecord::RecordInvalid => e puts "#{row[2]} - #{e.message}" end diff --git a/script/rubocop_autocorrect b/script/rubocop_autocorrect new file mode 100755 index 0000000000..1ca248ddfa --- /dev/null +++ b/script/rubocop_autocorrect @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +COP="$1" + +bundle exec rubocop -a --only "$COP" +git add -A +git commit -m "Auto correct Rubocop's ${COP} cop" diff --git a/spec/archive/features/consumer/checkout_spec.rb b/spec/archive/features/consumer/checkout_spec.rb index 74a2443b36..da147e7b2b 100644 --- a/spec/archive/features/consumer/checkout_spec.rb +++ b/spec/archive/features/consumer/checkout_spec.rb @@ -306,8 +306,7 @@ feature %q{ within('fieldset#shipping') do [@distributor.name, @distributor.distributor_info, - @distributor.next_collection_at - ].each do |value| + @distributor.next_collection_at].each do |value| page.should have_content value end @@ -375,8 +374,7 @@ feature %q{ within('fieldset#shipping') do [@distributor_oc.name, @distributor_oc.distributor_info, - @distributor_oc.next_collection_at - ].each do |value| + @distributor_oc.next_collection_at].each do |value| page.should have_content value end diff --git a/spec/features/admin/overview_spec.rb b/spec/features/admin/overview_spec.rb index 26a7afd046..c1119a252e 100644 --- a/spec/features/admin/overview_spec.rb +++ b/spec/features/admin/overview_spec.rb @@ -132,7 +132,6 @@ feature %q{ expect(Spree::Dash::Config.configured?).to be true block.call - ensure Spree::Dash::Config.preferred_app_id = nil Spree::Dash::Config.preferred_site_id = nil diff --git a/spec/helpers/products_helper_spec.rb b/spec/helpers/products_helper_spec.rb index 22fd7f4606..812b053fb1 100644 --- a/spec/helpers/products_helper_spec.rb +++ b/spec/helpers/products_helper_spec.rb @@ -14,6 +14,7 @@ module Spree end private + def make_variant_stub(product_price, variant_price) product = double(:product, price: product_price) variant = double(:variant, product: product, price: variant_price) diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index 348f1efc1f..71e0c52eb1 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -3,7 +3,6 @@ require "cancan/matchers" require 'support/cancan_helper' module Spree - describe User do describe "broad permissions" do diff --git a/spec/serializers/variant_serializer_spec.rb b/spec/serializers/variant_serializer_spec.rb index 2df65b100e..3c6aebf6a9 100644 --- a/spec/serializers/variant_serializer_spec.rb +++ b/spec/serializers/variant_serializer_spec.rb @@ -7,7 +7,7 @@ describe Api::VariantSerializer do it "includes the expected attributes" do expect(subject.attributes.keys). to include( - :id, + :id, :name_to_display, :is_master, :count_on_hand, @@ -21,6 +21,6 @@ describe Api::VariantSerializer do :price_with_fees, :product_name, :tag_list # Used to apply tag rules - ) + ) end end diff --git a/spec/support/request/distribution_helper.rb b/spec/support/request/distribution_helper.rb index a35c4d0c61..7a565cb2b9 100644 --- a/spec/support/request/distribution_helper.rb +++ b/spec/support/request/distribution_helper.rb @@ -1,6 +1,5 @@ module OpenFoodNetwork module DistributionHelper - def select_distribution(distributor, order_cycle=nil) create_enterprise_group_for distributor visit root_path diff --git a/spec/support/request/ui_component_helper.rb b/spec/support/request/ui_component_helper.rb index 873e933f36..1203a50222 100644 --- a/spec/support/request/ui_component_helper.rb +++ b/spec/support/request/ui_component_helper.rb @@ -1,5 +1,4 @@ module UIComponentHelper - def browse_as_medium page.driver.resize(1024, 768) end diff --git a/spec/support/request/web_helper.rb b/spec/support/request/web_helper.rb index e95d02ede7..5e1712b131 100644 --- a/spec/support/request/web_helper.rb +++ b/spec/support/request/web_helper.rb @@ -199,6 +199,7 @@ module WebHelper end private + def wait_for_ajax wait_until { page.evaluate_script("$.active") == 0 } end