Add and apply rules for multi-line hashes

For the HashAlignment rule, we're using the default `key` style (keys
are aligned and values aren't) instead of the `table` style (both keys
and values are aligned) because, even if we used both in the
application, we used the `key` style a lot more. Furthermore, the
`table` style looks strange in places where there are both very long and
very short keys and sometimes we weren't even consistent with the
`table` style, aligning some keys without aligning other keys.

Ideally we could align hashes to "either key or table", so developers
can decide whether keeping the symmetry of the code is worth it in a
case-per-case basis, but Rubocop doesn't allow this option.
This commit is contained in:
Javi Martín
2023-07-01 16:17:33 +02:00
parent 97aca0cf95
commit 8b13daad95
130 changed files with 676 additions and 592 deletions

View File

@@ -64,6 +64,13 @@ Layout/FirstArrayElementIndentation:
Enabled: true
EnforcedStyle: consistent
Layout/FirstHashElementIndentation:
Enabled: true
EnforcedStyle: consistent
Layout/HashAlignment:
Enabled: true
Layout/HeredocIndentation:
Enabled: true
@@ -92,6 +99,12 @@ Layout/MultilineArrayBraceLayout:
Layout/MultilineBlockLayout:
Enabled: true
Layout/MultilineHashBraceLayout:
Enabled: true
Layout/MultilineHashKeyLineBreaks:
Enabled: true
Layout/SpaceAfterColon:
Enabled: true

View File

@@ -83,10 +83,10 @@ class Admin::Budgets::ActionsComponent < ApplicationComponent
balloting_phase = budget.phases.find_by(kind: "balloting")
admin_polls_path(poll: {
name: budget.name,
name: budget.name,
budget_id: budget.id,
starts_at: balloting_phase.starts_at,
ends_at: balloting_phase.ends_at
ends_at: balloting_phase.ends_at
})
end

View File

@@ -41,6 +41,6 @@
<div class="small-12 column">
<%= f.submit(value: t("admin.geozones.edit.form.submit_button"),
class: "button success") %>
class: "button success") %>
</div>
<% end %>

View File

@@ -5,5 +5,5 @@
rows: 5,
class: "js-globalize-attribute",
style: site_customization_display_translation_style(locale),
data: { locale: locale } %>
data: { locale: locale } %>
<% end %>

View File

@@ -51,10 +51,10 @@
<% if feature?(:map) %>
<div>
<%= render "map_locations/form_fields",
form: f,
form: f,
map_location: investment.map_location || MapLocation.new,
label: t("budgets.investments.form.map_location"),
help: t("budgets.investments.form.map_location_instructions"),
label: t("budgets.investments.form.map_location"),
help: t("budgets.investments.form.map_location_instructions"),
i18n_namespace: "budgets.investments" %>
</div>
<% end %>
@@ -80,11 +80,11 @@
<br>
<%= f.text_field :tag_list, value: investment.tag_list.to_s,
label: false,
placeholder: t("budgets.investments.form.tags_placeholder"),
aria: { describedby: "tags-list-help-text" },
class: "js-tag-list tag-autocomplete",
data: { js_url: suggest_tags_path } %>
label: false,
placeholder: t("budgets.investments.form.tags_placeholder"),
aria: { describedby: "tags-list-help-text" },
class: "js-tag-list tag-autocomplete",
data: { js_url: suggest_tags_path } %>
</div>
<%= render SDG::RelatedListSelectorComponent.new(f) %>

View File

@@ -27,7 +27,7 @@
title: t("budgets.investments.investment.support_title"),
method: "post",
remote: !display_support_alert?,
data: ({ confirm: confirm_vote_message } if display_support_alert?),
data: ({ confirm: confirm_vote_message } if display_support_alert?),
"aria-label": support_aria_label %>
<% end %>
<% end %>

View File

@@ -29,10 +29,10 @@
<div>
<%= f.text_field :tag_list, value: debate.tag_list.to_s,
hint: t("debates.form.tags_instructions"),
placeholder: t("debates.form.tags_placeholder"),
data: { js_url: suggest_tags_path },
class: "tag-autocomplete" %>
hint: t("debates.form.tags_instructions"),
placeholder: t("debates.form.tags_placeholder"),
data: { js_url: suggest_tags_path },
class: "tag-autocomplete" %>
</div>
<%= render SDG::RelatedListSelectorComponent.new(f) %>

View File

@@ -17,8 +17,8 @@ class Documents::NestedComponent < ApplicationComponent
def note
t "documents.form.note", max_documents_allowed: max_documents_allowed,
accepted_content_types: Document.humanized_accepted_content_types,
max_file_size: documentable.class.max_file_size
accepted_content_types: Document.humanized_accepted_content_types,
max_file_size: documentable.class.max_file_size
end
def max_documents_allowed?

View File

@@ -14,6 +14,6 @@ class Images::NestedComponent < ApplicationComponent
def note
t "images.form.note", accepted_content_types: Image.humanized_accepted_content_types,
max_file_size: Image.max_file_size
max_file_size: Image.max_file_size
end
end

View File

@@ -8,7 +8,7 @@
<p class="info">
<%= sanitize(t("layouts.footer.description",
open_source: link_to(t("layouts.footer.open_source"), t("layouts.footer.open_source_url"), target: "blank", rel: "nofollow"),
consul: link_to(t("layouts.footer.consul"), t("layouts.footer.consul_url"), target: "blank", rel: "nofollow"))) %>
consul: link_to(t("layouts.footer.consul"), t("layouts.footer.consul_url"), target: "blank", rel: "nofollow"))) %>
</p>
</div>

View File

@@ -1,7 +1,8 @@
<% if user %>
<li id="notifications">
<%= link_to notifications_path, rel: "nofollow", title: text,
class: "notifications #{notifications_class}" do %>
<%= link_to notifications_path, rel: "nofollow",
title: text,
class: "notifications #{notifications_class}" do %>
<span class="show-for-sr">
<%= t("layouts.header.notification_item.notifications") %>
</span>

View File

@@ -59,10 +59,10 @@
<% if feature?(:map) %>
<div>
<%= render "map_locations/form_fields",
form: f,
form: f,
map_location: proposal.map_location || MapLocation.new,
label: t("proposals.form.map_location"),
help: t("proposals.form.map_location_instructions"),
label: t("proposals.form.map_location"),
help: t("proposals.form.map_location_instructions"),
i18n_namespace: "proposals" %>
</div>
<% end %>
@@ -80,11 +80,11 @@
<br>
<%= f.text_field :tag_list, value: proposal.tag_list.to_s,
label: false,
placeholder: t("proposals.form.tags_placeholder"),
class: "js-tag-list tag-autocomplete",
aria: { describedby: "tag-list-help-text" },
data: { js_url: suggest_tags_path } %>
label: false,
placeholder: t("proposals.form.tags_placeholder"),
class: "js-tag-list tag-autocomplete",
aria: { describedby: "tag-list-help-text" },
data: { js_url: suggest_tags_path } %>
</div>
<% if current_user.unverified? %>

View File

@@ -37,8 +37,10 @@ class Admin::BudgetsWizard::BudgetsController < Admin::BudgetsWizard::BaseContro
end
def allowed_params
valid_attributes = [:currency_symbol, :voting_style, :hide_money, administrator_ids: [],
valuator_ids: [], image_attributes: image_attributes]
valid_attributes = [:currency_symbol, :voting_style, :hide_money,
administrator_ids: [],
valuator_ids: [],
image_attributes: image_attributes]
[*valid_attributes, translation_params(Budget)]
end

View File

@@ -1,10 +1,10 @@
class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomization::BaseController
load_and_authorize_resource :content_block, class: "SiteCustomization::ContentBlock",
except: [
:delete_heading_content_block,
:edit_heading_content_block,
:update_heading_content_block
]
except: [
:delete_heading_content_block,
:edit_heading_content_block,
:update_heading_content_block
]
def index
@content_blocks = SiteCustomization::ContentBlock.order(:name, :locale)

