Merge pull request #3803 from consul/rubocop_layout
Add rubocop style rules
This commit is contained in:
63
.rubocop.yml
63
.rubocop.yml
@@ -58,12 +58,21 @@ Layout/EndOfLine:
|
||||
Layout/ExtraSpacing:
|
||||
Enabled: true
|
||||
|
||||
Layout/IndentAssignment:
|
||||
Enabled: true
|
||||
|
||||
Layout/IndentHeredoc:
|
||||
Enabled: true
|
||||
|
||||
Layout/IndentationConsistency:
|
||||
EnforcedStyle: indented_internal_methods
|
||||
|
||||
Layout/IndentationWidth:
|
||||
Enabled: true
|
||||
|
||||
Layout/LeadingBlankLines:
|
||||
Enabled: true
|
||||
|
||||
Layout/MultilineBlockLayout:
|
||||
Enabled: true
|
||||
|
||||
@@ -106,6 +115,9 @@ Layout/SpaceBeforeFirstArg:
|
||||
Layout/SpaceBeforeSemicolon:
|
||||
Enabled: true
|
||||
|
||||
Layout/SpaceInLambdaLiteral:
|
||||
Enabled: true
|
||||
|
||||
Layout/SpaceInsideArrayLiteralBrackets:
|
||||
Enabled: true
|
||||
|
||||
@@ -355,14 +367,65 @@ Security/JSONLoad:
|
||||
Security/YAMLLoad:
|
||||
Enabled: true
|
||||
|
||||
Style/AndOr:
|
||||
Enabled: true
|
||||
|
||||
Style/BlockDelimiters:
|
||||
Enabled: true
|
||||
|
||||
Style/ClassCheck:
|
||||
Enabled: true
|
||||
|
||||
Style/ClassVars:
|
||||
Enabled: true
|
||||
|
||||
Style/CollectionMethods:
|
||||
Enabled: true
|
||||
|
||||
Style/HashSyntax:
|
||||
Enabled: true
|
||||
|
||||
Style/IdenticalConditionalBranches:
|
||||
Enabled: true
|
||||
|
||||
Style/MethodDefParentheses:
|
||||
Enabled: true
|
||||
|
||||
Style/MutableConstant:
|
||||
Enabled: true
|
||||
|
||||
Style/Not:
|
||||
Enabled: true
|
||||
|
||||
Style/OrAssignment:
|
||||
Enabled: true
|
||||
|
||||
Style/PercentLiteralDelimiters:
|
||||
Enabled: true
|
||||
|
||||
Style/Proc:
|
||||
Enabled: true
|
||||
|
||||
Style/RedundantFreeze:
|
||||
Enabled: true
|
||||
|
||||
Style/RedundantReturn:
|
||||
Enabled: true
|
||||
|
||||
Style/SafeNavigation:
|
||||
Enabled: true
|
||||
|
||||
Style/StringLiterals:
|
||||
EnforcedStyle: double_quotes
|
||||
|
||||
Style/StringLiteralsInInterpolation:
|
||||
EnforcedStyle: double_quotes
|
||||
|
||||
Style/SymbolProc:
|
||||
Enabled: true
|
||||
|
||||
Style/TrailingCommaInArrayLiteral:
|
||||
Enabled: true
|
||||
|
||||
Style/TrailingCommaInHashLiteral:
|
||||
Enabled: true
|
||||
|
||||
@@ -62,7 +62,6 @@ class Admin::BannersController < Admin::BaseController
|
||||
end
|
||||
|
||||
def resource
|
||||
@banner = Banner.find(params[:id]) unless @banner
|
||||
@banner
|
||||
@banner ||= Banner.find(params[:id])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -84,7 +84,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||
|
||||
def load_investments
|
||||
@investments = Budget::Investment.scoped_filter(params, @current_filter).order_filter(params)
|
||||
@investments = Kaminari.paginate_array(@investments) if @investments.kind_of?(Array)
|
||||
@investments = Kaminari.paginate_array(@investments) if @investments.is_a?(Array)
|
||||
@investments = @investments.page(params[:page]) unless request.format.csv?
|
||||
end
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController
|
||||
end
|
||||
|
||||
def search_officers
|
||||
@officers = User.search(params[:search]).order(username: :asc).select { |o| o.poll_officer? }
|
||||
@officers = User.search(params[:search]).order(username: :asc).select(&:poll_officer?)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -8,7 +8,7 @@ class Admin::SettingsController < Admin::BaseController
|
||||
:poster_feature_short_title_setting, :poster_feature_description_setting
|
||||
|
||||
def index
|
||||
all_settings = Setting.all.group_by { |setting| setting.type }
|
||||
all_settings = Setting.all.group_by(&:type)
|
||||
@configuration_settings = all_settings["configuration"]
|
||||
@feature_settings = all_settings["feature"]
|
||||
@participation_processes_settings = all_settings["process"]
|
||||
|
||||
@@ -9,7 +9,7 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
|
||||
def index
|
||||
@content_blocks = SiteCustomization::ContentBlock.order(:name, :locale)
|
||||
@headings_content_blocks = Budget::ContentBlock.all
|
||||
all_settings = Setting.all.group_by { |setting| setting.type }
|
||||
all_settings = Setting.all.group_by(&:type)
|
||||
@html_settings = all_settings["html"]
|
||||
end
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ class Admin::SiteCustomization::ImagesController < Admin::SiteCustomization::Bas
|
||||
@image.image = nil
|
||||
if @image.save
|
||||
notice = t("admin.site_customization.images.destroy.notice")
|
||||
redirect_to admin_site_customization_images_path, notice: notice
|
||||
else
|
||||
notice = t("admin.site_customization.images.destroy.error")
|
||||
redirect_to admin_site_customization_images_path, notice: notice
|
||||
end
|
||||
|
||||
redirect_to admin_site_customization_images_path, notice: notice
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -80,9 +80,9 @@ class Admin::StatsController < Admin::BaseController
|
||||
|
||||
@vote_count = @budget.lines.count
|
||||
|
||||
@vote_count_by_heading = @budget.lines.group(:heading_id).count.collect { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
||||
@vote_count_by_heading = @budget.lines.group(:heading_id).count.map { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
||||
|
||||
@user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.collect { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
||||
@user_count_by_district = User.where.not(balloted_heading_id: nil).group(:balloted_heading_id).count.map { |k, v| [Budget::Heading.find(k).name, v] }.sort
|
||||
end
|
||||
|
||||
def polls
|
||||
|
||||
@@ -91,7 +91,7 @@ class Admin::SystemEmailsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def load_sample_reply
|
||||
reply = Comment.select { |comment| comment.reply? }.last
|
||||
reply = Comment.select(&:reply?).last
|
||||
if reply
|
||||
@email = ReplyEmail.new(reply)
|
||||
else
|
||||
|
||||
@@ -73,9 +73,7 @@ module Budgets
|
||||
|
||||
def load_map
|
||||
@investments ||= []
|
||||
@investments_map_coordinates = MapLocation.where(investment: @investments).map do |loc|
|
||||
loc.json_data
|
||||
end
|
||||
@investments_map_coordinates = MapLocation.where(investment: @investments).map(&:json_data)
|
||||
@map_location = MapLocation.load_from_heading(@heading)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ module Dashboard::GroupSupports
|
||||
|
||||
def accumulate_supports(grouped_votes)
|
||||
grouped_votes.each do |group, votes|
|
||||
grouped_votes[group] = votes.inject(0) { |sum, vote| sum + vote.vote_weight }
|
||||
grouped_votes[group] = votes.reduce(0) { |sum, vote| sum + vote.vote_weight }
|
||||
end
|
||||
|
||||
accumulated = 0
|
||||
|
||||
@@ -20,7 +20,7 @@ module RemotelyTranslatable
|
||||
end
|
||||
|
||||
def resources_groups(*args)
|
||||
feeds = args.detect { |arg| arg&.first.class == Widget::Feed } || []
|
||||
feeds = args.find { |arg| arg&.first.class == Widget::Feed } || []
|
||||
|
||||
args.compact - [feeds] + feeds.map(&:items)
|
||||
end
|
||||
|
||||
@@ -36,12 +36,12 @@ class Dashboard::AchievementsController < Dashboard::BaseController
|
||||
|
||||
def executed_proposed_actions
|
||||
@executed_proposed_actions ||=
|
||||
Dashboard::ExecutedAction
|
||||
.joins(:action)
|
||||
.includes(:action)
|
||||
.where(proposal: proposal)
|
||||
.where(executed_at: start_date.beginning_of_day..end_date.end_of_day)
|
||||
.where(dashboard_actions: { action_type: 0 })
|
||||
.order(executed_at: :asc)
|
||||
Dashboard::ExecutedAction
|
||||
.joins(:action)
|
||||
.includes(:action)
|
||||
.where(proposal: proposal)
|
||||
.where(executed_at: start_date.beginning_of_day..end_date.end_of_day)
|
||||
.where(dashboard_actions: { action_type: 0 })
|
||||
.order(executed_at: :asc)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -19,7 +19,7 @@ class NotificationsController < ApplicationController
|
||||
end
|
||||
|
||||
def mark_all_as_read
|
||||
current_user.notifications.unread.each { |notification| notification.mark_as_read }
|
||||
current_user.notifications.unread.each(&:mark_as_read)
|
||||
redirect_to notifications_path
|
||||
end
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class Officing::ResultsController < Officing::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
@results.each { |result| result.save! }
|
||||
@results.each(&:save!)
|
||||
|
||||
notice = t("officing.results.flash.create")
|
||||
redirect_to new_officing_poll_result_path(@poll), notice: notice
|
||||
|
||||
@@ -2,9 +2,7 @@ class Organizations::RegistrationsController < Devise::RegistrationsController
|
||||
invisible_captcha only: [:create], honeypot: :address, scope: :user
|
||||
|
||||
def new
|
||||
super do |user|
|
||||
user.build_organization
|
||||
end
|
||||
super(&:build_organization)
|
||||
end
|
||||
|
||||
def success
|
||||
|
||||
@@ -26,9 +26,7 @@ class Polls::AnswersController < ApplicationController
|
||||
def delete
|
||||
@question = Poll::Question.find_by(id: params[:id])
|
||||
!@question.answers.find_by(author: current_user, answer: params[:answer]).destroy
|
||||
@question.question_answers.each do |question_answer|
|
||||
question_answer.set_most_voted
|
||||
end
|
||||
@question.question_answers.each(&:set_most_voted)
|
||||
question_answers
|
||||
load_for_answers
|
||||
if @question.enum_type&.include?("answer_couples")
|
||||
|
||||
@@ -49,9 +49,7 @@ class Polls::QuestionsController < ApplicationController
|
||||
answer.touch if answer.persisted?
|
||||
answer.save!
|
||||
answer.record_voter_participation(token)
|
||||
@question.question_answers.visibles.where(question_id: @question).each do |question_answer|
|
||||
question_answer.set_most_voted
|
||||
end
|
||||
@question.question_answers.visibles.where(question_id: @question).each(&:set_most_voted)
|
||||
end
|
||||
|
||||
def store_answer
|
||||
|
||||
@@ -58,7 +58,7 @@ class Tracking::BudgetInvestmentsController < Tracking::BaseController
|
||||
}
|
||||
]
|
||||
|
||||
investment_headings.inject(all_headings_filter) do |filters, heading|
|
||||
investment_headings.reduce(all_headings_filter) do |filters, heading|
|
||||
filters << {
|
||||
name: heading.name,
|
||||
id: heading.id,
|
||||
|
||||
@@ -83,7 +83,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
}
|
||||
]
|
||||
|
||||
investment_headings.inject(all_headings_filter) do |filters, heading|
|
||||
investment_headings.reduce(all_headings_filter) do |filters, heading|
|
||||
filters << {
|
||||
name: heading.name,
|
||||
id: heading.id,
|
||||
|
||||
@@ -83,9 +83,7 @@ module AdminHelper
|
||||
end
|
||||
|
||||
def admin_select_options
|
||||
Administrator.with_user
|
||||
.collect { |v| [v.description_or_name, v.id] }
|
||||
.sort_by { |a| a[0] }
|
||||
Administrator.with_user.map { |v| [v.description_or_name, v.id] }.sort_by { |a| a[0] }
|
||||
end
|
||||
|
||||
def admin_submit_action(resource)
|
||||
|
||||
@@ -82,7 +82,7 @@ module BudgetsHelper
|
||||
investments = current_budget.investments
|
||||
end
|
||||
|
||||
MapLocation.where(investment_id: investments).map { |l| l.json_data }
|
||||
MapLocation.where(investment_id: investments).map(&:json_data)
|
||||
end
|
||||
|
||||
def display_calculate_winners_button?(budget)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module EmbedVideosHelper
|
||||
VIMEO_REGEX = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/
|
||||
YOUTUBE_REGEX = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
|
||||
VIMEO_REGEX = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/.freeze
|
||||
YOUTUBE_REGEX = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/.freeze
|
||||
|
||||
def embedded_video_code(resource)
|
||||
link = resource.video_url
|
||||
|
||||
@@ -4,6 +4,6 @@ module GeozonesHelper
|
||||
end
|
||||
|
||||
def geozone_select_options
|
||||
Geozone.all.order(name: :asc).collect { |g| [g.name, g.id] }
|
||||
Geozone.all.order(name: :asc).map { |g| [g.name, g.id] }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module PollsHelper
|
||||
def poll_select_options(include_all = nil)
|
||||
options = @polls.collect do |poll|
|
||||
options = @polls.map do |poll|
|
||||
[poll.name, current_path_with_query_params(poll_id: poll.id)]
|
||||
end
|
||||
options << all_polls if include_all
|
||||
|
||||
@@ -28,7 +28,7 @@ module ProposalsHelper
|
||||
end
|
||||
|
||||
def retire_proposals_options
|
||||
Proposal::RETIRE_OPTIONS.collect { |option| [t("proposals.retire_options.#{option}"), option] }
|
||||
Proposal::RETIRE_OPTIONS.map { |option| [t("proposals.retire_options.#{option}"), option] }
|
||||
end
|
||||
|
||||
def empty_recommended_proposals_message_text(user)
|
||||
|
||||
@@ -8,7 +8,7 @@ module ShiftsHelper
|
||||
def shift_recount_scrutiny_dates(booth, polls)
|
||||
return [] if polls.blank?
|
||||
|
||||
dates = polls.map(&:ends_at).map(&:to_date).sort.inject([]) do |total, date|
|
||||
dates = polls.map(&:ends_at).map(&:to_date).sort.reduce([]) do |total, date|
|
||||
initial_date = date < Date.current ? Date.current : date
|
||||
total << (initial_date..date + Poll::RECOUNT_DURATION).to_a
|
||||
end
|
||||
@@ -33,7 +33,7 @@ module ShiftsHelper
|
||||
end
|
||||
|
||||
def officer_select_options(officers)
|
||||
officers.collect { |officer| [officer.name, officer.id] }
|
||||
officers.map { |officer| [officer.name, officer.id] }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -26,7 +26,7 @@ module SignatureSheetsHelper
|
||||
text_help += tag(:br)
|
||||
text_help += t("admin.signature_sheets.new.text_help.required_fields_structure_note")
|
||||
|
||||
return text_help
|
||||
text_help
|
||||
end
|
||||
|
||||
def example_text_help
|
||||
@@ -45,6 +45,6 @@ module SignatureSheetsHelper
|
||||
end
|
||||
|
||||
text_example += "#{example_1}; #{example_2}"
|
||||
return text_example
|
||||
text_example
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,13 +60,11 @@ module TranslatableFormHelper
|
||||
end
|
||||
|
||||
def existing_translation_for(locale)
|
||||
@object.translations.detect { |translation| translation.locale == locale }
|
||||
@object.translations.find { |translation| translation.locale == locale }
|
||||
end
|
||||
|
||||
def new_translation_for(locale)
|
||||
@object.translations.new(locale: locale).tap do |translation|
|
||||
translation.mark_for_destruction
|
||||
end
|
||||
@object.translations.new(locale: locale).tap(&:mark_for_destruction)
|
||||
end
|
||||
|
||||
def highlight_translation_html_class
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module UserSegmentsHelper
|
||||
def user_segments_options
|
||||
UserSegments::SEGMENTS.collect do |user_segment_name|
|
||||
UserSegments::SEGMENTS.map do |user_segment_name|
|
||||
[t("admin.segment_recipient.#{user_segment_name}"), user_segment_name]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,11 +5,11 @@ module ValuationHelper
|
||||
|
||||
def valuator_select_options
|
||||
Valuator.order("description ASC").order("users.email ASC").includes(:user).
|
||||
collect { |v| [v.description_or_email, "valuator_#{v.id}"] }
|
||||
map { |v| [v.description_or_email, "valuator_#{v.id}"] }
|
||||
end
|
||||
|
||||
def valuator_group_select_options
|
||||
ValuatorGroup.order("name ASC").collect { |g| [g.name, "group_#{g.id}"] }
|
||||
ValuatorGroup.order("name ASC").map { |g| [g.name, "group_#{g.id}"] }
|
||||
end
|
||||
|
||||
def explanation_field(field)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class ApplicationMailer < ActionMailer::Base
|
||||
helper :settings
|
||||
helper :application
|
||||
default from: Proc.new { "#{Setting["mailer_from_name"]} <#{Setting["mailer_from_address"]}>" }
|
||||
default from: proc { "#{Setting["mailer_from_name"]} <#{Setting["mailer_from_address"]}>" }
|
||||
layout "mailer"
|
||||
end
|
||||
|
||||
@@ -67,7 +67,7 @@ module Abilities
|
||||
can :create, Budget::ValuatorAssignment
|
||||
can [:edit_dossier], Budget::Investment
|
||||
|
||||
can(:read_admin_stats, Budget) { |budget| budget.balloting_or_later? }
|
||||
can :read_admin_stats, Budget, &:balloting_or_later?
|
||||
|
||||
can [:search, :edit, :update, :create, :index, :destroy], Banner
|
||||
|
||||
|
||||
@@ -85,9 +85,7 @@ module Abilities
|
||||
end
|
||||
|
||||
if user.level_two_or_three_verified?
|
||||
can :vote, Proposal do |proposal|
|
||||
proposal.published?
|
||||
end
|
||||
can :vote, Proposal, &:published?
|
||||
can :vote_featured, Proposal
|
||||
|
||||
can :vote, Legislation::Proposal
|
||||
|
||||
@@ -25,9 +25,7 @@ module Abilities
|
||||
can :new, DirectMessage
|
||||
can [:read, :debate, :draft_publication, :allegations, :result_publication,
|
||||
:proposals, :milestones], Legislation::Process, published: true
|
||||
can :resume, Legislation::Process do |process|
|
||||
process.past?
|
||||
end
|
||||
can :resume, Legislation::Process, &:past?
|
||||
can [:read, :changes, :go_to_version], Legislation::DraftVersion
|
||||
can [:read], Legislation::Question
|
||||
can [:read, :map, :share], Legislation::Proposal
|
||||
|
||||
@@ -2,7 +2,7 @@ class Activity < ApplicationRecord
|
||||
belongs_to :actionable, -> { with_hidden }, polymorphic: true
|
||||
belongs_to :user, -> { with_hidden }, inverse_of: :activities
|
||||
|
||||
VALID_ACTIONS = %w[hide block restore valuate email]
|
||||
VALID_ACTIONS = %w[hide block restore valuate email].freeze
|
||||
|
||||
validates :action, inclusion: { in: VALID_ACTIONS }
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Budget
|
||||
class Heading < ApplicationRecord
|
||||
OSM_DISTRICT_LEVEL_ZOOM = 12.freeze
|
||||
OSM_DISTRICT_LEVEL_ZOOM = 12
|
||||
|
||||
include Sluggable
|
||||
|
||||
|
||||
@@ -376,11 +376,11 @@ class Budget
|
||||
end
|
||||
|
||||
def assigned_valuators
|
||||
self.valuators.collect(&:description_or_name).compact.join(", ").presence
|
||||
self.valuators.map(&:description_or_name).compact.join(", ").presence
|
||||
end
|
||||
|
||||
def assigned_valuation_groups
|
||||
self.valuator_groups.collect(&:name).compact.join(", ").presence
|
||||
self.valuator_groups.map(&:name).compact.join(", ").presence
|
||||
end
|
||||
|
||||
def valuation_tag_list
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Budget
|
||||
class ReclassifiedVote < ApplicationRecord
|
||||
REASONS = %w[heading_changed unfeasible]
|
||||
REASONS = %w[heading_changed unfeasible].freeze
|
||||
|
||||
belongs_to :user
|
||||
belongs_to :investment
|
||||
|
||||
@@ -54,7 +54,7 @@ class Budget::Stats
|
||||
end
|
||||
|
||||
def total_votes
|
||||
budget.ballots.pluck(:ballot_lines_count).inject(0) { |sum, x| sum + x }
|
||||
budget.ballots.pluck(:ballot_lines_count).reduce(0) { |sum, x| sum + x }
|
||||
end
|
||||
|
||||
def total_selected_investments
|
||||
@@ -72,18 +72,18 @@ class Budget::Stats
|
||||
end
|
||||
|
||||
groups[:total] = Hash.new(0)
|
||||
groups[:total][:total_investments_count] = groups.collect { |_k, v| v[:total_investments_count] }.sum
|
||||
groups[:total][:total_participants_support_phase] = groups.collect { |_k, v| v[:total_participants_support_phase] }.sum
|
||||
groups[:total][:total_participants_vote_phase] = groups.collect { |_k, v| v[:total_participants_vote_phase] }.sum
|
||||
groups[:total][:total_participants_every_phase] = groups.collect { |_k, v| v[:total_participants_every_phase] }.sum
|
||||
groups[:total][:total_investments_count] = groups.map { |_k, v| v[:total_investments_count] }.sum
|
||||
groups[:total][:total_participants_support_phase] = groups.map { |_k, v| v[:total_participants_support_phase] }.sum
|
||||
groups[:total][:total_participants_vote_phase] = groups.map { |_k, v| v[:total_participants_vote_phase] }.sum
|
||||
groups[:total][:total_participants_every_phase] = groups.map { |_k, v| v[:total_participants_every_phase] }.sum
|
||||
|
||||
budget.headings.each do |heading|
|
||||
groups[heading.id].merge!(calculate_heading_stats_with_totals(groups[heading.id], groups[:total], heading.population))
|
||||
end
|
||||
|
||||
groups[:total][:percentage_participants_support_phase] = groups.collect { |_k, v| v[:percentage_participants_support_phase] }.sum
|
||||
groups[:total][:percentage_participants_vote_phase] = groups.collect { |_k, v| v[:percentage_participants_vote_phase] }.sum
|
||||
groups[:total][:percentage_participants_every_phase] = groups.collect { |_k, v| v[:percentage_participants_every_phase] }.sum
|
||||
groups[:total][:percentage_participants_support_phase] = groups.map { |_k, v| v[:percentage_participants_support_phase] }.sum
|
||||
groups[:total][:percentage_participants_vote_phase] = groups.map { |_k, v| v[:percentage_participants_vote_phase] }.sum
|
||||
groups[:total][:percentage_participants_every_phase] = groups.map { |_k, v| v[:percentage_participants_every_phase] }.sum
|
||||
|
||||
groups
|
||||
end
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
class BudgetAdministrator < ApplicationRecord
|
||||
belongs_to :budget
|
||||
belongs_to :administrator
|
||||
|
||||
@@ -3,11 +3,11 @@ module Measurable
|
||||
|
||||
class_methods do
|
||||
def title_max_length
|
||||
@@title_max_length ||= (columns.find { |c| c.name == "title" }.limit rescue nil) || 80
|
||||
@title_max_length ||= (columns.find { |c| c.name == "title" }&.limit) || 80
|
||||
end
|
||||
|
||||
def responsible_name_max_length
|
||||
@@responsible_name_max_length ||= (columns.find { |c| c.name == "responsible_name" }.limit rescue nil) || 60
|
||||
@responsible_name_max_length ||= (columns.find { |c| c.name == "responsible_name" }&.limit) || 60
|
||||
end
|
||||
|
||||
def question_max_length
|
||||
|
||||
@@ -13,6 +13,6 @@ module Relationable
|
||||
end
|
||||
|
||||
def relationed_contents
|
||||
related_contents.not_hidden.map { |related_content| related_content.child_relationable }
|
||||
related_contents.not_hidden.map(&:child_relationable)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ module SearchCache
|
||||
def searchable_values_sql
|
||||
searchable_values
|
||||
.select { |k, _| k.present? }
|
||||
.collect { |value, weight| set_tsvector(value, weight) }
|
||||
.map { |value, weight| set_tsvector(value, weight) }
|
||||
.join(" || ")
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module Statisticable
|
||||
extend ActiveSupport::Concern
|
||||
PARTICIPATIONS = %w[gender age geozone]
|
||||
PARTICIPATIONS = %w[gender age geozone].freeze
|
||||
|
||||
included do
|
||||
attr_reader :resource
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
require_dependency Rails.root.join("app", "models", "verification", "residence").to_s
|
||||
|
||||
class Verification::Residence
|
||||
|
||||
@@ -74,7 +74,7 @@ class Debate < ApplicationRecord
|
||||
{
|
||||
author.username => "B",
|
||||
tag_list.join(" ") => "B",
|
||||
geozone&.name => "B",
|
||||
geozone&.name => "B"
|
||||
}.merge!(searchable_globalized_values)
|
||||
end
|
||||
|
||||
@@ -165,6 +165,6 @@ class Debate < ApplicationRecord
|
||||
def self.debates_orders(user)
|
||||
orders = %w[hot_score confidence_score created_at relevance]
|
||||
orders << "recommendations" if Setting["feature.user.recommendations_on_debates"] && user&.recommended_debates
|
||||
return orders
|
||||
orders
|
||||
end
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ class I18nContent < ApplicationRecord
|
||||
return output.update({ path => input }) unless input.is_a? Hash
|
||||
|
||||
input.map { |key, value| flat_hash(value, [path, key].compact.join("."), output) }
|
||||
return output
|
||||
output
|
||||
end
|
||||
|
||||
def self.content_for(tab)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Legislation::DraftVersion < ApplicationRecord
|
||||
VALID_STATUSES = %w[draft published]
|
||||
VALID_STATUSES = %w[draft published].freeze
|
||||
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
@@ -23,7 +23,7 @@ class Legislation::Process < ApplicationRecord
|
||||
proposals_phase people_proposals_phase draft_publication
|
||||
result_publication].freeze
|
||||
|
||||
CSS_HEX_COLOR = /\A#?(?:[A-F0-9]{3}){1,2}\z/i
|
||||
CSS_HEX_COLOR = /\A#?(?:[A-F0-9]{3}){1,2}\z/i.freeze
|
||||
|
||||
has_many :draft_versions, -> { order(:id) },
|
||||
foreign_key: "legislation_process_id",
|
||||
|
||||
@@ -7,7 +7,7 @@ class LocalCensusRecord < ApplicationRecord
|
||||
validates :postal_code, presence: true
|
||||
validates :document_number, uniqueness: { scope: :document_type }
|
||||
|
||||
scope :search, -> (terms) { where("document_number ILIKE ?", "%#{terms}%") }
|
||||
scope :search, ->(terms) { where("document_number ILIKE ?", "%#{terms}%") }
|
||||
|
||||
private
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ class Organization < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.name_max_length
|
||||
@@name_max_length ||= columns.find { |c| c.name == "name" }.limit || 60
|
||||
@name_max_length ||= columns.find { |c| c.name == "name" }.limit || 60
|
||||
end
|
||||
|
||||
def self.responsible_name_max_length
|
||||
@@responsible_name_max_length ||= columns.find { |c| c.name == "responsible_name" }.limit || 60
|
||||
@responsible_name_max_length ||= columns.find { |c| c.name == "responsible_name" }.limit || 60
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Poll::PartialResult < ApplicationRecord
|
||||
VALID_ORIGINS = %w[web booth]
|
||||
VALID_ORIGINS = %w[web booth].freeze
|
||||
|
||||
belongs_to :question, -> { with_hidden }, inverse_of: :partial_results
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", inverse_of: :poll_partial_results
|
||||
@@ -9,7 +9,7 @@ class Poll::PartialResult < ApplicationRecord
|
||||
validates :question, presence: true
|
||||
validates :author, presence: true
|
||||
validates :answer, presence: true
|
||||
validates :answer, inclusion: { in: -> (a) { a.question.possible_answers }},
|
||||
validates :answer, inclusion: { in: ->(a) { a.question.possible_answers }},
|
||||
unless: ->(a) { a.question.blank? }
|
||||
validates :origin, inclusion: { in: VALID_ORIGINS }
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class Poll::Question < ApplicationRecord
|
||||
|
||||
validates_translation :title, presence: true, length: { minimum: 4 }
|
||||
validates :author, presence: true
|
||||
validates :poll_id, presence: true, if: Proc.new { |question| question.poll.nil? }
|
||||
validates :poll_id, presence: true, if: proc { |question| question.poll.nil? }
|
||||
|
||||
validates_associated :votation_type
|
||||
accepts_nested_attributes_for :question_answers, reject_if: :all_blank, allow_destroy: true
|
||||
@@ -71,11 +71,11 @@ class Poll::Question < ApplicationRecord
|
||||
end
|
||||
|
||||
def answers_total_votes
|
||||
question_answers.visibles.inject(0) { |total, question_answer| total + question_answer.total_votes }
|
||||
question_answers.visibles.reduce(0) { |total, question_answer| total + question_answer.total_votes }
|
||||
end
|
||||
|
||||
def most_voted_answer_id
|
||||
question_answers.max_by { |answer| answer.total_votes }.id
|
||||
question_answers.max_by(&:total_votes).id
|
||||
end
|
||||
|
||||
def answers_with_read_more?
|
||||
|
||||
@@ -15,7 +15,7 @@ class Poll::Question::Answer < ApplicationRecord
|
||||
validates_translation :title, presence: true
|
||||
validates :given_order, presence: true, uniqueness: { scope: :question_id }
|
||||
|
||||
scope :by_author, -> (author) { where(author: author) }
|
||||
scope :by_author, ->(author) { where(author: author) }
|
||||
|
||||
scope :visibles, -> { where(hidden: false) }
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
class Poll::Question::Answer::Video < ApplicationRecord
|
||||
belongs_to :answer, class_name: "Poll::Question::Answer"
|
||||
|
||||
VIMEO_REGEX = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/
|
||||
YOUTUBE_REGEX = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/
|
||||
VIMEO_REGEX = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/.freeze
|
||||
YOUTUBE_REGEX = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/.freeze
|
||||
|
||||
validates :title, presence: true
|
||||
validate :valid_url?
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class ProgressBar < ApplicationRecord
|
||||
self.inheritance_column = nil
|
||||
RANGE = 0..100
|
||||
RANGE = (0..100).freeze
|
||||
|
||||
enum kind: %i[primary secondary]
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class Proposal < ApplicationRecord
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
RETIRE_OPTIONS = %w[duplicated started unfeasible done other]
|
||||
RETIRE_OPTIONS = %w[duplicated started unfeasible done other].freeze
|
||||
|
||||
translates :title, touch: true
|
||||
translates :description, touch: true
|
||||
@@ -243,7 +243,7 @@ class Proposal < ApplicationRecord
|
||||
def self.proposals_orders(user)
|
||||
orders = %w[hot_score confidence_score created_at relevance archival_date]
|
||||
orders << "recommendations" if Setting["feature.user.recommendations_on_proposals"] && user&.recommended_proposals
|
||||
return orders
|
||||
orders
|
||||
end
|
||||
|
||||
def skip_user_verification?
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Report < ApplicationRecord
|
||||
KINDS = %i[results stats advanced_stats]
|
||||
KINDS = %i[results stats advanced_stats].freeze
|
||||
|
||||
belongs_to :process, polymorphic: true
|
||||
end
|
||||
|
||||
@@ -71,7 +71,7 @@ class Signature < ApplicationRecord
|
||||
end
|
||||
|
||||
def in_census?
|
||||
document_types.detect do |document_type|
|
||||
document_types.find do |document_type|
|
||||
response = CensusCaller.new.call(document_type, document_number, date_of_birth, postal_code)
|
||||
if response.valid?
|
||||
@census_api_response = response
|
||||
|
||||
@@ -2,7 +2,7 @@ class SignatureSheet < ApplicationRecord
|
||||
belongs_to :signable, polymorphic: true
|
||||
belongs_to :author, class_name: "User"
|
||||
|
||||
VALID_SIGNABLES = %w[Proposal Budget::Investment]
|
||||
VALID_SIGNABLES = %w[Proposal Budget::Investment].freeze
|
||||
|
||||
has_many :signatures
|
||||
|
||||
@@ -35,7 +35,7 @@ class SignatureSheet < ApplicationRecord
|
||||
end
|
||||
|
||||
def parsed_required_fields_to_verify_groups
|
||||
required_fields_to_verify.split(/[;]/).collect { |d| d.gsub(/\s+/, "") }.map { |group| group.split(/[,]/) }
|
||||
required_fields_to_verify.split(/[;]/).map { |d| d.gsub(/\s+/, "") }.map { |group| group.split(/[,]/) }
|
||||
end
|
||||
|
||||
def signable_found
|
||||
@@ -52,11 +52,11 @@ class SignatureSheet < ApplicationRecord
|
||||
|
||||
def parse_postal_code(required_fields_to_verify)
|
||||
if Setting.force_presence_date_of_birth? && Setting.force_presence_postal_code?
|
||||
return required_fields_to_verify[2]
|
||||
required_fields_to_verify[2]
|
||||
elsif Setting.force_presence_postal_code?
|
||||
return required_fields_to_verify[1]
|
||||
required_fields_to_verify[1]
|
||||
else
|
||||
return nil
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class SiteCustomization::ContentBlock < ApplicationRecord
|
||||
VALID_BLOCKS = %w[top_links footer subnavigation_left subnavigation_right]
|
||||
VALID_BLOCKS = %w[top_links footer subnavigation_left subnavigation_right].freeze
|
||||
|
||||
validates :locale, presence: true, inclusion: { in: I18n.available_locales.map(&:to_s) }
|
||||
validates :name, presence: true, uniqueness: { scope: :locale }, inclusion: { in: VALID_BLOCKS }
|
||||
|
||||
@@ -7,7 +7,7 @@ class SiteCustomization::Image < ApplicationRecord
|
||||
"budget_execution_no_image" => [800, 600],
|
||||
"map" => [420, 500],
|
||||
"logo_email" => [400, 80]
|
||||
}
|
||||
}.freeze
|
||||
|
||||
has_attached_file :image
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class SiteCustomization::Page < ApplicationRecord
|
||||
VALID_STATUSES = %w[draft published]
|
||||
VALID_STATUSES = %w[draft published].freeze
|
||||
has_many :cards,
|
||||
class_name: "Widget::Card",
|
||||
foreign_key: "site_customization_page_id",
|
||||
|
||||
@@ -123,7 +123,7 @@ class User < ApplicationRecord
|
||||
string = "%#{search_string}%"
|
||||
where("username ILIKE ? OR email ILIKE ? OR document_number ILIKE ?", string, string, string)
|
||||
end
|
||||
scope :between_ages, -> (from, to) do
|
||||
scope :between_ages, ->(from, to) do
|
||||
where(
|
||||
"date_of_birth > ? AND date_of_birth < ?",
|
||||
to.years.ago.beginning_of_year,
|
||||
@@ -313,7 +313,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.username_max_length
|
||||
@@username_max_length ||= columns.find { |c| c.name == "username" }.limit || 60
|
||||
@username_max_length ||= columns.find { |c| c.name == "username" }.limit || 60
|
||||
end
|
||||
|
||||
def self.minimum_required_age
|
||||
|
||||
@@ -2,5 +2,5 @@ class VotationSetAnswer < ApplicationRecord
|
||||
belongs_to :votation_type
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", inverse_of: :votation_set_answers
|
||||
|
||||
scope :by_author, -> (author) { where(author: author) }
|
||||
scope :by_author, ->(author) { where(author: author) }
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ class VotationType < ApplicationRecord
|
||||
answer_set_open: { enum_type: 7, open_answer: true, prioritized: false,
|
||||
variables: [:max_votes, :max_groups_answers] },
|
||||
answer_set_closed: { enum_type: 8, open_answer: false, prioritized: false,
|
||||
variables: [:max_votes, :max_groups_answers] },
|
||||
variables: [:max_votes, :max_groups_answers] }
|
||||
}.freeze
|
||||
|
||||
enum enum_type: ENUM_TYPES_PROPS.map { |k, v| [k, v[:enum_type]] }.to_h.freeze
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class Widget::Feed < ApplicationRecord
|
||||
self.table_name = "widget_feeds"
|
||||
|
||||
KINDS = %w[proposals debates processes]
|
||||
KINDS = %w[proposals debates processes].freeze
|
||||
|
||||
def active?
|
||||
setting.value.present?
|
||||
@@ -12,7 +12,7 @@ class Widget::Feed < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.active
|
||||
KINDS.collect do |kind|
|
||||
KINDS.map do |kind|
|
||||
feed = find_or_create_by!(kind: kind)
|
||||
feed if feed.active?
|
||||
end.compact
|
||||
|
||||
@@ -5,10 +5,10 @@ wb.add_worksheet(name: "Resume") do |sheet|
|
||||
sheet.add_row [t("legislation.summary.debates_phase"), t("legislation.questions.question.total", count: @process.questions.count)]
|
||||
@process.questions.each do |question|
|
||||
sheet.add_row [question.title, t("legislation.summary.comments", count: question.comments.count)]
|
||||
sheet.add_hyperlink :location => legislation_process_question_url(question.process, question), :ref => sheet.rows.last.cells.first
|
||||
sheet.add_hyperlink location: legislation_process_question_url(question.process, question), ref: sheet.rows.last.cells.first
|
||||
question.best_comments(3).each do |comment|
|
||||
sheet.add_row [comment.body, (comment.cached_votes_up - comment.cached_votes_down).to_s + space + t("legislation.summary.votes")]
|
||||
sheet.add_hyperlink :location => comment_url(comment), :ref => sheet.rows.last.cells.first
|
||||
sheet.add_hyperlink location: comment_url(comment), ref: sheet.rows.last.cells.first
|
||||
end
|
||||
sheet.add_row ["", ""]
|
||||
end
|
||||
@@ -19,7 +19,7 @@ wb.add_worksheet(name: "Resume") do |sheet|
|
||||
Legislation::Proposal.where(legislation_process_id: @process).where(selected: true).order("cached_votes_score desc").each do |proposal|
|
||||
sheet.add_row [proposal.title,
|
||||
(proposal.cached_votes_total - proposal.cached_votes_down).to_s + space + t("legislation.summary.votes")]
|
||||
sheet.add_hyperlink :location => legislation_process_proposal_url(proposal.legislation_process_id, proposal), :ref => sheet.rows.last.cells.first
|
||||
sheet.add_hyperlink location: legislation_process_proposal_url(proposal.legislation_process_id, proposal), ref: sheet.rows.last.cells.first
|
||||
end
|
||||
sheet.add_row ["", ""]
|
||||
end
|
||||
@@ -30,7 +30,7 @@ wb.add_worksheet(name: "Resume") do |sheet|
|
||||
@process.get_best_annotation_comments.take(10).each do |comment|
|
||||
sheet.add_row [Legislation::Annotation.find_by(id: comment.commentable_id).quote, ""]
|
||||
sheet.add_row [comment.body, (comment.cached_votes_up - comment.cached_votes_down).to_s + space + t("legislation.summary.votes")]
|
||||
sheet.add_hyperlink :location => comment_url(comment), :ref => sheet.rows.last.cells.first
|
||||
sheet.add_hyperlink location: comment_url(comment), ref: sheet.rows.last.cells.first
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ unless defined?(Spring)
|
||||
require "bundler"
|
||||
|
||||
lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
|
||||
spring = lockfile.specs.detect { |spec| spec.name == "spring" }
|
||||
spring = lockfile.specs.find { |spec| spec.name == "spring" }
|
||||
if spring
|
||||
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
|
||||
gem "spring", spring.version
|
||||
|
||||
@@ -12,7 +12,7 @@ Devise.setup do |config|
|
||||
# Configure the e-mail address which will be shown in Devise::Mailer,
|
||||
# note that it will be overwritten if you use your own mailer class
|
||||
# with default "from" parameter.
|
||||
config.mailer_sender = Proc.new { "'#{Setting["mailer_from_name"]}' <#{Setting["mailer_from_address"]}>" }
|
||||
config.mailer_sender = proc { "'#{Setting["mailer_from_name"]}' <#{Setting["mailer_from_address"]}>" }
|
||||
|
||||
# Configure the class responsible to send e-mails.
|
||||
config.mailer = "DeviseMailer"
|
||||
|
||||
@@ -62,7 +62,7 @@ module Devise
|
||||
if !self.new_record? && !self.encrypted_password_change.nil? && !self.erased?
|
||||
dummy = self.class.new
|
||||
dummy.encrypted_password = self.encrypted_password_change.first
|
||||
dummy.password_salt = self.password_salt_change.first if self.respond_to? :password_salt_change and not self.password_salt_change.nil?
|
||||
dummy.password_salt = self.password_salt_change.first if self.respond_to?(:password_salt_change) && !self.password_salt_change.nil?
|
||||
self.errors.add(:password, :equal_to_current_password) if dummy.valid_password?(self.password)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ module GraphQLApi
|
||||
if ActiveRecord::Base.connection.tables.any?
|
||||
api_config = YAML.load_file("./config/api.yml")
|
||||
GraphqlController.const_set "API_TYPE_DEFINITIONS",
|
||||
GraphQL::ApiTypesCreator::parse_api_config_file(api_config)
|
||||
GraphQL::ApiTypesCreator.parse_api_config_file(api_config)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ end
|
||||
devise_for :organizations, class_name: "User",
|
||||
controllers: {
|
||||
registrations: "organizations/registrations",
|
||||
sessions: "devise/sessions",
|
||||
sessions: "devise/sessions"
|
||||
},
|
||||
skip: [:omniauth_callbacks]
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ section "Creating Poll Questions & Answers" do
|
||||
end
|
||||
question.save!
|
||||
Faker::Lorem.words((2..4).to_a.sample).each_with_index do |title, index|
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join('</p><p>')}</p>"
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
|
||||
answer = Poll::Question::Answer.new(question: question,
|
||||
title: title.capitalize,
|
||||
description: description,
|
||||
|
||||
@@ -10,6 +10,6 @@ class CreateInappropiateFlags < ActiveRecord::Migration[4.2]
|
||||
end
|
||||
|
||||
add_index :inappropiate_flags, [:flaggable_type, :flaggable_id]
|
||||
add_index :inappropiate_flags, [:user_id, :flaggable_type, :flaggable_id], :name => "access_inappropiate_flags"
|
||||
add_index :inappropiate_flags, [:user_id, :flaggable_type, :flaggable_id], name: "access_inappropiate_flags"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ class AddCollaborativeLegislationTranslations < ActiveRecord::Migration[4.2]
|
||||
title: :string,
|
||||
summary: :text,
|
||||
description: :text,
|
||||
additional_info: :text,
|
||||
additional_info: :text
|
||||
},
|
||||
{ migrate_data: true }
|
||||
)
|
||||
|
||||
@@ -9,11 +9,11 @@ class AddTranslatePages < ActiveRecord::Migration[4.2]
|
||||
{ migrate_data: true }
|
||||
)
|
||||
|
||||
change_column :site_customization_pages, :title, :string, :null => true
|
||||
change_column :site_customization_pages, :title, :string, null: true
|
||||
end
|
||||
|
||||
def self.down
|
||||
SiteCustomization::Page.drop_translation_table!
|
||||
change_column :site_customization_pages, :title, :string, :null => false
|
||||
change_column :site_customization_pages, :title, :string, null: false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ module GraphQL
|
||||
float: GraphQL::FLOAT_TYPE,
|
||||
double: GraphQL::FLOAT_TYPE,
|
||||
string: GraphQL::STRING_TYPE
|
||||
}
|
||||
}.freeze
|
||||
|
||||
def self.create(api_types_definitions)
|
||||
created_types = {}
|
||||
|
||||
@@ -4,7 +4,7 @@ class ManagerAuthenticator
|
||||
end
|
||||
|
||||
def auth
|
||||
return false unless [@manager[:login], @manager[:user_key], @manager[:date]].all? { |manager| manager.present? }
|
||||
return false unless [@manager[:login], @manager[:user_key], @manager[:date]].all?(&:present?)
|
||||
return @manager if manager_exists? && application_authorized?
|
||||
|
||||
false
|
||||
|
||||
@@ -66,7 +66,7 @@ class RemoteCensusApi
|
||||
end
|
||||
|
||||
def parse_response_path(path_value)
|
||||
path_value.split(".").map { |section| section.to_sym } if path_value.present?
|
||||
path_value.split(".").map(&:to_sym) if path_value.present?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ require "json"
|
||||
class RemoteTranslations::Microsoft::AvailableLocales
|
||||
def self.available_locales
|
||||
daily_cache("locales") do
|
||||
remote_available_locales.map { |locale| locale.first }
|
||||
remote_available_locales.map(&:first)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -38,7 +38,7 @@ class RemoteTranslations::Microsoft::AvailableLocales
|
||||
request = Net::HTTP::Get.new(uri)
|
||||
request["Ocp-Apim-Subscription-Key"] = Rails.application.secrets.microsoft_api_key
|
||||
|
||||
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == "https") do |http|
|
||||
response = Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == "https") do |http|
|
||||
http.request(request)
|
||||
end
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ include RemoteTranslations::Microsoft::SentencesParser
|
||||
|
||||
class RemoteTranslations::Microsoft::Client
|
||||
CHARACTERS_LIMIT_PER_REQUEST = 5000
|
||||
PREVENTING_TRANSLATION_KEY = "notranslate"
|
||||
PREVENTING_TRANSLATION_KEY = "notranslate".freeze
|
||||
|
||||
def initialize
|
||||
api_key = Rails.application.secrets.microsoft_api_key
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class TagSanitizer
|
||||
DISALLOWED_STRINGS = %w[? < > = /]
|
||||
DISALLOWED_STRINGS = %w[? < > = /].freeze
|
||||
|
||||
def sanitize_tag(tag)
|
||||
tag = tag.dup
|
||||
|
||||
@@ -384,7 +384,7 @@ namespace :proposal_actions do
|
||||
5
|
||||
]
|
||||
|
||||
votes_count = expected_supports.inject(0.0) { |sum, x| sum + x }
|
||||
votes_count = expected_supports.reduce(0.0) { |sum, x| sum + x }
|
||||
goal_votes = Setting["votes_for_proposal_success"].to_f
|
||||
cached_votes_up = 0
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ class UserSegments
|
||||
feasible_and_undecided_investment_authors
|
||||
selected_investment_authors
|
||||
winner_investment_authors
|
||||
not_supported_on_current_budget]
|
||||
not_supported_on_current_budget].freeze
|
||||
|
||||
def self.all_users
|
||||
User.active
|
||||
|
||||
@@ -6,8 +6,8 @@ FactoryBot.define do
|
||||
|
||||
factory :geozone do
|
||||
sequence(:name) { |n| "District #{n}" }
|
||||
sequence(:external_code) { |n| n.to_s }
|
||||
sequence(:census_code) { |n| n.to_s }
|
||||
sequence(:external_code, &:to_s)
|
||||
sequence(:census_code, &:to_s)
|
||||
|
||||
trait :in_census do
|
||||
census_code { "01" }
|
||||
|
||||
@@ -12,6 +12,6 @@ FactoryBot.define do
|
||||
|
||||
factory :campaign do
|
||||
sequence(:name) { |n| "Campaign #{n}" }
|
||||
sequence(:track_id) { |n| n.to_s }
|
||||
sequence(:track_id, &:to_s)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -101,7 +101,7 @@ FactoryBot.define do
|
||||
incompatible { false }
|
||||
|
||||
trait :with_confidence_score do
|
||||
before(:save) { |i| i.calculate_confidence_score }
|
||||
before(:save, &:calculate_confidence_score)
|
||||
end
|
||||
|
||||
trait :feasible do
|
||||
|
||||
@@ -23,7 +23,7 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
trait :with_confidence_score do
|
||||
before(:save) { |d| d.calculate_confidence_score }
|
||||
before(:save, &:calculate_confidence_score)
|
||||
end
|
||||
|
||||
trait :valuation do
|
||||
|
||||
@@ -24,11 +24,11 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
trait :with_hot_score do
|
||||
before(:save) { |d| d.calculate_hot_score }
|
||||
before(:save, &:calculate_hot_score)
|
||||
end
|
||||
|
||||
trait :with_confidence_score do
|
||||
before(:save) { |d| d.calculate_confidence_score }
|
||||
before(:save, &:calculate_confidence_score)
|
||||
end
|
||||
|
||||
trait :conflictive do
|
||||
|
||||
@@ -124,19 +124,19 @@ FactoryBot.define do
|
||||
changelog { "What changed in this version" }
|
||||
status { "draft" }
|
||||
final_version { false }
|
||||
body { <<-LOREM_IPSUM }
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
|
||||
body { <<~LOREM_IPSUM }
|
||||
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.
|
||||
|
||||
Expetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.
|
||||
Expetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.
|
||||
|
||||
His audiam deserunt in, eum ubique voluptatibus te. In reque dicta usu. Ne rebum dissentiet eam, vim omnis deseruisse id. Ullum deleniti vituperata at quo, insolens complectitur te eos, ea pri dico munere propriae. Vel ferri facilis ut, qui paulo ridens praesent ad. Possim alterum qui cu. Accusamus consulatu ius te, cu decore soleat appareat usu.
|
||||
His audiam deserunt in, eum ubique voluptatibus te. In reque dicta usu. Ne rebum dissentiet eam, vim omnis deseruisse id. Ullum deleniti vituperata at quo, insolens complectitur te eos, ea pri dico munere propriae. Vel ferri facilis ut, qui paulo ridens praesent ad. Possim alterum qui cu. Accusamus consulatu ius te, cu decore soleat appareat usu.
|
||||
|
||||
Est ei erat mucius quaeque. Ei his quas phaedrum, efficiantur mediocritatem ne sed, hinc oratio blandit ei sed. Blandit gloriatur eam et. Brute noluisse per et, verear disputando neglegentur at quo. Sea quem legere ei, unum soluta ne duo. Ludus complectitur quo te, ut vide autem homero pro.
|
||||
Est ei erat mucius quaeque. Ei his quas phaedrum, efficiantur mediocritatem ne sed, hinc oratio blandit ei sed. Blandit gloriatur eam et. Brute noluisse per et, verear disputando neglegentur at quo. Sea quem legere ei, unum soluta ne duo. Ludus complectitur quo te, ut vide autem homero pro.
|
||||
|
||||
Vis id minim dicant sensibus. Pri aliquip conclusionemque ad, ad malis evertitur torquatos his. Has ei solum harum reprimique, id illum saperet tractatos his. Ei omnis soleat antiopam quo. Ad augue inani postulant mel, mel ea qualisque forensibus.
|
||||
Vis id minim dicant sensibus. Pri aliquip conclusionemque ad, ad malis evertitur torquatos his. Has ei solum harum reprimique, id illum saperet tractatos his. Ei omnis soleat antiopam quo. Ad augue inani postulant mel, mel ea qualisque forensibus.
|
||||
|
||||
Lorem salutandi eu mea, eam in soleat iriure assentior. Tamquam lobortis id qui. Ea sanctus democritum mei, per eu alterum electram adversarium. Ea vix probo dicta iuvaret, posse epicurei suavitate eam an, nam et vidit menandri. Ut his accusata petentium.
|
||||
LOREM_IPSUM
|
||||
Lorem salutandi eu mea, eam in soleat iriure assentior. Tamquam lobortis id qui. Ea sanctus democritum mei, per eu alterum electram adversarium. Ea vix probo dicta iuvaret, posse epicurei suavitate eam an, nam et vidit menandri. Ut his accusata petentium.
|
||||
LOREM_IPSUM
|
||||
|
||||
trait :published do
|
||||
status { "published" }
|
||||
|
||||
@@ -38,11 +38,11 @@ FactoryBot.define do
|
||||
end
|
||||
|
||||
trait :with_hot_score do
|
||||
before(:save) { |d| d.calculate_hot_score }
|
||||
before(:save, &:calculate_hot_score)
|
||||
end
|
||||
|
||||
trait :with_confidence_score do
|
||||
before(:save) { |d| d.calculate_confidence_score }
|
||||
before(:save, &:calculate_confidence_score)
|
||||
end
|
||||
|
||||
trait :conflictive do
|
||||
|
||||
@@ -157,7 +157,7 @@ describe "Admin collaborative legislation" do
|
||||
end
|
||||
|
||||
scenario "Create a legislation process with an image", :js do
|
||||
visit new_admin_legislation_process_path()
|
||||
visit new_admin_legislation_process_path
|
||||
fill_in "Process Title", with: "An example legislation process"
|
||||
fill_in "Summary", with: "Summary of the process"
|
||||
|
||||
|
||||
@@ -194,13 +194,13 @@ describe "Admin booths assignments" do
|
||||
end
|
||||
|
||||
within("#recounts_list") do
|
||||
within("#recounting_#{poll.starts_at.to_date.strftime('%Y%m%d')}") do
|
||||
within("#recounting_#{poll.starts_at.to_date.strftime("%Y%m%d")}") do
|
||||
expect(page).to have_content 1
|
||||
end
|
||||
within("#recounting_#{(poll.ends_at.to_date - 5.days).strftime('%Y%m%d')}") do
|
||||
within("#recounting_#{(poll.ends_at.to_date - 5.days).strftime("%Y%m%d")}") do
|
||||
expect(page).to have_content "-"
|
||||
end
|
||||
within("#recounting_#{poll.ends_at.to_date.strftime('%Y%m%d')}") do
|
||||
within("#recounting_#{poll.ends_at.to_date.strftime("%Y%m%d")}") do
|
||||
expect(page).to have_content 1
|
||||
end
|
||||
end
|
||||
|
||||
@@ -632,11 +632,11 @@ describe "Budget Investments" do
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
within(".submenu .is-active") { expect(page).to have_content "random" }
|
||||
order = all(".budget-investment h3").collect { |i| i.text }
|
||||
order = all(".budget-investment h3").map(&:text)
|
||||
expect(order).not_to be_empty
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
new_order = all(".budget-investment h3").collect { |i| i.text }
|
||||
new_order = all(".budget-investment h3").map(&:text)
|
||||
|
||||
expect(order).to eq(new_order)
|
||||
end
|
||||
@@ -645,14 +645,14 @@ describe "Budget Investments" do
|
||||
(per_page + 2).times { create(:budget_investment, heading: heading) }
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
order = all(".budget-investment h3").collect { |i| i.text }
|
||||
order = all(".budget-investment h3").map(&:text)
|
||||
expect(order).not_to be_empty
|
||||
|
||||
click_link "highest rated"
|
||||
click_link "random"
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
new_order = all(".budget-investment h3").collect { |i| i.text }
|
||||
new_order = all(".budget-investment h3").map(&:text)
|
||||
|
||||
expect(order).to eq(new_order)
|
||||
end
|
||||
@@ -662,7 +662,7 @@ describe "Budget Investments" do
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
order = all(".budget-investment h3").collect { |i| i.text }
|
||||
order = all(".budget-investment h3").map(&:text)
|
||||
expect(order).not_to be_empty
|
||||
|
||||
click_link "Next"
|
||||
@@ -671,7 +671,7 @@ describe "Budget Investments" do
|
||||
click_link "Previous"
|
||||
expect(page).to have_content "You're on page 1"
|
||||
|
||||
new_order = all(".budget-investment h3").collect { |i| i.text }
|
||||
new_order = all(".budget-investment h3").map(&:text)
|
||||
expect(order).to eq(new_order)
|
||||
end
|
||||
|
||||
@@ -680,13 +680,13 @@ describe "Budget Investments" do
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
order = all(".budget-investment h3").collect { |i| i.text }
|
||||
order = all(".budget-investment h3").map(&:text)
|
||||
expect(order).not_to be_empty
|
||||
|
||||
click_link Budget::Investment.first.title
|
||||
click_link "Go back"
|
||||
|
||||
new_order = all(".budget-investment h3").collect { |i| i.text }
|
||||
new_order = all(".budget-investment h3").map(&:text)
|
||||
expect(order).to eq(new_order)
|
||||
end
|
||||
|
||||
@@ -812,11 +812,11 @@ describe "Budget Investments" do
|
||||
budget.update!(phase: "finished")
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
order = all(".budget-investment h3").collect { |i| i.text }
|
||||
order = all(".budget-investment h3").map(&:text)
|
||||
expect(order).not_to be_empty
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
new_order = all(".budget-investment h3").collect { |i| i.text }
|
||||
new_order = all(".budget-investment h3").map(&:text)
|
||||
|
||||
expect(order).to eq(new_order)
|
||||
end
|
||||
@@ -844,7 +844,7 @@ describe "Budget Investments" do
|
||||
end
|
||||
|
||||
def investments_order
|
||||
all(".budget-investment h3").collect { |i| i.text }
|
||||
all(".budget-investment h3").map(&:text)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1038,7 +1038,7 @@ describe "Budget Investments" do
|
||||
|
||||
visit new_budget_investment_path(budget)
|
||||
|
||||
select_options = find("#budget_investment_heading_id").all("option").collect(&:text)
|
||||
select_options = find("#budget_investment_heading_id").all("option").map(&:text)
|
||||
expect(select_options).to eq ["",
|
||||
"Toda la ciudad",
|
||||
"Health: More health professionals",
|
||||
|
||||
@@ -142,7 +142,7 @@ describe "Legislation" do
|
||||
|
||||
phases.each do |phase|
|
||||
within(".legislation-process-list") do
|
||||
find("li", :text => "#{phase}").click_link
|
||||
find("li", text: "#{phase}").click_link
|
||||
end
|
||||
|
||||
expect(page).to have_content(document.title)
|
||||
|
||||
@@ -133,7 +133,7 @@ describe "Legislation Proposals" do
|
||||
end
|
||||
|
||||
def legislation_proposals_order
|
||||
all("[id^='legislation_proposal_']").collect { |e| e[:id] }
|
||||
all("[id^='legislation_proposal_']").map { |e| e[:id] }
|
||||
end
|
||||
|
||||
scenario "Create a legislation proposal with an image", :js do
|
||||
|
||||
@@ -229,7 +229,7 @@ describe "Notifications" do
|
||||
end
|
||||
|
||||
def remove_users_without_pending_notifications
|
||||
users_without_notifications.each { |user| user.destroy }
|
||||
users_without_notifications.each(&:destroy)
|
||||
end
|
||||
|
||||
def users_without_notifications
|
||||
|
||||
@@ -276,8 +276,8 @@ describe "Valuation budget investments" do
|
||||
|
||||
expect(page).to have_content("Create progress bar")
|
||||
|
||||
select("Primary", :from => "Type")
|
||||
fill_in("Current progress", :with => 50)
|
||||
select("Primary", from: "Type")
|
||||
fill_in("Current progress", with: 50)
|
||||
|
||||
click_button "Create Progress bar"
|
||||
|
||||
@@ -295,9 +295,9 @@ describe "Valuation budget investments" do
|
||||
|
||||
expect(page).to have_content("Create progress bar")
|
||||
|
||||
select("Secondary", :from => "Type")
|
||||
fill_in("Title", :with => "secondary_progress_bar")
|
||||
fill_in("Current progress", :with => 50)
|
||||
select("Secondary", from: "Type")
|
||||
fill_in("Title", with: "secondary_progress_bar")
|
||||
fill_in("Current progress", with: 50)
|
||||
|
||||
click_button "Create Progress bar"
|
||||
|
||||
@@ -340,7 +340,7 @@ describe "Valuation budget investments" do
|
||||
|
||||
page.find("#progress_bar_#{secondary_progress_bar.id}").click_link("Edit")
|
||||
|
||||
fill_in("Title", :with => "edited")
|
||||
fill_in("Title", with: "edited")
|
||||
click_button "Update Progress bar"
|
||||
|
||||
expect(page).to have_content("Progress bars")
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user