Apply IndentationWidth rubocop rule

This commit is contained in:
Javi Martín
2019-06-18 02:29:00 +02:00
parent b5b07bccd3
commit e252d82cdb
21 changed files with 119 additions and 119 deletions

View File

@@ -34,9 +34,9 @@ class Admin::Poll::Questions::Answers::VideosController < Admin::Poll::BaseContr
def destroy def destroy
notice = if @video.destroy notice = if @video.destroy
t("flash.actions.destroy.poll_question_answer_video") t("flash.actions.destroy.poll_question_answer_video")
else else
t("flash.actions.destroy.error") t("flash.actions.destroy.error")
end end
redirect_back(fallback_location: (request.referrer || root_path), notice: notice) redirect_back(fallback_location: (request.referrer || root_path), notice: notice)
end end

View File

@@ -46,16 +46,16 @@ class RelatedContentsController < ApplicationController
end end
def related_object def related_object
if valid_url? if valid_url?
url = params[:url] url = params[:url]
related_klass = url.scan(/\/(#{RelatedContent::RELATIONABLE_MODELS.join("|")})\//) related_klass = url.scan(/\/(#{RelatedContent::RELATIONABLE_MODELS.join("|")})\//)
.flatten.map { |i| i.to_s.singularize.camelize }.join("::") .flatten.map { |i| i.to_s.singularize.camelize }.join("::")
related_id = url.match(/\/(\d+)(?!.*\/\d)/)[1] related_id = url.match(/\/(\d+)(?!.*\/\d)/)[1]
@related = related_klass.singularize.camelize.constantize.find_by(id: related_id) @related = related_klass.singularize.camelize.constantize.find_by(id: related_id)
end end
rescue rescue
nil nil
end end
end end

View File

@@ -48,9 +48,9 @@ module WelcomeHelper
def calculate_offset(debates, proposals, apply_offset) def calculate_offset(debates, proposals, apply_offset)
if debates.any? && proposals.any? if debates.any? && proposals.any?
offset = if apply_offset offset = if apply_offset
"medium-offset-2 large-offset-2" "medium-offset-2 large-offset-2"
else else
"end" "end"
end end
end end
end end

View File

@@ -60,11 +60,11 @@ class Document < ApplicationRecord
def custom_hash_data(attachment) def custom_hash_data(attachment)
original_filename = if !attachment.instance.persisted? && attachment.instance.remove original_filename = if !attachment.instance.persisted? && attachment.instance.remove
attachment.instance.original_filename attachment.instance.original_filename
elsif !attachment.instance.persisted? elsif !attachment.instance.persisted?
attachment.instance.attachment_file_name attachment.instance.attachment_file_name
else else
attachment.instance.title attachment.instance.title
end end
"#{attachment.instance.user_id}/#{original_filename}" "#{attachment.instance.user_id}/#{original_filename}"
end end

View File

@@ -28,9 +28,9 @@ class LocalCensus
end end
def district_code def district_code
@body.district_code @body.district_code
rescue rescue
nil nil
end end
def gender def gender
@@ -45,9 +45,9 @@ class LocalCensus
end end
def name def name
"#{@body.nombre} #{@body.apellido1}" "#{@body.nombre} #{@body.apellido1}"
rescue rescue
nil nil
end end
private private

View File

@@ -15,7 +15,7 @@ class Migrations::Reports
stats: poll.read_attribute(:stats_enabled), stats: poll.read_attribute(:stats_enabled),
advanced_stats: poll.read_attribute(:stats_enabled), advanced_stats: poll.read_attribute(:stats_enabled),
) )
end end
end end

View File

@@ -159,14 +159,14 @@ FactoryBot.define do
end end
trait :flagged do trait :flagged do
after :create do |investment| after :create do |investment|
Flag.flag(create(:user), investment) Flag.flag(create(:user), investment)
end end
end end
trait :with_confirmed_hide do trait :with_confirmed_hide do
confirmed_hide_at { Time.current } confirmed_hide_at { Time.current }
end end
trait :with_milestone_tags do trait :with_milestone_tags do
after(:create) { |investment| investment.milestone_tags << create(:tag, :milestone) } after(:create) { |investment| investment.milestone_tags << create(:tag, :milestone) }

View File

@@ -115,25 +115,25 @@ describe "Commenting Budget::Investments" do
end end
scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do 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) old_root = create(:comment, commentable: investment, created_at: Time.current - 10)
new_root = create(:comment, commentable: investment, created_at: Time.current) 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) 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) 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(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.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_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.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_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body) expect(old_child.body).to appear_before(new_child.body)
end end
scenario "Turns links into html links" do scenario "Turns links into html links" do

View File