View File

@@ -4,17 +4,17 @@ class Admin::SystemEmailsController < Admin::BaseController
def index
@system_emails = {
proposal_notification_digest: %w[view preview_pending],
budget_investment_created: %w[view edit_info],
budget_investment_selected: %w[view edit_info],
budget_investment_created: %w[view edit_info],
budget_investment_selected: %w[view edit_info],
budget_investment_unfeasible: %w[view edit_info],
budget_investment_unselected: %w[view edit_info],
comment: %w[view edit_info],
reply: %w[view edit_info],
direct_message_for_receiver: %w[view edit_info],
direct_message_for_sender: %w[view edit_info],
email_verification: %w[view edit_info],
user_invite: %w[view edit_info],
evaluation_comment: %w[view edit_info]
comment: %w[view edit_info],
reply: %w[view edit_info],
direct_message_for_receiver: %w[view edit_info],
direct_message_for_sender: %w[view edit_info],
email_verification: %w[view edit_info],
user_invite: %w[view edit_info],
evaluation_comment: %w[view edit_info]
}
end

View File

@@ -30,8 +30,9 @@ class Dashboard::ActionsController < Dashboard::BaseController
def execute
authorize! :dashboard, proposal
Dashboard::ExecutedAction.create(proposal: proposal, action: dashboard_action,
executed_at: Time.current)
Dashboard::ExecutedAction.create(proposal: proposal,
action: dashboard_action,
executed_at: Time.current)
redirect_to request.referer
end

View File

@@ -10,7 +10,7 @@ class Dashboard::PosterController < Dashboard::BaseController
dpi: 300,
zoom: 0.32,
show_as_html: Rails.env.test? || params.key?("debug"),
margin: { top: 0 }
margin: { top: 0 }
end
end
end

View File

