From e252d82cdb2f5aa7c9b7fac5bb4160a619fe76fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 18 Jun 2019 02:29:00 +0200 Subject: [PATCH] Apply `IndentationWidth` rubocop rule --- .../questions/answers/videos_controller.rb | 4 +- .../related_contents_controller.rb | 16 ++++---- app/helpers/welcome_helper.rb | 4 +- app/models/document.rb | 6 +-- lib/local_census.rb | 8 ++-- lib/migrations/reports.rb | 2 +- spec/factories/budgets.rb | 14 +++---- .../comments/budget_investments_spec.rb | 26 ++++++------ spec/features/comments/polls_spec.rb | 26 ++++++------ spec/features/comments/proposals_spec.rb | 26 ++++++------ spec/features/moderation/users_spec.rb | 6 +-- spec/features/tracks_spec.rb | 4 +- .../verification/verified_user_spec.rb | 2 +- spec/models/budget/investment_spec.rb | 40 +++++++++---------- spec/models/legislation/annotation_spec.rb | 2 +- spec/models/legislation/draft_version_spec.rb | 6 +-- spec/models/poll/voter_spec.rb | 4 +- spec/models/proposal_spec.rb | 4 +- spec/shared/features/mappable.rb | 2 +- spec/shared/features/nested_imageable.rb | 4 +- spec/shared/models/map_validations.rb | 32 +++++++-------- 21 files changed, 119 insertions(+), 119 deletions(-) diff --git a/app/controllers/admin/poll/questions/answers/videos_controller.rb b/app/controllers/admin/poll/questions/answers/videos_controller.rb index 7628ab081..3e76531d8 100644 --- a/app/controllers/admin/poll/questions/answers/videos_controller.rb +++ b/app/controllers/admin/poll/questions/answers/videos_controller.rb @@ -34,9 +34,9 @@ class Admin::Poll::Questions::Answers::VideosController < Admin::Poll::BaseContr def destroy notice = if @video.destroy - t("flash.actions.destroy.poll_question_answer_video") + t("flash.actions.destroy.poll_question_answer_video") else - t("flash.actions.destroy.error") + t("flash.actions.destroy.error") end redirect_back(fallback_location: (request.referrer || root_path), notice: notice) end diff --git a/app/controllers/related_contents_controller.rb b/app/controllers/related_contents_controller.rb index 0c31d5f69..ae18564b9 100644 --- a/app/controllers/related_contents_controller.rb +++ b/app/controllers/related_contents_controller.rb @@ -46,16 +46,16 @@ class RelatedContentsController < ApplicationController end def related_object - if valid_url? - url = params[:url] + if valid_url? + url = params[:url] - related_klass = url.scan(/\/(#{RelatedContent::RELATIONABLE_MODELS.join("|")})\//) - .flatten.map { |i| i.to_s.singularize.camelize }.join("::") - related_id = url.match(/\/(\d+)(?!.*\/\d)/)[1] + related_klass = url.scan(/\/(#{RelatedContent::RELATIONABLE_MODELS.join("|")})\//) + .flatten.map { |i| i.to_s.singularize.camelize }.join("::") + related_id = url.match(/\/(\d+)(?!.*\/\d)/)[1] - @related = related_klass.singularize.camelize.constantize.find_by(id: related_id) - end + @related = related_klass.singularize.camelize.constantize.find_by(id: related_id) + end rescue - nil + nil end end diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index fa729492e..8f674574c 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -48,9 +48,9 @@ module WelcomeHelper def calculate_offset(debates, proposals, apply_offset) if debates.any? && proposals.any? offset = if apply_offset - "medium-offset-2 large-offset-2" + "medium-offset-2 large-offset-2" else - "end" + "end" end end end diff --git a/app/models/document.rb b/app/models/document.rb index 3edf203d6..67c220e64 100644 --- a/app/models/document.rb +++ b/app/models/document.rb @@ -60,11 +60,11 @@ class Document < ApplicationRecord def custom_hash_data(attachment) original_filename = if !attachment.instance.persisted? && attachment.instance.remove - attachment.instance.original_filename + attachment.instance.original_filename elsif !attachment.instance.persisted? - attachment.instance.attachment_file_name + attachment.instance.attachment_file_name else - attachment.instance.title + attachment.instance.title end "#{attachment.instance.user_id}/#{original_filename}" end diff --git a/lib/local_census.rb b/lib/local_census.rb index fc309730a..1ff5112a5 100644 --- a/lib/local_census.rb +++ b/lib/local_census.rb @@ -28,9 +28,9 @@ class LocalCensus end def district_code - @body.district_code + @body.district_code rescue - nil + nil end def gender @@ -45,9 +45,9 @@ class LocalCensus end def name - "#{@body.nombre} #{@body.apellido1}" + "#{@body.nombre} #{@body.apellido1}" rescue - nil + nil end private diff --git a/lib/migrations/reports.rb b/lib/migrations/reports.rb index 7a378a126..31a57eade 100644 --- a/lib/migrations/reports.rb +++ b/lib/migrations/reports.rb @@ -15,7 +15,7 @@ class Migrations::Reports stats: poll.read_attribute(:stats_enabled), advanced_stats: poll.read_attribute(:stats_enabled), ) - end + end end diff --git a/spec/factories/budgets.rb b/spec/factories/budgets.rb index cecefbc2e..cfb5e9574 100644 --- a/spec/factories/budgets.rb +++ b/spec/factories/budgets.rb @@ -159,14 +159,14 @@ FactoryBot.define do end trait :flagged do - after :create do |investment| - Flag.flag(create(:user), investment) - end - end + after :create do |investment| + Flag.flag(create(:user), investment) + end + end - trait :with_confirmed_hide do - confirmed_hide_at { Time.current } - end + trait :with_confirmed_hide do + confirmed_hide_at { Time.current } + end trait :with_milestone_tags do after(:create) { |investment| investment.milestone_tags << create(:tag, :milestone) } diff --git a/spec/features/comments/budget_investments_spec.rb b/spec/features/comments/budget_investments_spec.rb index b171d5b88..9e09f6de9 100644 --- a/spec/features/comments/budget_investments_spec.rb +++ b/spec/features/comments/budget_investments_spec.rb @@ -115,25 +115,25 @@ describe "Commenting Budget::Investments" do end scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do - old_root = create(:comment, commentable: investment, created_at: Time.current - 10) - new_root = create(:comment, commentable: investment, created_at: Time.current) - old_child = create(:comment, commentable: investment, parent_id: new_root.id, created_at: Time.current - 10) - new_child = create(:comment, commentable: investment, parent_id: new_root.id, created_at: Time.current) + old_root = create(:comment, commentable: investment, created_at: Time.current - 10) + new_root = create(:comment, commentable: investment, created_at: Time.current) + old_child = create(:comment, commentable: investment, parent_id: new_root.id, created_at: Time.current - 10) + new_child = create(:comment, commentable: investment, parent_id: new_root.id, created_at: Time.current) - visit budget_investment_path(investment.budget, investment, order: :most_voted) + visit budget_investment_path(investment.budget, investment, order: :most_voted) - expect(new_root.body).to appear_before(old_root.body) - expect(old_child.body).to appear_before(new_child.body) + expect(new_root.body).to appear_before(old_root.body) + expect(old_child.body).to appear_before(new_child.body) - visit budget_investment_path(investment.budget, investment, order: :newest) + visit budget_investment_path(investment.budget, investment, order: :newest) - expect(new_root.body).to appear_before(old_root.body) - expect(new_child.body).to appear_before(old_child.body) + expect(new_root.body).to appear_before(old_root.body) + expect(new_child.body).to appear_before(old_child.body) - visit budget_investment_path(investment.budget, investment, order: :oldest) + visit budget_investment_path(investment.budget, investment, order: :oldest) - expect(old_root.body).to appear_before(new_root.body) - expect(old_child.body).to appear_before(new_child.body) + expect(old_root.body).to appear_before(new_root.body) + expect(old_child.body).to appear_before(new_child.body) end scenario "Turns links into html links" do diff --git a/spec/features/comments/polls_spec.rb b/spec/features/comments/polls_spec.rb index 8a1fb1b27..6b0f84761 100644 --- a/spec/features/comments/polls_spec.rb +++ b/spec/features/comments/polls_spec.rb @@ -111,25 +111,25 @@ describe "Commenting polls" do end scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do - old_root = create(:comment, commentable: poll, created_at: Time.current - 10) - new_root = create(:comment, commentable: poll, created_at: Time.current) - old_child = create(:comment, commentable: poll, parent_id: new_root.id, created_at: Time.current - 10) - new_child = create(:comment, commentable: poll, parent_id: new_root.id, created_at: Time.current) + old_root = create(:comment, commentable: poll, created_at: Time.current - 10) + new_root = create(:comment, commentable: poll, created_at: Time.current) + old_child = create(:comment, commentable: poll, parent_id: new_root.id, created_at: Time.current - 10) + new_child = create(:comment, commentable: poll, parent_id: new_root.id, created_at: Time.current) - visit poll_path(poll, order: :most_voted) + visit poll_path(poll, order: :most_voted) - expect(new_root.body).to appear_before(old_root.body) - expect(old_child.body).to appear_before(new_child.body) + expect(new_root.body).to appear_before(old_root.body) + expect(old_child.body).to appear_before(new_child.body) - visit poll_path(poll, order: :newest) + visit poll_path(poll, order: :newest) - expect(new_root.body).to appear_before(old_root.body) - expect(new_child.body).to appear_before(old_child.body) + expect(new_root.body).to appear_before(old_root.body) + expect(new_child.body).to appear_before(old_child.body) - visit poll_path(poll, order: :oldest) + visit poll_path(poll, order: :oldest) - expect(old_root.body).to appear_before(new_root.body) - expect(old_child.body).to appear_before(new_child.body) + expect(old_root.body).to appear_before(new_root.body) + expect(old_child.body).to appear_before(new_child.body) end scenario "Turns links into html links" do diff --git a/spec/features/comments/proposals_spec.rb b/spec/features/comments/proposals_spec.rb index 9c0ae0cb3..e5e84d183 100644 --- a/spec/features/comments/proposals_spec.rb +++ b/spec/features/comments/proposals_spec.rb @@ -109,25 +109,25 @@ describe "Commenting proposals" do end scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do - old_root = create(:comment, commentable: proposal, created_at: Time.current - 10) - new_root = create(:comment, commentable: proposal, created_at: Time.current) - old_child = create(:comment, commentable: proposal, parent_id: new_root.id, created_at: Time.current - 10) - new_child = create(:comment, commentable: proposal, parent_id: new_root.id, created_at: Time.current) + old_root = create(:comment, commentable: proposal, created_at: Time.current - 10) + new_root = create(:comment, commentable: proposal, created_at: Time.current) + old_child = create(:comment, commentable: proposal, parent_id: new_root.id, created_at: Time.current - 10) + new_child = create(:comment, commentable: proposal, parent_id: new_root.id, created_at: Time.current) - visit proposal_path(proposal, order: :most_voted) + visit proposal_path(proposal, order: :most_voted) - expect(new_root.body).to appear_before(old_root.body) - expect(old_child.body).to appear_before(new_child.body) + expect(new_root.body).to appear_before(old_root.body) + expect(old_child.body).to appear_before(new_child.body) - visit proposal_path(proposal, order: :newest) + visit proposal_path(proposal, order: :newest) - expect(new_root.body).to appear_before(old_root.body) - expect(new_child.body).to appear_before(old_child.body) + expect(new_root.body).to appear_before(old_root.body) + expect(new_child.body).to appear_before(old_child.body) - visit proposal_path(proposal, order: :oldest) + visit proposal_path(proposal, order: :oldest) - expect(old_root.body).to appear_before(new_root.body) - expect(old_child.body).to appear_before(new_child.body) + expect(old_root.body).to appear_before(new_root.body) + expect(old_child.body).to appear_before(new_child.body) end scenario "Turns links into html links" do diff --git a/spec/features/moderation/users_spec.rb b/spec/features/moderation/users_spec.rb index 6fc04cff2..845106f7f 100644 --- a/spec/features/moderation/users_spec.rb +++ b/spec/features/moderation/users_spec.rb @@ -63,9 +63,9 @@ describe "Moderate users" do click_button "Search" within("#moderation_users") do - expect(page).to have_content citizen.name - expect(page).not_to have_content "Blocked" - click_link "Block" + expect(page).to have_content citizen.name + expect(page).not_to have_content "Blocked" + click_link "Block" end within("#moderation_users") do diff --git a/spec/features/tracks_spec.rb b/spec/features/tracks_spec.rb index 70538cb03..b866a3fbb 100644 --- a/spec/features/tracks_spec.rb +++ b/spec/features/tracks_spec.rb @@ -4,11 +4,11 @@ describe "Tracking" do context "Custom variable" do - scenario "Usertype anonymous" do + scenario "Usertype anonymous" do visit proposals_path expect(page.html).to include "anonymous" - end + end scenario "Usertype level_1_user" do create(:geozone) diff --git a/spec/features/verification/verified_user_spec.rb b/spec/features/verification/verified_user_spec.rb index 8a9e1c936..579629a62 100644 --- a/spec/features/verification/verified_user_spec.rb +++ b/spec/features/verification/verified_user_spec.rb @@ -82,7 +82,7 @@ describe "Verified users" do visit verified_user_path within("#verified_user_#{verified_user.id}_email") do - click_button "Send code" + click_button "Send code" end expect(page).to have_content "We have sent a confirmation email to your account: rock@example.com" diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index b6c471925..f8bd836e9 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -104,14 +104,14 @@ describe Budget::Investment do describe "#code" do let(:investment) { create(:budget_investment) } - it "returns the proposal id" do - expect(investment.code).to include(investment.id.to_s) - end + it "returns the proposal id" do + expect(investment.code).to include(investment.id.to_s) + end - it "returns the administrator id when assigned" do - investment.administrator = create(:administrator) - expect(investment.code).to include("#{investment.id}-A#{investment.administrator.id}") - end + it "returns the administrator id when assigned" do + investment.administrator = create(:administrator) + expect(investment.code).to include("#{investment.id}-A#{investment.administrator.id}") + end end describe "#send_unfeasible_email" do @@ -307,24 +307,24 @@ describe Budget::Investment do describe "#by_budget" do it "returns investments scoped by budget" do - budget1 = create(:budget) - budget2 = create(:budget) + budget1 = create(:budget) + budget2 = create(:budget) - group1 = create(:budget_group, budget: budget1) - group2 = create(:budget_group, budget: budget2) + group1 = create(:budget_group, budget: budget1) + group2 = create(:budget_group, budget: budget2) - heading1 = create(:budget_heading, group: group1) - heading2 = create(:budget_heading, group: group2) + heading1 = create(:budget_heading, group: group1) + heading2 = create(:budget_heading, group: group2) - investment1 = create(:budget_investment, heading: heading1) - investment2 = create(:budget_investment, heading: heading1) - investment3 = create(:budget_investment, heading: heading2) + investment1 = create(:budget_investment, heading: heading1) + investment2 = create(:budget_investment, heading: heading1) + investment3 = create(:budget_investment, heading: heading2) - investments_by_budget = Budget::Investment.by_budget(budget1) + investments_by_budget = Budget::Investment.by_budget(budget1) - expect(investments_by_budget).to include investment1 - expect(investments_by_budget).to include investment2 - expect(investments_by_budget).not_to include investment3 + expect(investments_by_budget).to include investment1 + expect(investments_by_budget).to include investment2 + expect(investments_by_budget).not_to include investment3 end end diff --git a/spec/models/legislation/annotation_spec.rb b/spec/models/legislation/annotation_spec.rb index bd68ec5bf..676137716 100644 --- a/spec/models/legislation/annotation_spec.rb +++ b/spec/models/legislation/annotation_spec.rb @@ -1,4 +1,4 @@ - require "rails_helper" +require "rails_helper" RSpec.describe Legislation::Annotation, type: :model do let(:draft_version) { create(:legislation_draft_version) } diff --git a/spec/models/legislation/draft_version_spec.rb b/spec/models/legislation/draft_version_spec.rb index 0b8ceb451..5beb04a1b 100644 --- a/spec/models/legislation/draft_version_spec.rb +++ b/spec/models/legislation/draft_version_spec.rb @@ -29,7 +29,7 @@ describe Legislation::DraftVersion do end def body_markdown -<<-BODY_MARKDOWN + <<-BODY_MARKDOWN # Title 1 Some paragraph. @@ -50,7 +50,7 @@ BODY_MARKDOWN end def body_html -<<-BODY_HTML + <<-BODY_HTML

Title 1

Some paragraph.

@@ -73,7 +73,7 @@ BODY_HTML end def toc_html -<<-TOC_HTML + <<-TOC_HTML