@@ -111,25 +111,25 @@ describe "Commenting polls" do
end end
scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do 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) old_root = create(:comment, commentable: poll, created_at: Time.current - 10)
new_root = create(:comment, commentable: poll, created_at: Time.current) 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) 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) 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(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.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_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.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_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body) expect(old_child.body).to appear_before(new_child.body)
end end
scenario "Turns links into html links" do scenario "Turns links into html links" do

View File

@@ -109,25 +109,25 @@ describe "Commenting proposals" do
end end
scenario "Creation date works differently in roots and in child comments, when sorting by confidence_score" do 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) old_root = create(:comment, commentable: proposal, created_at: Time.current - 10)
new_root = create(:comment, commentable: proposal, created_at: Time.current) 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) 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) 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(new_root.body).to appear_before(old_root.body)
expect(old_child.body).to appear_before(new_child.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_root.body).to appear_before(old_root.body)
expect(new_child.body).to appear_before(old_child.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_root.body).to appear_before(new_root.body)
expect(old_child.body).to appear_before(new_child.body) expect(old_child.body).to appear_before(new_child.body)
end end
scenario "Turns links into html links" do scenario "Turns links into html links" do

View File

@@ -63,9 +63,9 @@ describe "Moderate users" do
click_button "Search" click_button "Search"
within("#moderation_users") do within("#moderation_users") do
expect(page).to have_content citizen.name expect(page).to have_content citizen.name
expect(page).not_to have_content "Blocked" expect(page).not_to have_content "Blocked"
click_link "Block" click_link "Block"
end end
within("#moderation_users") do within("#moderation_users") do

View File

@@ -4,11 +4,11 @@ describe "Tracking" do
context "Custom variable" do context "Custom variable" do
scenario "Usertype anonymous" do scenario "Usertype anonymous" do
visit proposals_path visit proposals_path
expect(page.html).to include "anonymous" expect(page.html).to include "anonymous"
end end
scenario "Usertype level_1_user" do scenario "Usertype level_1_user" do
create(:geozone) create(:geozone)

View File

@@ -82,7 +82,7 @@ describe "Verified users" do
visit verified_user_path visit verified_user_path
within("#verified_user_#{verified_user.id}_email") do within("#verified_user_#{verified_user.id}_email") do
click_button "Send code" click_button "Send code"
end end
expect(page).to have_content "We have sent a confirmation email to your account: rock@example.com" expect(page).to have_content "We have sent a confirmation email to your account: rock@example.com"

View File

@@ -104,14 +104,14 @@ describe Budget::Investment do
describe "#code" do describe "#code" do
let(:investment) { create(:budget_investment) } let(:investment) { create(:budget_investment) }
it "returns the proposal id" do it "returns the proposal id" do
expect(investment.code).to include(investment.id.to_s) expect(investment.code).to include(investment.id.to_s)
end end
it "returns the administrator id when assigned" do it "returns the administrator id when assigned" do
investment.administrator = create(:administrator) investment.administrator = create(:administrator)
expect(investment.code).to include("#{investment.id}-A#{investment.administrator.id}") expect(investment.code).to include("#{investment.id}-A#{investment.administrator.id}")
end end
end end
describe "#send_unfeasible_email" do describe "#send_unfeasible_email" do
@@ -307,24 +307,24 @@ describe Budget::Investment do
describe "#by_budget" do describe "#by_budget" do
it "returns investments scoped by budget" do it "returns investments scoped by budget" do
budget1 = create(:budget) budget1 = create(:budget)
budget2 = create(:budget) budget2 = create(:budget)
group1 = create(:budget_group, budget: budget1) group1 = create(:budget_group, budget: budget1)
group2 = create(:budget_group, budget: budget2) group2 = create(:budget_group, budget: budget2)
heading1 = create(:budget_heading, group: group1) heading1 = create(:budget_heading, group: group1)
heading2 = create(:budget_heading, group: group2) heading2 = create(:budget_heading, group: group2)
investment1 = create(:budget_investment, heading: heading1) investment1 = create(:budget_investment, heading: heading1)
investment2 = create(:budget_investment, heading: heading1) investment2 = create(:budget_investment, heading: heading1)
investment3 = create(:budget_investment, heading: heading2) 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 investment1
expect(investments_by_budget).to include investment2 expect(investments_by_budget).to include investment2
expect(investments_by_budget).not_to include investment3 expect(investments_by_budget).not_to include investment3
end end
end end

View File

@@ -1,4 +1,4 @@
require "rails_helper" require "rails_helper"
RSpec.describe Legislation::Annotation, type: :model do RSpec.describe Legislation::Annotation, type: :model do
let(:draft_version) { create(:legislation_draft_version) } let(:draft_version) { create(:legislation_draft_version) }

View File