@@ -13,7 +13,7 @@ class Officing::VotersController < Officing::BaseController
def create
@poll = Poll.find(voter_params[:poll_id])
@user = User.find(voter_params[:user_id])
@voter = Poll::Voter.new(document_type: @user.document_type,
@voter = Poll::Voter.new(document_type: @user.document_type,
document_number: @user.document_number,
user: @user,
poll: @poll,

View File

@@ -86,10 +86,10 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
investment_headings.reduce(all_headings_filter) do |filters, heading|
filters << {
name: heading.name,
id: heading.id,
count: investments.count { |i| i.heading_id == heading.id }
}
name: heading.name,
id: heading.id,
count: investments.count { |i| i.heading_id == heading.id }
}
end
end

View File

@@ -33,13 +33,13 @@ module BudgetsHelper
def budget_subnav_items_for(budget)
{
results: t("budgets.results.link"),
stats: t("stats.budgets.link"),
results: t("budgets.results.link"),
stats: t("stats.budgets.link"),
executions: t("budgets.executions.link")
}.select { |section, _| can?(:"read_#{section}", budget) }.map do |section, text|
{
text: text,
url: send("budget_#{section}_path", budget),
url: send("budget_#{section}_path", budget),
active: controller_name == section.to_s
}
end

View File

@@ -9,12 +9,12 @@ module LegislationHelper
def legislation_process_tabs(process)
{
"info" => edit_admin_legislation_process_path(process),
"homepage" => edit_admin_legislation_process_homepage_path(process),
"questions" => admin_legislation_process_questions_path(process),
"proposals" => admin_legislation_process_proposals_path(process),
"info" => edit_admin_legislation_process_path(process),
"homepage" => edit_admin_legislation_process_homepage_path(process),
"questions" => admin_legislation_process_questions_path(process),
"proposals" => admin_legislation_process_proposals_path(process),
"draft_versions" => admin_legislation_process_draft_versions_path(process),
"milestones" => admin_legislation_process_milestones_path(process)
"milestones" => admin_legislation_process_milestones_path(process)
}
end

View File

@@ -3,7 +3,7 @@ module MilestonesHelper
text = number_to_percentage(progress_bar.percentage, precision: 0)
tag.div class: "progress",
role: "progressbar",
role: "progressbar",
"aria-valuenow": progress_bar.percentage,
"aria-valuetext": "#{progress_bar.percentage}%",
"aria-valuemax": ProgressBar::RANGE.max,

View File

@@ -70,7 +70,7 @@ module TranslatableFormHelper
{
class: "translatable-fields js-globalize-attribute #{highlight_translation_html_class}",
style: @template.display_translation_style(resource.globalized_model, locale),
data: { locale: locale }
data: { locale: locale }
}
end

View File

@@ -33,9 +33,9 @@ class Budget
validates :slug, presence: true, format: /\A[a-z0-9\-_]+\z/
validates :population, numericality: { greater_than: 0 }, allow_nil: true
validates :latitude, length: { maximum: 22 }, allow_blank: true, \
format: /\A(-|\+)?([1-8]?\d(?:\.\d{1,})?|90(?:\.0{1,6})?)\z/
format: /\A(-|\+)?([1-8]?\d(?:\.\d{1,})?|90(?:\.0{1,6})?)\z/
validates :longitude, length: { maximum: 22 }, allow_blank: true, \
format: /\A(-|\+)?((?:1[0-7]|[1-9])?\d(?:\.\d{1,})?|180(?:\.0{1,})?)\z/
format: /\A(-|\+)?((?:1[0-7]|[1-9])?\d(?:\.\d{1,})?|180(?:\.0{1,})?)\z/
validates :max_ballot_lines, numericality: { greater_than_or_equal_to: 1 }
delegate :budget, :budget_id, to: :group, allow_nil: true

View File

@@ -51,7 +51,7 @@ class Budget
has_many :comments, -> { where(valuation: false) }, as: :commentable, inverse_of: :commentable
has_one :summary_comment, as: :commentable, class_name: "MlSummaryComment", dependent: :destroy
has_many :valuations, -> { where(valuation: true) },
as: :commentable,
as: :commentable,
inverse_of: :commentable,
class_name: "Comment"
@@ -203,8 +203,9 @@ class Budget
end
def searchable_values
{ author.username => "B",
heading.name => "B",
{
author.username => "B",
heading.name => "B",
tag_list.join(" ") => "B"
}.merge(searchable_globalized_values)
end
@@ -394,7 +395,7 @@ class Budget
end
def searchable_translations_definitions
{ title => "A",
{ title => "A",
description => "D" }
end
end

View File

@@ -57,10 +57,10 @@ class Comment < ApplicationRecord
def self.build(commentable, user, body, p_id = nil, valuation = false)
new(commentable: commentable,
user_id: user.id,
body: body,
parent_id: p_id,
valuation: valuation)
user_id: user.id,
body: body,
parent_id: p_id,
valuation: valuation)
end
def self.find_commentable(c_type, c_id)
@@ -134,7 +134,7 @@ class Comment < ApplicationRecord
def searchable_values
{
body => "A",
body => "A",
commentable&.title => "B"
}
end

View File

@@ -3,9 +3,9 @@ module Relationable
included do
has_many :related_contents,
as: :parent_relationable,
as: :parent_relationable,
inverse_of: :parent_relationable,
dependent: :destroy
dependent: :destroy
end
def find_related_content(relationable)

View File

@@ -57,15 +57,15 @@ class Debate < ApplicationRecord
end
def searchable_translations_definitions
{ title => "A",
{ title => "A",
description => "D" }
end
def searchable_values
{
author.username => "B",
author.username => "B",
tag_list.join(" ") => "B",
geozone&.name => "B"
geozone&.name => "B"
}.merge!(searchable_globalized_values)
end

View File

@@ -12,8 +12,8 @@ class Legislation::DraftVersion < ApplicationRecord
belongs_to :process, foreign_key: "legislation_process_id", inverse_of: :draft_versions
has_many :annotations,
foreign_key: "legislation_draft_version_id",
inverse_of: :draft_version,
dependent: :destroy
inverse_of: :draft_version,
dependent: :destroy
validates_translation :title, presence: true
validates_translation :body, presence: true

View File

@@ -28,20 +28,20 @@ class Legislation::Process < ApplicationRecord
has_many :draft_versions, -> { order(:id) },
foreign_key: "legislation_process_id",
inverse_of: :process,
dependent: :destroy
inverse_of: :process,
dependent: :destroy
has_one :final_draft_version, -> { where final_version: true, status: "published" },
class_name: "Legislation::DraftVersion",
class_name: "Legislation::DraftVersion",
foreign_key: "legislation_process_id",
inverse_of: :process
inverse_of: :process
has_many :questions, -> { order(:id) },
foreign_key: "legislation_process_id",
inverse_of: :process,
dependent: :destroy
inverse_of: :process,
dependent: :destroy
has_many :proposals, -> { order(:id) },
foreign_key: "legislation_process_id",
inverse_of: :process,
dependent: :destroy
inverse_of: :process,
dependent: :destroy
validates_translation :title, presence: true
validates :start_date, presence: true
@@ -127,8 +127,8 @@ class Legislation::Process < ApplicationRecord
def searchable_translations_definitions
{
title => "A",
summary => "C",
title => "A",
summary => "C",
description => "D"
}
end

View File

@@ -57,12 +57,12 @@ class Legislation::Proposal < ApplicationRecord
end
def searchable_values
{ title => "A",
author.username => "B",
{ title => "A",
author.username => "B",
tag_list.join(" ") => "B",
geozone&.name => "B",
summary => "C",
description => "D" }
geozone&.name => "B",
summary => "C",
description => "D" }
end
def self.search(terms)

View File

@@ -32,17 +32,17 @@ class Officing::Residence
user.update!(verified_at: Time.current)
else
user_params = {
document_number: document_number,
document_type: document_type,
geozone: geozone,
date_of_birth: response_date_of_birth.in_time_zone.to_datetime,
gender: gender,
document_number: document_number,
document_type: document_type,
geozone: geozone,
date_of_birth: response_date_of_birth.in_time_zone.to_datetime,
gender: gender,
residence_verified_at: Time.current,
verified_at: Time.current,
erased_at: Time.current,
password: random_password,
terms_of_service: "1",
email: nil
verified_at: Time.current,
erased_at: Time.current,
password: random_password,
terms_of_service: "1",
email: nil
}
self.user = User.create!(user_params)
end

View File

@@ -205,8 +205,8 @@ class Poll < ApplicationRecord
def searchable_translations_definitions
{
name => "A",
summary => "C",
name => "A",
summary => "C",
description => "D"
}
end

View File

@@ -36,8 +36,8 @@ class Poll::BallotSheet < ApplicationRecord
def create_ballot(poll_ballot)
Budget::Ballot.where(physical: true,
user: nil,
poll_ballot: poll_ballot,
budget: poll.budget).first_or_create!
user: nil,
poll_ballot: poll_ballot,
budget: poll.budget).first_or_create!
end
end

View File

@@ -17,7 +17,7 @@ class Poll::Question < ApplicationRecord
has_many :question_answers, -> { order "given_order asc" },
class_name: "Poll::Question::Answer",
inverse_of: :question,
dependent: :destroy
dependent: :destroy
has_many :partial_results
belongs_to :proposal
@@ -40,9 +40,9 @@ class Poll::Question < ApplicationRecord
end
def searchable_values
{ title => "A",
proposal&.title => "A",
author.username => "C",
{ title => "A",
proposal&.title => "A",
author.username => "C",
author_visible_name => "C" }
end

View File

@@ -28,10 +28,10 @@ class Poll
def create_officer_assignments
booth.booth_assignments.order(:id).each do |booth_assignment|
attrs = {
officer_id: officer_id,
date: date,
officer_id: officer_id,
date: date,
booth_assignment_id: booth_assignment.id,
final: recount_scrutiny?
final: recount_scrutiny?
}
Poll::OfficerAssignment.create!(attrs)
end

View File

@@ -12,10 +12,10 @@ class ProgressBar < ApplicationRecord
validates :progressable, presence: true
validates :kind, presence: true,
uniqueness: {
scope: [:progressable_type, :progressable_id],
conditions: -> { primary }
}
uniqueness: {
scope: [:progressable_type, :progressable_id],
conditions: -> { primary }
}
validates :percentage, presence: true, inclusion: { in: ->(*) { RANGE }}, numericality: { only_integer: true }
validates_translation :title, presence: true, unless: :primary?

View File

@@ -118,16 +118,16 @@ class Proposal < ApplicationRecord
end
def searchable_translations_definitions
{ title => "A",
summary => "C",
{ title => "A",
summary => "C",
description => "D" }
end
def searchable_values
{
author.username => "B",
tag_list.join(" ") => "B",
geozone&.name => "B"
author.username => "B",
tag_list.join(" ") => "B",
geozone&.name => "B"
}.merge!(searchable_globalized_values)
end

View File

@@ -59,7 +59,7 @@ class ProposalNotification < ApplicationRecord
def searchable_values
{
title => "A",
body => "B"
body => "B"
}
end

View File

@@ -9,7 +9,7 @@ class SDG::LocalTarget < ApplicationRecord
validates_translation :description, presence: true
validates :code, presence: true, uniqueness: true,
format: ->(local_target) { /\A#{local_target.target&.code}\.\d+/ }
format: ->(local_target) { /\A#{local_target.target&.code}\.\d+/ }
validates :target, presence: true
validates :goal, presence: true

View File

@@ -61,18 +61,18 @@ class Setting < ApplicationRecord
def mime_types
{
"images" => {
"jpg" => "image/jpeg",
"png" => "image/png",
"gif" => "image/gif"
"jpg" => "image/jpeg",
"png" => "image/png",
"gif" => "image/gif"
},
"documents" => {
"pdf" => "application/pdf",
"doc" => "application/msword",
"pdf" => "application/pdf",
"doc" => "application/msword",
"docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
"xls" => "application/x-ole-storage",
"xls" => "application/x-ole-storage",
"xlsx" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
"csv" => "text/plain",
"zip" => "application/zip"
"csv" => "text/plain",
"zip" => "application/zip"
}
}
end

View File

@@ -26,55 +26,55 @@ class User < ApplicationRecord
has_many :proposals, -> { with_hidden }, foreign_key: :author_id, inverse_of: :author
has_many :activities
has_many :budget_investments, -> { with_hidden },
class_name: "Budget::Investment",
class_name: "Budget::Investment",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :comments, -> { with_hidden }, inverse_of: :user
has_many :failed_census_calls
has_many :notifications
has_many :direct_messages_sent,
class_name: "DirectMessage",
class_name: "DirectMessage",
foreign_key: :sender_id,
inverse_of: :sender
inverse_of: :sender
has_many :direct_messages_received,
class_name: "DirectMessage",
class_name: "DirectMessage",
foreign_key: :receiver_id,
inverse_of: :receiver
inverse_of: :receiver
has_many :legislation_answers, class_name: "Legislation::Answer", dependent: :destroy, inverse_of: :user
has_many :follows
has_many :legislation_annotations,
class_name: "Legislation::Annotation",
class_name: "Legislation::Annotation",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :legislation_proposals,
class_name: "Legislation::Proposal",
class_name: "Legislation::Proposal",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :legislation_questions,
class_name: "Legislation::Question",
class_name: "Legislation::Question",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :polls, foreign_key: :author_id, inverse_of: :author
has_many :poll_answers,
class_name: "Poll::Answer",
class_name: "Poll::Answer",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :poll_pair_answers,
class_name: "Poll::PairAnswer",
class_name: "Poll::PairAnswer",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :poll_partial_results,
class_name: "Poll::PartialResult",
class_name: "Poll::PartialResult",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :poll_questions,
class_name: "Poll::Question",
class_name: "Poll::Question",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :poll_recounts,
class_name: "Poll::Recount",
class_name: "Poll::Recount",
foreign_key: :author_id,
inverse_of: :author
inverse_of: :author
has_many :related_contents, foreign_key: :author_id, inverse_of: :author, dependent: nil
has_many :topics, foreign_key: :author_id, inverse_of: :author
belongs_to :geozone
@@ -136,7 +136,7 @@ class User < ApplicationRecord
oauth_user = User.find_by(email: oauth_email) if oauth_email_confirmed
oauth_user || User.new(
username: auth.info.name || auth.uid,
username: auth.info.name || auth.uid,
email: oauth_email,
oauth_email: oauth_email,
password: Devise.friendly_token[0, 20],

View File

@@ -3,7 +3,7 @@ class Verification::Management::ManagedUser
def self.find(document_type, document_number)
User.where.not(document_number: nil)
.find_or_initialize_by(document_type: document_type,
document_number: document_number)
.find_or_initialize_by(document_type: document_type,
document_number: document_number)
end
end

View File

@@ -29,11 +29,11 @@ class Verification::Residence
user.take_votes_if_erased_document(document_number, document_type)
user.update(document_number: document_number,
document_type: document_type,
geozone: geozone,
date_of_birth: date_of_birth.in_time_zone.to_datetime,
gender: gender,
user.update(document_number: document_number,
document_type: document_type,
geozone: geozone,
date_of_birth: date_of_birth.in_time_zone.to_datetime,
gender: gender,
residence_verified_at: Time.current)
end

View File

@@ -44,18 +44,21 @@
<div class="row expanded margin-top">
<div class="small-12 medium-4 column">
<%= f.number_field :day_offset, step: 1, min: 0,
hint: t("admin.dashboard.actions.form.help_text") %>
<%= f.number_field :day_offset, step: 1,
min: 0,
hint: t("admin.dashboard.actions.form.help_text") %>
</div>
<div class="small-12 medium-4 column">
<%= f.number_field :required_supports, step: 1, min: 0,
hint: t("admin.dashboard.actions.form.help_text") %>
<%= f.number_field :required_supports, step: 1,
min: 0,
hint: t("admin.dashboard.actions.form.help_text") %>
</div>
<div class="small-12 medium-4 column">
<%= f.number_field :order, step: 1, min: 0,
hint: t("admin.dashboard.actions.form.help_text") %>
<%= f.number_field :order, step: 1,
min: 0,
hint: t("admin.dashboard.actions.form.help_text") %>
</div>
</div>

View File

@@ -1,8 +1,11 @@
<%= render "shared/globalize_locales", resource: @draft_version %>
<%= translatable_form_for [:admin, @process, @draft_version], url: url,
html: { data: { markdown_changes_message: I18n.t("admin.legislation.draft_versions.edit.markdown_changes_message") }} do |f| %>
html: {
data: {
markdown_changes_message: I18n.t("admin.legislation.draft_versions.edit.markdown_changes_message")
}
} do |f| %>
<%= render "shared/errors", resource: @draft_version %>
<div class="row">
@@ -50,8 +53,9 @@
</div>
<div class="small-12 medium-6 column markdown-area">
<%= translations_form.text_area :body, label: false, rows: 10,
class: "legislation-draft-version-body" %>
<%= translations_form.text_area :body, label: false,
rows: 10,
class: "legislation-draft-version-body" %>
</div>
<div class="small-12 medium-6 column markdown-preview">

View File

@@ -4,11 +4,11 @@
<div class="small-12 medium-8 column">
<%= f.text_field :custom_list, value: @process.tag_list_on(:customs).sort.join(", "),
label: t("admin.legislation.proposals.form.custom_categories"),
hint: t("admin.legislation.proposals.form.custom_categories_description"),
placeholder: t("admin.legislation.proposals.form.custom_categories_placeholder"),
class: "js-tag-list",
aria: { describedby: "tag-list-help-text" } %>
label: t("admin.legislation.proposals.form.custom_categories"),
hint: t("admin.legislation.proposals.form.custom_categories_description"),
placeholder: t("admin.legislation.proposals.form.custom_categories_placeholder"),
class: "js-tag-list",
aria: { describedby: "tag-list-help-text" } %>
</div>
<div class="small-12 medium-3 column clear end">

View File

@@ -9,7 +9,7 @@
<div class="column">
<span class="help-text"><%= t("admin.active_polls.form.description.help_text") %></span>
<%= translations_form.text_area :description, class: "html-area",
maxlength: ActivePoll.description_max_length %>
maxlength: ActivePoll.description_max_length %>
</div>
<% end %>
</div>

View File

@@ -19,7 +19,7 @@
</div>
<%= f.text_area :required_fields_to_verify, rows: "6",
hint: sanitize("#{required_fields_to_verify_text_help}<br/>#{example_text_help}") %>
hint: sanitize("#{required_fields_to_verify_text_help}<br/>#{example_text_help}") %>
<%= f.submit(class: "button", value: t("admin.signature_sheets.new.submit")) %>
<% end %>

View File

@@ -21,8 +21,9 @@
</div>
<div class="small-12 medium-6 column">
<%= f.text_field :slug, size: 80, maxlength: 80,
hint: sanitize(t("admin.site_customization.pages.new.slug_help")) %>
<%= f.text_field :slug, size: 80,
maxlength: 80,
hint: sanitize(t("admin.site_customization.pages.new.slug_help")) %>
</div>
</div>

View File

@@ -32,7 +32,7 @@
<%= link_to t("admin.system_emails.preview_pending.moderate_pending"),
admin_system_email_moderate_pending_path(system_email_id: "proposal_notification_digest",
id: preview.id),
id: preview.id),
method: :put,
class: "button hollow float-right" %>
</div>

View File

@@ -100,8 +100,8 @@
<% if !valuation || can?(:comment_valuation, comment.commentable) %>
<%= render "comments/form", { commentable: comment.commentable,
parent_id: comment.id,
valuation: valuation } %>
parent_id: comment.id,
valuation: valuation } %>
<% end %>
<% end %>
</div>

View File

@@ -55,7 +55,7 @@
<td style="text-align: center;">
<%= link_to proposal_url(@proposal, anchor: "social-share") do %>
<%= image_tag("social_buttons_mailer.png", alt: t("dashboard.mailer.forward.share_in"),
style: "max-width: 100%;") %>
style: "max-width: 100%;") %>
<% end %>
</td>
</tr>

View File

@@ -53,7 +53,7 @@
border-radius: 6px; color: #fff !important; font-weight: bold;
padding: 17px 20px; text-align: center; text-decoration: none;
font-size: 20px; min-width: 200px; display: inline-block;",
target: "_blank" do %>
target: "_blank" do %>
<%= t("mailers.new_actions_notification_on_published.dashboard_button") %>
<% end %>
</td>

View File

@@ -24,8 +24,9 @@
<% end %>
</div>
<%= form_for poll, remote: true, data: { type: :json },
url: proposal_dashboard_poll_path(proposal, poll) do |f| %>
<%= form_for poll, remote: true,
data: { type: :json },
url: proposal_dashboard_poll_path(proposal, poll) do |f| %>
<%= f.check_box :results_enabled, class: "js-submit-on-change" %>
<% end %>
<p class="help-text"><%= t("dashboard.polls.poll.show_results_help") %></p>

View File

@@ -6,13 +6,14 @@
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.password_field :password, autofocus: true, autocomplete: "off",
label: t("devise_views.passwords.edit.password_label") %>
<%= f.password_field :password, autofocus: true,
autocomplete: "off",
label: t("devise_views.passwords.edit.password_label") %>
</div>
<div class="field">
<%= f.password_field :password_confirmation, autocomplete: "off",
label: t("devise_views.passwords.edit.password_confirmation_label") %>
label: t("devise_views.passwords.edit.password_confirmation_label") %>
</div>
<div class="actions">

View File

@@ -5,7 +5,7 @@
<div class="field">
<%= f.email_field :email, autofocus: true,
label: t("devise_views.unlocks.new.email_label") %>
label: t("devise_views.unlocks.new.email_label") %>
</div>
<div class="actions">

View File

@@ -1,7 +1,9 @@
<li id="<%= dom_id(document) %>">
<%= link_to t("documents.buttons.download_document"),
document.attachment, target: "_blank",
rel: "nofollow", class: "button hollow medium float-right" %>
document.attachment,
target: "_blank",
rel: "nofollow",
class: "button hollow medium float-right" %>
<strong><%= document.title %></strong>
<br>

View File

@@ -6,7 +6,7 @@
<div class="small-12 medium-4 column">
<%= link_to process, class: "button hollow big expanded",
title: t("legislation.processes.process.see_latest_comments_title") do %>
title: t("legislation.processes.process.see_latest_comments_title") do %>
<span class="icon-comments"></span>&nbsp;
<%= t("legislation.processes.process.see_latest_comments") %>
<% end %>

View File

@@ -12,7 +12,7 @@
<div class="small-12 column">
<%= f.text_area :summary, rows: 4, maxlength: 200,
hint: t("proposals.form.proposal_summary_note") %>
hint: t("proposals.form.proposal_summary_note") %>
</div>
<div class="small-12 column">
@@ -54,10 +54,10 @@
<br>
<%= f.text_field :tag_list, value: @proposal.tag_list.to_s,
label: false,
placeholder: t("proposals.form.tags_placeholder"),
class: "js-tag-list",
aria: { describedby: "tag-list-help-text" } %>
label: false,
placeholder: t("proposals.form.tags_placeholder"),
class: "js-tag-list",
aria: { describedby: "tag-list-help-text" } %>
</div>
<div class="small-12 column">

View File

@@ -23,8 +23,9 @@
<p class="margin-top">
<%= link_to t("management.users.create_user"),
new_management_user_path(user: {
document_number: @email_verification.document_number,
document_type: @email_verification.document_type }),
document_number: @email_verification.document_number,
document_type: @email_verification.document_type
}),
class: "button success" %>
</p>
</li>

View File

@@ -4,7 +4,7 @@
<label><%= t("management.user_invites.new.label") %></label>
<p class="help-text" id="emails-help-text"><%= t("management.user_invites.new.info") %></p>
<%= text_area_tag "emails", nil, rows: 5,
aria: { describedby: "emails-help-text" } %>
aria: { describedby: "emails-help-text" } %>
<div class="small-12 medium-6 large-3">
<input type="submit" name="" value="<%= t("management.user_invites.new.submit") %>" class="button expanded">
</div>

View File

@@ -6,7 +6,8 @@
</h1>
<%= link_to t("notifications.index.mark_all_as_read"),
mark_all_as_read_notifications_path, method: :put,
mark_all_as_read_notifications_path,
method: :put,
class: "button hollow float-right-medium" %>
<ul class="menu simple clear">

View File

@@ -4,9 +4,11 @@
</p>
</td>
<td id="actions" class="text-center">
<%= form_for @user, as: :voter, url: officing_voters_path,
method: :post, remote: true,
html: { id: "new_officing_voter" } do |f| %>
<%= form_for @user, as: :voter,
url: officing_voters_path,
method: :post,
remote: true,
html: { id: "new_officing_voter" } do |f| %>
<%= f.hidden_field :poll_id, value: poll.id %>
<%= f.hidden_field :user_id, value: @user.id %>
<%= f.submit t("officing.voters.show.submit"),

View File

@@ -22,7 +22,7 @@
<%= f.password_field :password, autocomplete: "off" %>
<%= f.password_field :password_confirmation, autocomplete: "off",
label: t("devise_views.organizations.registrations.new.password_confirmation_label") %>
label: t("devise_views.organizations.registrations.new.password_confirmation_label") %>
<%= f.check_box :terms_of_service,
title: t("devise_views.users.registrations.new.terms_title"),

View File

@@ -5,7 +5,7 @@
social_url: poll_url,
social_title: t("social_share.polls_show.title_#{@poll.id}", default: @poll.title),
social_description: t("social_share.polls_show.facebook_#{@poll.id}", default: @poll.title),
twitter_image_url: "social_media_polls_twitter.jpg",
twitter_image_url: "social_media_polls_twitter.jpg",
og_image_url: "social_media_polls.jpg" %>
<% end %>

View File

@@ -32,7 +32,8 @@
class: "button hollow expanded" %>
<%= link_to t("community.show.topic.destroy"),
community_topic_path(@community.id, @topic), method: :delete,
community_topic_path(@community.id, @topic),
method: :delete,
class: "button hollow expanded alert" %>
</aside>
<% end %>

View File

@@ -3,8 +3,8 @@
<h2><%= t("devise_views.users.registrations.delete_form.title") %></h2>
<%= form_for(resource, as: resource_name,
url: users_registrations_path,
html: { method: :delete }) do |f| %>
url: users_registrations_path,
html: { method: :delete }) do |f| %>
<%= render "shared/errors", resource: resource %>
<div data-alert class="callout alert">

View File

@@ -27,7 +27,7 @@
<%= f.password_field :password, autocomplete: "off" %>
<%= f.password_field :password_confirmation, autocomplete: "off",
label: t("devise_views.users.registrations.new.password_confirmation_label") %>
label: t("devise_views.users.registrations.new.password_confirmation_label") %>
<% if resource.use_redeemable_code %>
<%= f.text_field :redeemable_code %>

View File

@@ -1,6 +1,6 @@
<h2><%= t("valuation.budget_investments.valuation_comments") %></h2>
<% unless @comment_tree.nil? %>
<%= render "/comments/comment_tree", comment_tree: @comment_tree,
display_comments_count: false,
valuation: true %>
display_comments_count: false,
valuation: true %>
<% end %>

View File

@@ -101,15 +101,15 @@ module Consul
]
config.i18n.available_locales = available_locales
config.i18n.fallbacks = [I18n.default_locale, {
"ca" => "es",
"ca" => "es",
"es-PE" => "es",
"eu" => "es",
"fr" => "es",
"gl" => "es",
"it" => "es",
"oc" => "fr",
"eu" => "es",
"fr" => "es",
"gl" => "es",
"it" => "es",
"oc" => "fr",
"pt-BR" => "es",
"val" => "es"
"val" => "es"
}]
config.i18n.load_path += Dir[Rails.root.join("config", "locales", "**[^custom]*", "*.{rb,yml}")]

View File

@@ -1,9 +1,9 @@
devise_for :users, controllers: {
registrations: "users/registrations",
sessions: "users/sessions",
confirmations: "users/confirmations",
omniauth_callbacks: "users/omniauth_callbacks"
}
registrations: "users/registrations",
sessions: "users/sessions",
confirmations: "users/confirmations",
omniauth_callbacks: "users/omniauth_callbacks"
}
devise_scope :user do
patch "/user/confirmation", to: "users/confirmations#update", as: :update_user_confirmation
@@ -16,11 +16,11 @@ devise_scope :user do
end
devise_for :organizations, class_name: "User",
controllers: {
registrations: "organizations/registrations",
sessions: "devise/sessions"
},
skip: [:omniauth_callbacks]
controllers: {
registrations: "organizations/registrations",
sessions: "devise/sessions"
},
skip: [:omniauth_callbacks]
devise_scope :organization do
get "organizations/sign_up/success", to: "organizations/registrations#success"

