mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Rubocop: Auto-correct Style/EmptyLineBetweenDefs offences
This commit is contained in:
@@ -520,12 +520,6 @@ Style/EmptyElse:
|
||||
- 'app/models/spreadsheet_entry.rb'
|
||||
- 'app/serializers/api/admin/basic_order_cycle_serializer.rb'
|
||||
|
||||
# Offense count: 73
|
||||
# Cop supports --auto-correct.
|
||||
# Configuration parameters: AllowAdjacentOneLineDefs, NumberOfEmptyLines.
|
||||
Style/EmptyLineBetweenDefs:
|
||||
Enabled: false
|
||||
|
||||
# Offense count: 287
|
||||
# Cop supports --auto-correct.
|
||||
Style/EmptyLines:
|
||||
|
||||
@@ -52,7 +52,6 @@ module Admin
|
||||
@owner_email = @enterprise_group.andand.owner.andand.email || ""
|
||||
end
|
||||
|
||||
|
||||
def collection
|
||||
EnterpriseGroup.by_position
|
||||
end
|
||||
|
||||
@@ -4,7 +4,6 @@ module Admin
|
||||
"#{controller_name.classify}".constantize
|
||||
end
|
||||
|
||||
|
||||
# URL helpers
|
||||
def new_object_url(options = {})
|
||||
if parent_data.present?
|
||||
|
||||
@@ -12,7 +12,6 @@ module Admin
|
||||
def index
|
||||
end
|
||||
|
||||
|
||||
def bulk_update
|
||||
# Ensure we're authorised to update all variant overrides
|
||||
@vo_set.collection.each { |vo| authorize! :update, vo }
|
||||
|
||||
@@ -24,7 +24,6 @@ class ApplicationController < ActionController::Base
|
||||
params[:action].to_sym
|
||||
end
|
||||
|
||||
|
||||
def require_distributor_chosen
|
||||
unless @distributor = current_distributor
|
||||
redirect_to spree.root_path
|
||||
@@ -62,7 +61,6 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# All render calls within the block will be performed with the specified format
|
||||
# Useful for rendering html within a JSON response, particularly if the specified
|
||||
# template or partial then goes on to render further partials without specifying
|
||||
|
||||
@@ -123,7 +123,6 @@ class CheckoutController < Spree::CheckoutController
|
||||
false
|
||||
end
|
||||
|
||||
|
||||
def update_failed
|
||||
clear_ship_address
|
||||
respond_to do |format|
|
||||
|
||||
@@ -28,7 +28,6 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def set_included_tax
|
||||
if params[:tax_rate_id].present?
|
||||
tax_rate = TaxRate.find params[:tax_rate_id]
|
||||
|
||||
@@ -273,7 +273,6 @@ Spree::Admin::ReportsController.class_eval do
|
||||
render_report(@report.header, @report.table, params[:csv], "xero_invoices_#{timestamp}.csv")
|
||||
end
|
||||
|
||||
|
||||
def render_report(header, table, create_csv, csv_file_name)
|
||||
unless create_csv
|
||||
render :html => table
|
||||
|
||||
@@ -31,7 +31,6 @@ Spree::OrdersController.class_eval do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
@insufficient_stock_lines = []
|
||||
@order = order_to_update
|
||||
@@ -71,7 +70,6 @@ Spree::OrdersController.class_eval do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def populate
|
||||
# Without intervention, the Spree::Adjustment#update_adjustable callback is called many times
|
||||
# during cart population, for both taxation and enterprise fees. This operation triggers a
|
||||
@@ -99,7 +97,6 @@ Spree::OrdersController.class_eval do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Report the stock levels in the order for all variant ids requested
|
||||
def stock_levels(order, variant_ids)
|
||||
stock_levels = li_stock_levels(order)
|
||||
|
||||
@@ -11,7 +11,6 @@ module ApplicationHelper
|
||||
form_for(name, *(args << options.merge(:builder => AngularFormBuilder)), &block)
|
||||
end
|
||||
|
||||
|
||||
# Pass URL helper calls on to spree where applicable so that we don't need to use
|
||||
# spree.foo_path in any view rendered from non-spree-namespaced controllers.
|
||||
def method_missing(method, *args, &block)
|
||||
|
||||
@@ -80,7 +80,6 @@ module CheckoutHelper
|
||||
available_countries.map { |c| [c.name, c.id] }
|
||||
end
|
||||
|
||||
|
||||
def validated_input(name, path, args = {})
|
||||
attributes = {
|
||||
required: true,
|
||||
|
||||
@@ -43,7 +43,6 @@ module OrderCyclesHelper
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def order_cycle_options
|
||||
@order_cycles.
|
||||
with_distributor(current_distributor).
|
||||
|
||||
@@ -6,17 +6,14 @@ module Spree
|
||||
"(#{Spree::Money.new(variant.price).to_s})"
|
||||
end
|
||||
|
||||
|
||||
def product_has_variant_unit_option_type?(product)
|
||||
product.option_types.any? { |option_type| variant_unit_option_type? option_type }
|
||||
end
|
||||
|
||||
|
||||
def variant_unit_option_type?(option_type)
|
||||
Spree::Product.all_variant_unit_option_types.include? option_type
|
||||
end
|
||||
|
||||
|
||||
def product_variant_unit_options
|
||||
[['Weight', 'weight'],
|
||||
['Volume', 'volume'],
|
||||
|
||||
@@ -12,7 +12,6 @@ Spree::BaseMailer.class_eval do
|
||||
'test@example.com'
|
||||
end
|
||||
|
||||
|
||||
def roadie_options
|
||||
# This lets us specify assets using relative paths in email templates
|
||||
super.merge(url_options: {host: URI(spree.root_url).host })
|
||||
|
||||
@@ -61,7 +61,6 @@ class EnterpriseRelationship < ActiveRecord::Base
|
||||
relatives
|
||||
end
|
||||
|
||||
|
||||
def permissions_list=(perms)
|
||||
if perms.nil?
|
||||
permissions.destroy_all
|
||||
|
||||
@@ -115,7 +115,6 @@ class OrderCycle < ActiveRecord::Base
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
def clone!
|
||||
oc = self.dup
|
||||
oc.name = "COPY OF #{oc.name}"
|
||||
|
||||
@@ -240,7 +240,6 @@ class AbilityDecorator
|
||||
can [:admin, :index, :update, :destroy], Customer, enterprise_id: Enterprise.managed_by(user).pluck(:id)
|
||||
end
|
||||
|
||||
|
||||
def add_relationship_management_abilities(user)
|
||||
can [:admin, :index, :create], EnterpriseRelationship
|
||||
can [:destroy], EnterpriseRelationship do |enterprise_relationship|
|
||||
|
||||
@@ -61,7 +61,6 @@ module Spree
|
||||
[Spree::TaxRate.order("ABS(amount - #{approximation})").first]
|
||||
end
|
||||
|
||||
|
||||
def self.without_callbacks
|
||||
skip_callback :save, :after, :update_adjustable
|
||||
skip_callback :destroy, :after, :update_adjustable
|
||||
|
||||
@@ -47,7 +47,6 @@ Spree::LineItem.class_eval do
|
||||
update_attributes!(quantity: variant.on_hand) if quantity > variant.on_hand
|
||||
end
|
||||
|
||||
|
||||
def has_tax?
|
||||
adjustments.included_tax.any?
|
||||
end
|
||||
|
||||
@@ -164,7 +164,6 @@ Spree::Order.class_eval do
|
||||
line_items.each &:cap_quantity_at_stock!
|
||||
end
|
||||
|
||||
|
||||
def set_distributor!(distributor)
|
||||
self.distributor = distributor
|
||||
self.order_cycle = nil unless self.order_cycle.andand.has_distributor? distributor
|
||||
|
||||
@@ -82,7 +82,6 @@ Spree::OrderPopulator.class_eval do
|
||||
[quantity_to_add, max_quantity_to_add]
|
||||
end
|
||||
|
||||
|
||||
def cart_remove(variant_id)
|
||||
variant = Spree::Variant.find(variant_id)
|
||||
@order.remove_variant(variant)
|
||||
|
||||
@@ -13,7 +13,6 @@ module Spree::Preferences
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def get_preference(key)
|
||||
if !has_preference?(key) && has_attachment?(key)
|
||||
send key
|
||||
@@ -32,7 +31,6 @@ module Spree::Preferences
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# Spree's Configuration responds to preference methods via method_missing, but doesn't
|
||||
# override respond_to?, which consequently reports those methods as unavailable. Paperclip
|
||||
# errors if respond_to? isn't correct, so we override it here.
|
||||
@@ -41,7 +39,6 @@ module Spree::Preferences
|
||||
super(self.class.preference_getter_method(name), include_all) || super(method, include_all)
|
||||
end
|
||||
|
||||
|
||||
def has_attachment?(name)
|
||||
self.class.respond_to?(:attachment_definitions) &&
|
||||
self.class.attachment_definitions.keys.include?(name.to_sym)
|
||||
|
||||
@@ -42,7 +42,6 @@ Spree::ShippingMethod.class_eval do
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
def available_to_order_with_distributor_check?(order, display_on=nil)
|
||||
available_to_order_without_distributor_check?(order, display_on) &&
|
||||
self.distributors.include?(order.distributor)
|
||||
|
||||
@@ -70,7 +70,6 @@ Spree::Variant.class_eval do
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
def price_with_fees(distributor, order_cycle)
|
||||
price + fees_for(distributor, order_cycle)
|
||||
end
|
||||
|
||||
@@ -45,7 +45,6 @@ class VariantOverride < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def stock_overridden?
|
||||
count_on_hand.present?
|
||||
end
|
||||
|
||||
@@ -70,12 +70,10 @@ module Discourse
|
||||
@custom_fields ||= {}
|
||||
end
|
||||
|
||||
|
||||
def sign(payload)
|
||||
OpenSSL::HMAC.hexdigest("sha256", sso_secret, payload)
|
||||
end
|
||||
|
||||
|
||||
def to_url(base_url=nil)
|
||||
base = "#{base_url || sso_url}"
|
||||
"#{base}#{base.include?('?') ? '&' : '?'}#{payload}"
|
||||
|
||||
@@ -25,7 +25,6 @@ module OpenFoodNetwork
|
||||
end.select { |fee_type, amount| amount > 0 }
|
||||
end
|
||||
|
||||
|
||||
def fees_for(variant)
|
||||
per_item_enterprise_fee_applicators_for(variant).sum do |applicator|
|
||||
calculate_fee_for variant, applicator.enterprise_fee
|
||||
@@ -40,7 +39,6 @@ module OpenFoodNetwork
|
||||
end.select { |fee_type, amount| amount > 0 }
|
||||
end
|
||||
|
||||
|
||||
def create_line_item_adjustments_for(line_item)
|
||||
variant = line_item.variant
|
||||
@distributor = line_item.order.distributor
|
||||
@@ -100,7 +98,6 @@ module OpenFoodNetwork
|
||||
@indexed_enterprise_fees[variant.id] || []
|
||||
end
|
||||
|
||||
|
||||
def calculate_fee_for(variant, enterprise_fee)
|
||||
# Spree's Calculator interface accepts Orders or LineItems,
|
||||
# so we meet that interface with a struct.
|
||||
|
||||
@@ -25,7 +25,9 @@ module OpenFoodNetwork
|
||||
end
|
||||
|
||||
def valid?() true end
|
||||
|
||||
def new_record?() true end
|
||||
|
||||
def destroyed?() true end
|
||||
|
||||
def save
|
||||
@@ -37,7 +39,9 @@ module OpenFoodNetwork
|
||||
def errors
|
||||
obj = Object.new
|
||||
def obj.[](key) [] end
|
||||
|
||||
def obj.full_messages() [] end
|
||||
|
||||
def obj.any?() false end
|
||||
obj
|
||||
end
|
||||
|
||||
@@ -10,7 +10,6 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.variant_destroyed(variant, &block)
|
||||
exchanges = exchanges_featuring_variants(variant).to_a
|
||||
|
||||
@@ -21,7 +20,6 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.product_changed(product)
|
||||
exchanges_featuring_variants(product.variants).each do |exchange|
|
||||
refresh_cache exchange.receiver, exchange.order_cycle
|
||||
@@ -44,12 +42,10 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.variant_override_destroyed(variant_override)
|
||||
variant_override_changed variant_override
|
||||
end
|
||||
|
||||
|
||||
def self.producer_property_changed(producer_property)
|
||||
products = producer_property.producer.supplied_products
|
||||
variants = Spree::Variant.
|
||||
@@ -61,12 +57,10 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.producer_property_destroyed(producer_property)
|
||||
producer_property_changed producer_property
|
||||
end
|
||||
|
||||
|
||||
def self.order_cycle_changed(order_cycle)
|
||||
if order_cycle.dated? && !order_cycle.closed?
|
||||
order_cycle.exchanges.outgoing.each do |exchange|
|
||||
@@ -75,7 +69,6 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.exchange_changed(exchange)
|
||||
if exchange.incoming
|
||||
refresh_incoming_exchanges(Exchange.where(id: exchange))
|
||||
@@ -84,26 +77,22 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.exchange_destroyed(exchange)
|
||||
exchange_changed exchange
|
||||
end
|
||||
|
||||
|
||||
def self.enterprise_fee_changed(enterprise_fee)
|
||||
refresh_supplier_fee enterprise_fee
|
||||
refresh_coordinator_fee enterprise_fee
|
||||
refresh_distributor_fee enterprise_fee
|
||||
end
|
||||
|
||||
|
||||
def self.distributor_changed(enterprise)
|
||||
Exchange.cachable.where(receiver_id: enterprise).each do |exchange|
|
||||
refresh_cache exchange.receiver, exchange.order_cycle
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.inventory_item_changed(inventory_item)
|
||||
exchanges_featuring_variants(inventory_item.variant, distributor: inventory_item.enterprise).each do |exchange|
|
||||
refresh_cache exchange.receiver, exchange.order_cycle
|
||||
@@ -126,7 +115,6 @@ module OpenFoodNetwork
|
||||
exchanges
|
||||
end
|
||||
|
||||
|
||||
def self.refresh_incoming_exchanges(exchanges)
|
||||
incoming_exchanges(exchanges).map do |exchange|
|
||||
outgoing_exchanges_with_variants(exchange.order_cycle, exchange.variant_ids)
|
||||
@@ -135,26 +123,22 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.refresh_outgoing_exchange(exchange)
|
||||
if exchange.order_cycle.dated? && !exchange.order_cycle.closed?
|
||||
refresh_cache exchange.receiver, exchange.order_cycle
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.refresh_supplier_fee(enterprise_fee)
|
||||
refresh_incoming_exchanges(enterprise_fee.exchanges)
|
||||
end
|
||||
|
||||
|
||||
def self.refresh_coordinator_fee(enterprise_fee)
|
||||
enterprise_fee.order_cycles.each do |order_cycle|
|
||||
order_cycle_changed order_cycle
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.refresh_distributor_fee(enterprise_fee)
|
||||
enterprise_fee.exchange_fees.
|
||||
joins(:exchange => :order_cycle).
|
||||
@@ -167,7 +151,6 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def self.incoming_exchanges(exchanges)
|
||||
exchanges.
|
||||
incoming.
|
||||
@@ -176,14 +159,12 @@ module OpenFoodNetwork
|
||||
merge(OrderCycle.not_closed)
|
||||
end
|
||||
|
||||
|
||||
def self.outgoing_exchanges_with_variants(order_cycle, variant_ids)
|
||||
order_cycle.exchanges.outgoing.
|
||||
joins(:exchange_variants).
|
||||
where('exchange_variants.variant_id IN (?)', variant_ids)
|
||||
end
|
||||
|
||||
|
||||
def self.refresh_cache(distributor, order_cycle)
|
||||
ProductsCacheRefreshment.refresh distributor, order_cycle
|
||||
end
|
||||
|
||||
@@ -27,7 +27,6 @@ module OpenFoodNetwork::Reports
|
||||
rules.map &:to_h
|
||||
end
|
||||
|
||||
|
||||
# -- DSL
|
||||
def self.header(*columns)
|
||||
self._header = columns
|
||||
|
||||
@@ -44,7 +44,6 @@ module OpenFoodNetwork
|
||||
display_as
|
||||
end
|
||||
|
||||
|
||||
def update_units
|
||||
delete_unit_option_values
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ module Spree
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def sign_in_as_admin!
|
||||
let!(:current_api_user) do
|
||||
user = stub_model(Spree::LegacyUser)
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace :openfoodnetwork do
|
||||
Spree::User.all.reject { |u| u.email =~ /example.net/ }
|
||||
end
|
||||
|
||||
|
||||
def user_header
|
||||
["encrypted_password", "password_salt", "email", "remember_token", "persistence_token", "reset_password_token", "perishable_token", "sign_in_count", "failed_attempts", "last_request_at", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "login", "created_at", "updated_at", "authentication_token", "unlock_token", "locked_at", "remember_created_at", "reset_password_sent_at",
|
||||
|
||||
@@ -44,7 +43,6 @@ namespace :openfoodnetwork do
|
||||
"bill_address_firstname", "bill_address_lastname", "bill_address_address1", "bill_address_address2", "bill_address_city", "bill_address_zipcode", "bill_address_phone", "bill_address_state", "bill_address_country", "bill_address_created_at", "bill_address_updated_at", "bill_address_company",]
|
||||
end
|
||||
|
||||
|
||||
def user_row(user)
|
||||
sa = user.orders.last.andand.ship_address
|
||||
ba = user.orders.last.andand.bill_address
|
||||
@@ -58,7 +56,6 @@ namespace :openfoodnetwork do
|
||||
ba.andand.firstname, ba.andand.lastname, ba.andand.address1, ba.andand.address2, ba.andand.city, ba.andand.zipcode, ba.andand.phone, ba.andand.state, ba.andand.country, ba.andand.created_at, ba.andand.updated_at, ba.andand.company,]
|
||||
end
|
||||
|
||||
|
||||
def create_user_from(row)
|
||||
user = Spree::User.create!({password: 'changeme123', password_confirmation: 'changeme123', email: row[2], remember_token: row[3], persistence_token: row[4], reset_password_token: row[5], perishable_token: row[6], sign_in_count: row[7], failed_attempts: row[8], last_request_at: row[9], current_sign_in_at: row[10], last_sign_in_at: row[11], current_sign_in_ip: row[12], last_sign_in_ip: row[13], login: row[14], created_at: row[15], updated_at: row[16], authentication_token: row[17], unlock_token: row[18], locked_at: row[19], remember_created_at: row[20], reset_password_sent_at: row[21]}, without_protection: true)
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ module OpenFoodNetwork
|
||||
flush_jobs
|
||||
end
|
||||
|
||||
|
||||
# Process all pending Delayed jobs, keeping in mind jobs could spawn new
|
||||
# delayed job (so things might be added to the queue while processing)
|
||||
def flush_jobs(options = {})
|
||||
@@ -23,7 +22,6 @@ module OpenFoodNetwork
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def clear_jobs
|
||||
Delayed::Job.delete_all
|
||||
end
|
||||
|
||||
@@ -14,15 +14,19 @@ module CheckoutWorkflow
|
||||
def toggle_accordion(id)
|
||||
find("##{id} dd a").trigger "click"
|
||||
end
|
||||
|
||||
def toggle_details
|
||||
toggle_accordion :details
|
||||
end
|
||||
|
||||
def toggle_billing
|
||||
toggle_accordion :billing
|
||||
end
|
||||
|
||||
def toggle_shipping
|
||||
toggle_accordion :shipping
|
||||
end
|
||||
|
||||
def toggle_payment
|
||||
toggle_accordion :payment
|
||||
end
|
||||
|
||||
@@ -26,7 +26,6 @@ module WebHelper
|
||||
have_selector selector
|
||||
end
|
||||
|
||||
|
||||
def current_path_should_be path
|
||||
current_path = URI.parse(current_url).path
|
||||
expect(page).to have_current_path path
|
||||
@@ -47,7 +46,6 @@ module WebHelper
|
||||
page.find_by_id(from).find("option[value='#{value}']").select_option
|
||||
end
|
||||
|
||||
|
||||
def should_have_failed
|
||||
page.status_code.should == 200
|
||||
errors.count.should > 0
|
||||
|
||||
Reference in New Issue
Block a user