@@ -29,7 +29,7 @@ describe Legislation::DraftVersion do
end end
def body_markdown def body_markdown
<<-BODY_MARKDOWN <<-BODY_MARKDOWN
# Title 1 # Title 1
Some paragraph. Some paragraph.
@@ -50,7 +50,7 @@ BODY_MARKDOWN
end end
def body_html def body_html
<<-BODY_HTML <<-BODY_HTML
<h1 id="title-1">Title 1</h1> <h1 id="title-1">Title 1</h1>
<p>Some paragraph.</p> <p>Some paragraph.</p>
@@ -73,7 +73,7 @@ BODY_HTML
end end
def toc_html def toc_html
<<-TOC_HTML <<-TOC_HTML
<ul> <ul>
<li> <li>
<a href="#title-1">Title 1</a> <a href="#title-1">Title 1</a>

View File

@@ -25,9 +25,9 @@ describe Poll::Voter do
end end
it "is valid if has not voted" do it "is valid if has not voted" do
voter = build(:poll_voter, :valid_document) voter = build(:poll_voter, :valid_document)
expect(voter).to be_valid expect(voter).to be_valid
end end
it "is not valid if the user has already voted in the same poll or booth_assignment" do it "is not valid if the user has already voted in the same poll or booth_assignment" do

View File

@@ -88,14 +88,14 @@ describe Proposal do
proposal.responsible_name = "12345678Z" proposal.responsible_name = "12345678Z"
end end
it "is the document_number if level three user" do it "is the document_number if level three user" do
author = create(:user, :level_three, document_number: "12345678Z") author = create(:user, :level_three, document_number: "12345678Z")
proposal.author = author proposal.author = author
proposal.responsible_name = nil proposal.responsible_name = nil
expect(proposal).to be_valid expect(proposal).to be_valid
proposal.responsible_name = "12345678Z" proposal.responsible_name = "12345678Z"
end end
it "is not updated when the author is deleted" do it "is not updated when the author is deleted" do
author = create(:user, :level_three, document_number: "12345678Z") author = create(:user, :level_three, document_number: "12345678Z")

View File

@@ -283,6 +283,6 @@ end
def set_arguments(arguments, mappable, mappable_path_arguments) def set_arguments(arguments, mappable, mappable_path_arguments)
mappable_path_arguments&.each do |argument_name, path_to_value| mappable_path_arguments&.each do |argument_name, path_to_value|
arguments.merge!("#{argument_name}": mappable.send(path_to_value)) arguments.merge!("#{argument_name}": mappable.send(path_to_value))
end end
end end

View File

@@ -16,7 +16,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path,
Setting["feature.allow_images"] = true Setting["feature.allow_images"] = true
imageable_path_arguments&.each do |argument_name, path_to_value| imageable_path_arguments&.each do |argument_name, path_to_value|
arguments.merge!("#{argument_name}": imageable.send(path_to_value)) arguments.merge!("#{argument_name}": imageable.send(path_to_value))
end end
imageable.update(author: user) if imageable.respond_to?(:author) imageable.update(author: user) if imageable.respond_to?(:author)
@@ -176,7 +176,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path,
scenario "Should show successful notice when resource filled correctly without any nested images", :js do scenario "Should show successful notice when resource filled correctly without any nested images", :js do
if has_many_images if has_many_images
skip "no need to test, there are no attributes for the parent resource" skip "no need to test, there are no attributes for the parent resource"
else else
login_as user login_as user
visit send(path, arguments) visit send(path, arguments)

View File

@@ -9,43 +9,43 @@ shared_examples "map validations" do
end end
after do after do
Setting["feature.map"] = nil Setting["feature.map"] = nil
end end
it "is valid with a map location" do it "is valid with a map location" do
mappable.map_location = build(:map_location) mappable.map_location = build(:map_location)
mappable.skip_map = nil mappable.skip_map = nil
expect(mappable).to be_valid expect(mappable).to be_valid
end end
it "is valid accepting that the mappable has no map" do it "is valid accepting that the mappable has no map" do
mappable.skip_map = "1" mappable.skip_map = "1"
mappable.map_location = nil mappable.map_location = nil
expect(mappable).to be_valid expect(mappable).to be_valid
end end
it "is valid when the feature map is deactivated" do it "is valid when the feature map is deactivated" do
Setting["feature.map"] = nil Setting["feature.map"] = nil
mappable.map_location = nil mappable.map_location = nil
mappable.skip_map = nil mappable.skip_map = nil
expect(mappable).to be_valid expect(mappable).to be_valid
end end
it "is not valid without a map location" do it "is not valid without a map location" do
mappable.map_location = nil mappable.map_location = nil
mappable.skip_map = nil mappable.skip_map = nil
expect(mappable).not_to be_valid expect(mappable).not_to be_valid
end end
it "is not valid without accepting that the mappable has no map" do it "is not valid without accepting that the mappable has no map" do
mappable.skip_map = nil mappable.skip_map = nil
expect(mappable).not_to be_valid expect(mappable).not_to be_valid
end end
end end