View File

@@ -7,7 +7,7 @@ section "Creating banners" do
description: description,
target_url: target_url,
post_started_at: rand((1.week.ago)..(1.day.ago)),
post_ended_at: rand((1.day.ago)..(1.week.from_now)),
post_ended_at: rand((1.day.ago)..(1.week.from_now)),
created_at: rand((1.week.ago)..Time.current))
I18n.available_locales.map do |locale|
Globalize.with_locale(locale) do

View File

@@ -29,7 +29,7 @@ section "Creating investment milestones" do
rand(0..3).times do
progress_bar = record.progress_bars.build(
kind: :secondary,
kind: :secondary,
percentage: rand(ProgressBar::RANGE)
)

View File

@@ -13,30 +13,30 @@ section "Creating polls" do
create_poll!(name: I18n.t("seeds.polls.current_poll"),
slug: I18n.t("seeds.polls.current_poll").parameterize,
starts_at: 7.days.ago,
ends_at: 7.days.from_now,
ends_at: 7.days.from_now,
geozone_restricted: false)
create_poll!(name: I18n.t("seeds.polls.current_poll_geozone_restricted"),
slug: I18n.t("seeds.polls.current_poll_geozone_restricted").parameterize,
starts_at: 5.days.ago,
ends_at: 5.days.from_now,
ends_at: 5.days.from_now,
geozone_restricted: true,
geozones: Geozone.sample(3))
create_poll!(name: I18n.t("seeds.polls.recounting_poll"),
slug: I18n.t("seeds.polls.recounting_poll").parameterize,
starts_at: 15.days.ago,
ends_at: 2.days.ago)
ends_at: 2.days.ago)
create_poll!(name: I18n.t("seeds.polls.expired_poll_without_stats"),
slug: I18n.t("seeds.polls.expired_poll_without_stats").parameterize,
starts_at: 2.months.ago,
ends_at: 1.month.ago)
ends_at: 1.month.ago)
create_poll!(name: I18n.t("seeds.polls.expired_poll_with_stats"),
slug: I18n.t("seeds.polls.expired_poll_with_stats").parameterize,
starts_at: 2.months.ago,
ends_at: 1.month.ago,
ends_at: 1.month.ago,
results_enabled: true,
stats_enabled: true)

