Fix basic rubocop issues in recently added controllers from spree_backend

This commit is contained in:
luisramos0
2019-09-17 16:12:25 +01:00
parent 2377b833ee
commit 686840e262
2 changed files with 33 additions and 22 deletions

View File

@@ -1,13 +1,12 @@
module Spree
module Admin
class GeneralSettingsController < Spree::Admin::BaseController
def edit
@preferences_general = [:site_name, :default_seo_title, :default_meta_keywords,
:default_meta_description, :site_url]
:default_meta_description, :site_url]
@preferences_security = [:allow_ssl_in_production,
:allow_ssl_in_staging, :allow_ssl_in_development_and_test,
:check_for_spree_alerts]
:allow_ssl_in_staging, :allow_ssl_in_development_and_test,
:check_for_spree_alerts]
@preferences_currency = [:display_currency, :hide_cents]
end
@@ -16,18 +15,20 @@ module Spree
next unless Spree::Config.has_preference? name
Spree::Config[name] = value
end
flash[:success] = Spree.t(:successfully_updated, :resource => Spree.t(:general_settings))
flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:general_settings))
redirect_to edit_admin_general_settings_path
end
def dismiss_alert
if request.xhr? and params[:alert_id]
dismissed = Spree::Config[:dismissed_spree_alerts] || ''
Spree::Config.set :dismissed_spree_alerts => dismissed.split(',').push(params[:alert_id]).join(',')
filter_dismissed_alerts
render :nothing => true
end
return unless request.xhr? && params[:alert_id]
dismissed = Spree::Config[:dismissed_spree_alerts] || ''
Spree::Config.set(dismissed_spree_alerts: dismissed.
split(',').
push(params[:alert_id]).
join(','))
filter_dismissed_alerts
render nothing: true
end
end
end

View File

@@ -24,9 +24,11 @@ module Spree
private
def update_styles(params)
params[:new_attachment_styles].each do |index, style|
params[:attachment_styles][style[:name]] = style[:value] unless style[:value].empty?
end if params[:new_attachment_styles].present?
if params[:new_attachment_styles].present?
params[:new_attachment_styles].each do |_index, style|
params[:attachment_styles][style[:name]] = style[:value] unless style[:value].empty?
end
end
styles = params[:attachment_styles]
@@ -34,9 +36,11 @@ module Spree
end
def update_headers(params)
params[:new_s3_headers].each do |index, header|
params[:s3_headers][header[:name]] = header[:value] unless header[:value].empty?
end if params[:new_s3_headers].present?
if params[:new_s3_headers].present?
params[:new_s3_headers].each do |_index, header|
params[:s3_headers][header[:name]] = header[:value] unless header[:value].empty?
end
end
headers = params[:s3_headers]
@@ -45,19 +49,25 @@ module Spree
def update_paperclip_settings
if Spree::Config[:use_s3]
s3_creds = { :access_key_id => Spree::Config[:s3_access_key], :secret_access_key => Spree::Config[:s3_secret], :bucket => Spree::Config[:s3_bucket] }
s3_creds = { access_key_id: Spree::Config[:s3_access_key],
secret_access_key: Spree::Config[:s3_secret],
bucket: Spree::Config[:s3_bucket] }
Spree::Image.attachment_definitions[:attachment][:storage] = :s3
Spree::Image.attachment_definitions[:attachment][:s3_credentials] = s3_creds
Spree::Image.attachment_definitions[:attachment][:s3_headers] = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
Spree::Image.attachment_definitions[:attachment][:s3_headers] =
ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
Spree::Image.attachment_definitions[:attachment][:bucket] = Spree::Config[:s3_bucket]
else
Spree::Image.attachment_definitions[:attachment].delete :storage
end
Spree::Image.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:attachment_styles]).symbolize_keys!
Spree::Image.attachment_definitions[:attachment][:styles] =
ActiveSupport::JSON.decode(Spree::Config[:attachment_styles]).symbolize_keys!
Spree::Image.attachment_definitions[:attachment][:path] = Spree::Config[:attachment_path]
Spree::Image.attachment_definitions[:attachment][:default_url] = Spree::Config[:attachment_default_url]
Spree::Image.attachment_definitions[:attachment][:default_style] = Spree::Config[:attachment_default_style]
Spree::Image.attachment_definitions[:attachment][:default_url] =
Spree::Config[:attachment_default_url]
Spree::Image.attachment_definitions[:attachment][:default_style] =
Spree::Config[:attachment_default_style]
end
end
end