Fix rubocop issues

This commit is contained in:
Matt-Yorkley
2020-03-21 10:54:02 +01:00
parent 7baa875a91
commit d847560d7c
3 changed files with 20 additions and 9 deletions

View File

@@ -33,7 +33,8 @@ module Admin
end
def edit
@object = Enterprise.where(permalink: params[:id]).includes(users: [:ship_address, :bill_address]).first
@object = Enterprise.where(permalink: params[:id]).
includes(users: [:ship_address, :bill_address]).first
super
end

View File

@@ -3,10 +3,10 @@ require 'open_food_network/enterprise_injection_data'
module InjectionHelper
include SerializerHelper
def inject_enterprises(enterprises = Enterprise.activated.includes(address: [:state, :country]).all)
def inject_enterprises(enterprises = nil)
inject_json_ams(
"enterprises",
enterprises,
enterprises || default_enterprise_query,
Api::EnterpriseSerializer,
enterprise_injection_data
)
@@ -41,8 +41,14 @@ module InjectionHelper
end
def inject_enterprise_and_relatives
enterprises_and_relatives = current_distributor.
relatives_including_self.
activated.
includes(address: [:state, :country]).
all
inject_json_ams "enterprises",
current_distributor.relatives_including_self.activated.includes(address: [:state, :country]).all,
enterprises_and_relatives,
Api::EnterpriseSerializer, enterprise_injection_data
end
@@ -140,6 +146,10 @@ module InjectionHelper
private
def default_enterprise_query
Enterprise.activated.includes(address: [:state, :country]).all
end
def enterprise_injection_data
@enterprise_injection_data ||= OpenFoodNetwork::EnterpriseInjectionData.new
{ data: @enterprise_injection_data }

View File

@@ -10,11 +10,11 @@ module Spree
def available_countries
checkout_zone = Zone.find_by_name(Spree::Config[:checkout_zone])
if checkout_zone && checkout_zone.kind == 'country'
countries = checkout_zone.country_list
else
countries = Country.includes(:states).all
end
countries = if checkout_zone && checkout_zone.kind == 'country'
checkout_zone.country_list
else
Country.includes(:states).all
end
countries.collect do |country|
country.name = Spree.t(country.iso, scope: 'country_names', default: country.name)