View File

@@ -34,6 +34,6 @@ end
section "Creating SDG homepage cards" do
SDG::Phase.all.each do |phase|
Widget::Card.create!(cardable: phase, title: "#{phase.title} card",
link_text: "Link Text", link_url: "/any_path")
link_text: "Link Text", link_url: "/any_path")
end
end

View File

@@ -2,15 +2,15 @@ section "Creating Users" do
def create_user(email, username)
password = "12345678"
User.create!(
username: username,
email: email,
password: password,
password_confirmation: password,
confirmed_at: Time.current,
terms_of_service: "1",
gender: %w[male female].sample,
date_of_birth: rand((80.years.ago)..(16.years.ago)),
public_activity: (rand(1..100) > 30)
username: username,
email: email,
password: password,
password_confirmation: password,
confirmed_at: Time.current,
terms_of_service: "1",
gender: %w[male female].sample,
date_of_birth: rand((80.years.ago)..(16.years.ago)),
public_activity: (rand(1..100) > 30)
)
end
@@ -23,56 +23,69 @@ section "Creating Users" do
admin = create_user("admin@consul.dev", "admin")
admin.create_administrator
admin.update!(residence_verified_at: Time.current,
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
verified_at: Time.current, document_number: unique_document_number)
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
verified_at: Time.current, document_number: unique_document_number)
moderator = create_user("mod@consul.dev", "moderator")
moderator.create_moderator
moderator.update!(residence_verified_at: Time.current,
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
verified_at: Time.current, document_number: unique_document_number)
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
verified_at: Time.current, document_number: unique_document_number)
manager = create_user("manager@consul.dev", "manager")
manager.create_manager
manager.update!(residence_verified_at: Time.current,
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
verified_at: Time.current, document_number: unique_document_number)
confirmed_phone: Faker::PhoneNumber.phone_number,
document_type: "1",
verified_at: Time.current,
document_number: unique_document_number)
valuator = create_user("valuator@consul.dev", "valuator")
valuator.create_valuator
valuator.update!(residence_verified_at: Time.current,
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
verified_at: Time.current, document_number: unique_document_number)
confirmed_phone: Faker::PhoneNumber.phone_number,
document_type: "1",
verified_at: Time.current,
document_number: unique_document_number)
poll_officer = create_user("poll_officer@consul.dev", "Paul O. Fisher")
poll_officer.create_poll_officer
poll_officer.update!(residence_verified_at: Time.current,
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
verified_at: Time.current, document_number: unique_document_number)
confirmed_phone: Faker::PhoneNumber.phone_number,
document_type: "1",
verified_at: Time.current,
document_number: unique_document_number)
poll_officer2 = create_user("poll_officer2@consul.dev", "Pauline M. Espinosa")
poll_officer2.create_poll_officer
poll_officer2.update!(residence_verified_at: Time.current,
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
verified_at: Time.current, document_number: unique_document_number)
confirmed_phone: Faker::PhoneNumber.phone_number,
document_type: "1",
verified_at: Time.current,
document_number: unique_document_number)
sdg_manager = create_user("sdg_manager@consul.dev", "SDG manager")
sdg_manager.create_sdg_manager
sdg_manager.update!(residence_verified_at: Time.current,
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
verified_at: Time.current, document_number: unique_document_number)
confirmed_phone: Faker::PhoneNumber.phone_number,
document_type: "1",
verified_at: Time.current,
document_number: unique_document_number)
create_user("unverified@consul.dev", "unverified")
level_2 = create_user("leveltwo@consul.dev", "level 2")
level_2.update!(residence_verified_at: Time.current,
confirmed_phone: Faker::PhoneNumber.phone_number,
document_number: unique_document_number, document_type: "1")
confirmed_phone: Faker::PhoneNumber.phone_number,
document_number: unique_document_number,
document_type: "1")
verified = create_user("verified@consul.dev", "verified")
verified.update!(residence_verified_at: Time.current,
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
verified_at: Time.current, document_number: unique_document_number)
confirmed_phone: Faker::PhoneNumber.phone_number,
document_type: "1",
verified_at: Time.current,
document_number: unique_document_number)
[
I18n.t("seeds.organizations.neighborhood_association"),

View File

@@ -2,10 +2,10 @@ class AddTimeZoneToDefaultDatetimes < ActiveRecord::Migration[4.2]
def change
change_column_default :users, :password_changed_at,
from: Time.zone.local(2015, 1, 1, 1, 1, 1),
to: DateTime.new(2015, 1, 1, 1, 1, 1, "+00:00")
to: DateTime.new(2015, 1, 1, 1, 1, 1, "+00:00")
change_column_default :locks, :locked_until,
from: Time.zone.local(2000, 1, 1, 1, 1, 1),
to: DateTime.new(2000, 1, 1, 1, 1, 1, "+00:00")
to: DateTime.new(2000, 1, 1, 1, 1, 1, "+00:00")
end
end

View File

@@ -71,11 +71,11 @@ class CensusApi
def request(document_type, document_number)
{ request:
{ codigo_institucion: Rails.application.secrets.census_api_institution_code,
codigo_portal: Rails.application.secrets.census_api_portal_name,
codigo_usuario: Rails.application.secrets.census_api_user_code,
documento: document_number,
tipo_documento: document_type,
codigo_idioma: 102,
codigo_portal: Rails.application.secrets.census_api_portal_name,
codigo_usuario: Rails.application.secrets.census_api_user_code,
documento: document_number,
tipo_documento: document_type,
codigo_idioma: 102,
nivel: 3 }}
end

View File

@@ -28,21 +28,21 @@ class MarkdownConverter
def default_render_options
{
filter_html: false,
hard_wrap: true,
filter_html: false,
hard_wrap: true,
link_attributes: { target: "_blank" }
}
end
def extensions
{
autolink: true,
autolink: true,
fenced_code_blocks: true,
lax_spacing: true,
no_intra_emphasis: true,
strikethrough: true,
superscript: true,
tables: true
lax_spacing: true,
no_intra_emphasis: true,
strikethrough: true,
superscript: true,
tables: true
}
end
end

View File

@@ -13,10 +13,10 @@ module OmniAuth
info do
{
name: raw_info["display_name"],
email: raw_info["user_email"],
nickname: raw_info["user_nicename"],
urls: { "Website" => raw_info["user_url"] }
name: raw_info["display_name"],
email: raw_info["user_email"],
nickname: raw_info["user_nicename"],
urls: { "Website" => raw_info["user_url"] }
}
end

View File

@@ -24,7 +24,7 @@ class SMSApi
end
def request(phone, code)
{ autorizacion: authorization,
{ autorizacion: authorization,
destinatarios: { destinatario: phone },
texto_mensaje: "Clave para verificarte: #{code}. Gobierno Abierto",
solicita_notificacion: "All" }

View File

@@ -12,8 +12,8 @@ describe Relationable::RelatedListComponent do
create(:related_content, parent_relationable: proposal, child_relationable: user_proposal)
create(:related_content, parent_relationable: proposal,
child_relationable: machine_proposal,
machine_learning: true)
child_relationable: machine_proposal,
machine_learning: true)
end
it "displays machine learning and user content when machine learning is enabled" do

View File

@@ -5,9 +5,9 @@ describe Shared::BannerComponent do
banner = create(:banner,
title: "Vote now!",
description: "Banner description",
target_url: "http://www.url.com",
target_url: "http://www.url.com",
post_started_at: (Date.current - 4.days),
post_ended_at: (Date.current + 10.days),
post_ended_at: (Date.current + 10.days),
background_color: "#FF0000",
font_color: "#FFFFFF"
)

View File

@@ -8,10 +8,10 @@ describe Admin::Poll::Questions::Answers::VideosController, :admin do
it "is not possible for an already started poll" do
post :create, params: {
poll_question_answer_video: {
title: "Video from started poll",
url: "https://www.youtube.com/watch?v=-JMf43st-1A"
},
answer_id: current_answer
title: "Video from started poll",
url: "https://www.youtube.com/watch?v=-JMf43st-1A"
},
answer_id: current_answer
}
expect(flash[:alert]).to eq "You do not have permission to carry out the action 'create' on Video."
@@ -21,8 +21,8 @@ describe Admin::Poll::Questions::Answers::VideosController, :admin do
it "is possible for a not started poll" do
post :create, params: {
poll_question_answer_video: {
title: "Video from not started poll",
url: "https://www.youtube.com/watch?v=-JMf43st-1A"
title: "Video from not started poll",
url: "https://www.youtube.com/watch?v=-JMf43st-1A"
},
answer_id: future_answer
}

