Commit babfaa7c authored by hellekin's avatar hellekin

Make rubocop happy

parent 96f6c38d
......@@ -11,7 +11,11 @@ class ApplicationController < ActionController::API
if Rails.env.development?
# @see https://github.com/varvet/pundit#ensuring-policies-and-scopes-are-used
after_action :verify_authorized, except: :index, if: proc { params[:pundit] == 'verify' }
after_action :verify_policy_scoped, only: :index, if: proc { params[:pundit] == 'verify' }
with_options if: proc { params[:pundit] == 'verify' } do
# rubocop:disable Rails/LexicallyScopedActionFilter
after_action :verify_authorized, except: :index
after_action :verify_policy_scoped, only: :index
# rubocop:enable Rails/LexicallyScopedActionFilter
end
end
end
# coding: utf-8
# frozen_string_literal: true
require_relative '../../config/application'
......@@ -12,7 +11,7 @@ raise ArgumentError, "RCR Agent does not exist!\n#{agent&.errors&.inspect}" unle
entries = JSON.parse File.read(Rails.root.join('doc', 'import', 'rcr-initiatives.json'))
rcr = agent.taxonomies.includes(:categories, :sections)
.find_by(name: 'RCR').categories.map(&:sections).flatten
.find_by(name: 'RCR').categories.map(&:sections).flatten
# Data from RCR are very groovy. You can find letters in phone numbers and other
# inconsistencies. Therefore we try our best to import everything in one go and
......@@ -39,7 +38,8 @@ def find_section_for(ent, sections)
sections.find do |i|
i.name == if ent['type_initiative'] == 'potager'
sections_by_initiative[:potager][ent['type_potager'].to_s.strip || 'unspecified']
typot = ent['type_potager'].to_s.strip || 'unspecified'
sections_by_initiative[:potager][typot]
else
sections_by_initiative[ent['type_initiative']]
end
......@@ -175,7 +175,9 @@ entries['initiatives'].each do |ent|
if res.valid?
sec = find_section_for(initiative, rcr)
if sec.nil?
res.meta['missing_section'] = initiative['type_initiative'] unless initiative.key?('type_potager')
unless initiative.key?('type_potager')
res.meta['missing_section'] = initiative['type_initiative']
end
else
res.sections << sec
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment