fix Hound violations
This commit is contained in:
@@ -62,7 +62,8 @@ class Admin::BudgetHeadingsController < Admin::BaseController
|
|||||||
end
|
end
|
||||||
|
|
||||||
def budget_heading_params
|
def budget_heading_params
|
||||||
params.require(:budget_heading).permit(:name, :price, :population, :allow_custom_content, :latitude, :longitude)
|
params.require(:budget_heading).permit(:name, :price, :population, :allow_custom_content,
|
||||||
|
:latitude, :longitude)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomization::BaseController
|
class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomization::BaseController
|
||||||
load_and_authorize_resource :content_block, class: "SiteCustomization::ContentBlock",
|
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
|
def index
|
||||||
@content_blocks = SiteCustomization::ContentBlock.order(:name, :locale)
|
@content_blocks = SiteCustomization::ContentBlock.order(:name, :locale)
|
||||||
@@ -27,7 +31,11 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
|
|||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@selected_content_block = (@content_block.is_a? SiteCustomization::ContentBlock) ? @content_block.name : "hcb_#{ @content_block.heading_id }"
|
if @content_block.is_a? SiteCustomization::ContentBlock
|
||||||
|
@selected_content_block = @content_block.name
|
||||||
|
else
|
||||||
|
@selected_content_block = "hcb_#{@content_block.heading_id}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@@ -65,7 +73,11 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
|
|||||||
|
|
||||||
def edit_heading_content_block
|
def edit_heading_content_block
|
||||||
@content_block = Budget::ContentBlock.find(params[:id])
|
@content_block = Budget::ContentBlock.find(params[:id])
|
||||||
@selected_content_block = (@content_block.is_a? Budget::ContentBlock) ? "hcb_#{ @content_block.heading_id }" : @content_block.heading.name
|
if @content_block.is_a? Budget::ContentBlock
|
||||||
|
@selected_content_block = "hcb_#{@content_block.heading_id}"
|
||||||
|
else
|
||||||
|
@selected_content_block = @content_block.heading.name
|
||||||
|
end
|
||||||
@is_heading_content_block = true
|
@is_heading_content_block = true
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
@@ -116,7 +128,8 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
|
|||||||
heading_content_block = Budget::ContentBlock.new
|
heading_content_block = Budget::ContentBlock.new
|
||||||
heading_content_block.body = params[:site_customization_content_block][:body]
|
heading_content_block.body = params[:site_customization_content_block][:body]
|
||||||
heading_content_block.locale = params[:site_customization_content_block][:locale]
|
heading_content_block.locale = params[:site_customization_content_block][:locale]
|
||||||
heading_content_block.heading_id = params[:site_customization_content_block][:name].sub('hcb_', '').to_i
|
block_heading_id = params[:site_customization_content_block][:name].sub('hcb_', '').to_i
|
||||||
|
heading_content_block.heading_id = block_heading_id
|
||||||
heading_content_block
|
heading_content_block
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -78,7 +78,9 @@ module Budgets
|
|||||||
|
|
||||||
def load_map
|
def load_map
|
||||||
@investments ||= []
|
@investments ||= []
|
||||||
@investments_map_coordinates = MapLocation.where(investment: @investments).map(&:json_data)
|
@investments_map_coordinates = MapLocation.where(investment: @investments).map do |loc|
|
||||||
|
loc.json_data
|
||||||
|
end
|
||||||
@map_location = MapLocation.load_from_heading(@heading)
|
@map_location = MapLocation.load_from_heading(@heading)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,9 @@ module Budgets
|
|||||||
@investments = all_investments.page(params[:page]).per(10).for_render
|
@investments = all_investments.page(params[:page]).per(10).for_render
|
||||||
|
|
||||||
@investment_ids = @investments.pluck(:id)
|
@investment_ids = @investments.pluck(:id)
|
||||||
@investments_map_coordinates = MapLocation.where(investment_id: all_investments).map { |l| l.json_data }
|
@investments_map_coordinates = MapLocation.where(investment: all_investments).map do |loc|
|
||||||
|
loc.json_data
|
||||||
|
end
|
||||||
|
|
||||||
load_investment_votes(@investments)
|
load_investment_votes(@investments)
|
||||||
@tag_cloud = tag_cloud
|
@tag_cloud = tag_cloud
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
module ContentBlocksHelper
|
module ContentBlocksHelper
|
||||||
def valid_blocks
|
def valid_blocks
|
||||||
options = SiteCustomization::ContentBlock::VALID_BLOCKS.map { |key| [t("admin.site_customization.content_blocks.content_block.names.#{key}"), key] }
|
options = SiteCustomization::ContentBlock::VALID_BLOCKS.map do
|
||||||
|
|key| [t("admin.site_customization.content_blocks.content_block.names.#{key}"), key]
|
||||||
|
end
|
||||||
Budget::Heading.allow_custom_content.each do |heading|
|
Budget::Heading.allow_custom_content.each do |heading|
|
||||||
options.push([heading.name, "hcb_#{heading.id}"])
|
options.push([heading.name, "hcb_#{heading.id}"])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,10 +8,12 @@ class MigrateSpendingProposalsToInvestments
|
|||||||
|
|
||||||
if sp.geozone_id.present?
|
if sp.geozone_id.present?
|
||||||
group = budget.groups.find_or_create_by!(name: "Barrios")
|
group = budget.groups.find_or_create_by!(name: "Barrios")
|
||||||
heading = group.headings.find_or_create_by!(name: sp.geozone.name, price: 10000000, latitude: '40.416775', longitude: '-3.703790')
|
heading = group.headings.find_or_create_by!(name: sp.geozone.name, price: 10000000,
|
||||||
|
latitude: '40.416775', longitude: '-3.703790')
|
||||||
else
|
else
|
||||||
group = budget.groups.find_or_create_by!(name: "Toda la ciudad")
|
group = budget.groups.find_or_create_by!(name: "Toda la ciudad")
|
||||||
heading = group.headings.find_or_create_by!(name: "Toda la ciudad", price: 10000000, latitude: '40.416775', longitude: '-3.703790')
|
heading = group.headings.find_or_create_by!(name: "Toda la ciudad", price: 10000000,
|
||||||
|
latitude: '40.416775', longitude: '-3.703790')
|
||||||
end
|
end
|
||||||
|
|
||||||
feasibility = case sp.feasible
|
feasibility = case sp.feasible
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ feature "Admin budget groups" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Disabled with a feature flag" do
|
scenario "Disabled with a feature flag" do
|
||||||
expect { visit admin_budget_groups_path(budget) }.to raise_exception(FeatureFlags::FeatureDisabled)
|
expect do
|
||||||
|
visit admin_budget_groups_path(budget)
|
||||||
|
end.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -30,7 +32,8 @@ feature "Admin budget groups" do
|
|||||||
scenario "Displaying no groups for budget" do
|
scenario "Displaying no groups for budget" do
|
||||||
visit admin_budget_groups_path(budget)
|
visit admin_budget_groups_path(budget)
|
||||||
|
|
||||||
expect(page).to have_content "No groups created yet. Each user will be able to vote in only one heading per group."
|
expect(page).to have_content "No groups created yet. "
|
||||||
|
expect(page).to have_content "Each user will be able to vote in only one heading per group."
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Displaying groups" do
|
scenario "Displaying groups" do
|
||||||
@@ -49,21 +52,21 @@ feature "Admin budget groups" do
|
|||||||
expect(page).to have_content(group1.name)
|
expect(page).to have_content(group1.name)
|
||||||
expect(page).to have_content(group1.max_votable_headings)
|
expect(page).to have_content(group1.max_votable_headings)
|
||||||
expect(page).to have_content(group1.headings.count)
|
expect(page).to have_content(group1.headings.count)
|
||||||
expect(page).to have_link "Manage headings", href: admin_budget_group_headings_path(budget, group1)
|
expect(page).to have_link "Manage headings"
|
||||||
end
|
end
|
||||||
|
|
||||||
within "#budget_group_#{group2.id}" do
|
within "#budget_group_#{group2.id}" do
|
||||||
expect(page).to have_content(group2.name)
|
expect(page).to have_content(group2.name)
|
||||||
expect(page).to have_content(group2.max_votable_headings)
|
expect(page).to have_content(group2.max_votable_headings)
|
||||||
expect(page).to have_content(group2.headings.count)
|
expect(page).to have_content(group2.headings.count)
|
||||||
expect(page).to have_link "Manage headings", href: admin_budget_group_headings_path(budget, group2)
|
expect(page).to have_link "Manage headings"
|
||||||
end
|
end
|
||||||
|
|
||||||
within "#budget_group_#{group3.id}" do
|
within "#budget_group_#{group3.id}" do
|
||||||
expect(page).to have_content(group3.name)
|
expect(page).to have_content(group3.name)
|
||||||
expect(page).to have_content(group3.max_votable_headings)
|
expect(page).to have_content(group3.max_votable_headings)
|
||||||
expect(page).to have_content(group3.headings.count)
|
expect(page).to have_content(group3.headings.count)
|
||||||
expect(page).to have_link "Manage headings", href: admin_budget_group_headings_path(budget, group3)
|
expect(page).to have_link "Manage headings"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,9 @@ feature "Admin budget headings" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
scenario "Disabled with a feature flag" do
|
scenario "Disabled with a feature flag" do
|
||||||
expect { visit admin_budget_group_headings_path(budget, group) }.to raise_exception(FeatureFlags::FeatureDisabled)
|
expect do
|
||||||
|
visit admin_budget_group_headings_path(budget, group)
|
||||||
|
end.to raise_exception(FeatureFlags::FeatureDisabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -31,7 +33,8 @@ feature "Admin budget headings" do
|
|||||||
scenario "Displaying no headings for group" do
|
scenario "Displaying no headings for group" do
|
||||||
visit admin_budget_group_headings_path(budget, group)
|
visit admin_budget_group_headings_path(budget, group)
|
||||||
|
|
||||||
expect(page).to have_content "No headings created yet. Each user will be able to vote in only one heading per group."
|
expect(page).to have_content "No headings created yet. "
|
||||||
|
expect(page).to have_content "Each user will be able to vote in only one heading per group."
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Displaying headings" do
|
scenario "Displaying headings" do
|
||||||
@@ -47,8 +50,8 @@ feature "Admin budget headings" do
|
|||||||
expect(page).to have_content "€1,000"
|
expect(page).to have_content "€1,000"
|
||||||
expect(page).not_to have_content "10000"
|
expect(page).not_to have_content "10000"
|
||||||
expect(page).to have_content "Yes"
|
expect(page).to have_content "Yes"
|
||||||
expect(page).to have_link "Edit", href: edit_admin_budget_group_heading_path(budget, group, heading1)
|
expect(page).to have_link "Edit"
|
||||||
expect(page).to have_link "Delete", href: admin_budget_group_heading_path(budget, group, heading1)
|
expect(page).to have_link "Delete"
|
||||||
end
|
end
|
||||||
|
|
||||||
within "#budget_heading_#{heading2.id}" do
|
within "#budget_heading_#{heading2.id}" do
|
||||||
@@ -56,8 +59,8 @@ feature "Admin budget headings" do
|
|||||||
expect(page).to have_content "€2,000"
|
expect(page).to have_content "€2,000"
|
||||||
expect(page).to have_content "10000"
|
expect(page).to have_content "10000"
|
||||||
expect(page).to have_content "No"
|
expect(page).to have_content "No"
|
||||||
expect(page).to have_link "Edit", href: edit_admin_budget_group_heading_path(budget, group, heading2)
|
expect(page).to have_link "Edit"
|
||||||
expect(page).to have_link "Delete", href: admin_budget_group_heading_path(budget, group, heading2)
|
expect(page).to have_link "Delete"
|
||||||
end
|
end
|
||||||
|
|
||||||
within "#budget_heading_#{heading3.id}" do
|
within "#budget_heading_#{heading3.id}" do
|
||||||
@@ -65,8 +68,8 @@ feature "Admin budget headings" do
|
|||||||
expect(page).to have_content "€3,000"
|
expect(page).to have_content "€3,000"
|
||||||
expect(page).to have_content "10000"
|
expect(page).to have_content "10000"
|
||||||
expect(page).to have_content "No"
|
expect(page).to have_content "No"
|
||||||
expect(page).to have_link "Edit", href: edit_admin_budget_group_heading_path(budget, group, heading3)
|
expect(page).to have_link "Edit"
|
||||||
expect(page).to have_link "Delete", href: admin_budget_group_heading_path(budget, group, heading3)
|
expect(page).to have_link "Delete"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1425,10 +1425,12 @@ feature 'Budget Investments' do
|
|||||||
user = create(:user, :level_two)
|
user = create(:user, :level_two)
|
||||||
|
|
||||||
global_group = create(:budget_group, budget: budget, name: 'Global Group')
|
global_group = create(:budget_group, budget: budget, name: 'Global Group')
|
||||||
global_heading = create(:budget_heading, group: global_group, name: 'Global Heading', latitude: -43.145412, longitude: 12.009423)
|
global_heading = create(:budget_heading, group: global_group, name: 'Global Heading',
|
||||||
|
latitude: -43.145412, longitude: 12.009423)
|
||||||
|
|
||||||
carabanchel_heading = create(:budget_heading, group: group, name: "Carabanchel")
|
carabanchel_heading = create(:budget_heading, group: group, name: "Carabanchel")
|
||||||
new_york_heading = create(:budget_heading, group: group, name: "New York", latitude: -43.223412, longitude: 12.009423)
|
new_york_heading = create(:budget_heading, group: group, name: "New York",
|
||||||
|
latitude: -43.223412, longitude: 12.009423)
|
||||||
|
|
||||||
sp1 = create(:budget_investment, :selected, price: 1, heading: global_heading)
|
sp1 = create(:budget_investment, :selected, price: 1, heading: global_heading)
|
||||||
sp2 = create(:budget_investment, :selected, price: 10, heading: global_heading)
|
sp2 = create(:budget_investment, :selected, price: 10, heading: global_heading)
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ feature 'Tags' do
|
|||||||
let(:author) { create(:user, :level_two, username: 'Isabel') }
|
let(:author) { create(:user, :level_two, username: 'Isabel') }
|
||||||
let(:budget) { create(:budget, name: "Big Budget") }
|
let(:budget) { create(:budget, name: "Big Budget") }
|
||||||
let(:group) { create(:budget_group, name: "Health", budget: 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) { create(:budget_heading, name: "More hospitals",
|
||||||
|
group: group, latitude: '40.416775', longitude: '-3.703790') }
|
||||||
let!(:tag_medio_ambiente) { create(:tag, :category, name: 'Medio Ambiente') }
|
let!(:tag_medio_ambiente) { create(:tag, :category, name: 'Medio Ambiente') }
|
||||||
let!(:tag_economia) { create(:tag, :category, name: 'Economía') }
|
let!(:tag_economia) { create(:tag, :category, name: 'Economía') }
|
||||||
let(:admin) { create(:administrator).user }
|
let(:admin) { create(:administrator).user }
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
RSpec.describe Budget::ContentBlock do
|
describe Budget::ContentBlock do
|
||||||
let(:block) { build(:heading_content_block) }
|
let(:block) { build(:heading_content_block) }
|
||||||
|
|
||||||
it "is valid" do
|
it "is valid" do
|
||||||
@@ -9,12 +9,14 @@ RSpec.describe Budget::ContentBlock do
|
|||||||
|
|
||||||
it "Heading is unique per locale" do
|
it "Heading is unique per locale" do
|
||||||
heading_content_block_en = create(:heading_content_block, locale: "en")
|
heading_content_block_en = create(:heading_content_block, locale: "en")
|
||||||
invalid_block = build(:heading_content_block, heading: heading_content_block_en.heading, locale: "en")
|
invalid_block = build(:heading_content_block,
|
||||||
|
heading: heading_content_block_en.heading, locale: "en")
|
||||||
|
|
||||||
expect(invalid_block).to be_invalid
|
expect(invalid_block).to be_invalid
|
||||||
expect(invalid_block.errors.full_messages).to include("Heading has already been taken")
|
expect(invalid_block.errors.full_messages).to include("Heading has already been taken")
|
||||||
|
|
||||||
valid_block = build(:heading_content_block, heading: heading_content_block_en.heading, locale: "es")
|
valid_block = build(:heading_content_block,
|
||||||
|
heading: heading_content_block_en.heading, locale: "es")
|
||||||
expect(valid_block).to be_valid
|
expect(valid_block).to be_valid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -7,8 +7,8 @@ describe Budget::Heading do
|
|||||||
|
|
||||||
it_behaves_like "sluggable", updatable_slug_trait: :drafting_budget
|
it_behaves_like "sluggable", updatable_slug_trait: :drafting_budget
|
||||||
|
|
||||||
describe "::OSM_DISTRICT_LEVEL_ZOOM" do
|
describe "OSM_DISTRICT_LEVEL_ZOOM constant" do
|
||||||
it "should be defined" do
|
it "is defined" do
|
||||||
expect(Budget::Heading::OSM_DISTRICT_LEVEL_ZOOM).to be 12
|
expect(Budget::Heading::OSM_DISTRICT_LEVEL_ZOOM).to be 12
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -205,7 +205,8 @@ describe Budget::Heading do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "Allows longitude inside [-180,180] interval" do
|
it "Allows longitude inside [-180,180] interval" do
|
||||||
heading = create(:budget_heading, group: group, name: 'Longitude is inside [-180,180] interval')
|
heading = create(:budget_heading, group: group,
|
||||||
|
name: 'Longitude is inside [-180,180] interval')
|
||||||
|
|
||||||
heading.longitude = '180'
|
heading.longitude = '180'
|
||||||
expect(heading).to be_valid
|
expect(heading).to be_valid
|
||||||
|
|||||||
Reference in New Issue
Block a user