View File

@@ -4,7 +4,7 @@ describe CommentsController do
describe "POST create" do
let(:legal_process) do
create(:legislation_process, debate_start_date: Date.current - 3.days,
debate_end_date: Date.current + 2.days)
debate_end_date: Date.current + 2.days)
end
let(:question) { create(:legislation_question, process: legal_process, title: "Question 1") }
let(:user) { create(:user, :level_two) }
@@ -53,13 +53,13 @@ describe CommentsController do
expect do
post :create, xhr: true,
params: {
comment: {
commentable_id: annotation.id,
commentable_type: "Legislation::Annotation",
body: "a comment"
}
}
params: {
comment: {
commentable_id: annotation.id,
commentable_type: "Legislation::Annotation",
body: "a comment"
}
}
end.not_to change { annotation.reload.comments_count }
end

View File

@@ -25,7 +25,7 @@ describe Legislation::AnnotationsController do
describe "POST create" do
let(:legal_process) do
create(:legislation_process, allegations_start_date: Date.current - 3.days,
allegations_end_date: Date.current + 2.days)
allegations_end_date: Date.current + 2.days)
end
let(:draft_version) do
create(:legislation_draft_version, :published, process: legal_process, title: "Version 1")
@@ -40,19 +40,19 @@ describe Legislation::AnnotationsController do
sign_in user
post :create, params: {
process_id: legal_process.id,
draft_version_id: draft_version.id,
legislation_annotation: {
"quote" => "ipsum",
"ranges" => [{
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
"text" => "una anotacion"
}
}
process_id: legal_process.id,
draft_version_id: draft_version.id,
legislation_annotation: {
"quote" => "ipsum",
"ranges" => [{
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
"text" => "una anotacion"
}
}
expect(Ahoy::Event.where(name: :legislation_annotation_created).count).to eq 1
expect(Ahoy::Event.last.properties["legislation_annotation_id"]).to eq Legislation::Annotation.last.id
end
@@ -61,19 +61,19 @@ describe Legislation::AnnotationsController do
sign_in user
post :create, params: {
process_id: legal_process.id,
draft_version_id: final_version.id,
legislation_annotation: {
"quote" => "ipsum",
"ranges" => [{
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
"text" => "una anotacion"
}
}
process_id: legal_process.id,
draft_version_id: final_version.id,
legislation_annotation: {
"quote" => "ipsum",
"ranges" => [{
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
"text" => "una anotacion"
}
}
expect(response).to have_http_status(:not_found)
end
@@ -87,14 +87,14 @@ describe Legislation::AnnotationsController do
process_id: legal_process.id,
draft_version_id: draft_version.id,
legislation_annotation: {
"quote" => "ipsum",
"quote" => "ipsum",
"ranges" => [{
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
"text" => "una anotacion"
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
"text" => "una anotacion"
}
}
end.to change { draft_version.annotations.count }.by(1)
@@ -112,11 +112,11 @@ describe Legislation::AnnotationsController do
legislation_annotation: {
"quote" => "ipsum",
"ranges" => [{
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
"text" => "una anotacion"
}
}
@@ -132,14 +132,14 @@ describe Legislation::AnnotationsController do
process_id: legal_process.id,
draft_version_id: draft_version.id,
legislation_annotation: {
"quote" => "ipsum",
"quote" => "ipsum",
"ranges" => [{
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}].to_json,
"text" => "una anotacion"
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}].to_json,
"text" => "una anotacion"
}
}
end.to change { draft_version.annotations.count }.by(1)
@@ -149,15 +149,15 @@ describe Legislation::AnnotationsController do
annotation = create(:legislation_annotation, draft_version: draft_version,
text: "my annotation",
ranges: [{
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
range_start: "/p[1]",
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
range_start: "/p[1]",
range_start_offset: 6,
range_end: "/p[1]",
range_end_offset: 11)
range_end: "/p[1]",
range_end_offset: 11)
sign_in user
expect do
@@ -166,14 +166,14 @@ describe Legislation::AnnotationsController do
process_id: legal_process.id,
draft_version_id: draft_version.id,
legislation_annotation: {
"quote" => "ipsum",
"quote" => "ipsum",
"ranges" => [{
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
"text" => "una anotacion"
"start" => "/p[1]",
"startOffset" => 6,
"end" => "/p[1]",
"endOffset" => 11
}],
"text" => "una anotacion"
}
}
end.not_to change { draft_version.annotations.count }

View File

@@ -4,7 +4,7 @@ describe Legislation::AnswersController do
describe "POST create" do
let(:legal_process) do
create(:legislation_process, debate_start_date: Date.current - 3.days,
debate_end_date: Date.current + 2.days)
debate_end_date: Date.current + 2.days)
end
let(:question) { create(:legislation_question, process: legal_process, title: "Question 1") }
let(:question_option) { create(:legislation_question_option, question: question, value: "Yes") }
@@ -14,12 +14,12 @@ describe Legislation::AnswersController do
sign_in user
post :create, params: {
process_id: legal_process.id,
question_id: question.id,
legislation_answer: {
legislation_question_option_id: question_option.id
}
}
process_id: legal_process.id,
question_id: question.id,
legislation_answer: {
legislation_question_option_id: question_option.id
}
}
expect(Ahoy::Event.where(name: :legislation_answer_created).count).to eq 1
expect(Ahoy::Event.last.properties["legislation_answer_id"]).to eq Legislation::Answer.last.id
end

View File

@@ -16,10 +16,10 @@ describe Management::SessionsController do
allow_any_instance_of(ManagerAuthenticator).to receive(:auth).and_return(manager)
get :create, params: {
login: "JJB033",
clave_usuario: "31415926",
fecha_conexion: "20151031135905"
}
login: "JJB033",
clave_usuario: "31415926",
fecha_conexion: "20151031135905"
}
expect(response).to be_redirect
expect(session[:manager][:login]).to eq "JJB033"
end

View File

@@ -36,7 +36,7 @@ describe RemoteCensusApi do
params = {
"document_type" => "1",
"date_of_birth" => "1980-12-31",
"postal_code" => "28013"
"postal_code" => "28013"
}
savon.expects(:verify_residence)
@@ -79,8 +79,8 @@ describe RemoteCensusApi do
params = {
"document_type" => "1",
"date_of_birth" => "1980-12-31",
"postal_code" => "28013",
"api_key" => "your_api_key"
"postal_code" => "28013",
"api_key" => "your_api_key"
}
savon.expects(:verify_residence)

View File

@@ -10,8 +10,10 @@ describe "rake db:seed" do
SiteCustomization::Page.destroy_all
load Rails.root.join("db", "pages.rb")
paths = { accessibility: "pages.accessibility.title", conditions: "pages.conditions.title",
faq: "pages.help.faq.page.title", privacy: "pages.privacy.title",
paths = { accessibility: "pages.accessibility.title",
conditions: "pages.conditions.title",
faq: "pages.help.faq.page.title",
privacy: "pages.privacy.title",
welcome_not_verified: "welcome.welcome.title",
welcome_level_two_verified: "welcome.welcome.title",
welcome_level_three_verified: "welcome.welcome.title" }

View File

@@ -52,7 +52,7 @@ describe Budget::Ballot::Line do
it "is not valid if there are no votes left" do
create(:budget_ballot_line, ballot: ballot,
investment: create(:budget_investment, :selected, heading: heading))
investment: create(:budget_investment, :selected, heading: heading))
expect(ballot_line).not_to be_valid
end

View File

@@ -223,7 +223,7 @@ describe Budget::Heading do
it "Allows longitude inside [-180,180] interval" do
heading = create(:budget_heading, group: group,
name: "Longitude is inside [-180,180] interval")
name: "Longitude is inside [-180,180] interval")
heading.longitude = "180"
expect(heading).to be_valid

View File

@@ -175,8 +175,8 @@ describe Budget::Phase do
describe "when being enabled" do
before do
accepting_phase.update!(enabled: false,
starts_at: Date.current,
ends_at: Date.current + 2.days)
starts_at: Date.current,
ends_at: Date.current + 2.days)
end
it "adjusts previous enabled phase end date to its own start date" do
@@ -211,16 +211,16 @@ describe Budget::Phase do
it "doesn't adjust previous enabled phase end date to its own start date" do
expect do
accepting_phase.update(enabled: false,
starts_at: Date.current,
ends_at: Date.current + 2.days)
starts_at: Date.current,
ends_at: Date.current + 2.days)
end.not_to change { prev_enabled_phase.ends_at }
end
it "adjusts next enabled phase start date to its own start date" do
expect do
accepting_phase.update(enabled: false,
starts_at: Date.current,
ends_at: Date.current + 2.days)
starts_at: Date.current,
ends_at: Date.current + 2.days)
end.to change { next_enabled_phase.starts_at.to_date }.to(Date.current)
end
end

