Add and apply Style/BlockDelimiters rubocop rule
We were already using it most of the time, but there were a few places were we used brackets for multiline blocks.
This commit is contained in:
@@ -41,6 +41,9 @@ Layout/EmptyLines:
|
||||
Layout/EndOfLine:
|
||||
EnforcedStyle: lf
|
||||
|
||||
Layout/MultilineBlockLayout:
|
||||
Enabled: true
|
||||
|
||||
Layout/SpaceAfterColon:
|
||||
Enabled: true
|
||||
|
||||
@@ -229,6 +232,9 @@ RSpec/ScatteredSetup:
|
||||
RSpec/VoidExpect:
|
||||
Enabled: true
|
||||
|
||||
Style/BlockDelimiters:
|
||||
Enabled: true
|
||||
|
||||
Style/PercentLiteralDelimiters:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -7,10 +7,13 @@ class Admin::CommentsController < Admin::BaseController
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv { send_data to_csv(Comment.sort_by_newest, Comment),
|
||||
|
||||
format.csv do
|
||||
send_data to_csv(Comment.sort_by_newest, Comment),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "comments.csv" }
|
||||
filename: "comments.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -12,10 +12,12 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
.page(params[:page])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv { send_data to_csv(process_for_download, Legislation::Process),
|
||||
format.csv do
|
||||
send_data to_csv(process_for_download, Legislation::Process),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "legislation_processes.csv" }
|
||||
filename: "legislation_processes.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -15,12 +15,12 @@ module Budgets
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv { send_data to_csv(downloadables,
|
||||
Budget::Investment,
|
||||
1),
|
||||
format.csv do
|
||||
send_data to_csv(downloadables, Budget::Investment, 1),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "budget_investment_milestones.csv" }
|
||||
filename: "budget_investment_milestones.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -13,10 +13,12 @@ module Budgets
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv { send_data to_csv(@investments.compatible, Budget::Investment),
|
||||
format.csv do
|
||||
send_data to_csv(@investments.compatible, Budget::Investment),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "budget_investment_results.csv" }
|
||||
filename: "budget_investment_results.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -28,10 +28,12 @@ module CommentableActions
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv { send_data to_csv(resources_csv, resource_model),
|
||||
format.csv do
|
||||
send_data to_csv(resources_csv, resource_model),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "#{get_resource(resource_model)}.csv" }
|
||||
filename: "#{get_resource(resource_model)}.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -22,17 +22,17 @@ class Dashboard::AchievementsController < Dashboard::BaseController
|
||||
|
||||
def groups
|
||||
if params[:group_by] == "week"
|
||||
return executed_proposed_actions.group_by {
|
||||
|v| "#{v.executed_at.to_date.cweek}/#{v.executed_at.to_date.year}" }
|
||||
executed_proposed_actions.group_by do |v|
|
||||
"#{v.executed_at.to_date.cweek}/#{v.executed_at.to_date.year}"
|
||||
end
|
||||
|
||||
if params[:group_by] == "month"
|
||||
return executed_proposed_actions.group_by {
|
||||
|v| "#{v.executed_at.to_date.year}-#{v.executed_at.to_date.month}" }
|
||||
elsif params[:group_by] == "month"
|
||||
executed_proposed_actions.group_by do |v|
|
||||
"#{v.executed_at.to_date.year}-#{v.executed_at.to_date.month}"
|
||||
end
|
||||
|
||||
else
|
||||
executed_proposed_actions.group_by { |a| a.executed_at.to_date }
|
||||
end
|
||||
end
|
||||
|
||||
def executed_proposed_actions
|
||||
@executed_proposed_actions ||=
|
||||
|
||||
@@ -25,8 +25,11 @@ class Dashboard::PollsController < Dashboard::BaseController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if poll.update(poll_params)
|
||||
format.html { redirect_to proposal_dashboard_polls_path(proposal),
|
||||
notice: t("flash.actions.update.poll") }
|
||||
format.html do
|
||||
redirect_to proposal_dashboard_polls_path(proposal),
|
||||
notice: t("flash.actions.update.poll")
|
||||
end
|
||||
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render :edit }
|
||||
|
||||
@@ -17,10 +17,12 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv { send_data to_csv(process_for_download, Legislation::Process),
|
||||
format.csv do
|
||||
send_data to_csv(process_for_download, Legislation::Process),
|
||||
type: "text/csv",
|
||||
disposition: "attachment",
|
||||
filename: "legislation_processes.csv" }
|
||||
filename: "legislation_processes.csv"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -20,11 +20,9 @@ class RemoteTranslationsController < ApplicationController
|
||||
def set_remote_translations
|
||||
remote_translations = remote_translations_params["remote_translations"]
|
||||
decoded_remote_translations = ActiveSupport::JSON.decode(remote_translations)
|
||||
@remote_translations = decoded_remote_translations.map { |remote_translation|
|
||||
remote_translation.slice("remote_translatable_id",
|
||||
"remote_translatable_type",
|
||||
"locale")
|
||||
}
|
||||
@remote_translations = decoded_remote_translations.map do |remote_translation|
|
||||
remote_translation.slice("remote_translatable_id", "remote_translatable_type", "locale")
|
||||
end
|
||||
end
|
||||
|
||||
def translations_enqueued?(remote_translation)
|
||||
|
||||
@@ -75,8 +75,8 @@ class Poll::Question < ApplicationRecord
|
||||
end
|
||||
|
||||
def answers_with_read_more?
|
||||
question_answers.visibles.any? do |answer| answer.description.present? || answer.images.any? ||
|
||||
answer.documents.present? || answer.videos.present?
|
||||
question_answers.visibles.any? do |answer|
|
||||
answer.description.present? || answer.images.any? || answer.documents.present? || answer.videos.present?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@ require "rails_helper"
|
||||
describe CommentsController do
|
||||
|
||||
describe "POST create" do
|
||||
|
||||
let(:legal_process) { create(:legislation_process, debate_start_date: Date.current - 3.days,
|
||||
debate_end_date: Date.current + 2.days) }
|
||||
let(:legal_process) do
|
||||
create(:legislation_process, debate_start_date: Date.current - 3.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) }
|
||||
let(:unverified_user) { create(:user) }
|
||||
|
||||
@@ -4,16 +4,17 @@ describe Legislation::AnnotationsController do
|
||||
|
||||
describe "POST create" do
|
||||
|
||||
let(:legal_process) { create(:legislation_process,
|
||||
allegations_start_date: Date.current - 3.days,
|
||||
allegations_end_date: Date.current + 2.days) }
|
||||
let(:draft_version) { create(:legislation_draft_version, :published,
|
||||
process: legal_process,
|
||||
title: "Version 1") }
|
||||
let(:final_version) { create(:legislation_draft_version, :published,
|
||||
:final_version,
|
||||
process: legal_process,
|
||||
title: "Final version") }
|
||||
let(:legal_process) do
|
||||
create(:legislation_process, allegations_start_date: Date.current - 3.days,
|
||||
allegations_end_date: Date.current + 2.days)
|
||||
end
|
||||
let(:draft_version) do
|
||||
create(:legislation_draft_version, :published, process: legal_process, title: "Version 1")
|
||||
end
|
||||
let(:final_version) do
|
||||
create(:legislation_draft_version, :published, :final_version,
|
||||
process: legal_process, title: "Final version")
|
||||
end
|
||||
let(:user) { create(:user, :level_two) }
|
||||
|
||||
it "creates an ahoy event" do
|
||||
|
||||
@@ -4,8 +4,10 @@ describe Legislation::AnswersController do
|
||||
|
||||
describe "POST create" do
|
||||
|
||||
let(:legal_process) { create(:legislation_process, debate_start_date: Date.current - 3.days,
|
||||
debate_end_date: Date.current + 2.days) }
|
||||
let(:legal_process) do
|
||||
create(:legislation_process, debate_start_date: Date.current - 3.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") }
|
||||
let(:user) { create(:user, :level_two) }
|
||||
|
||||
@@ -6,10 +6,10 @@ FactoryBot.define do
|
||||
postal_code { "28002" }
|
||||
end
|
||||
factory :local_census_records_import, class: "LocalCensusRecords::Import" do
|
||||
file {
|
||||
file do
|
||||
path = %w[spec fixtures files local_census_records import valid.csv]
|
||||
Rack::Test::UploadedFile.new(Rails.root.join(*path))
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
sequence(:document_number) { |n| "#{n.to_s.rjust(8, "0")}X" }
|
||||
|
||||
@@ -51,13 +51,13 @@ describe "Admin administrators" do
|
||||
end
|
||||
|
||||
context "Search" do
|
||||
let!(:administrator1) do
|
||||
create(:administrator, user: create(:user, username: "Bernard Sumner", email: "bernard@sumner.com"))
|
||||
end
|
||||
|
||||
let!(:administrator1) { create(:administrator, user: create(:user,
|
||||
username: "Bernard Sumner",
|
||||
email: "bernard@sumner.com")) }
|
||||
let!(:administrator2) { create(:administrator, user: create(:user,
|
||||
username: "Tony Soprano",
|
||||
email: "tony@soprano.com")) }
|
||||
let!(:administrator2) do
|
||||
create(:administrator, user: create(:user, username: "Tony Soprano", email: "tony@soprano.com"))
|
||||
end
|
||||
|
||||
before do
|
||||
visit admin_administrators_path
|
||||
@@ -102,9 +102,9 @@ describe "Admin administrators" do
|
||||
end
|
||||
|
||||
context "Edit" do
|
||||
let!(:administrator1) { create(:administrator, user: create(:user,
|
||||
username: "Bernard Sumner",
|
||||
email: "bernard@sumner.com")) }
|
||||
let!(:administrator1) do
|
||||
create(:administrator, user: create(:user, username: "Bernard Sumner", email: "bernard@sumner.com"))
|
||||
end
|
||||
|
||||
scenario "admin can edit administrator1" do
|
||||
visit(edit_admin_administrator_path(administrator1))
|
||||
|
||||
@@ -224,14 +224,16 @@ describe "Admin budget headings" do
|
||||
end
|
||||
|
||||
context "Update" do
|
||||
let(:heading) { create(:budget_heading,
|
||||
let(:heading) do
|
||||
create(:budget_heading,
|
||||
group: group,
|
||||
name: "All City",
|
||||
price: 1000,
|
||||
population: 10000,
|
||||
longitude: 20.50,
|
||||
latitude: -10.50,
|
||||
allow_custom_content: true) }
|
||||
allow_custom_content: true)
|
||||
end
|
||||
|
||||
scenario "Updates group" do
|
||||
visit edit_admin_budget_group_heading_path(budget, group, heading)
|
||||
|
||||
@@ -1360,19 +1360,29 @@ describe "Admin budget investments" do
|
||||
end
|
||||
|
||||
context "Selecting" do
|
||||
let!(:unfeasible_bi) do
|
||||
create(:budget_investment, :unfeasible, budget: budget, title: "Unfeasible project")
|
||||
end
|
||||
|
||||
let!(:unfeasible_bi) { create(:budget_investment, :unfeasible, budget: budget,
|
||||
title: "Unfeasible project") }
|
||||
let!(:feasible_bi) { create(:budget_investment, :feasible, budget: budget,
|
||||
title: "Feasible project") }
|
||||
let!(:feasible_vf_bi) { create(:budget_investment, :feasible, :finished, budget: budget,
|
||||
title: "Feasible, VF project") }
|
||||
let!(:selected_bi) { create(:budget_investment, :selected, budget: budget,
|
||||
title: "Selected project") }
|
||||
let!(:winner_bi) { create(:budget_investment, :winner, budget: budget,
|
||||
title: "Winner project") }
|
||||
let!(:undecided_bi) { create(:budget_investment, :undecided, budget: budget,
|
||||
title: "Undecided project") }
|
||||
let!(:feasible_bi) do
|
||||
create(:budget_investment, :feasible, budget: budget, title: "Feasible project")
|
||||
end
|
||||
|
||||
let!(:feasible_vf_bi) do
|
||||
create(:budget_investment, :feasible, :finished, budget: budget, title: "Feasible, VF project")
|
||||
end
|
||||
|
||||
let!(:selected_bi) do
|
||||
create(:budget_investment, :selected, budget: budget, title: "Selected project")
|
||||
end
|
||||
|
||||
let!(:winner_bi) do
|
||||
create(:budget_investment, :winner, budget: budget, title: "Winner project")
|
||||
end
|
||||
|
||||
let!(:undecided_bi) do
|
||||
create(:budget_investment, :undecided, budget: budget, title: "Undecided project")
|
||||
end
|
||||
|
||||
scenario "Filtering by valuation and selection", :js do
|
||||
visit admin_budget_budget_investments_path(budget)
|
||||
|
||||
@@ -263,26 +263,22 @@ describe "Admin download settings" do
|
||||
let(:budget_finished) { create(:budget, :finished) }
|
||||
let(:heading) { create(:budget_heading, budget: budget_finished, price: 1000) }
|
||||
|
||||
let(:investment1) { create(:budget_investment,
|
||||
:selected,
|
||||
heading: heading,
|
||||
price: 200,
|
||||
ballot_lines_count: 900) }
|
||||
let(:investment2) { create(:budget_investment,
|
||||
:selected,
|
||||
heading: heading,
|
||||
price: 300,
|
||||
ballot_lines_count: 800) }
|
||||
let(:investment3) { create(:budget_investment,
|
||||
:incompatible,
|
||||
heading: heading,
|
||||
price: 500,
|
||||
ballot_lines_count: 700) }
|
||||
let(:investment4) { create(:budget_investment,
|
||||
:selected,
|
||||
heading: heading,
|
||||
price: 600,
|
||||
ballot_lines_count: 600) }
|
||||
let(:investment1) do
|
||||
create(:budget_investment, :selected, heading: heading, price: 200, ballot_lines_count: 900)
|
||||
end
|
||||
|
||||
let(:investment2) do
|
||||
create(:budget_investment, :selected, heading: heading, price: 300, ballot_lines_count: 800)
|
||||
end
|
||||
|
||||
let(:investment3) do
|
||||
create(:budget_investment, :incompatible, heading: heading, price: 500, ballot_lines_count: 700)
|
||||
end
|
||||
|
||||
let(:investment4) do
|
||||
create(:budget_investment, :selected, heading: heading, price: 600, ballot_lines_count: 600)
|
||||
end
|
||||
|
||||
let(:budget) { create :budget }
|
||||
|
||||
before do
|
||||
|
||||
@@ -234,8 +234,9 @@ describe "Notifications" do
|
||||
end
|
||||
|
||||
def users_without_notifications
|
||||
User.all.select { |user| user.notifications.not_emailed
|
||||
.where(notifiable_type: "ProposalNotification").blank? }
|
||||
User.all.select do |user|
|
||||
user.notifications.not_emailed.where(notifiable_type: "ProposalNotification").blank?
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -368,9 +368,7 @@ describe "Proposal Notifications" do
|
||||
login_as user.reload
|
||||
visit root_path
|
||||
|
||||
within("#notifications") {
|
||||
expect(page).to have_content :all, "You have 3 new notifications"
|
||||
}
|
||||
within("#notifications") { expect(page).to have_content :all, "You have 3 new notifications" }
|
||||
find(".icon-notification").click
|
||||
|
||||
expect(page).to have_css ".notification", count: 3
|
||||
|
||||
@@ -6,8 +6,9 @@ describe "Social media meta tags" do
|
||||
|
||||
let(:meta_keywords) { "citizen, participation, open government" }
|
||||
let(:meta_title) { "CONSUL" }
|
||||
let(:meta_description) { "Citizen participation tool for an open, "\
|
||||
"transparent and democratic government." }
|
||||
let(:meta_description) do
|
||||
"Citizen participation tool for an open, transparent and democratic government."
|
||||
end
|
||||
let(:twitter_handle) { "@consul_test" }
|
||||
let(:url) { "http://consul.dev" }
|
||||
let(:facebook_handle) { "consultest" }
|
||||
|
||||
@@ -5,8 +5,10 @@ describe "Tags" do
|
||||
let(:author) { create(:user, :level_two, username: "Isabel") }
|
||||
let(:budget) { create(:budget, name: "Big Budget") }
|
||||
let(:group) { create(:budget_group, name: "Health", budget: budget) }
|
||||
let!(:heading) { create(:budget_heading, name: "More hospitals",
|
||||
group: group, latitude: "40.416775", longitude: "-3.703790") }
|
||||
let!(:heading) do
|
||||
create(:budget_heading, name: "More hospitals",
|
||||
group: group, latitude: "40.416775", longitude: "-3.703790")
|
||||
end
|
||||
let!(:tag_medio_ambiente) { create(:tag, :category, name: "Medio Ambiente") }
|
||||
let!(:tag_economia) { create(:tag, :category, name: "Economía") }
|
||||
let(:admin) { create(:administrator).user }
|
||||
|
||||
@@ -13,9 +13,9 @@ describe "Valuation budget investments" do
|
||||
|
||||
scenario "Disabled with a feature flag" do
|
||||
Setting["process.budgets"] = nil
|
||||
expect {
|
||||
expect do
|
||||
visit tracking_budget_budget_investments_path(create(:budget))
|
||||
}.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
scenario "Display link to tracking section" do
|
||||
@@ -161,9 +161,9 @@ describe "Valuation budget investments" do
|
||||
logout
|
||||
login_as create(:tracker).user
|
||||
|
||||
expect {
|
||||
expect do
|
||||
visit tracking_budget_budget_investment_path(budget, investment)
|
||||
}.to raise_error "Not Found"
|
||||
end.to raise_error "Not Found"
|
||||
end
|
||||
|
||||
end
|
||||
@@ -269,9 +269,9 @@ describe "Valuation budget investments" do
|
||||
logout
|
||||
login_as create(:tracker, user: create(:user)).user
|
||||
|
||||
expect {
|
||||
expect do
|
||||
visit tracking_budget_budget_investment_progress_bars_path(budget, investment)
|
||||
}.to raise_error "Not Found"
|
||||
end.to raise_error "Not Found"
|
||||
end
|
||||
|
||||
scenario "create primary progress bar" do
|
||||
|
||||
@@ -37,9 +37,9 @@ describe "Valuation budget investments" do
|
||||
|
||||
scenario "Disabled with a feature flag" do
|
||||
Setting["process.budgets"] = nil
|
||||
expect {
|
||||
expect do
|
||||
visit valuation_budget_budget_investments_path(create(:budget))
|
||||
}.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||
end
|
||||
|
||||
scenario "Display link to valuation section" do
|
||||
@@ -282,9 +282,9 @@ describe "Valuation budget investments" do
|
||||
logout
|
||||
login_as create(:valuator).user
|
||||
|
||||
expect {
|
||||
expect do
|
||||
visit valuation_budget_budget_investment_path(budget, investment)
|
||||
}.to raise_error "Not Found"
|
||||
end.to raise_error "Not Found"
|
||||
end
|
||||
|
||||
scenario "preview is visible" do
|
||||
|
||||
@@ -11,14 +11,13 @@ describe RemoteTranslations::Caller do
|
||||
end
|
||||
|
||||
describe "#call" do
|
||||
|
||||
let(:client) { RemoteTranslations::Microsoft::Client }
|
||||
|
||||
context "Debates" do
|
||||
|
||||
let(:debate) { create(:debate) }
|
||||
let(:remote_translation) { create(:remote_translation,
|
||||
remote_translatable: debate, locale: :es) }
|
||||
let(:remote_translation) do
|
||||
create(:remote_translation, remote_translatable: debate, locale: :es)
|
||||
end
|
||||
let(:caller) { RemoteTranslations::Caller.new(remote_translation) }
|
||||
|
||||
it "returns the resource with new translation persisted" do
|
||||
@@ -65,8 +64,9 @@ describe RemoteTranslations::Caller do
|
||||
context "Proposals" do
|
||||
|
||||
let!(:proposal) { create(:proposal) }
|
||||
let(:remote_translation) { create(:remote_translation,
|
||||
remote_translatable: proposal, locale: :es) }
|
||||
let(:remote_translation) do
|
||||
create(:remote_translation, remote_translatable: proposal, locale: :es)
|
||||
end
|
||||
let(:caller) { RemoteTranslations::Caller.new(remote_translation) }
|
||||
|
||||
it "returns the resource with new translation persisted" do
|
||||
@@ -115,9 +115,9 @@ describe RemoteTranslations::Caller do
|
||||
context "Budget Investments" do
|
||||
|
||||
let(:budget_investment) { create(:budget_investment) }
|
||||
let(:remote_translation) { create(:remote_translation,
|
||||
remote_translatable: budget_investment,
|
||||
locale: :es) }
|
||||
let(:remote_translation) do
|
||||
create(:remote_translation, remote_translatable: budget_investment, locale: :es)
|
||||
end
|
||||
let(:caller) { RemoteTranslations::Caller.new(remote_translation) }
|
||||
|
||||
it "returns the resource with new translation persisted" do
|
||||
@@ -162,10 +162,10 @@ describe RemoteTranslations::Caller do
|
||||
end
|
||||
|
||||
context "Comments" do
|
||||
|
||||
let(:comment) { create(:comment) }
|
||||
let(:remote_translation) { create(:remote_translation,
|
||||
remote_translatable: comment, locale: :es) }
|
||||
let(:remote_translation) do
|
||||
create(:remote_translation, remote_translatable: comment, locale: :es)
|
||||
end
|
||||
let(:caller) { RemoteTranslations::Caller.new(remote_translation) }
|
||||
|
||||
it "returns the resource with new translation persisted" do
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Dashboard::Mailer do
|
||||
let!(:action) do
|
||||
create(:dashboard_action, :proposed_action, :active, day_offset: 0, published_proposal: true)
|
||||
end
|
||||
|
||||
let!(:action) { create(:dashboard_action, :proposed_action, :active,
|
||||
day_offset: 0,
|
||||
published_proposal: true) }
|
||||
let!(:resource) { create(:dashboard_action, :resource, :active,
|
||||
day_offset: 0,
|
||||
published_proposal: true) }
|
||||
let!(:resource) do
|
||||
create(:dashboard_action, :resource, :active, day_offset: 0, published_proposal: true)
|
||||
end
|
||||
|
||||
before do
|
||||
Setting["dashboard.emails"] = true
|
||||
|
||||
@@ -758,13 +758,13 @@ describe Budget::Investment do
|
||||
end
|
||||
|
||||
describe "search" do
|
||||
|
||||
context "attributes" do
|
||||
|
||||
let(:attributes) { { title: "save the world",
|
||||
let(:attributes) do
|
||||
{ title: "save the world",
|
||||
description: "in order to save the world one must think about...",
|
||||
title_es: "para salvar el mundo uno debe pensar en...",
|
||||
description_es: "uno debe pensar" } }
|
||||
description_es: "uno debe pensar" }
|
||||
end
|
||||
|
||||
it "searches by title" do
|
||||
budget_investment = create(:budget_investment, attributes)
|
||||
|
||||
@@ -138,19 +138,14 @@ describe Budget::Phase do
|
||||
end
|
||||
|
||||
it "adjusts previous enabled phase end date to its own start date" do
|
||||
expect {
|
||||
second_phase.update_attributes(enabled: true)
|
||||
}.to change {
|
||||
prev_enabled_phase.ends_at.to_date
|
||||
}.to(Date.current)
|
||||
expect { second_phase.update_attributes(enabled: true) }
|
||||
.to change { prev_enabled_phase.ends_at.to_date }.to(Date.current)
|
||||
end
|
||||
|
||||
it "adjusts next enabled phase start date to its own end date" do
|
||||
expect {
|
||||
expect do
|
||||
second_phase.update_attributes(enabled: true)
|
||||
}.to change {
|
||||
next_enabled_phase.starts_at.to_date
|
||||
}.to(Date.current + 2.days)
|
||||
end.to change { next_enabled_phase.starts_at.to_date }.to(Date.current + 2.days)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -160,35 +155,31 @@ describe Budget::Phase do
|
||||
end
|
||||
|
||||
it "doesn't change previous enabled phase end date" do
|
||||
expect {
|
||||
second_phase.update_attributes(starts_at: Date.current,
|
||||
ends_at: Date.current + 2.days)
|
||||
}.not_to (change { prev_enabled_phase.ends_at })
|
||||
expect { second_phase.update_attributes(starts_at: Date.current, ends_at: Date.current + 2.days) }
|
||||
.not_to change { prev_enabled_phase.ends_at }
|
||||
end
|
||||
|
||||
it "doesn't change next enabled phase start date" do
|
||||
expect {
|
||||
second_phase.update_attributes(starts_at: Date.current,
|
||||
ends_at: Date.current + 2.days)
|
||||
}.not_to (change { next_enabled_phase.starts_at })
|
||||
expect { second_phase.update_attributes(starts_at: Date.current, ends_at: Date.current + 2.days) }
|
||||
.not_to change { next_enabled_phase.starts_at }
|
||||
end
|
||||
end
|
||||
|
||||
describe "when being disabled" do
|
||||
it "doesn't adjust previous enabled phase end date to its own start date" do
|
||||
expect {
|
||||
expect do
|
||||
second_phase.update_attributes(enabled: false,
|
||||
starts_at: Date.current,
|
||||
ends_at: Date.current + 2.days)
|
||||
}.not_to (change { prev_enabled_phase.ends_at })
|
||||
end.not_to (change { prev_enabled_phase.ends_at })
|
||||
end
|
||||
|
||||
it "adjusts next enabled phase start date to its own start date" do
|
||||
expect {
|
||||
expect do
|
||||
second_phase.update_attributes(enabled: false,
|
||||
starts_at: Date.current,
|
||||
ends_at: Date.current + 2.days)
|
||||
}.to change { next_enabled_phase.starts_at.to_date }.to(Date.current)
|
||||
end.to change { next_enabled_phase.starts_at.to_date }.to(Date.current)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -217,9 +208,9 @@ describe Budget::Phase do
|
||||
|
||||
describe "#sanitize_description" do
|
||||
it "removes not allowed html entities from the description" do
|
||||
expect {
|
||||
expect do
|
||||
first_phase.update_attributes(description: '<p><a href="/"><b>a</b></a></p> <script>javascript</script>')
|
||||
}.to change { first_phase.description }.to('<p><a href="/">a</a></p> javascript')
|
||||
end.to change { first_phase.description }.to('<p><a href="/">a</a></p> javascript')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -152,21 +152,31 @@ describe Dashboard::Action do
|
||||
|
||||
context "#active_for" do
|
||||
let!(:active_action) { create :dashboard_action, :active, day_offset: 0, required_supports: 0 }
|
||||
let!(:not_enough_supports_action) { create :dashboard_action, :active, day_offset: 0,
|
||||
required_supports: 10_000 }
|
||||
let!(:inactive_action) { create :dashboard_action, :inactive }
|
||||
let!(:future_action) { create :dashboard_action, :active, day_offset: 300,
|
||||
required_supports: 0 }
|
||||
let!(:action_published_proposal) { create :dashboard_action,
|
||||
let!(:not_enough_supports_action) do
|
||||
create :dashboard_action, :active, day_offset: 0, required_supports: 10_000
|
||||
end
|
||||
|
||||
let!(:future_action) do
|
||||
create :dashboard_action, :active, day_offset: 300, required_supports: 0
|
||||
end
|
||||
|
||||
let!(:action_published_proposal) do
|
||||
create :dashboard_action,
|
||||
:active,
|
||||
day_offset: 0,
|
||||
required_supports: 0,
|
||||
published_proposal: true }
|
||||
let!(:action_for_draft_proposal) { create :dashboard_action,
|
||||
published_proposal: true
|
||||
end
|
||||
|
||||
let!(:action_for_draft_proposal) do
|
||||
create :dashboard_action,
|
||||
:active,
|
||||
day_offset: 0,
|
||||
required_supports: 0,
|
||||
published_proposal: false }
|
||||
published_proposal: false
|
||||
end
|
||||
|
||||
let(:proposal) { create :proposal }
|
||||
let(:draft_proposal) { create :proposal, :draft }
|
||||
|
||||
@@ -205,8 +215,9 @@ describe Dashboard::Action do
|
||||
|
||||
context "#course_for" do
|
||||
let!(:proposed_action) { create :dashboard_action, :active, required_supports: 0 }
|
||||
let!(:inactive_resource) { create :dashboard_action, :inactive, :resource,
|
||||
required_supports: 0 }
|
||||
let!(:inactive_resource) do
|
||||
create :dashboard_action, :inactive, :resource, required_supports: 0
|
||||
end
|
||||
let!(:resource) { create :dashboard_action, :active, :resource, required_supports: 10_000 }
|
||||
let!(:achieved_resource) { create :dashboard_action, :active, :resource, required_supports: 0 }
|
||||
let(:proposal) { create :proposal }
|
||||
@@ -272,12 +283,15 @@ describe Dashboard::Action do
|
||||
describe "Detect new actions when there are news actions actived" do
|
||||
|
||||
context "for published proposals" do
|
||||
|
||||
let!(:proposal) { create(:proposal) }
|
||||
let!(:action) { create(:dashboard_action, :proposed_action, :active, day_offset: 0,
|
||||
published_proposal: true) }
|
||||
let!(:resource) { create(:dashboard_action, :resource, :active, day_offset: 0,
|
||||
published_proposal: true) }
|
||||
|
||||
let!(:action) do
|
||||
create(:dashboard_action, :proposed_action, :active, day_offset: 0, published_proposal: true)
|
||||
end
|
||||
|
||||
let!(:resource) do
|
||||
create(:dashboard_action, :resource, :active, day_offset: 0, published_proposal: true)
|
||||
end
|
||||
|
||||
it "when proposal has been created today and day_offset is valid only for today" do
|
||||
expect(Dashboard::Action.detect_new_actions_since(Date.yesterday,
|
||||
@@ -301,12 +315,15 @@ describe Dashboard::Action do
|
||||
end
|
||||
|
||||
context "for draft proposals" do
|
||||
|
||||
let!(:proposal) { create(:proposal, :draft) }
|
||||
let!(:action) { create(:dashboard_action, :proposed_action, :active, day_offset: 0,
|
||||
published_proposal: false) }
|
||||
let!(:resource) { create(:dashboard_action, :resource, :active, day_offset: 0,
|
||||
published_proposal: false) }
|
||||
|
||||
let!(:action) do
|
||||
create(:dashboard_action, :proposed_action, :active, day_offset: 0, published_proposal: false)
|
||||
end
|
||||
|
||||
let!(:resource) do
|
||||
create(:dashboard_action, :resource, :active, day_offset: 0, published_proposal: false)
|
||||
end
|
||||
|
||||
it "when day_offset field is valid for today and invalid for yesterday" do
|
||||
expect(Dashboard::Action.detect_new_actions_since(Date.yesterday,
|
||||
|
||||
@@ -461,13 +461,13 @@ describe Debate do
|
||||
end
|
||||
|
||||
describe "search" do
|
||||
|
||||
context "attributes" do
|
||||
|
||||
let(:attributes) { { title: "save the world",
|
||||
let(:attributes) do
|
||||
{ title: "save the world",
|
||||
description: "in order to save the world one must think about...",
|
||||
title_es: "para salvar el mundo uno debe pensar en...",
|
||||
description_es: "uno debe pensar" } }
|
||||
description_es: "uno debe pensar" }
|
||||
end
|
||||
|
||||
it "searches by title" do
|
||||
debate = create(:debate, attributes)
|
||||
|
||||
@@ -81,9 +81,7 @@ RSpec.describe I18nContent, type: :model do
|
||||
end
|
||||
|
||||
it "uses the first and last parameters" do
|
||||
expect {
|
||||
I18nContent.flat_hash("string", nil, "not hash")
|
||||
}.to raise_error(NoMethodError)
|
||||
expect { I18nContent.flat_hash("string", nil, "not hash") }.to raise_error(NoMethodError)
|
||||
|
||||
expect(I18nContent.flat_hash(nil, nil, { q: "other string" })).to eq({
|
||||
q: "other string",
|
||||
@@ -102,9 +100,7 @@ RSpec.describe I18nContent, type: :model do
|
||||
end
|
||||
|
||||
it "uses all parameters" do
|
||||
expect {
|
||||
I18nContent.flat_hash("string", "f", "not hash")
|
||||
}.to raise_error NoMethodError
|
||||
expect { I18nContent.flat_hash("string", "f", "not hash") }.to raise_error NoMethodError
|
||||
|
||||
expect(I18nContent.flat_hash(nil, "f", { q: "other string" })).to eq({
|
||||
q: "other string",
|
||||
|
||||
@@ -97,12 +97,17 @@ describe Legislation::Process do
|
||||
|
||||
describe "filter scopes" do
|
||||
describe "open and past filters" do
|
||||
let!(:process_1) { create(:legislation_process, start_date: Date.current - 2.days,
|
||||
end_date: Date.current + 1.day) }
|
||||
let!(:process_2) { create(:legislation_process, start_date: Date.current + 1.day,
|
||||
end_date: Date.current + 3.days) }
|
||||
let!(:process_3) { create(:legislation_process, start_date: Date.current - 4.days,
|
||||
end_date: Date.current - 3.days) }
|
||||
let!(:process_1) do
|
||||
create(:legislation_process, start_date: Date.current - 2.days, end_date: Date.current + 1.day)
|
||||
end
|
||||
|
||||
let!(:process_2) do
|
||||
create(:legislation_process, start_date: Date.current + 1.day, end_date: Date.current + 3.days)
|
||||
end
|
||||
|
||||
let!(:process_3) do
|
||||
create(:legislation_process, start_date: Date.current - 4.days, end_date: Date.current - 3.days)
|
||||
end
|
||||
|
||||
it "filters open" do
|
||||
open_processes = ::Legislation::Process.open
|
||||
@@ -184,15 +189,13 @@ describe Legislation::Process do
|
||||
end
|
||||
|
||||
it "invalid format colors" do
|
||||
expect {
|
||||
expect do
|
||||
create(:legislation_process, background_color: "#123ghi", font_color: "#fff")
|
||||
}.to raise_error(ActiveRecord::RecordInvalid,
|
||||
"Validation failed: Background color is invalid")
|
||||
end.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Background color is invalid")
|
||||
|
||||
expect {
|
||||
expect do
|
||||
create(:legislation_process, background_color: "#fff", font_color: "ggg")
|
||||
}.to raise_error(ActiveRecord::RecordInvalid,
|
||||
"Validation failed: Font color is invalid")
|
||||
end.to raise_error(ActiveRecord::RecordInvalid, "Validation failed: Font color is invalid")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -37,11 +37,12 @@ describe Officing::Residence do
|
||||
end
|
||||
|
||||
describe "custom validations" do
|
||||
|
||||
let(:custom_residence) { build(:officing_residence,
|
||||
let(:custom_residence) do
|
||||
build(:officing_residence,
|
||||
document_number: "12345678Z",
|
||||
date_of_birth: "01/01/1980",
|
||||
postal_code: "28001") }
|
||||
postal_code: "28001")
|
||||
end
|
||||
|
||||
before do
|
||||
Setting["feature.remote_census"] = true
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Poll::BallotSheet do
|
||||
|
||||
let(:ballot_sheet) { build(:poll_ballot_sheet, poll: create(:poll),
|
||||
let(:ballot_sheet) do
|
||||
build(:poll_ballot_sheet, poll: create(:poll),
|
||||
officer_assignment: create(:poll_officer_assignment),
|
||||
data: "1234;5678") }
|
||||
data: "1234;5678")
|
||||
end
|
||||
|
||||
context "Validations" do
|
||||
|
||||
|
||||
@@ -145,8 +145,9 @@ describe Poll do
|
||||
let!(:expired_poll) { create(:poll, :expired) }
|
||||
|
||||
let!(:current_restricted_poll) { create(:poll, geozone_restricted: true, geozones: [geozone]) }
|
||||
let!(:expired_restricted_poll) { create(:poll, :expired, geozone_restricted: true,
|
||||
geozones: [geozone]) }
|
||||
let!(:expired_restricted_poll) do
|
||||
create(:poll, :expired, geozone_restricted: true, geozones: [geozone])
|
||||
end
|
||||
|
||||
let!(:all_polls) { [current_poll, expired_poll, current_poll, expired_restricted_poll] }
|
||||
let(:non_current_polls) { [expired_poll, expired_restricted_poll] }
|
||||
@@ -313,13 +314,17 @@ describe Poll do
|
||||
let(:proposal) { create :proposal }
|
||||
let(:other_proposal) { create :proposal }
|
||||
let(:poll) { create(:poll, related: proposal) }
|
||||
let(:overlaping_poll) { build(:poll, related: proposal, starts_at: poll.starts_at + 1.day,
|
||||
ends_at: poll.ends_at - 1.day) }
|
||||
let(:non_overlaping_poll) { create(:poll, related: proposal, starts_at: poll.ends_at + 1.day,
|
||||
ends_at: poll.ends_at + 31.days) }
|
||||
let(:overlaping_poll_2) { create(:poll, related: other_proposal,
|
||||
starts_at: poll.starts_at + 1.day,
|
||||
ends_at: poll.ends_at - 1.day) }
|
||||
let(:overlaping_poll) do
|
||||
build(:poll, related: proposal, starts_at: poll.starts_at + 1.day, ends_at: poll.ends_at - 1.day)
|
||||
end
|
||||
|
||||
let(:non_overlaping_poll) do
|
||||
create(:poll, related: proposal, starts_at: poll.ends_at + 1.day, ends_at: poll.ends_at + 31.days)
|
||||
end
|
||||
|
||||
let(:overlaping_poll_2) do
|
||||
create(:poll, related: other_proposal, starts_at: poll.starts_at + 1.day, ends_at: poll.ends_at - 1.day)
|
||||
end
|
||||
|
||||
it "a poll can not overlap itself" do
|
||||
expect(Poll.overlaping_with(poll)).not_to include(poll)
|
||||
|
||||
@@ -473,15 +473,15 @@ describe Proposal do
|
||||
end
|
||||
|
||||
describe "search" do
|
||||
|
||||
context "attributes" do
|
||||
|
||||
let(:attributes) { { title: "save the world",
|
||||
let(:attributes) do
|
||||
{ title: "save the world",
|
||||
summary: "basically",
|
||||
description: "in order to save the world one must think about...",
|
||||
title_es: "para salvar el mundo uno debe pensar en...",
|
||||
summary_es: "basicamente",
|
||||
description_es: "uno debe pensar" } }
|
||||
description_es: "uno debe pensar" }
|
||||
end
|
||||
|
||||
it "searches by title" do
|
||||
proposal = create(:proposal, attributes)
|
||||
|
||||
@@ -29,11 +29,12 @@ describe Signature do
|
||||
end
|
||||
|
||||
describe "custom validations" do
|
||||
|
||||
let(:signature) { build(:signature,
|
||||
let(:signature) do
|
||||
build(:signature,
|
||||
document_number: "12345678Z",
|
||||
date_of_birth: "31/12/1980",
|
||||
postal_code: "28013") }
|
||||
postal_code: "28013")
|
||||
end
|
||||
|
||||
before do
|
||||
Setting["feature.remote_census"] = true
|
||||
|
||||
Reference in New Issue
Block a user