View File

@@ -77,7 +77,7 @@ describe Budget::Stats do
it "doesn't count nil user ids" do
create(:budget_ballot_line, investment: investment,
ballot: create(:budget_ballot, budget: budget.reload, user: nil, physical: true)
ballot: create(:budget_ballot, budget: budget.reload, user: nil, physical: true)
)
expect(stats.total_participants_vote_phase).to be 0

View File

@@ -37,7 +37,7 @@ RSpec.describe Legislation::Process::Phase, type: :model do
# started
process.update!(debate_start_date: Date.current - 2.days,
debate_end_date: Date.current + 1.day)
debate_end_date: Date.current + 1.day)
expect(process.debate_phase.started?).to be true
# starts today

View File

@@ -208,7 +208,7 @@ describe Legislation::Process do
it "is valid if allegations_end_date is the same as allegations_start_date" do
process = build(:legislation_process, allegations_start_date: Date.current - 1.day,
allegations_end_date: Date.current - 1.day)
allegations_end_date: Date.current - 1.day)
expect(process).to be_valid
end
end

View File

@@ -41,7 +41,7 @@ describe LocalCensusRecord do
it "is not valid when a record already exists with same document_number and document_type" do
create(:local_census_record, document_number: "#DOC_NUMBER", document_type: "1")
local_census_record = build(:local_census_record, document_number: "#DOC_NUMBER",
document_type: "1")
document_type: "1")
expect(local_census_record).not_to be_valid
end

View File

@@ -522,17 +522,23 @@ describe MachineLearning do
machine_learning = MachineLearning.new(job)
tags_data = [
{ id: 0,
name: "Existing tag" },
{ id: 1,
name: "Machine learning tag" }
{
id: 0,
name: "Existing tag"
},
{
id: 1,
name: "Machine learning tag"
}
]
taggings_data = [
{ tag_id: 0,
{
tag_id: 0,
taggable_id: proposal.id
},
{ tag_id: 1,
{
tag_id: 1,
taggable_id: proposal.id
}
]
@@ -564,17 +570,23 @@ describe MachineLearning do
machine_learning = MachineLearning.new(job)
tags_data = [
{ id: 0,
name: "Existing tag" },
{ id: 1,
name: "Machine learning tag" }
{
id: 0,
name: "Existing tag"
},
{
id: 1,
name: "Machine learning tag"
}
]
taggings_data = [
{ tag_id: 0,
{
tag_id: 0,
taggable_id: investment.id
},
{ tag_id: 1,
{
tag_id: 1,
taggable_id: investment.id
}
]

View File

@@ -85,8 +85,8 @@ describe Officing::Residence do
describe "dates" do
it "is not valid but not because date of birth" do
custom_residence = Officing::Residence.new("date_of_birth(3i)" => "1",
"date_of_birth(2i)" => "1",
"date_of_birth(1i)" => "1980")
"date_of_birth(2i)" => "1",
"date_of_birth(1i)" => "1980")
expect(custom_residence).not_to be_valid
expect(custom_residence.errors[:date_of_birth]).to be_empty
@@ -94,8 +94,8 @@ describe Officing::Residence do
it "is not valid without a date of birth" do
custom_residence = Officing::Residence.new("date_of_birth(3i)" => "",
"date_of_birth(2i)" => "",
"date_of_birth(1i)" => "")
"date_of_birth(2i)" => "",
"date_of_birth(1i)" => "")
expect(custom_residence).not_to be_valid
expect(custom_residence.errors[:date_of_birth]).to include("can't be blank")
end
@@ -117,10 +117,10 @@ describe Officing::Residence do
expect(FailedCensusCall.count).to eq(1)
expect(FailedCensusCall.first).to have_attributes(
user_id: residence.user.id,
user_id: residence.user.id,
poll_officer_id: residence.officer.id,
document_number: "12345678Z",
document_type: "1",
document_type: "1",
date_of_birth: nil,
postal_code: "00001",
year_of_birth: Time.current.year
@@ -209,13 +209,13 @@ describe Officing::Residence do
expect(FailedCensusCall.count).to eq(1)
expect(FailedCensusCall.first).to have_attributes(
user_id: residence.user.id,
user_id: residence.user.id,
poll_officer_id: residence.officer.id,
document_number: "12345678Z",
document_type: "1",
document_type: "1",
date_of_birth: nil,
postal_code: nil,
year_of_birth: Time.current.year
year_of_birth: Time.current.year
)
end
end

Some files were not shown because too many files have changed in this diff Show More