From 43137df4a53afec9228c1c37a0ade8a05eb0cd70 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 Jan 2018 01:05:47 +0100 Subject: [PATCH 01/46] Format heading price at admin table --- app/views/admin/budgets/_heading.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/budgets/_heading.html.erb b/app/views/admin/budgets/_heading.html.erb index bc9d59c5f..ba53a1d36 100644 --- a/app/views/admin/budgets/_heading.html.erb +++ b/app/views/admin/budgets/_heading.html.erb @@ -3,7 +3,7 @@ <%= heading.name %> - <%= heading.price %> + <%= heading.budget.formatted_heading_price(heading) %> <%= heading.population %> From d75fd596841d4911ccae9a9faaac5b8c7c11b346 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 Jan 2018 01:06:18 +0100 Subject: [PATCH 02/46] Align right heading amount & population at admin table --- app/views/admin/budgets/_group.html.erb | 4 ++-- app/views/admin/budgets/_heading.html.erb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/admin/budgets/_group.html.erb b/app/views/admin/budgets/_group.html.erb index 8f3fbe2cc..c3ce314aa 100644 --- a/app/views/admin/budgets/_group.html.erb +++ b/app/views/admin/budgets/_group.html.erb @@ -20,8 +20,8 @@ <% else %> <%= t("admin.budgets.form.table_heading") %> - <%= t("admin.budgets.form.table_amount") %> - <%= t("admin.budgets.form.table_population") %> + <%= t("admin.budgets.form.table_amount") %> + <%= t("admin.budgets.form.table_population") %> <%= t("admin.actions.actions") %> diff --git a/app/views/admin/budgets/_heading.html.erb b/app/views/admin/budgets/_heading.html.erb index ba53a1d36..da3139a1b 100644 --- a/app/views/admin/budgets/_heading.html.erb +++ b/app/views/admin/budgets/_heading.html.erb @@ -2,10 +2,10 @@ <%= heading.name %> - + <%= heading.budget.formatted_heading_price(heading) %> - + <%= heading.population %> From bd64c4749f8706d855ba38e781598523ea73afa8 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 Jan 2018 01:17:37 +0100 Subject: [PATCH 03/46] Update groups & headings management feature spec --- spec/features/admin/budgets_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 7a78a349b..354414b2d 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -270,7 +270,7 @@ feature 'Admin budgets' do expect(page).not_to have_content 'This group has no assigned heading.' expect(page).to have_content 'District 9 reconstruction' - expect(page).to have_content '6785' + expect(page).to have_content '€6,785' expect(page).to have_content '100500' end end @@ -293,7 +293,7 @@ feature 'Admin budgets' do end expect(page).to have_content 'District 2' - expect(page).to have_content '10000' + expect(page).to have_content '€10,000' expect(page).to have_content '6000' end From 2a500a14bc4bc9d776de73f200489b377bfd1030 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 Jan 2018 01:20:29 +0100 Subject: [PATCH 04/46] Make budget admin feature spec linelenght compliant --- spec/features/admin/budgets_spec.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 354414b2d..e032daf29 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -191,16 +191,19 @@ feature 'Admin budgets' do budget = create(:budget, phase: 'reviewing_ballots') group = create(:budget_group, budget: budget) heading = create(:budget_heading, group: group, price: 4) - unselected_investment = create(:budget_investment, :unselected, heading: heading, price: 1, ballot_lines_count: 3) - winner_investment = create(:budget_investment, :winner, heading: heading, price: 3, ballot_lines_count: 2) - selected_investment = create(:budget_investment, :selected, heading: heading, price: 2, ballot_lines_count: 1) + unselected = create(:budget_investment, :unselected, heading: heading, price: 1, + ballot_lines_count: 3) + winner = create(:budget_investment, :winner, heading: heading, price: 3, + ballot_lines_count: 2) + selected = create(:budget_investment, :selected, heading: heading, price: 2, + ballot_lines_count: 1) visit edit_admin_budget_path(budget) click_link 'Calculate Winner Investments' expect(page).to have_content 'Winners being calculated, it may take a minute.' - expect(page).to have_content winner_investment.title - expect(page).not_to have_content unselected_investment.title - expect(page).not_to have_content selected_investment.title + expect(page).to have_content winner.title + expect(page).not_to have_content unselected.title + expect(page).not_to have_content selected.title end scenario 'For a finished Budget' do From 18a5bc664228107ca263d060c2028dbef98d5511 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 Jan 2018 11:37:43 +0100 Subject: [PATCH 05/46] Make English the default locale --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index 091f85479..e851bc345 100644 --- a/config/application.rb +++ b/config/application.rb @@ -19,7 +19,7 @@ module Consul # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] - config.i18n.default_locale = :es + config.i18n.default_locale = :en config.i18n.available_locales = [:en, :es, :fr, :nl, 'pt-BR'] config.i18n.fallbacks = {'fr' => 'es', 'pt-br' => 'es', 'nl' => 'en'} config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')] From 9bb088a5c72eddac5848f4bda59e043abeda6fea Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 22 Jan 2018 19:43:28 +0100 Subject: [PATCH 06/46] Add single_heading_group? helper at Budget::Group model --- app/models/budget/group.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/budget/group.rb b/app/models/budget/group.rb index 93d7bba63..a2b3179a3 100644 --- a/app/models/budget/group.rb +++ b/app/models/budget/group.rb @@ -10,5 +10,8 @@ class Budget validates :name, presence: true, uniqueness: { scope: :budget } validates :slug, presence: true, format: /\A[a-z0-9\-_]+\z/ + def single_heading_group? + headings.count == 1 + end end end From ce3bf2015265bd0840cde8400269d49b4094769d Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 22 Jan 2018 19:43:54 +0100 Subject: [PATCH 07/46] Add group name on heading options if more than one heading per group --- app/models/budget/heading.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/budget/heading.rb b/app/models/budget/heading.rb index c9719a709..8816d1abf 100644 --- a/app/models/budget/heading.rb +++ b/app/models/budget/heading.rb @@ -17,7 +17,7 @@ class Budget scope :order_by_group_name, -> { includes(:group).order('budget_groups.name', 'budget_headings.name') } def name_scoped_by_group - "#{group.name}: #{name}" + group.single_heading_group? ? name : "#{group.name}: #{name}" end def name_exists_in_budget_headings From 31956312bfb22d19246666d5e6c6da8b6d8293a8 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 22 Jan 2018 19:52:28 +0100 Subject: [PATCH 08/46] Make use of new single_heading_group? on existing similar logic --- app/views/budgets/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/budgets/show.html.erb b/app/views/budgets/show.html.erb index 54d87498f..1719624aa 100644 --- a/app/views/budgets/show.html.erb +++ b/app/views/budgets/show.html.erb @@ -60,7 +60,7 @@ <% @budget.groups.each do |group| %> - <% if group.headings.count == 1 %> + <% if group.single_heading_group? %> <%= link_to group.name, budget_investments_path(@budget, heading_id: group.headings.first.id, From e0abb862673a1605618cc46d78cea2c72465137c Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 22 Jan 2018 19:48:13 +0100 Subject: [PATCH 09/46] Update specs for new heading options naming rules * Update budget heading order scenario to check new option name rules * Update other scenarios that were expecting old heading naming convention --- .../features/admin/budget_investments_spec.rb | 2 +- spec/features/budgets/investments_spec.rb | 22 ++++++- spec/features/emails_spec.rb | 2 +- .../management/budget_investments_spec.rb | 2 +- spec/features/tags/budget_investments_spec.rb | 58 +++++++++++++++++-- 5 files changed, 76 insertions(+), 10 deletions(-) diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 05e3f905d..980f19283 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -101,7 +101,7 @@ feature 'Admin budget investments' do expect(page).to have_link("Change name") expect(page).to have_link("Plant trees") - select "Parks: Central Park", from: "heading_id" + select "Central Park", from: "heading_id" expect(page).not_to have_link("Realocate visitors") expect(page).not_to have_link("Change name") diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 9bd9ae458..af27facb3 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -609,7 +609,7 @@ feature 'Budget Investments' do login_as(author) visit new_budget_investment_path(budget_id: budget.id) - select 'Health: More hospitals', from: 'budget_investment_heading_id' + select heading.name, from: 'budget_investment_heading_id' fill_in 'budget_investment_title', with: 'I am a bot' fill_in 'budget_investment_subtitle', with: 'This is the honeypot' fill_in 'budget_investment_description', with: 'This is the description' @@ -628,7 +628,7 @@ feature 'Budget Investments' do login_as(author) visit new_budget_investment_path(budget_id: budget.id) - select 'Health: More hospitals', from: 'budget_investment_heading_id' + select heading.name, from: 'budget_investment_heading_id' fill_in 'budget_investment_title', with: 'I am a bot' fill_in 'budget_investment_description', with: 'This is the description' check 'budget_investment_terms_of_service' @@ -644,7 +644,7 @@ feature 'Budget Investments' do visit new_budget_investment_path(budget_id: budget.id) - select 'Health: More hospitals', from: 'budget_investment_heading_id' + select heading.name, from: 'budget_investment_heading_id' fill_in 'budget_investment_title', with: 'Build a skyscraper' fill_in 'budget_investment_description', with: 'I want to live in a high tower over the clouds' fill_in 'budget_investment_location', with: 'City center' @@ -735,6 +735,22 @@ feature 'Budget Investments' do expect(page).not_to have_content('My ballot') end end + + scenario "Heading options are correctly ordered" do + city_group = create(:budget_group, name: "Toda la ciudad", budget: budget) + create(:budget_heading, name: "Toda la ciudad", price: 333333, group: city_group) + create(:budget_heading, name: "More health professionals", price: 999999, group: group) + + login_as(author) + + visit new_budget_investment_path(budget_id: budget.id) + + select_options = find('#budget_investment_heading_id').all('option').collect(&:text) + expect(select_options.first).to eq('') + expect(select_options.second).to eq('Health: More health professionals') + expect(select_options.third).to eq('Health: More hospitals') + expect(select_options.fourth).to eq('Toda la ciudad') + end end scenario "Show" do diff --git a/spec/features/emails_spec.rb b/spec/features/emails_spec.rb index 16be1cbf4..02892ef18 100644 --- a/spec/features/emails_spec.rb +++ b/spec/features/emails_spec.rb @@ -366,7 +366,7 @@ feature 'Emails' do login_as(author) visit new_budget_investment_path(budget_id: budget.id) - select "#{group.name}: #{heading.name}", from: 'budget_investment_heading_id' + select heading.name, from: 'budget_investment_heading_id' fill_in 'budget_investment_title', with: 'Build a hospital' fill_in 'budget_investment_description', with: 'We have lots of people that require medical attention' check 'budget_investment_terms_of_service' diff --git a/spec/features/management/budget_investments_spec.rb b/spec/features/management/budget_investments_spec.rb index 6132c40cd..26df620e5 100644 --- a/spec/features/management/budget_investments_spec.rb +++ b/spec/features/management/budget_investments_spec.rb @@ -29,7 +29,7 @@ feature 'Budget Investments' do expect(page).to have_content user.document_number end - select "Whole city: Health", from: 'budget_investment_heading_id' + select "Health", from: 'budget_investment_heading_id' fill_in 'budget_investment_title', with: 'Build a park in my neighborhood' fill_in 'budget_investment_description', with: 'There is no parks here...' fill_in 'budget_investment_location', with: 'City center' diff --git a/spec/features/tags/budget_investments_spec.rb b/spec/features/tags/budget_investments_spec.rb index 04fb05ddb..9afbdf7a8 100644 --- a/spec/features/tags/budget_investments_spec.rb +++ b/spec/features/tags/budget_investments_spec.rb @@ -65,7 +65,7 @@ feature 'Tags' do visit new_budget_investment_path(budget_id: budget.id) - select "#{group.name}: #{heading.name}", from: 'budget_investment_heading_id' + select heading.name, from: 'budget_investment_heading_id' fill_in 'budget_investment_title', with: 'Build a skyscraper' fill_in 'budget_investment_description', with: 'I want to live in a high tower over the clouds' check 'budget_investment_terms_of_service' @@ -84,7 +84,7 @@ feature 'Tags' do visit new_budget_investment_path(budget_id: budget.id) - select "#{group.name}: #{heading.name}", from: 'budget_investment_heading_id' + select heading.name, from: 'budget_investment_heading_id' fill_in 'budget_investment_title', with: 'Build a skyscraper' fill_in_ckeditor 'budget_investment_description', with: 'If I had a gym near my place I could go do Zumba' check 'budget_investment_terms_of_service' @@ -100,12 +100,62 @@ feature 'Tags' do end end + scenario "Turbolinks sanity check from budget's show", :js do + login_as(author) + + education = create(:tag, name: 'Education', kind: 'category') + health = create(:tag, name: 'Health', kind: 'category') + + visit budget_path(budget) + click_link "Create a budget investment" + + select heading.name, from: 'budget_investment_heading_id' + fill_in 'budget_investment_title', with: 'Build a skyscraper' + fill_in_ckeditor 'budget_investment_description', with: 'If I had a gym near my place I could go do Zumba' + check 'budget_investment_terms_of_service' + + find('.js-add-tag-link', text: 'Education').click + click_button 'Create Investment' + + expect(page).to have_content 'Investment created successfully.' + + within "#tags_budget_investment_#{Budget::Investment.last.id}" do + expect(page).to have_content 'Education' + expect(page).not_to have_content 'Health' + end + end + + scenario "Turbolinks sanity check from budget heading's show", :js do + login_as(author) + + education = create(:tag, name: 'Education', kind: 'category') + health = create(:tag, name: 'Health', kind: 'category') + + visit budget_investments_path(budget, heading_id: heading.id) + click_link "Create a budget investment" + + select heading.name, from: 'budget_investment_heading_id' + fill_in 'budget_investment_title', with: 'Build a skyscraper' + fill_in_ckeditor 'budget_investment_description', with: 'If I had a gym near my place I could go do Zumba' + check 'budget_investment_terms_of_service' + + find('.js-add-tag-link', text: 'Education').click + click_button 'Create Investment' + + expect(page).to have_content 'Investment created successfully.' + + within "#tags_budget_investment_#{Budget::Investment.last.id}" do + expect(page).to have_content 'Education' + expect(page).not_to have_content 'Health' + end + end + scenario 'Create with too many tags' do login_as(author) visit new_budget_investment_path(budget_id: budget.id) - select "#{group.name}: #{heading.name}", from: 'budget_investment_heading_id' + select heading.name, from: 'budget_investment_heading_id' fill_in 'budget_investment_title', with: 'Build a skyscraper' fill_in 'budget_investment_description', with: 'I want to live in a high tower over the clouds' check 'budget_investment_terms_of_service' @@ -123,7 +173,7 @@ feature 'Tags' do visit new_budget_investment_path(budget_id: budget.id) - select "#{group.name}: #{heading.name}", from: 'budget_investment_heading_id' + select heading.name, from: 'budget_investment_heading_id' fill_in 'budget_investment_title', with: 'Build a skyscraper' fill_in 'budget_investment_description', with: 'I want to live in a high tower over the clouds' check 'budget_investment_terms_of_service' From d6a6b99624c2396497250f9232b2bcab632c259e Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 Jan 2018 15:06:40 +0100 Subject: [PATCH 10/46] Fix rare flaky test, expect a price not just the number --- spec/features/budgets/investments_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 9bd9ae458..14b00bc0c 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -1210,13 +1210,13 @@ feature 'Budget Investments' do within("#budget_group_#{global_group.id}") do expect(page).to have_content sp1.title - expect(page).to have_content sp1.price + expect(page).to have_content "€#{sp1.price}" expect(page).to have_content sp2.title - expect(page).to have_content sp2.price + expect(page).to have_content "€#{sp2.price}" expect(page).not_to have_content sp3.title - expect(page).not_to have_content sp3.price + expect(page).not_to have_content "#{sp3.price}" end within("#budget_group_#{group.id}") do From d692ff781a9131ffd866bec7b0bf833e5abcd0c7 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 Jan 2018 23:27:02 +0100 Subject: [PATCH 11/46] Refactor Budget feature spec Index scenario Budget's home page has changed, no longer we'll be showing a list of active budgets, but only one current (open) budget and a list of finished ones. So no need to create 3 budgets in a row, but a finished budget (because we already have a valid budget created) --- spec/features/budgets/budgets_spec.rb | 29 +++++++++++---------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/spec/features/budgets/budgets_spec.rb b/spec/features/budgets/budgets_spec.rb index 71c6c6e71..d4646f873 100644 --- a/spec/features/budgets/budgets_spec.rb +++ b/spec/features/budgets/budgets_spec.rb @@ -6,32 +6,30 @@ feature 'Budgets' do let(:level_two_user) { create(:user, :level_two) } context 'Index' do - let(:budgets) { create_list(:budget, 3) } - let(:last_budget) { budgets.last } scenario 'Show normal index with links' do - group1 = create(:budget_group, budget: last_budget) - group2 = create(:budget_group, budget: last_budget) + finished_budget = create(:budget, :finished) + group1 = create(:budget_group, budget: budget) + group2 = create(:budget_group, budget: budget) heading1 = create(:budget_heading, group: group1) heading2 = create(:budget_heading, group: group2) - last_budget.update_attributes(phase: 'informing') + budget.update_attributes(phase: 'informing') visit budgets_path within("#budget_heading") do - expect(page).to have_content(last_budget.name) - expect(page).to have_content(last_budget.description) + expect(page).to have_content(budget.name) + expect(page).to have_content(budget.description) + expect(page).to have_content("Actual phase") expect(page).to have_content(I18n.t('budgets.phase.informing')) expect(page).to have_link 'Help with participatory budgets' expect(page).to have_link 'See all phases' end - expect(page).to have_content("Accepting projects") - - last_budget.update_attributes(phase: 'publishing_prices') + budget.update_attributes(phase: 'publishing_prices') visit budgets_path within("#budget_heading") do @@ -42,18 +40,15 @@ feature 'Budgets' do expect(page).to have_content group1.name expect(page).to have_content group2.name expect(page).to have_content heading1.name - expect(page).to have_content last_budget.formatted_heading_price(heading1) + expect(page).to have_content budget.formatted_heading_price(heading1) expect(page).to have_content heading2.name - expect(page).to have_content last_budget.formatted_heading_price(heading2) - - expect(page).to have_content budgets.first.name - expect(page).to have_content budgets[2].name + expect(page).to have_content budget.formatted_heading_price(heading2) end end scenario 'Show informing index without links' do - last_budget.update_attributes(phase: 'informing') - group = create(:budget_group, budget: last_budget) + budget.update_attributes(phase: 'informing') + group = create(:budget_group, budget: budget) heading = create(:budget_heading, group: group) visit budgets_path From 210032e1ce58a3ffd57ce98634b6f2041cbca2ff Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 Jan 2018 23:38:55 +0100 Subject: [PATCH 12/46] Expect finished budget be listed at budget index But only finished budgets should be listed here, not drafting ones, neither current ones. --- spec/features/budgets/budgets_spec.rb | 29 ++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/spec/features/budgets/budgets_spec.rb b/spec/features/budgets/budgets_spec.rb index d4646f873..db2122abb 100644 --- a/spec/features/budgets/budgets_spec.rb +++ b/spec/features/budgets/budgets_spec.rb @@ -8,10 +8,8 @@ feature 'Budgets' do context 'Index' do scenario 'Show normal index with links' do - finished_budget = create(:budget, :finished) group1 = create(:budget_group, budget: budget) group2 = create(:budget_group, budget: budget) - heading1 = create(:budget_heading, group: group1) heading2 = create(:budget_heading, group: group2) @@ -19,7 +17,6 @@ feature 'Budgets' do visit budgets_path - within("#budget_heading") do expect(page).to have_content(budget.name) expect(page).to have_content(budget.description) @@ -37,12 +34,26 @@ feature 'Budgets' do end within('#budget_info') do - expect(page).to have_content group1.name - expect(page).to have_content group2.name - expect(page).to have_content heading1.name - expect(page).to have_content budget.formatted_heading_price(heading1) - expect(page).to have_content heading2.name - expect(page).to have_content budget.formatted_heading_price(heading2) + expect(page).to have_content(group1.name) + expect(page).to have_content(group2.name) + expect(page).to have_content(heading1.name) + expect(page).to have_content(budget.formatted_heading_price(heading1)) + expect(page).to have_content(heading2.name) + expect(page).to have_content(budget.formatted_heading_price(heading2)) + end + + expect(page).not_to have_content("#finished_budgets") + end + + scenario 'Show finished budgets list' do + finished_budget = create(:budget, :finished) + drafting_budget = create(:budget, :drafting) + visit budgets_path + + within("#finished_budgets") do + expect(page).to have_content(finished_budget.name) + expect(page).not_to have_content(budget.name) + expect(page).not_to have_content(drafting_budget.name) end end From bc3c92acb4d31c37c70425fc338ac274619cac5c Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 Jan 2018 23:41:32 +0100 Subject: [PATCH 13/46] Remove no longer valid drafting budget scenarios Drafting budgets will no longer be listed under any conditions at the budget index... not even as "current" budget. --- spec/features/budgets/budgets_spec.rb | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/spec/features/budgets/budgets_spec.rb b/spec/features/budgets/budgets_spec.rb index db2122abb..ae54ecbc1 100644 --- a/spec/features/budgets/budgets_spec.rb +++ b/spec/features/budgets/budgets_spec.rb @@ -205,25 +205,11 @@ feature 'Budgets' do end context "Listed" do - scenario "Not listed to guest users at the public budgets list" do + scenario "Not listed at public budgets list" do visit budgets_path expect(page).not_to have_content(budget.name) end - - scenario "Not listed to logged users at the public budgets list" do - login_as(level_two_user) - visit budgets_path - - expect(page).not_to have_content(budget.name) - end - - scenario "Is listed to admins at the public budgets list" do - login_as(admin) - visit budgets_path - - expect(page).to have_content(budget.name) - end end context "Shown" do From e5cff2fb604fa967b74366a33fc8bdf151ca862a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 Jan 2018 23:48:18 +0100 Subject: [PATCH 14/46] Make budget feature spec comply with 100 linelenght --- spec/features/budgets/budgets_spec.rb | 58 +++++++++++++-------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/spec/features/budgets/budgets_spec.rb b/spec/features/budgets/budgets_spec.rb index ae54ecbc1..84f38b0fa 100644 --- a/spec/features/budgets/budgets_spec.rb +++ b/spec/features/budgets/budgets_spec.rb @@ -80,42 +80,42 @@ feature 'Budgets' do scenario 'Index shows only published phases' do budget.update(phase: :finished) + phases = budget.phases + phases.drafting.update(starts_at: '30-12-2017', ends_at: '31-12-2017', enabled: true, + description: 'Description of drafting phase', + summary: '

This is the summary for drafting phase

') - budget.phases.drafting.update(starts_at: '30-12-2017', ends_at: '31-12-2017', enabled: true, - description: 'Description of drafting phase', - summary: '

This is the summary for drafting phase

') + phases.accepting.update(starts_at: '01-01-2018', ends_at: '10-01-2018', enabled: true, + description: 'Description of accepting phase', + summary: 'This is the summary for accepting phase') - budget.phases.accepting.update(starts_at: '01-01-2018', ends_at: '10-01-2018', enabled: true, - description: 'Description of accepting phase', - summary: 'This is the summary for accepting phase') + phases.reviewing.update(starts_at: '11-01-2018', ends_at: '20-01-2018', enabled: false, + description: 'Description of reviewing phase', + summary: 'This is the summary for reviewing phase') - budget.phases.reviewing.update(starts_at: '11-01-2018', ends_at: '20-01-2018', enabled: false, - description: 'Description of reviewing phase', - summary: 'This is the summary for reviewing phase') + phases.selecting.update(starts_at: '21-01-2018', ends_at: '01-02-2018', enabled: true, + description: 'Description of selecting phase', + summary: 'This is the summary for selecting phase') - budget.phases.selecting.update(starts_at: '21-01-2018', ends_at: '01-02-2018', enabled: true, - description: 'Description of selecting phase', - summary: 'This is the summary for selecting phase') + phases.valuating.update(starts_at: '10-02-2018', ends_at: '20-02-2018', enabled: false, + description: 'Description of valuating phase', + summary: 'This is the summary for valuating phase') - budget.phases.valuating.update(starts_at: '10-02-2018', ends_at: '20-02-2018', enabled: false, - description: 'Description of valuating phase', - summary: 'This is the summary for valuating phase') + phases.publishing_prices.update(starts_at: '21-02-2018', ends_at: '01-03-2018', enabled: false, + description: 'Description of publishing prices phase', + summary: 'This is the summary for publishing_prices phase') - budget.phases.publishing_prices.update(starts_at: '21-02-2018', ends_at: '01-03-2018', enabled: false, - description: 'Description of publishing prices phase', - summary: 'This is the summary for publishing_prices phase') + phases.balloting.update(starts_at: '02-03-2018', ends_at: '10-03-2018', enabled: true, + description: 'Description of balloting phase', + summary: 'This is the summary for balloting phase') - budget.phases.balloting.update(starts_at: '02-03-2018', ends_at: '10-03-2018', enabled: true, - description: 'Description of balloting phase', - summary: 'This is the summary for balloting phase') + phases.reviewing_ballots.update(starts_at: '11-03-2018', ends_at: '20-03-2018', enabled: false, + description: 'Description of reviewing ballots phase', + summary: 'This is the summary for reviewing_ballots phase') - budget.phases.reviewing_ballots.update(starts_at: '11-03-2018', ends_at: '20-03-2018', enabled: false, - description: 'Description of reviewing ballots phase', - summary: 'This is the summary for reviewing_ballots phase') - - budget.phases.finished.update(starts_at: '21-03-2018', ends_at: '30-03-2018', enabled: true, - description: 'Description of finished phase', - summary: 'This is the summary for finished phase') + phases.finished.update(starts_at: '21-03-2018', ends_at: '30-03-2018', enabled: true, + description: 'Description of finished phase', + summary: 'This is the summary for finished phase') visit budgets_path @@ -261,7 +261,7 @@ feature 'Budgets' do scenario "user not logged in" do visit budget_path(budget) - expect(page).to have_content "To create a new budget investment you must sign in or sign up." + expect(page).to have_content "To create a new budget investment you must sign in or sign up" end end From e62ca48a9456ab5abd3f66f8ce60017e084b922b Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 Jan 2018 23:52:42 +0100 Subject: [PATCH 15/46] Show only finished budgets at budget's index We only need finished budget's at budget's index "Finished budgets" section. So we add the `finished` scope to @budgets variable, and rename it so its clear what it contains. Also avoid showing the "Finished budgets" section if there is none --- app/controllers/budgets_controller.rb | 2 +- app/views/budgets/index.html.erb | 60 ++++++++++++++------------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/app/controllers/budgets_controller.rb b/app/controllers/budgets_controller.rb index 385734121..6d3b5e154 100644 --- a/app/controllers/budgets_controller.rb +++ b/app/controllers/budgets_controller.rb @@ -14,7 +14,7 @@ class BudgetsController < ApplicationController end def index - @budgets = @budgets.order(created_at: :desc) + @finished_budgets = @budgets.finished.order(created_at: :desc) @budget = current_budget @budgets_coordinates = current_budget_map_locations end diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index 99571e70a..c343b6f39 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -108,44 +108,46 @@ -
-
- + <% if @finished_budgets.present? %> +
+
+ -
- <% @budgets.each do |budget| %> - <% if budget_published?(budget) %> -
-
-
-
-
-

<%= budget.name %>

+
+ <% @finished_budgets.each do |budget| %> + <% if budget_published?(budget) %> +
+
+
+
+
+

<%= budget.name %>

+
-
-
-
- <%= link_to t("budgets.index.see_results"), - budget_results_path(budget.id), - class: "button expanded" %> +
+
+ <%= link_to t("budgets.index.see_results"), + budget_results_path(budget.id), + class: "button expanded" %> +
-
+ <% end %> <% end %> - <% end %> +
-
+ <% end %>
From 791f081a91bc31491eabca9cea36e8d92a3bbf82 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 23 Jan 2018 23:55:37 +0100 Subject: [PATCH 16/46] Rename @budget to @current budget at budget index Clear instance variable names help understand what's going around when you're deep 2 or 3 partials. In this case @budget is only used to carry around the current_budget so @current_budget is more descriptive. Using `current_budget` directly around would be an alternative, but maybe not as maintainable in case we want to change which budget is being shown (for example the drafting one if you're admin). --- app/controllers/budgets_controller.rb | 2 +- app/views/budgets/_phases.html.erb | 4 ++-- app/views/budgets/index.html.erb | 28 +++++++++++++-------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/app/controllers/budgets_controller.rb b/app/controllers/budgets_controller.rb index 6d3b5e154..8d69b8c98 100644 --- a/app/controllers/budgets_controller.rb +++ b/app/controllers/budgets_controller.rb @@ -15,7 +15,7 @@ class BudgetsController < ApplicationController def index @finished_budgets = @budgets.finished.order(created_at: :desc) - @budget = current_budget + @current_budget = current_budget @budgets_coordinates = current_budget_map_locations end diff --git a/app/views/budgets/_phases.html.erb b/app/views/budgets/_phases.html.erb index 1d0968c46..928ffb993 100644 --- a/app/views/budgets/_phases.html.erb +++ b/app/views/budgets/_phases.html.erb @@ -1,6 +1,6 @@
    - <% @budget.published_phases.each do |phase| %> -
  • + <% @current_budget.published_phases.each do |phase| %> +
  • <%= t("budgets.phase.#{phase.kind}") %>

    <%= l(phase.starts_at.to_date, format: :long) if phase.starts_at.present? %> diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index c343b6f39..204df0039 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -7,9 +7,9 @@
    -

    <%= @budget.name %>

    +

    <%= @current_budget.name %>

    - <%= safe_html_with_links(@budget.description) %> + <%= safe_html_with_links(@current_budget.description) %>

    <%= link_to t("budgets.index.section_header.help"), "#section_help" %> @@ -19,11 +19,11 @@

    <%= t('budgets.show.phase') %>

    -

    <%= t("budgets.phase.#{@budget.phase}") %>

    +

    <%= t("budgets.phase.#{@current_budget.phase}") %>

    <%= link_to t("budgets.index.section_header.all_phases"), "#all_phases" %> - <% if @budget.accepting? %> + <% if @current_budget.accepting? %> <% if current_user %> <% if current_user.level_two_or_three_verified? %> <%= link_to t("budgets.investments.index.sidebar.create"), @@ -48,9 +48,9 @@ <% end %> - <% if @budget.finished? || (@budget.balloting? && can?(:read_results, @budget)) %> + <% if @current_budget.finished? || (@current_budget.balloting? && can?(:read_results, @current_budget)) %> <%= link_to t("budgets.show.see_results"), - budget_results_path(@budget, heading_id: @budget.headings.first), + budget_results_path(@current_budget, heading_id: @current_budget.headings.first), class: "button margin-top expanded" %> <% end %>
    @@ -62,18 +62,18 @@
    - <% @budget.groups.each do |group| %> + <% @current_budget.groups.each do |group| %>

    <%= group.name %>

      <% group.headings.order_by_group_name.each do |heading| %>
    • <% unless @budget.informing? %> - <%= link_to budget_investments_path(@budget.id, heading_id: heading.id) do %> - <%= heading_name_and_price_html(heading, @budget) %> + <%= link_to budget_investments_path(@current_budget.id, heading_id: heading.id) do %> + <%= heading_name_and_price_html(heading, @current_budget) %> <% end %> <% else %>
      - <%= heading_name_and_price_html(heading, @budget) %> + <%= heading_name_and_price_html(heading, @current_budget) %>
      <% end %>
    • @@ -89,13 +89,13 @@

    - <%= link_to budget_investments_path(@budget.id) do %> + <%= link_to budget_investments_path(@current_budget.id) do %> <%= t("budgets.index.investment_proyects") %> <% end %>
    - <%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unfeasible') do %> + <%= link_to budget_investments_path(budget_id: @current_budget.id, filter: 'unfeasible') do %> <%= t("budgets.index.unfeasible_investment_proyects") %> <% end %>
    - <%= link_to budget_investments_path(budget_id: @budget.id, filter: 'unselected') do %> + <%= link_to budget_investments_path(budget_id: @current_budget.id, filter: 'unselected') do %> <%= t("budgets.index.not_selected_investment_proyects") %> <% end %>

    @@ -103,7 +103,7 @@

    <%= t("budgets.index.all_phases") %>

    - <%= render "phases" %> + <%= render "phases", budget: @current_budget %>
    From 8749b46ec4354e1b725ab9225493df218c63aab9 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 Jan 2018 13:09:00 +0100 Subject: [PATCH 17/46] Remove budget_published? usage on budget index, drafting budgets no longer listed --- app/views/budgets/index.html.erb | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index 204df0039..fa1492a51 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -123,26 +123,24 @@
    <% @finished_budgets.each do |budget| %> - <% if budget_published?(budget) %> -
    -
    -
    -
    -
    -

    <%= budget.name %>

    -
    +
    +
    +
    +
    +
    +

    <%= budget.name %>

    -
    -
    - <%= link_to t("budgets.index.see_results"), - budget_results_path(budget.id), - class: "button expanded" %> -
    +
    +
    +
    + <%= link_to t("budgets.index.see_results"), + budget_results_path(budget.id), + class: "button expanded" %>
    - <% end %> +
    <% end %>
    From c01c08a3f480807d5a79204291cf6dadeab7558d Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 24 Jan 2018 13:09:47 +0100 Subject: [PATCH 18/46] Use current_budget directly instead of instance variable --- app/controllers/budgets_controller.rb | 1 - app/views/budgets/_phases.html.erb | 4 ++-- app/views/budgets/index.html.erb | 32 +++++++++++++-------------- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/app/controllers/budgets_controller.rb b/app/controllers/budgets_controller.rb index 8d69b8c98..298425174 100644 --- a/app/controllers/budgets_controller.rb +++ b/app/controllers/budgets_controller.rb @@ -15,7 +15,6 @@ class BudgetsController < ApplicationController def index @finished_budgets = @budgets.finished.order(created_at: :desc) - @current_budget = current_budget @budgets_coordinates = current_budget_map_locations end diff --git a/app/views/budgets/_phases.html.erb b/app/views/budgets/_phases.html.erb index 928ffb993..2d11ef01f 100644 --- a/app/views/budgets/_phases.html.erb +++ b/app/views/budgets/_phases.html.erb @@ -1,6 +1,6 @@
      - <% @current_budget.published_phases.each do |phase| %> -
    • + <% current_budget.published_phases.each do |phase| %> +
    • <%= t("budgets.phase.#{phase.kind}") %>

      <%= l(phase.starts_at.to_date, format: :long) if phase.starts_at.present? %> diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index fa1492a51..810c505ae 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -7,9 +7,9 @@
      -

      <%= @current_budget.name %>

      +

      <%= current_budget.name %>

      - <%= safe_html_with_links(@current_budget.description) %> + <%= safe_html_with_links(current_budget.description) %>

      <%= link_to t("budgets.index.section_header.help"), "#section_help" %> @@ -19,11 +19,11 @@

      <%= t('budgets.show.phase') %>

      -

      <%= t("budgets.phase.#{@current_budget.phase}") %>

      +

      <%= t("budgets.phase.#{current_budget.phase}") %>

      <%= link_to t("budgets.index.section_header.all_phases"), "#all_phases" %> - <% if @current_budget.accepting? %> + <% if current_budget.accepting? %> <% if current_user %> <% if current_user.level_two_or_three_verified? %> <%= link_to t("budgets.investments.index.sidebar.create"), @@ -48,9 +48,9 @@ <% end %> - <% if @current_budget.finished? || (@current_budget.balloting? && can?(:read_results, @current_budget)) %> + <% if current_budget.finished? || (current_budget.balloting? && can?(:read_results, current_budget)) %> <%= link_to t("budgets.show.see_results"), - budget_results_path(@current_budget, heading_id: @current_budget.headings.first), + budget_results_path(current_budget, heading_id: current_budget.headings.first), class: "button margin-top expanded" %> <% end %>
      @@ -62,18 +62,18 @@
      - <% @current_budget.groups.each do |group| %> + <% current_budget.groups.each do |group| %>

      <%= group.name %>

        <% group.headings.order_by_group_name.each do |heading| %>
      • - <% unless @budget.informing? %> - <%= link_to budget_investments_path(@current_budget.id, heading_id: heading.id) do %> - <%= heading_name_and_price_html(heading, @current_budget) %> + <% unless current_budget.informing? %> + <%= link_to budget_investments_path(current_budget.id, heading_id: heading.id) do %> + <%= heading_name_and_price_html(heading, current_budget) %> <% end %> <% else %>
        - <%= heading_name_and_price_html(heading, @current_budget) %> + <%= heading_name_and_price_html(heading, current_budget) %>
        <% end %>
      • @@ -82,20 +82,20 @@ <% end %>
      - <% unless @budget.informing? %> + <% unless current_budget.informing? %>

      <%= t("budgets.index.map") %>

      <%= render_map(nil, "budgets", false, nil, @budgets_coordinates) %>

      - <%= link_to budget_investments_path(@current_budget.id) do %> + <%= link_to budget_investments_path(current_budget.id) do %> <%= t("budgets.index.investment_proyects") %> <% end %>
      - <%= link_to budget_investments_path(budget_id: @current_budget.id, filter: 'unfeasible') do %> + <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unfeasible') do %> <%= t("budgets.index.unfeasible_investment_proyects") %> <% end %>
      - <%= link_to budget_investments_path(budget_id: @current_budget.id, filter: 'unselected') do %> + <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unselected') do %> <%= t("budgets.index.not_selected_investment_proyects") %> <% end %>

      @@ -103,7 +103,7 @@

      <%= t("budgets.index.all_phases") %>

      - <%= render "phases", budget: @current_budget %> + <%= render "phases", budget: current_budget %>
      From 2cee29d883aac433f4253fa7f96e2f409213835e Mon Sep 17 00:00:00 2001 From: Angel Perez Date: Mon, 29 Jan 2018 18:34:15 -0400 Subject: [PATCH 19/46] Fix: Admin investments table not showing up properly --- .../admin/budget_investments/index.html.erb | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/app/views/admin/budget_investments/index.html.erb b/app/views/admin/budget_investments/index.html.erb index 19acdebd3..73a06a402 100644 --- a/app/views/admin/budget_investments/index.html.erb +++ b/app/views/admin/budget_investments/index.html.erb @@ -27,15 +27,14 @@ class: "js-submit-on-change" } %>
    -
    - <%= select_tag :tag_name, - options_for_select(investment_tags_select_options(@budget), params[:tag_name]), - { prompt: t("admin.budget_investments.index.tags_filter_all"), - label: false, - class: "js-submit-on-change" } %> -
    - <% end %> -
    +
    + <%= select_tag :tag_name, + options_for_select(investment_tags_select_options(@budget), params[:tag_name]), + { prompt: t("admin.budget_investments.index.tags_filter_all"), + label: false, + class: "js-submit-on-change" } %> +
    +<% end %> <%= render "advanced_filters", i18n_namespace: "admin.budget_investments.index" %> From 04d5a830310e2dd99f9bb2d626393eb534d60aa3 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 Jan 2018 03:01:44 +0100 Subject: [PATCH 20/46] Improve Budget's index feature spec scenarios --- spec/features/budgets/budgets_spec.rb | 28 ++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/spec/features/budgets/budgets_spec.rb b/spec/features/budgets/budgets_spec.rb index 84f38b0fa..71ae6805a 100644 --- a/spec/features/budgets/budgets_spec.rb +++ b/spec/features/budgets/budgets_spec.rb @@ -20,17 +20,17 @@ feature 'Budgets' do within("#budget_heading") do expect(page).to have_content(budget.name) expect(page).to have_content(budget.description) - expect(page).to have_content("Actual phase") - expect(page).to have_content(I18n.t('budgets.phase.informing')) - expect(page).to have_link 'Help with participatory budgets' - expect(page).to have_link 'See all phases' + expect(page).to have_content('Actual phase') + expect(page).to have_content('Informing') + expect(page).to have_link('Help with participatory budgets') + expect(page).to have_link('See all phases') end budget.update_attributes(phase: 'publishing_prices') visit budgets_path within("#budget_heading") do - expect(page).to have_content(I18n.t('budgets.phase.publishing_prices')) + expect(page).to have_content('Publishing projects prices') end within('#budget_info') do @@ -46,12 +46,14 @@ feature 'Budgets' do end scenario 'Show finished budgets list' do - finished_budget = create(:budget, :finished) + finished_budget_1 = create(:budget, :finished) + finished_budget_2 = create(:budget, :finished) drafting_budget = create(:budget, :drafting) visit budgets_path within("#finished_budgets") do - expect(page).to have_content(finished_budget.name) + expect(page).to have_content(finished_budget_1.name) + expect(page).to have_content(finished_budget_2.name) expect(page).not_to have_content(budget.name) expect(page).not_to have_content(drafting_budget.name) end @@ -60,17 +62,17 @@ feature 'Budgets' do scenario 'Show informing index without links' do budget.update_attributes(phase: 'informing') group = create(:budget_group, budget: budget) - heading = create(:budget_heading, group: group) + heading = create(:budget_heading, group: group, name: 'Health') visit budgets_path within('#budget_info') do - expect(page).not_to have_link "#{heading.name} €1,000,000" - expect(page).to have_content "#{heading.name} €1,000,000" + expect(page).not_to have_link("Health €1,000,000") + expect(page).to have_content("Health €1,000,000") - expect(page).not_to have_link "List of all investment projects" - expect(page).not_to have_link "List of all unfeasible investment projects" - expect(page).not_to have_link "List of all investment projects not selected for balloting" + expect(page).not_to have_link("List of all investment projects") + expect(page).not_to have_link("List of all unfeasible investment projects") + expect(page).not_to have_link("List of all investment projects not selected for balloting") expect(page).not_to have_css('div#map') end From 093b191f1630e46b9b00750e7e2a51e1eb05f7c5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 Jan 2018 03:07:52 +0100 Subject: [PATCH 21/46] Small rubocop autocorrections --- .../admin/budget_investments_controller.rb | 11 ++++++----- spec/features/admin/budget_investments_spec.rb | 2 +- spec/features/admin/budget_phases_spec.rb | 10 +++++----- spec/models/budget_spec.rb | 2 +- 4 files changed, 13 insertions(+), 12 deletions(-) diff --git a/app/controllers/admin/budget_investments_controller.rb b/app/controllers/admin/budget_investments_controller.rb index 9bf4d4610..c81ccfcc3 100644 --- a/app/controllers/admin/budget_investments_controller.rb +++ b/app/controllers/admin/budget_investments_controller.rb @@ -61,12 +61,13 @@ class Admin::BudgetInvestmentsController < Admin::BaseController end def load_investments - if params[:project_title].present? - @investments = Budget::Investment.where("title ILIKE ?", "%#{params[:project_title].strip}%") - else - @investments = Budget::Investment.scoped_filter(params, @current_filter) + @investments = if params[:project_title].present? + Budget::Investment.where("title ILIKE ?", + "%#{params[:project_title].strip}%") + else + Budget::Investment.scoped_filter(params, @current_filter) .order(sort_by(params[:sort_by])) - end + end @investments = @investments.page(params[:page]) unless request.format.csv? end diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 096bb5146..e6f8ab0a2 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -372,7 +372,7 @@ feature 'Admin budget investments' do click_button 'Search' expect(page).to have_content(@investment_1.title) - expect(page).to_not have_content(@investment_2.title) + expect(page).not_to have_content(@investment_2.title) end end diff --git a/spec/features/admin/budget_phases_spec.rb b/spec/features/admin/budget_phases_spec.rb index 3395c1e68..c22037936 100644 --- a/spec/features/admin/budget_phases_spec.rb +++ b/spec/features/admin/budget_phases_spec.rb @@ -5,7 +5,7 @@ feature 'Admin budget phases' do context 'Edit' do - before :each do + before do admin = create(:administrator) login_as(admin.user) end @@ -13,8 +13,8 @@ feature 'Admin budget phases' do scenario 'Update phase' do visit edit_admin_budget_budget_phase_path(budget, budget.current_phase) - fill_in 'start_date', with: DateTime.current + 1.days - fill_in 'end_date', with: DateTime.current + 12.days + fill_in 'start_date', with: Date.current + 1.days + fill_in 'end_date', with: Date.current + 12.days fill_in 'budget_phase_summary', with: 'This is the summary of the phase.' fill_in 'budget_phase_description', with: 'This is the description of the phase.' uncheck 'budget_phase_enabled' @@ -23,8 +23,8 @@ feature 'Admin budget phases' do expect(page).to have_current_path(edit_admin_budget_path(budget)) expect(page).to have_content 'Changes saved' - expect(budget.current_phase.starts_at.to_date).to eq((DateTime.current + 1.days).to_date) - expect(budget.current_phase.ends_at.to_date).to eq((DateTime.current + 12.days).to_date) + expect(budget.current_phase.starts_at.to_date).to eq((Date.current + 1.days).to_date) + expect(budget.current_phase.ends_at.to_date).to eq((Date.current + 12.days).to_date) expect(budget.current_phase.summary).to eq('This is the summary of the phase.') expect(budget.current_phase.description).to eq('This is the description of the phase.') expect(budget.current_phase.enabled).to be(false) diff --git a/spec/models/budget_spec.rb b/spec/models/budget_spec.rb index 75e78a6dd..c41182bdd 100644 --- a/spec/models/budget_spec.rb +++ b/spec/models/budget_spec.rb @@ -192,7 +192,7 @@ describe Budget do describe "#generate_phases" do let(:drafting_phase) { budget.phases.drafting } - let(:informing_phase) { budget.phases.informing } + let(:informing_phase) { budget.phases.informing } let(:accepting_phase) { budget.phases.accepting } let(:reviewing_phase) { budget.phases.reviewing } let(:selecting_phase) { budget.phases.selecting } From a4fb568654ce7b0d7240af80c3e5f92b2d8bba0f Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 Jan 2018 03:29:20 +0100 Subject: [PATCH 22/46] Improve dev seeds comments adding them to investments --- db/dev_seeds.rb | 205 +++++++++++++++++++++++------------------------- 1 file changed, 97 insertions(+), 108 deletions(-) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index d8f170149..eb5a350e5 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -319,114 +319,6 @@ section "Creating Successful Proposals" do end end -section "Commenting Debates" do - 100.times do - author = User.all.sample - debate = Debate.all.sample - Comment.create!(user: author, - created_at: rand(debate.created_at..Time.current), - commentable: debate, - body: Faker::Lorem.sentence) - end -end - -section "Commenting Proposals" do - 100.times do - author = User.all.sample - proposal = Proposal.all.sample - Comment.create!(user: author, - created_at: rand(proposal.created_at..Time.current), - commentable: proposal, - body: Faker::Lorem.sentence) - end -end - -section "Commenting Comments" do - 200.times do - author = User.all.sample - parent = Comment.all.sample - Comment.create!(user: author, - created_at: rand(parent.created_at..Time.current), - commentable_id: parent.commentable_id, - commentable_type: parent.commentable_type, - body: Faker::Lorem.sentence, - parent: parent) - end -end - -section "Voting Debates, Proposals & Comments" do - not_org_users = User.where(['users.id NOT IN(?)', User.organizations.pluck(:id)]) - 100.times do - voter = not_org_users.level_two_or_three_verified.all.sample - vote = [true, false].sample - debate = Debate.all.sample - debate.vote_by(voter: voter, vote: vote) - end - - 100.times do - voter = not_org_users.all.sample - vote = [true, false].sample - comment = Comment.all.sample - comment.vote_by(voter: voter, vote: vote) - end - - 100.times do - voter = not_org_users.level_two_or_three_verified.all.sample - proposal = Proposal.all.sample - proposal.vote_by(voter: voter, vote: true) - end -end - -section "Flagging Debates & Comments" do - 40.times do - debate = Debate.all.sample - flagger = User.where(["users.id <> ?", debate.author_id]).all.sample - Flag.flag(flagger, debate) - end - - 40.times do - comment = Comment.all.sample - flagger = User.where(["users.id <> ?", comment.user_id]).all.sample - Flag.flag(flagger, comment) - end - - 40.times do - proposal = Proposal.all.sample - flagger = User.where(["users.id <> ?", proposal.author_id]).all.sample - Flag.flag(flagger, proposal) - end -end - -section "Creating Spending Proposals" do - tags = Faker::Lorem.words(10) - 60.times do - geozone = Geozone.all.sample - author = User.all.sample - description = "

    #{Faker::Lorem.paragraphs.join('

    ')}

    " - feasible_explanation = "

    #{Faker::Lorem.paragraphs.join('

    ')}

    " - valuation_finished = [true, false].sample - feasible = [true, false].sample - spending_proposal = SpendingProposal.create!(author: author, - title: Faker::Lorem.sentence(3).truncate(60), - external_url: Faker::Internet.url, - description: description, - created_at: rand((Time.current - 1.week)..Time.current), - geozone: [geozone, nil].sample, - feasible: feasible, - feasible_explanation: feasible_explanation, - valuation_finished: valuation_finished, - tag_list: tags.sample(3).join(','), - price: rand(1000000), - terms_of_service: "1") - end -end - -section "Creating Valuation Assignments" do - (1..17).to_a.sample.times do - SpendingProposal.all.sample.valuators << Valuator.first - end -end - section "Creating Budgets" do Budget.create( name: "Budget #{Date.current.year - 1}", @@ -533,6 +425,103 @@ section "Creating Valuation Assignments" do end end +section "Commenting Investments, Debates & Proposals" do + %w(Budget::Investment Debate Proposal).each do |commentable_class| + 100.times do + commentable = commentable_class.constantize.all.sample + Comment.create!(user: User.all.sample, + created_at: rand(commentable.created_at..Time.current), + commentable: commentable, + body: Faker::Lorem.sentence) + end + end +end + +section "Commenting Comments" do + 200.times do + parent = Comment.all.sample + Comment.create!(user: User.all.sample, + created_at: rand(parent.created_at..Time.current), + commentable_id: parent.commentable_id, + commentable_type: parent.commentable_type, + body: Faker::Lorem.sentence, + parent: parent) + end +end + +section "Voting Debates, Proposals & Comments" do + not_org_users = User.where(['users.id NOT IN(?)', User.organizations.pluck(:id)]) + 100.times do + voter = not_org_users.level_two_or_three_verified.all.sample + vote = [true, false].sample + debate = Debate.all.sample + debate.vote_by(voter: voter, vote: vote) + end + + 100.times do + voter = not_org_users.all.sample + vote = [true, false].sample + comment = Comment.all.sample + comment.vote_by(voter: voter, vote: vote) + end + + 100.times do + voter = not_org_users.level_two_or_three_verified.all.sample + proposal = Proposal.all.sample + proposal.vote_by(voter: voter, vote: true) + end +end + +section "Flagging Debates & Comments" do + 40.times do + debate = Debate.all.sample + flagger = User.where(["users.id <> ?", debate.author_id]).all.sample + Flag.flag(flagger, debate) + end + + 40.times do + comment = Comment.all.sample + flagger = User.where(["users.id <> ?", comment.user_id]).all.sample + Flag.flag(flagger, comment) + end + + 40.times do + proposal = Proposal.all.sample + flagger = User.where(["users.id <> ?", proposal.author_id]).all.sample + Flag.flag(flagger, proposal) + end +end + +section "Creating Spending Proposals" do + tags = Faker::Lorem.words(10) + 60.times do + geozone = Geozone.all.sample + author = User.all.sample + description = "

    #{Faker::Lorem.paragraphs.join('

    ')}

    " + feasible_explanation = "

    #{Faker::Lorem.paragraphs.join('

    ')}

    " + valuation_finished = [true, false].sample + feasible = [true, false].sample + spending_proposal = SpendingProposal.create!(author: author, + title: Faker::Lorem.sentence(3).truncate(60), + external_url: Faker::Internet.url, + description: description, + created_at: rand((Time.current - 1.week)..Time.current), + geozone: [geozone, nil].sample, + feasible: feasible, + feasible_explanation: feasible_explanation, + valuation_finished: valuation_finished, + tag_list: tags.sample(3).join(','), + price: rand(1000000), + terms_of_service: "1") + end +end + +section "Creating Valuation Assignments" do + (1..17).to_a.sample.times do + SpendingProposal.all.sample.valuators << Valuator.first + end +end + section "Ignoring flags in Debates, comments & proposals" do Debate.flagged.reorder("RANDOM()").limit(10).each(&:ignore_flag) Comment.flagged.reorder("RANDOM()").limit(30).each(&:ignore_flag) From ffe7d4baad342734eaec3bf788874661c01fc392 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 Jan 2018 03:31:41 +0100 Subject: [PATCH 23/46] Fix rubocop issues at dev seeds --- db/dev_seeds.rb | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index eb5a350e5..aff3759ee 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -501,11 +501,12 @@ section "Creating Spending Proposals" do feasible_explanation = "

    #{Faker::Lorem.paragraphs.join('

    ')}

    " valuation_finished = [true, false].sample feasible = [true, false].sample + created_at = rand((Time.current - 1.week)..Time.current) spending_proposal = SpendingProposal.create!(author: author, title: Faker::Lorem.sentence(3).truncate(60), external_url: Faker::Internet.url, description: description, - created_at: rand((Time.current - 1.week)..Time.current), + created_at: created_at, geozone: [geozone, nil].sample, feasible: feasible, feasible_explanation: feasible_explanation, @@ -544,13 +545,16 @@ section "Creating banners" do Proposal.last(3).each do |proposal| title = Faker::Lorem.sentence(word_count = 3) description = Faker::Lorem.sentence(word_count = 12) + target_url = Rails.application.routes.url_helpers.proposal_path(proposal) banner = Banner.create!(title: title, description: description, - style: ["banner-style banner-style-one", "banner-style banner-style-two", + style: ["banner-style banner-style-one", + "banner-style banner-style-two", "banner-style banner-style-three"].sample, - image: ["banner-img banner-img-one", "banner-img banner-img-two", + image: ["banner-img banner-img-one", + "banner-img banner-img-two", "banner-img banner-img-three"].sample, - target_url: Rails.application.routes.url_helpers.proposal_path(proposal), + target_url: target_url, post_started_at: rand((Time.current - 1.week)..(Time.current - 1.day)), post_ended_at: rand((Time.current - 1.day)..(Time.current + 1.week)), created_at: rand((Time.current - 1.week)..Time.current)) @@ -605,9 +609,10 @@ section "Creating Poll Questions & Answers" do title: Faker::Lorem.sentence(3).truncate(60) + '?', poll: poll) Faker::Lorem.words((2..4).to_a.sample).each do |answer| + description = "

    #{Faker::Lorem.paragraphs.join('

    ')}

    " Poll::Question::Answer.create!(question: question, title: answer.capitalize, - description: "

    #{Faker::Lorem.paragraphs.join('

    ')}

    ") + description: description) end end end @@ -615,17 +620,20 @@ end section "Creating Poll Booths & BoothAssignments" do 20.times do |i| - Poll::Booth.create(name: "Booth #{i}", location: Faker::Address.street_address, polls: [Poll.all.sample]) + Poll::Booth.create(name: "Booth #{i}", + location: Faker::Address.street_address, + polls: [Poll.all.sample]) end end section "Creating Poll Shifts for Poll Officers" do Poll.all.each do |poll| Poll::BoothAssignment.where(poll: poll).each do |booth_assignment| + scrutiny = (poll.ends_at.to_datetime..poll.ends_at.to_datetime + Poll::RECOUNT_DURATION) Poll::Officer.all.each do |poll_officer| { vote_collection: (poll.starts_at.to_datetime..poll.ends_at.to_datetime), - recount_scrutiny: (poll.ends_at.to_datetime..poll.ends_at.to_datetime + Poll::RECOUNT_DURATION) + recount_scrutiny: scrutiny }.each do |task_name, task_dates| task_dates.each do |shift_date| Poll::Shift.create(booth: booth_assignment.booth, @@ -699,13 +707,17 @@ section "Creating Poll Voters" do def randomly_answer_questions(poll, user) poll.questions.each do |question| next unless [true, false].sample - Poll::Answer.create!(question_id: question.id, author: user, answer: question.question_answers.sample.title) + Poll::Answer.create!(question_id: question.id, + author: user, + answer: question.question_answers.sample.title) end end (Poll.expired + Poll.current + Poll.recounting).uniq.each do |poll| level_two_verified_users = User.level_two_verified - level_two_verified_users = level_two_verified_users.where(geozone_id: poll.geozone_ids) if poll.geozone_restricted? + if poll.geozone_restricted? + level_two_verified_users = level_two_verified_users.where(geozone_id: poll.geozone_ids) + end user_groups = level_two_verified_users.in_groups(2) user_groups.first.each { |user| vote_poll_on_booth(user, poll) } user_groups.second.compact.each { |user| vote_poll_on_web(user, poll) } @@ -758,7 +770,9 @@ section "Creating Poll Questions from Proposals" do poll = Poll.current.first question = Poll::Question.create(poll: poll) Faker::Lorem.words((2..4).to_a.sample).each do |answer| - Poll::Question::Answer.create!(question: question, title: answer.capitalize, description: Faker::ChuckNorris.fact) + Poll::Question::Answer.create!(question: question, + title: answer.capitalize, + description: Faker::ChuckNorris.fact) end question.copy_attributes_from_proposal(proposal) question.save! @@ -771,7 +785,9 @@ section "Creating Successful Proposals" do poll = Poll.current.first question = Poll::Question.create(poll: poll) Faker::Lorem.words((2..4).to_a.sample).each do |answer| - Poll::Question::Answer.create!(question: question, title: answer.capitalize, description: Faker::ChuckNorris.fact) + Poll::Question::Answer.create!(question: question, + title: answer.capitalize, + description: Faker::ChuckNorris.fact) end question.copy_attributes_from_proposal(proposal) question.save! From b3e7f8a78f111f702735b807ddc894e99298bbcc Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 Jan 2018 12:09:18 +0100 Subject: [PATCH 24/46] Remove no longer neccesary feature flags from valuation feature spec --- spec/features/valuation_spec.rb | 168 +++++++++++++++----------------- 1 file changed, 80 insertions(+), 88 deletions(-) diff --git a/spec/features/valuation_spec.rb b/spec/features/valuation_spec.rb index 1cb95d23d..3ae2558a5 100644 --- a/spec/features/valuation_spec.rb +++ b/spec/features/valuation_spec.rb @@ -3,96 +3,88 @@ require 'rails_helper' feature 'Valuation' do let(:user) { create(:user) } - background do - Setting['feature.spending_proposals'] = true - Setting['feature.spending_proposal_features.voting_allowed'] = true + context 'Access' do + scenario 'Access as regular user is not authorized' do + login_as(user) + visit root_path + + expect(page).not_to have_link("Valuation") + visit valuation_root_path + + expect(page).not_to have_current_path(valuation_root_path) + expect(page).to have_current_path(root_path) + expect(page).to have_content "You do not have permission to access this page" + end + + scenario 'Access as moderator is not authorized' do + create(:moderator, user: user) + login_as(user) + visit root_path + + expect(page).not_to have_link("Valuation") + visit valuation_root_path + + expect(page).not_to have_current_path(valuation_root_path) + expect(page).to have_current_path(root_path) + expect(page).to have_content "You do not have permission to access this page" + end + + scenario 'Access as manager is not authorized' do + create(:manager, user: user) + login_as(user) + visit root_path + + expect(page).not_to have_link("Valuation") + visit valuation_root_path + + expect(page).not_to have_current_path(valuation_root_path) + expect(page).to have_current_path(root_path) + expect(page).to have_content "You do not have permission to access this page" + end + + scenario 'Access as poll officer is not authorized' do + create(:poll_officer, user: user) + login_as(user) + visit root_path + + expect(page).not_to have_link("Valuation") + visit valuation_root_path + + expect(page).not_to have_current_path(valuation_root_path) + expect(page).to have_current_path(root_path) + expect(page).to have_content "You do not have permission to access this page" + end + + scenario 'Access as a valuator is authorized' do + create(:valuator, user: user) + create(:budget) + + login_as(user) + visit root_path + + expect(page).to have_link("Valuation") + click_on "Valuation" + + expect(page).to have_current_path(valuation_root_path) + expect(page).not_to have_content "You do not have permission to access this page" + end + + scenario 'Access as an administrator is authorized' do + create(:administrator, user: user) + create(:budget) + + login_as(user) + visit root_path + + expect(page).to have_link("Valuation") + click_on "Valuation" + + expect(page).to have_current_path(valuation_root_path) + expect(page).not_to have_content "You do not have permission to access this page" + end end - after do - Setting['feature.spending_proposals'] = nil - Setting['feature.spending_proposal_features.voting_allowed'] = nil - end - - scenario 'Access as regular user is not authorized' do - login_as(user) - visit root_path - - expect(page).not_to have_link("Valuation") - visit valuation_root_path - - expect(page).not_to have_current_path(valuation_root_path) - expect(page).to have_current_path(root_path) - expect(page).to have_content "You do not have permission to access this page" - end - - scenario 'Access as moderator is not authorized' do - create(:moderator, user: user) - login_as(user) - visit root_path - - expect(page).not_to have_link("Valuation") - visit valuation_root_path - - expect(page).not_to have_current_path(valuation_root_path) - expect(page).to have_current_path(root_path) - expect(page).to have_content "You do not have permission to access this page" - end - - scenario 'Access as manager is not authorized' do - create(:manager, user: user) - login_as(user) - visit root_path - - expect(page).not_to have_link("Valuation") - visit valuation_root_path - - expect(page).not_to have_current_path(valuation_root_path) - expect(page).to have_current_path(root_path) - expect(page).to have_content "You do not have permission to access this page" - end - - scenario 'Access as poll officer is not authorized' do - create(:poll_officer, user: user) - login_as(user) - visit root_path - - expect(page).not_to have_link("Valuation") - visit valuation_root_path - - expect(page).not_to have_current_path(valuation_root_path) - expect(page).to have_current_path(root_path) - expect(page).to have_content "You do not have permission to access this page" - end - - scenario 'Access as a valuator is authorized' do - create(:valuator, user: user) - create(:budget) - - login_as(user) - visit root_path - - expect(page).to have_link("Valuation") - click_on "Valuation" - - expect(page).to have_current_path(valuation_root_path) - expect(page).not_to have_content "You do not have permission to access this page" - end - - scenario 'Access as an administrator is authorized' do - create(:administrator, user: user) - create(:budget) - - login_as(user) - visit root_path - - expect(page).to have_link("Valuation") - click_on "Valuation" - - expect(page).to have_current_path(valuation_root_path) - expect(page).not_to have_content "You do not have permission to access this page" - end - - scenario "Valuation access links" do + scenario 'Valuation access links' do create(:valuator, user: user) create(:budget) From 345d513342daed549894eb717e42cd50cb9aea39 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 Jan 2018 12:13:01 +0100 Subject: [PATCH 25/46] Remove unnecesary feature flag setting at spec --- spec/features/valuation/budget_investments_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb index 33ab47b8e..91bf20985 100644 --- a/spec/features/valuation/budget_investments_spec.rb +++ b/spec/features/valuation/budget_investments_spec.rb @@ -16,7 +16,6 @@ feature 'Valuation budget investments' do end scenario 'Display link to valuation section' do - Setting['feature.budgets'] = true visit root_path expect(page).to have_link "Valuation", href: valuation_root_path end From e5ce55b1cd440fab79baf15a67c4546bc77c06ed Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 29 Jan 2018 20:51:21 +0100 Subject: [PATCH 26/46] Hide order selectors when only one order available --- app/views/shared/_order_selector.html.erb | 30 +++++++------ .../shared/_wide_order_selector.html.erb | 45 ++++++++++--------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/app/views/shared/_order_selector.html.erb b/app/views/shared/_order_selector.html.erb index e36123293..4caa83b3c 100644 --- a/app/views/shared/_order_selector.html.erb +++ b/app/views/shared/_order_selector.html.erb @@ -1,14 +1,16 @@ -
    - - -
    +<% if @valid_orders.present? && @valid_orders.count > 1 %> +
    + + +
    +<% end %> diff --git a/app/views/shared/_wide_order_selector.html.erb b/app/views/shared/_wide_order_selector.html.erb index 0fda8b0b5..d5b1405eb 100644 --- a/app/views/shared/_wide_order_selector.html.erb +++ b/app/views/shared/_wide_order_selector.html.erb @@ -2,25 +2,26 @@ # # i18n_namespace: for example "moderation.debates.index" %> - -
    -
    -
    - -
    -
    - -
    -
    -
    +<% if @valid_orders.present? && @valid_orders.count > 1 %> +
    +
    +
    + +
    +
    + +
    +
    +
    +<% end %> From 213152349bc11d7b087ba6181e317ce9fa91a0cd Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 30 Jan 2018 18:10:42 +0100 Subject: [PATCH 27/46] Changes more info link to help --- app/views/shared/_subnavigation.html.erb | 4 ++-- app/views/welcome/index.html.erb | 2 +- config/locales/en/activerecord.yml | 2 +- config/locales/en/general.yml | 3 ++- config/locales/es/activerecord.yml | 2 +- config/locales/es/general.yml | 3 ++- 6 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/views/shared/_subnavigation.html.erb b/app/views/shared/_subnavigation.html.erb index ffa188709..aebbe1d13 100644 --- a/app/views/shared/_subnavigation.html.erb +++ b/app/views/shared/_subnavigation.html.erb @@ -53,11 +53,11 @@
  • <% end %>
  • - <%= link_to t("layouts.header.more_info"), + <%= link_to t("layouts.header.help"), more_info_path, accesskey: "5", class: ("active" if current_page?(more_info_path)), - title: t("shared.go_to_page") + t("layouts.header.more_info") %> + title: t("shared.go_to_page") + t("layouts.header.help") %>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index de64d9cd8..70919b235 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -17,7 +17,7 @@ <%= t("layouts.header.open_city_slogan_html") %>

- <%= link_to t("layouts.header.more_info"), more_info_path, class: "button expanded large" %> + <%= link_to t("shared.more_info"), more_info_path, class: "button expanded large" %>
diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml index 81b25dcad..d231eb2d0 100644 --- a/config/locales/en/activerecord.yml +++ b/config/locales/en/activerecord.yml @@ -187,7 +187,7 @@ en: status: Status title: Title updated_at: Updated at - more_info_flag: Show in more information page + more_info_flag: Show in help page print_content_flag: Print content button locale: Language site_customization/image: diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 205db683c..c3960a3df 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -231,7 +231,7 @@ en: moderation: Moderation valuation: Valuation officing: Polling officers - more_info: More information + help: Help my_account_link: My account my_activity_link: My activity notifications: Notifications @@ -623,6 +623,7 @@ en: previous_slide: Previous Slide next_slide: Next Slide documentation: Additional documentation + more_info: More information social: blog: "%{org} Blog" facebook: "%{org} Facebook" diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml index b604224cf..f891ed3fc 100644 --- a/config/locales/es/activerecord.yml +++ b/config/locales/es/activerecord.yml @@ -183,7 +183,7 @@ es: status: Estado title: Título updated_at: última actualización - more_info_flag: Mostrar en la página de más información + more_info_flag: Mostrar en la página de ayuda print_content_flag: Botón de imprimir contenido locale: Idioma site_customization/image: diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 7ac16c170..3200f4be0 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -231,7 +231,7 @@ es: moderation: Moderar valuation: Evaluación officing: Presidentes de mesa - more_info: Más información + help: Ayuda my_account_link: Mi cuenta my_activity_link: Mi actividad notifications: Notificaciones @@ -622,6 +622,7 @@ es: previous_slide: Imagen anterior next_slide: Siguiente imagen documentation: Documentación adicional + more_info: Más información social: blog: "Blog de %{org}" facebook: "Facebook de %{org}" From 735630cff06ac7553d4cddeea89c49ee2cdfd255 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 30 Jan 2018 18:11:13 +0100 Subject: [PATCH 28/46] Updates text of intro section of more info page --- app/views/pages/more_info/index.html.erb | 10 +++++----- config/locales/en/pages.yml | 8 ++++---- config/locales/es/pages.yml | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/app/views/pages/more_info/index.html.erb b/app/views/pages/more_info/index.html.erb index 79cbd77b5..7bb05d1f6 100644 --- a/app/views/pages/more_info/index.html.erb +++ b/app/views/pages/more_info/index.html.erb @@ -1,14 +1,14 @@ -<% provide :title do %><%= t("pages.titles.more_info", org_name: setting['org_name']) %><% end %> +<% provide :title do %><%= t("pages.titles.more_info", org: setting['org_name']) %><% end %> <% content_for :canonical do %> <%= render "shared/canonical", href: more_info_url %> <% end %>
-
-

<%= t("pages.more_info.title", org_name: setting['org_name']) %>

-

<%= t("pages.more_info.subtitle") %>

-

<%= t("pages.more_info.guide", org_name: setting['org_name']) %>

+
+

<%= t("pages.more_info.title", org: setting['org_name']) %>

+

<%= t("pages.more_info.subtitle", org: setting['org_name']) %>

+

<%= t("pages.more_info.guide", org: setting['org_name']) %>

diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index c0b8f3a0b..80230e248 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -4,9 +4,9 @@ en: conditions: Terms and conditions of use general_terms: Terms and Conditions more_info: - title: "Discover %{org_name}" - subtitle: "Learn everything you can do on this website." - guide: 'This guide explains each section of %{org_name}. You can expand the information on "Detailed information" links.' + title: "%{org} is a platform for citizen participation" + subtitle: "In %{org} you can make proposals, vote in citizen consultations, propose participatory budget projects, decide on municipal regulations and open debates to exchange opinions with others." + guide: "This guide explains what each of the %{org} sections are for and how they work." menu: debates: "Debates" proposals: "Proposals" @@ -71,7 +71,7 @@ en: titles: accessibility: Accessibility conditions: Terms of use - more_info: "More information about %{org_name}" + more_info: "What is %{org}? - Citizen participation" privacy: Privacy Policy verify: code: Code you received in letter diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index 0f0fe12d4..b53d113cd 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -4,9 +4,9 @@ es: conditions: Condiciones de uso general_terms: Términos y Condiciones more_info: - title: "Descubre %{org_name}" - subtitle: "Aprende todo lo que puedes hacer en esta web." - guide: 'Esta guía explica cada una de las secciones de %{org_name}. Puedes ampliar la información en los enlaces de "Información detallada".' + title: "%{org} es una plataforma de participación ciudadana" + subtitle: "En %{org} se pueden hacer propuestas, votar en consultas ciudadanas, plantear proyectos de presupuestos participativos, decidir la normativa municipal y abrir debates para intercambiar opiniones con otras personas." + guide: 'Esta guía explica para qué sirven y cómo funcionan cada una de las secciones de %{org}.' menu: debates: "Debates" proposals: "Propuestas" @@ -71,7 +71,7 @@ es: titles: accessibility: Accesibilidad conditions: Condiciones de uso - more_info: "Más información sobre %{org_name}" + more_info: "¿Qué es %{org}? - Participación ciudadana" privacy: Política de Privacidad verify: code: Código que has recibido en tu carta From 59a02301c24ab4742b9d9f3f2424751c86e6c7d7 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 30 Jan 2018 18:11:50 +0100 Subject: [PATCH 29/46] Updates text of debates section of more info page --- app/views/pages/more_info/_debates.html.erb | 12 ++++++++---- config/locales/en/pages.yml | 8 ++++---- config/locales/es/pages.yml | 8 ++++---- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/views/pages/more_info/_debates.html.erb b/app/views/pages/more_info/_debates.html.erb index a8e76ba91..d8f3fdedd 100644 --- a/app/views/pages/more_info/_debates.html.erb +++ b/app/views/pages/more_info/_debates.html.erb @@ -3,14 +3,18 @@

<%= t("pages.more_info.debates.title") %>

-

<%= t("pages.more_info.debates.description") %>

+

+ <%= t("pages.more_info.debates.description", + org: setting['org_name'], + link: link_to(t("pages.more_info.debates.link"), + debates_path)).html_safe %> +

  • - <%= t("pages.more_info.debates.feature_1", - link: link_to(t("pages.more_info.debates.feature_1_link", org_name: setting['org_name']), + <%= t("pages.more_info.debates.feature_html", + link: link_to(t("pages.more_info.debates.feature_link", org: setting['org_name']), new_user_registration_path)).html_safe %>
  • -
  • <%= t("pages.more_info.debates.feature_2_html") %>
diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index 80230e248..fb02b1a43 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -14,10 +14,10 @@ en: other: "Other information of interest" debates: title: "Debates" - description: "Create a thread where you can discuss any topic you want to share with other people in your city." - feature_1: "To create a debate you have to %{link}" - feature_1_link: "sign up on %{org_name}" - feature_2_html: "Debates can be rated using the I agree or I disagree buttons you'll find on each of them." + description: "In the %{link} section you can present and share your opinion with other people on issues of concern to you related to the city. It is also a place to generate ideas that through the other sections of %{org} lead to concrete actions by the City Council." + link: "citizen debates" + feature_html: "You can open debates, comment and evaluate them with the I agree or I don't agree. For that you have to %{link}." + feature_link: "register in %{org}" image_alt: "Buttons to rate the debates" figcaption: '"I agree" and "I disagree" buttons to rate the debates.' proposals: diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index b53d113cd..bff35522b 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -14,10 +14,10 @@ es: other: "Otra información de interés" debates: title: "Debates" - description: "Crea un hilo en el que debatir sobre cualquier tema que quieras compartir con el resto de gente de tu ciudad." - feature_1: "Para crear un debate tienes que %{link}" - feature_1_link: "registrarte en %{org_name}" - feature_2_html: "Los debates pueden ser valorados utilizando los botones de Estoy de acuerdo o No estoy de acuerdo que encontrarás en cada uno de ellos." + description: "En la sección de %{link} puedes exponer y compartir tu opinión con otras personas sobre temas que te preocupan relacionados con la ciudad. También es un espacio donde generar ideas que a través de las otras secciones de %{org} lleven a actuaciones concretas por parte del Ayuntamiento." + link: "debates ciudadanos" + feature_html: "Puedes abrir debates, comentarlos y valorarlos con los botones de Estoy de acuerdo o No estoy de acuerdo. Para ello tienes que %{link}." + feature_link: "registrarte en %{org}" image_alt: "Botones para valorar los debates" figcaption: 'Botones "Estoy de acuerdo" y "No estoy de acuerdo" para valorar los debates.' proposals: From fffc769c90eac1fd5f8add048940f2103cbb4a23 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 30 Jan 2018 18:12:21 +0100 Subject: [PATCH 30/46] Updates text of proposals section of more info page --- app/views/pages/more_info/_proposals.html.erb | 13 +++++++------ config/locales/en/pages.yml | 8 +++----- config/locales/es/pages.yml | 8 +++----- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/views/pages/more_info/_proposals.html.erb b/app/views/pages/more_info/_proposals.html.erb index cf1822142..c9f10f92e 100644 --- a/app/views/pages/more_info/_proposals.html.erb +++ b/app/views/pages/more_info/_proposals.html.erb @@ -3,15 +3,16 @@

<%= t("pages.more_info.proposals.title") %>

-

<%= t("pages.more_info.proposals.description") %>

+

+ <%= t("pages.more_info.proposals.description", + link: link_to(t("pages.more_info.proposals.link"), proposals_path)).html_safe %> +

  • - <%= t("pages.more_info.proposals.feature_1", - link: link_to(t("pages.more_info.proposals.feature_1_link", org_name: setting['org_name']), - new_user_registration_path)).html_safe %> + <%= t("pages.more_info.proposals.feature_html", + org: setting['org_name'], + supports: setting['votes_for_proposal_success']).html_safe %>
  • -
  • <%= t("pages.more_info.proposals.feature_2_html") %>
  • -
  • <%= t("pages.more_info.proposals.feature_3_html") %>
diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index fb02b1a43..eb2636e99 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -22,11 +22,9 @@ en: figcaption: '"I agree" and "I disagree" buttons to rate the debates.' proposals: title: "Proposals" - description: "Propose what you want the City Council to do and support proposals from other people." - feature_1: "To create a proposal you have to %{link}, in addition to support you must verify your account." - feature_1_link: "sign up on %{org_name}" - feature_2_html: "Proposals that get support from 1% of people will be voted on." - feature_3_html: "If there are more people in favor than against, the City Council will publish their plan to accomplish the proposal and you can track its progress." + description: "In the %{link} section you can make proposals for the City Council to carry them out. The proposals require support, and if they reach sufficient support, they are put to a public vote. The proposals approved in these citizens' votes are accepted by the City Council and carried out." + link: "citizen proposals" + feature_html: "To create a proposal you must register in %{org}. The proposals that get the support on the website of 1% of people with the right to vote (%{supports} supports of people over 16 years old registered) go to vote. To support proposals it is necessary to verify your account." image_alt: "Button to support a proposal" figcaption_html: 'Button to "Support" a proposal.
When it reaches the number of supports will go to vote.' budgets: diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index bff35522b..2751652dc 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -22,11 +22,9 @@ es: figcaption: 'Botones "Estoy de acuerdo" y "No estoy de acuerdo" para valorar los debates.' proposals: title: "Propuestas" - description: "Propón lo que quieres que el Ayuntamiento lleve a cabo y apoya propuestas de otras personas." - feature_1: "Para crear una propuesta tienes que %{link}, además para apoyarlas debes verificar tu cuenta." - feature_1_link: "registrarte en %{org_name}" - feature_2_html: "Las propuestas que consigan el apoyo del 1% de la gente (mayor de 16 años empadronada; %{supports} apoyos) pasan a votación." - feature_3_html: "Si hay más gente a favor que en contra en la votación, el Ayuntamiento asume la propuesta y se hace." + description: "En la sección de %{link} puedes plantear propuestas para que el Ayuntamiento las lleve a cabo. Las propuestas recaban apoyos, y si alcanzan los apoyos suficientes se someten a votación ciudadana. Las propuestas aprobadas en estas votaciones ciudadanas son asumidas por el Ayuntamiento y se llevan a cabo." + link: "propuestas ciudadanas" + feature_html: "Para crear una propuesta hay que registrarse en %{org}. Las propuestas que consiguen el apoyo en la web del 1% de la gente con derecho a voto (%{supports} apoyos de personas mayores de 16 años empadronadas) pasan a votación. Para apoyar propuestas es necesario verificar tu cuenta." image_alt: "Botón para apoyar una propuesta" figcaption_html: 'Botón para "Apoyar" una propuesta.
Cuando alcance el número de apoyos pasará a votación.' budgets: From 037a3af5a618384eec2c8b53132018e791cb3d4b Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 30 Jan 2018 18:12:48 +0100 Subject: [PATCH 31/46] Updates text of budgets section of more info page --- app/views/pages/more_info/_budgets.html.erb | 19 ++++++++++++------- config/locales/en/pages.yml | 14 ++++++++------ config/locales/es/pages.yml | 14 ++++++++------ 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/app/views/pages/more_info/_budgets.html.erb b/app/views/pages/more_info/_budgets.html.erb index 6450bdffe..781463521 100644 --- a/app/views/pages/more_info/_budgets.html.erb +++ b/app/views/pages/more_info/_budgets.html.erb @@ -3,18 +3,23 @@

<%= t("pages.more_info.budgets.title") %>

-

<%= t("pages.more_info.budgets.description") %>

+

+ <%= t("pages.more_info.budgets.description", + link: link_to(t("pages.more_info.budgets.link"), budgets_path)).html_safe %> +

  • - <%= t("pages.more_info.budgets.feature_1", - link: link_to(t("pages.more_info.budgets.feature_1_link", org_name: setting['org_name']), - new_user_registration_path)).html_safe %> + <%= t("pages.more_info.budgets.feature") %>
  • -
  • <%= t("pages.more_info.budgets.feature_2_html") %>
  • -
  • <%= t("pages.more_info.budgets.feature_3_html") %>
  • -
  • <%= t("pages.more_info.budgets.feature_4_html") %>
  • +
  • <%= t("pages.more_info.budgets.phase_1_html", + org: setting['org_name']).html_safe %>
  • +
  • <%= t("pages.more_info.budgets.phase_2_html") %>
  • +
  • <%= t("pages.more_info.budgets.phase_3_html") %>
  • +
  • <%= t("pages.more_info.budgets.phase_4_html") %>
+

<%= t("pages.more_info.budgets.phase_5_html") %>

+
<%= image_tag "more_info/budgets_#{I18n.locale}.png", alt: t("pages.more_info.budgets.image_alt") %>
<%= t("pages.more_info.budgets.figcaption_html") %>
diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index eb2636e99..63905412f 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -29,12 +29,14 @@ en: figcaption_html: 'Button to "Support" a proposal.
When it reaches the number of supports will go to vote.' budgets: title: "Participatory Budgeting" - description: "The first six months of each year you can decide how to spend part of the budget." - feature_1: "To submit an investment project you have to %{link} and verify your account." - feature_1_link: "sign up on %{org_name}" - feature_2_html: "The first is the submit phase of investment projects." - feature_3_html: "Then there is a support phase to prioritize the most interesting, the most supported are evaluated by the City to see if they are viable and how much they are worth." - feature_4_html: "At the end there is a vote phase and you decide which of the approved projects to spend the budget on." + description: "The %{link} section helps people make a direct decision on what part of the municipal budget is spent on." + link: "participative budgets" + feature: "In this process, every year people raise, support and vote on projects. The most voted votes are financed by the municipal budget." + phase_1_html: "Between January and early March, people registered in %{org} can present." + phase_2_html: "In March, proposers have to gather support, in the form of preselection." + phase_3_html: "Between April and the beginning of May, the experts from the City Council rate projects on an order of more or less supported and check that they are viable." + phase_4_html: "Finally, between May and June, all citizens can vote projects that interest them the most." + phase_5_html: "From the approval of the budgets the following year the City Council begins to carry out the winning projects." image_alt: "Different phases of a participatory budget" figcaption_html: '"Support" and "Voting" phases of participatory budgets.' polls: diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index 2751652dc..3510cfe1a 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -29,12 +29,14 @@ es: figcaption_html: 'Botón para "Apoyar" una propuesta.
Cuando alcance el número de apoyos pasará a votación.' budgets: title: "Presupuestos participativos" - description: "Los primeros seis meses de cada año puedes decidir cómo gastar parte del presupuesto." - feature_1: "Para crear un proyecto de gasto tienes que %{link} y verificar tu cuenta." - feature_1_link: "registrarte en %{org_name}" - feature_2_html: "En primer lugar empieza la fase de aceptación de proyectos de gasto." - feature_3_html: "Después hay una fase de apoyos para priorizar lo más interesante, las más apoyadas son evaluadas por el Ayuntamiento para ver si son viables y cuánto valen." - feature_4_html: "Al final hay una fase de votación donde se decide en cuáles se gasta esa parte del presupuesto." + description: "La sección de %{link} sirve para que la gente decida de manera directa a qué se destina una parte del presupuesto municipal." + link: "presupuestos participativos" + feature: "En este proceso cada año la gente plantea, apoya y vota proyectos. Los más votados pasan a financiarse con el presupuesto municipal." + phase_1_html: "Entre enero y principios de marzo, las personas registradas en %{org} pueden presentar proyectos." + phase_2_html: "En marzo, los proponentes tienen que recabar apoyos, a modo de fase de preselección." + phase_3_html: "Entre abril y comienzos de mayo los técnicos del Ayuntamiento tasan los proyectos por orden de más a menos apoyados y comprueban que son viables." + phase_4_html: "Finalmente, entre mayo y junio, toda la ciudadanía puede votar los proyectos que más le interesan." + phase_5_html: "A partir de la aprobación de los presupuestos al año siguiente el Ayuntamiento empieza a llevar a cabo los proyectos ganadores." image_alt: "Diferentes fases de un presupuesto participativo" figcaption_html: 'Fase de "Apoyos" y fase de "Votación" de los presupuestos participativos.' polls: From a958a75bb184a96d382cee60c5e4c18f5634ea59 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 30 Jan 2018 18:13:24 +0100 Subject: [PATCH 32/46] Updates text of polls section of more info page --- app/views/pages/more_info/_polls.html.erb | 5 ++++- config/locales/en/pages.yml | 11 ++++++----- config/locales/es/pages.yml | 7 ++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/app/views/pages/more_info/_polls.html.erb b/app/views/pages/more_info/_polls.html.erb index 360558d99..16a5c08bd 100644 --- a/app/views/pages/more_info/_polls.html.erb +++ b/app/views/pages/more_info/_polls.html.erb @@ -1,7 +1,10 @@

<%= t("pages.more_info.polls.title") %>

-

<%= t("pages.more_info.polls.description") %>

+

+ <%= t("pages.more_info.polls.description", + link: link_to(t("pages.more_info.polls.link"), polls_path)).html_safe %> +

  • <%= t("pages.more_info.polls.feature_1", diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index 63905412f..38f6ed25d 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -41,11 +41,12 @@ en: figcaption_html: '"Support" and "Voting" phases of participatory budgets.' polls: title: "Polls" - description: "Citizen proposals that reach 1% of support will be put to a vote." - feature_1: "To participate in the next poll you have to %{link} and verify your account." - feature_1_link: "sign up on %{org_name}" - feature_2: "All verified users over 16 years old can vote." - feature_3: "The results of all votes shall be binding on the government." + description: "The %{link} section is activated each time a proposal reaches 1% support and goes to the vote or when the City Council proposes an issue for people to decide on." + link: "polls" + feature_1: "To participate in the voting you have to %{link} and verify your account." + feature_1_link: "register in %{org_name}" + feature_2: "All registered voters over the age of 16 can vote." + feature_3: "The results of all votes are binding on the municipal government." faq: title: "Technical problems?" description: "Read the FAQs and solve your questions." diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index 3510cfe1a..4ea5a44a9 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -41,11 +41,12 @@ es: figcaption_html: 'Fase de "Apoyos" y fase de "Votación" de los presupuestos participativos.' polls: title: "Votaciones" - description: "Las propuestas ciudadanas que alcancen el 1% de apoyos pasarán a votación." - feature_1: "Para participar en la próxima votación tienes que %{link} y verificar tu cuenta." + description: "La sección de %{link} se activa cada vez que una propuesta alcanza el 1% de apoyos y pasa a votación o cuando el Ayuntamiento propone un tema para que la gente decida sobre él." + link: "votaciones ciudadanas" + feature_1: "Para participar en las votaciones tienes que %{link} y verificar tu cuenta." feature_1_link: "registrarte en %{org_name}" feature_2: "Pueden votar todas las personas empadronadas en la ciudad mayores de 16 años." - feature_3: "Los resultados de todas las votaciones serán vinculantes para el gobierno." + feature_3: "Los resultados de todas las votaciones son vinculantes para el gobierno municipal." faq: title: "¿Problemas técnicos?" description: "Lee las preguntas frecuentes y resuelve tus dudas." From 286371c9d911f0859f3203a2a3a7245381a0c019 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 30 Jan 2018 18:26:30 +0100 Subject: [PATCH 33/46] Changes more_info folder and path to help --- app/views/debates/new.html.erb | 2 +- app/views/legislation/proposals/new.html.erb | 2 +- app/views/pages/{more_info => help}/_budgets.html.erb | 0 app/views/pages/{more_info => help}/_debates.html.erb | 0 app/views/pages/{more_info => help}/_menu.html.erb | 0 app/views/pages/{more_info => help}/_other.html.erb | 0 app/views/pages/{more_info => help}/_polls.html.erb | 0 app/views/pages/{more_info => help}/_proposals.html.erb | 0 app/views/pages/{more_info => help}/_sidebar.html.erb | 0 app/views/pages/{more_info => help}/faq/index.html.erb | 0 .../pages/{more_info => help}/how_to_use/index.html.erb | 0 app/views/pages/{more_info => help}/index.html.erb | 0 app/views/proposals/new.html.erb | 2 +- app/views/shared/_subnavigation.html.erb | 4 ++-- app/views/welcome/index.html.erb | 2 +- config/routes.rb | 6 +++--- config/sitemap.rb | 2 +- spec/features/site_customization/custom_pages_spec.rb | 6 +++--- spec/lib/tasks/sitemap_spec.rb | 2 +- 19 files changed, 14 insertions(+), 14 deletions(-) rename app/views/pages/{more_info => help}/_budgets.html.erb (100%) rename app/views/pages/{more_info => help}/_debates.html.erb (100%) rename app/views/pages/{more_info => help}/_menu.html.erb (100%) rename app/views/pages/{more_info => help}/_other.html.erb (100%) rename app/views/pages/{more_info => help}/_polls.html.erb (100%) rename app/views/pages/{more_info => help}/_proposals.html.erb (100%) rename app/views/pages/{more_info => help}/_sidebar.html.erb (100%) rename app/views/pages/{more_info => help}/faq/index.html.erb (100%) rename app/views/pages/{more_info => help}/how_to_use/index.html.erb (100%) rename app/views/pages/{more_info => help}/index.html.erb (100%) diff --git a/app/views/debates/new.html.erb b/app/views/debates/new.html.erb index 5085ca17a..97990048d 100644 --- a/app/views/debates/new.html.erb +++ b/app/views/debates/new.html.erb @@ -7,7 +7,7 @@
    <%= t("debates.new.info", info_link: link_to(t("debates.new.info_link"), new_proposal_path )).html_safe %> - <%= link_to more_info_path, title: t('shared.target_blank_html'), target: "_blank" do %> + <%= link_to help_path, title: t('shared.target_blank_html'), target: "_blank" do %> <%= t("debates.new.more_info") %> <% end %>
    diff --git a/app/views/legislation/proposals/new.html.erb b/app/views/legislation/proposals/new.html.erb index f6f31bff5..72051825e 100644 --- a/app/views/legislation/proposals/new.html.erb +++ b/app/views/legislation/proposals/new.html.erb @@ -5,7 +5,7 @@

    <%= t("proposals.new.start_new") %>

    - <%= link_to more_info_path(anchor: "proposals") ,title: t('shared.target_blank_html'), target: "_blank" do %> + <%= link_to help_path(anchor: "proposals") ,title: t('shared.target_blank_html'), target: "_blank" do %> <%= t("proposals.new.more_info")%> <% end %>
    diff --git a/app/views/pages/more_info/_budgets.html.erb b/app/views/pages/help/_budgets.html.erb similarity index 100% rename from app/views/pages/more_info/_budgets.html.erb rename to app/views/pages/help/_budgets.html.erb diff --git a/app/views/pages/more_info/_debates.html.erb b/app/views/pages/help/_debates.html.erb similarity index 100% rename from app/views/pages/more_info/_debates.html.erb rename to app/views/pages/help/_debates.html.erb diff --git a/app/views/pages/more_info/_menu.html.erb b/app/views/pages/help/_menu.html.erb similarity index 100% rename from app/views/pages/more_info/_menu.html.erb rename to app/views/pages/help/_menu.html.erb diff --git a/app/views/pages/more_info/_other.html.erb b/app/views/pages/help/_other.html.erb similarity index 100% rename from app/views/pages/more_info/_other.html.erb rename to app/views/pages/help/_other.html.erb diff --git a/app/views/pages/more_info/_polls.html.erb b/app/views/pages/help/_polls.html.erb similarity index 100% rename from app/views/pages/more_info/_polls.html.erb rename to app/views/pages/help/_polls.html.erb diff --git a/app/views/pages/more_info/_proposals.html.erb b/app/views/pages/help/_proposals.html.erb similarity index 100% rename from app/views/pages/more_info/_proposals.html.erb rename to app/views/pages/help/_proposals.html.erb diff --git a/app/views/pages/more_info/_sidebar.html.erb b/app/views/pages/help/_sidebar.html.erb similarity index 100% rename from app/views/pages/more_info/_sidebar.html.erb rename to app/views/pages/help/_sidebar.html.erb diff --git a/app/views/pages/more_info/faq/index.html.erb b/app/views/pages/help/faq/index.html.erb similarity index 100% rename from app/views/pages/more_info/faq/index.html.erb rename to app/views/pages/help/faq/index.html.erb diff --git a/app/views/pages/more_info/how_to_use/index.html.erb b/app/views/pages/help/how_to_use/index.html.erb similarity index 100% rename from app/views/pages/more_info/how_to_use/index.html.erb rename to app/views/pages/help/how_to_use/index.html.erb diff --git a/app/views/pages/more_info/index.html.erb b/app/views/pages/help/index.html.erb similarity index 100% rename from app/views/pages/more_info/index.html.erb rename to app/views/pages/help/index.html.erb diff --git a/app/views/proposals/new.html.erb b/app/views/proposals/new.html.erb index 95249e36e..df48c7754 100644 --- a/app/views/proposals/new.html.erb +++ b/app/views/proposals/new.html.erb @@ -5,7 +5,7 @@

    <%= t("proposals.new.start_new") %>

    - <%= link_to more_info_path(anchor: "proposals") ,title: t('shared.target_blank_html'), target: "_blank" do %> + <%= link_to help_path(anchor: "proposals") ,title: t('shared.target_blank_html'), target: "_blank" do %> <%= t("proposals.new.more_info")%> <% end %>
    diff --git a/app/views/shared/_subnavigation.html.erb b/app/views/shared/_subnavigation.html.erb index aebbe1d13..4c9b79580 100644 --- a/app/views/shared/_subnavigation.html.erb +++ b/app/views/shared/_subnavigation.html.erb @@ -54,9 +54,9 @@ <% end %>
  • <%= link_to t("layouts.header.help"), - more_info_path, + help_path, accesskey: "5", - class: ("active" if current_page?(more_info_path)), + class: ("active" if current_page?(help_path)), title: t("shared.go_to_page") + t("layouts.header.help") %>
diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 70919b235..7a55aa263 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -17,7 +17,7 @@ <%= t("layouts.header.open_city_slogan_html") %>

- <%= link_to t("shared.more_info"), more_info_path, class: "button expanded large" %> + <%= link_to t("shared.more_info"), help_path, class: "button expanded large" %>
diff --git a/config/routes.rb b/config/routes.rb index 73d1443d2..f3739c922 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,9 +42,9 @@ Rails.application.routes.draw do resources :follows, only: [:create, :destroy] # More info pages - get 'more-information', to: 'pages#show', id: 'more_info/index', as: 'more_info' - get 'more-information/how-to-use', to: 'pages#show', id: 'more_info/how_to_use/index', as: 'how_to_use' - get 'more-information/faq', to: 'pages#show', id: 'more_info/faq/index', as: 'faq' + get 'help', to: 'pages#show', id: 'help/index', as: 'help' + get 'help/how-to-use', to: 'pages#show', id: 'help/how_to_use/index', as: 'how_to_use' + get 'help/faq', to: 'pages#show', id: 'help/faq/index', as: 'faq' # Static pages get '/blog' => redirect("http://blog.consul/") diff --git a/config/sitemap.rb b/config/sitemap.rb index e60cee617..0846ecc91 100644 --- a/config/sitemap.rb +++ b/config/sitemap.rb @@ -14,7 +14,7 @@ SitemapGenerator::Sitemap.create do add page_path(id: page) end - add more_info_path + add help_path add how_to_use_path add faq_path diff --git a/spec/features/site_customization/custom_pages_spec.rb b/spec/features/site_customization/custom_pages_spec.rb index 38c2536e1..09ad797dc 100644 --- a/spec/features/site_customization/custom_pages_spec.rb +++ b/spec/features/site_customization/custom_pages_spec.rb @@ -80,7 +80,7 @@ feature "Custom Pages" do locale: "en" ) - visit more_info_path + visit help_path expect(page).to have_content("Another custom page") end @@ -93,7 +93,7 @@ feature "Custom Pages" do locale: "en" ) - visit more_info_path + visit help_path expect(page).not_to have_content("Another custom page") @@ -112,7 +112,7 @@ feature "Custom Pages" do locale: "fr" ) - visit more_info_path + visit help_path expect(page).not_to have_content("Ce texte est en français") diff --git a/spec/lib/tasks/sitemap_spec.rb b/spec/lib/tasks/sitemap_spec.rb index b68413ad6..01dd3f430 100644 --- a/spec/lib/tasks/sitemap_spec.rb +++ b/spec/lib/tasks/sitemap_spec.rb @@ -30,7 +30,7 @@ feature 'rake sitemap:create' do # Static pages expect(sitemap).to include(faq_path) - expect(sitemap).to include(more_info_path) + expect(sitemap).to include(help_path) expect(sitemap).to include(how_to_use_path) expect(sitemap).to include(page_path(id: 'general_terms')) From f92664331dd4d24c8f048158d306fa5c6c389b5c Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 30 Jan 2018 18:27:43 +0100 Subject: [PATCH 34/46] Changes .more-information class to .help --- app/assets/stylesheets/layout.scss | 2 +- app/views/sandbox/admin_test_sandbox.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 09902f649..cebd8c8eb 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -1641,7 +1641,7 @@ table { // 13. Pages // --------- -.more-information { +.help { li { border-bottom: 1px solid $border; diff --git a/app/views/sandbox/admin_test_sandbox.html.erb b/app/views/sandbox/admin_test_sandbox.html.erb index 5d61aab9d..69b7b521e 100644 --- a/app/views/sandbox/admin_test_sandbox.html.erb +++ b/app/views/sandbox/admin_test_sandbox.html.erb @@ -1,5 +1,5 @@
-
+

Más información

  • From fc89c899cccdec7d444b68a9bdc539a760aba8be Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 30 Jan 2018 18:28:05 +0100 Subject: [PATCH 35/46] Updates help url example on seeds --- db/seeds.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds.rb b/db/seeds.rb index 008c81bdd..844a24d81 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -112,7 +112,7 @@ Setting['mailer_from_address'] = 'noreply@consul.dev' Setting['verification_offices_url'] = 'http://oficinas-atencion-ciudadano.url/' Setting['min_age_to_participate'] = 16 -# Proposal improvement url path ('/more-information/proposal-improvement') +# Proposal improvement url path ('/help/proposal-improvement') Setting['proposal_improvement_path'] = nil # City map feature default configuration (Greenwich) From 42d0f471ee8436d78a5d586c8eae7896f9e38be1 Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 30 Jan 2018 19:10:48 +0100 Subject: [PATCH 36/46] Updates i18n keys and images folder --- .../images/{more_info => help}/budgets_en.png | Bin .../images/{more_info => help}/budgets_es.png | Bin .../images/{more_info => help}/budgets_fr.png | Bin .../images/{more_info => help}/budgets_nl.png | Bin .../{more_info => help}/budgets_pt-BR.png | Bin .../images/{more_info => help}/debates.png | Bin .../{more_info => help}/proposals_en.png | Bin .../{more_info => help}/proposals_es.png | Bin .../{more_info => help}/proposals_fr.png | Bin .../{more_info => help}/proposals_nl.png | Bin .../{more_info => help}/proposals_pt-BR.png | Bin app/views/pages/help/_budgets.html.erb | 22 ++++++++-------- app/views/pages/help/_debates.html.erb | 14 +++++----- app/views/pages/help/_menu.html.erb | 8 +++--- app/views/pages/help/_other.html.erb | 4 +-- app/views/pages/help/_polls.html.erb | 14 +++++----- app/views/pages/help/_proposals.html.erb | 12 ++++----- app/views/pages/help/_sidebar.html.erb | 6 ++--- app/views/pages/help/faq/index.html.erb | 10 ++++---- .../pages/help/how_to_use/index.html.erb | 4 +-- app/views/pages/help/index.html.erb | 24 +++++++++--------- config/locales/en/pages.yml | 4 +-- config/locales/es/pages.yml | 4 +-- spec/controllers/pages_controller_spec.rb | 6 ++--- 24 files changed, 66 insertions(+), 66 deletions(-) rename app/assets/images/{more_info => help}/budgets_en.png (100%) rename app/assets/images/{more_info => help}/budgets_es.png (100%) rename app/assets/images/{more_info => help}/budgets_fr.png (100%) rename app/assets/images/{more_info => help}/budgets_nl.png (100%) rename app/assets/images/{more_info => help}/budgets_pt-BR.png (100%) rename app/assets/images/{more_info => help}/debates.png (100%) rename app/assets/images/{more_info => help}/proposals_en.png (100%) rename app/assets/images/{more_info => help}/proposals_es.png (100%) rename app/assets/images/{more_info => help}/proposals_fr.png (100%) rename app/assets/images/{more_info => help}/proposals_nl.png (100%) rename app/assets/images/{more_info => help}/proposals_pt-BR.png (100%) diff --git a/app/assets/images/more_info/budgets_en.png b/app/assets/images/help/budgets_en.png similarity index 100% rename from app/assets/images/more_info/budgets_en.png rename to app/assets/images/help/budgets_en.png diff --git a/app/assets/images/more_info/budgets_es.png b/app/assets/images/help/budgets_es.png similarity index 100% rename from app/assets/images/more_info/budgets_es.png rename to app/assets/images/help/budgets_es.png diff --git a/app/assets/images/more_info/budgets_fr.png b/app/assets/images/help/budgets_fr.png similarity index 100% rename from app/assets/images/more_info/budgets_fr.png rename to app/assets/images/help/budgets_fr.png diff --git a/app/assets/images/more_info/budgets_nl.png b/app/assets/images/help/budgets_nl.png similarity index 100% rename from app/assets/images/more_info/budgets_nl.png rename to app/assets/images/help/budgets_nl.png diff --git a/app/assets/images/more_info/budgets_pt-BR.png b/app/assets/images/help/budgets_pt-BR.png similarity index 100% rename from app/assets/images/more_info/budgets_pt-BR.png rename to app/assets/images/help/budgets_pt-BR.png diff --git a/app/assets/images/more_info/debates.png b/app/assets/images/help/debates.png similarity index 100% rename from app/assets/images/more_info/debates.png rename to app/assets/images/help/debates.png diff --git a/app/assets/images/more_info/proposals_en.png b/app/assets/images/help/proposals_en.png similarity index 100% rename from app/assets/images/more_info/proposals_en.png rename to app/assets/images/help/proposals_en.png diff --git a/app/assets/images/more_info/proposals_es.png b/app/assets/images/help/proposals_es.png similarity index 100% rename from app/assets/images/more_info/proposals_es.png rename to app/assets/images/help/proposals_es.png diff --git a/app/assets/images/more_info/proposals_fr.png b/app/assets/images/help/proposals_fr.png similarity index 100% rename from app/assets/images/more_info/proposals_fr.png rename to app/assets/images/help/proposals_fr.png diff --git a/app/assets/images/more_info/proposals_nl.png b/app/assets/images/help/proposals_nl.png similarity index 100% rename from app/assets/images/more_info/proposals_nl.png rename to app/assets/images/help/proposals_nl.png diff --git a/app/assets/images/more_info/proposals_pt-BR.png b/app/assets/images/help/proposals_pt-BR.png similarity index 100% rename from app/assets/images/more_info/proposals_pt-BR.png rename to app/assets/images/help/proposals_pt-BR.png diff --git a/app/views/pages/help/_budgets.html.erb b/app/views/pages/help/_budgets.html.erb index 781463521..1e6cd251d 100644 --- a/app/views/pages/help/_budgets.html.erb +++ b/app/views/pages/help/_budgets.html.erb @@ -1,28 +1,28 @@

    - <%= t("pages.more_info.budgets.title") %> + <%= t("pages.help.budgets.title") %>

    - <%= t("pages.more_info.budgets.description", - link: link_to(t("pages.more_info.budgets.link"), budgets_path)).html_safe %> + <%= t("pages.help.budgets.description", + link: link_to(t("pages.help.budgets.link"), budgets_path)).html_safe %>

    • - <%= t("pages.more_info.budgets.feature") %> + <%= t("pages.help.budgets.feature") %>
    • -
    • <%= t("pages.more_info.budgets.phase_1_html", +
    • <%= t("pages.help.budgets.phase_1_html", org: setting['org_name']).html_safe %>
    • -
    • <%= t("pages.more_info.budgets.phase_2_html") %>
    • -
    • <%= t("pages.more_info.budgets.phase_3_html") %>
    • -
    • <%= t("pages.more_info.budgets.phase_4_html") %>
    • +
    • <%= t("pages.help.budgets.phase_2_html") %>
    • +
    • <%= t("pages.help.budgets.phase_3_html") %>
    • +
    • <%= t("pages.help.budgets.phase_4_html") %>
    -

    <%= t("pages.more_info.budgets.phase_5_html") %>

    +

    <%= t("pages.help.budgets.phase_5_html") %>

    - <%= image_tag "more_info/budgets_#{I18n.locale}.png", alt: t("pages.more_info.budgets.image_alt") %> -
    <%= t("pages.more_info.budgets.figcaption_html") %>
    + <%= image_tag "help/budgets_#{I18n.locale}.png", alt: t("pages.help.budgets.image_alt") %> +
    <%= t("pages.help.budgets.figcaption_html") %>
    diff --git a/app/views/pages/help/_debates.html.erb b/app/views/pages/help/_debates.html.erb index d8f3fdedd..a70d8b05b 100644 --- a/app/views/pages/help/_debates.html.erb +++ b/app/views/pages/help/_debates.html.erb @@ -1,25 +1,25 @@

    - <%= t("pages.more_info.debates.title") %> + <%= t("pages.help.debates.title") %>

    - <%= t("pages.more_info.debates.description", + <%= t("pages.help.debates.description", org: setting['org_name'], - link: link_to(t("pages.more_info.debates.link"), + link: link_to(t("pages.help.debates.link"), debates_path)).html_safe %>

    • - <%= t("pages.more_info.debates.feature_html", - link: link_to(t("pages.more_info.debates.feature_link", org: setting['org_name']), + <%= t("pages.help.debates.feature_html", + link: link_to(t("pages.help.debates.feature_link", org: setting['org_name']), new_user_registration_path)).html_safe %>
    - <%= image_tag "more_info/debates.png", alt: t("pages.more_info.debates.image_alt") %> -
    <%= t("pages.more_info.debates.figcaption") %>
    + <%= image_tag "help/debates.png", alt: t("pages.help.debates.image_alt") %> +
    <%= t("pages.help.debates.figcaption") %>
    diff --git a/app/views/pages/help/_menu.html.erb b/app/views/pages/help/_menu.html.erb index e48d47b5b..0a1b7ff85 100644 --- a/app/views/pages/help/_menu.html.erb +++ b/app/views/pages/help/_menu.html.erb @@ -3,21 +3,21 @@
diff --git a/app/views/pages/help/_other.html.erb b/app/views/pages/help/_other.html.erb index 5ed1b9f4e..bdae779d8 100644 --- a/app/views/pages/help/_other.html.erb +++ b/app/views/pages/help/_other.html.erb @@ -1,7 +1,7 @@ -

<%= t("pages.more_info.other.title") %>

+

<%= t("pages.help.other.title") %>

    -
  • <%= link_to t("pages.more_info.other.how_to_use", org_name: setting['org_name']), how_to_use_path %>
  • +
  • <%= link_to t("pages.help.other.how_to_use", org_name: setting['org_name']), how_to_use_path %>
  • <% SiteCustomization::Page.with_more_info_flag.with_same_locale.each do |custom_page| %>
  • <%= link_to custom_page.title, page_path(custom_page.slug) %>
  • diff --git a/app/views/pages/help/_polls.html.erb b/app/views/pages/help/_polls.html.erb index 16a5c08bd..64a7d23f2 100644 --- a/app/views/pages/help/_polls.html.erb +++ b/app/views/pages/help/_polls.html.erb @@ -1,18 +1,18 @@
    -

    <%= t("pages.more_info.polls.title") %>

    +

    <%= t("pages.help.polls.title") %>

    - <%= t("pages.more_info.polls.description", - link: link_to(t("pages.more_info.polls.link"), polls_path)).html_safe %> + <%= t("pages.help.polls.description", + link: link_to(t("pages.help.polls.link"), polls_path)).html_safe %>

    • - <%= t("pages.more_info.polls.feature_1", - link: link_to(t("pages.more_info.polls.feature_1_link", org_name: setting['org_name']), + <%= t("pages.help.polls.feature_1", + link: link_to(t("pages.help.polls.feature_1_link", org_name: setting['org_name']), new_user_registration_path)).html_safe %>
    • -
    • <%= t("pages.more_info.polls.feature_2") %>
    • -
    • <%= t("pages.more_info.polls.feature_3") %>
    • +
    • <%= t("pages.help.polls.feature_2") %>
    • +
    • <%= t("pages.help.polls.feature_3") %>
    diff --git a/app/views/pages/help/_proposals.html.erb b/app/views/pages/help/_proposals.html.erb index c9f10f92e..c8333b5fd 100644 --- a/app/views/pages/help/_proposals.html.erb +++ b/app/views/pages/help/_proposals.html.erb @@ -1,23 +1,23 @@

    - <%= t("pages.more_info.proposals.title") %> + <%= t("pages.help.proposals.title") %>

    - <%= t("pages.more_info.proposals.description", - link: link_to(t("pages.more_info.proposals.link"), proposals_path)).html_safe %> + <%= t("pages.help.proposals.description", + link: link_to(t("pages.help.proposals.link"), proposals_path)).html_safe %>

    • - <%= t("pages.more_info.proposals.feature_html", + <%= t("pages.help.proposals.feature_html", org: setting['org_name'], supports: setting['votes_for_proposal_success']).html_safe %>
    - <%= image_tag "more_info/proposals_#{I18n.locale}.png", alt: t("pages.more_info.proposals.image_alt") %> -
    <%= t("pages.more_info.proposals.figcaption_html") %>
    + <%= image_tag "help/proposals_#{I18n.locale}.png", alt: t("pages.help.proposals.image_alt") %> +
    <%= t("pages.help.proposals.figcaption_html") %>
    diff --git a/app/views/pages/help/_sidebar.html.erb b/app/views/pages/help/_sidebar.html.erb index 09131685b..428aadf04 100644 --- a/app/views/pages/help/_sidebar.html.erb +++ b/app/views/pages/help/_sidebar.html.erb @@ -1,5 +1,5 @@ diff --git a/app/views/pages/help/faq/index.html.erb b/app/views/pages/help/faq/index.html.erb index db8bfaf6e..36c7d98b8 100644 --- a/app/views/pages/help/faq/index.html.erb +++ b/app/views/pages/help/faq/index.html.erb @@ -7,15 +7,15 @@ <%= back_link_to %>
-

<%= t("pages.more_info.faq.page.title") %>

-

<%= t("pages.more_info.faq.page.description") %>

+

<%= t("pages.help.faq.page.title") %>

+

<%= t("pages.help.faq.page.description") %>

-

<%= t("pages.more_info.faq.page.faq_1_title") %>

-

<%= t("pages.more_info.faq.page.faq_1_description") %>

+

<%= t("pages.help.faq.page.faq_1_title") %>

+

<%= t("pages.help.faq.page.faq_1_description") %>

diff --git a/app/views/pages/help/how_to_use/index.html.erb b/app/views/pages/help/how_to_use/index.html.erb index f396b69a1..8da48d35d 100644 --- a/app/views/pages/help/how_to_use/index.html.erb +++ b/app/views/pages/help/how_to_use/index.html.erb @@ -6,8 +6,8 @@
<%= back_link_to %> -

<%= t('pages.more_info.titles.how_to_use') %>

+

<%= t('pages.help.titles.how_to_use') %>

- <%= markdown t('pages.more_info.how_to_use.text') %> + <%= markdown t('pages.help.how_to_use.text') %>
diff --git a/app/views/pages/help/index.html.erb b/app/views/pages/help/index.html.erb index 7bb05d1f6..3ab4ae595 100644 --- a/app/views/pages/help/index.html.erb +++ b/app/views/pages/help/index.html.erb @@ -1,48 +1,48 @@ -<% provide :title do %><%= t("pages.titles.more_info", org: setting['org_name']) %><% end %> +<% provide :title do %><%= t("pages.titles.help", org: setting['org_name']) %><% end %> <% content_for :canonical do %> - <%= render "shared/canonical", href: more_info_url %> + <%= render "shared/canonical", href: help_url %> <% end %>
-

<%= t("pages.more_info.title", org: setting['org_name']) %>

-

<%= t("pages.more_info.subtitle", org: setting['org_name']) %>

-

<%= t("pages.more_info.guide", org: setting['org_name']) %>

+

<%= t("pages.help.title", org: setting['org_name']) %>

+

<%= t("pages.help.subtitle", org: setting['org_name']) %>

+

<%= t("pages.help.guide", org: setting['org_name']) %>

- <%= render "pages/more_info/menu" %> + <%= render "pages/help/menu" %>
<% if feature?(:debates) %> - <%= render "pages/more_info/debates" %> + <%= render "pages/help/debates" %> <% end %> <% if feature?(:proposals) %> - <%= render "pages/more_info/proposals" %> + <%= render "pages/help/proposals" %> <% end %> <% if feature?(:budgets) %> - <%= render "pages/more_info/budgets" %> + <%= render "pages/help/budgets" %> <% end %> <% if feature?(:polls) %> - <%= render "pages/more_info/polls" %> + <%= render "pages/help/polls" %> <% end %>
- <%= render "pages/more_info/sidebar" %> + <%= render "pages/help/sidebar" %>

- <%= render "pages/more_info/other" %> + <%= render "pages/help/other" %>
diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index 38f6ed25d..3692052d1 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -3,7 +3,7 @@ en: census_terms: To confirm the account, you must be 16 or older and be registered, having provided the information requested previously, will verify. By accepting the verification process, you also consent to the verification of this information, as well as the contact methods featuring in said files. The data provided will be acquired and processed in a file mentioned previously in the terms and conditions of use for the Portal. conditions: Terms and conditions of use general_terms: Terms and Conditions - more_info: + help: title: "%{org} is a platform for citizen participation" subtitle: "In %{org} you can make proposals, vote in citizen consultations, propose participatory budget projects, decide on municipal regulations and open debates to exchange opinions with others." guide: "This guide explains what each of the %{org} sections are for and how they work." @@ -72,7 +72,7 @@ en: titles: accessibility: Accessibility conditions: Terms of use - more_info: "What is %{org}? - Citizen participation" + help: "What is %{org}? - Citizen participation" privacy: Privacy Policy verify: code: Code you received in letter diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index 4ea5a44a9..0667bdfd8 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -3,7 +3,7 @@ es: census_terms: Para verificar la cuenta hay que tener 16 años o más y estar empadronado aportando los datos indicados anteriormente, los cuales serán contrastados. Aceptando el proceso de verificación acepta dar su consentimiento para contrastar dicha información, así como medios de contacto que figuren en dichos ficheros. Los datos aportados serán incorporados y tratados en un fichero indicado anteriormente en las condiciones de uso del portal. conditions: Condiciones de uso general_terms: Términos y Condiciones - more_info: + help: title: "%{org} es una plataforma de participación ciudadana" subtitle: "En %{org} se pueden hacer propuestas, votar en consultas ciudadanas, plantear proyectos de presupuestos participativos, decidir la normativa municipal y abrir debates para intercambiar opiniones con otras personas." guide: 'Esta guía explica para qué sirven y cómo funcionan cada una de las secciones de %{org}.' @@ -72,7 +72,7 @@ es: titles: accessibility: Accesibilidad conditions: Condiciones de uso - more_info: "¿Qué es %{org}? - Participación ciudadana" + help: "¿Qué es %{org}? - Participación ciudadana" privacy: Política de Privacidad verify: code: Código que has recibido en tu carta diff --git a/spec/controllers/pages_controller_spec.rb b/spec/controllers/pages_controller_spec.rb index 17a17dc3c..e5c3cfd0a 100644 --- a/spec/controllers/pages_controller_spec.rb +++ b/spec/controllers/pages_controller_spec.rb @@ -32,17 +32,17 @@ describe PagesController do describe 'More info pages' do it 'includes a more info page' do - get :show, id: 'more_info/index' + get :show, id: 'help/index' expect(response).to be_ok end it 'includes a how_to_use page' do - get :show, id: 'more_info/how_to_use/index' + get :show, id: 'help/how_to_use/index' expect(response).to be_ok end it 'includes a faq page' do - get :show, id: 'more_info/faq/index' + get :show, id: 'help/faq/index' expect(response).to be_ok end end From c84b2f0704ddafdbbcee3b96ee3a903801c96a24 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 29 Jan 2018 21:47:01 +0100 Subject: [PATCH 37/46] Add valuation boolean flag to Comment model Why: Budget Investment's valuators need to be able to comment on investments without making those comments public. We need a way to clearly make a distinction to avoid "leaking" internal valuation comments. How: Adding a boolean `valuation` attribute defaulted to false to the Comments table, and index on it with concurrent algorithm as explained at https://robots.thoughtbot.com/how-to-create-postgres-indexes-concurrently-in The name `valuation` was chosen instead of `internal` because of the more specific meaning as well as avoiding a collision with existing internal_comments attribute on Budget::Investment model (soon to be deprecated & removed) --- .../20180129190931_add_valuation_flag_to_comments.rb | 5 +++++ .../20180129190950_add_index_to_valuation_comments.rb | 7 +++++++ db/schema.rb | 8 +++++--- 3 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20180129190931_add_valuation_flag_to_comments.rb create mode 100644 db/migrate/20180129190950_add_index_to_valuation_comments.rb diff --git a/db/migrate/20180129190931_add_valuation_flag_to_comments.rb b/db/migrate/20180129190931_add_valuation_flag_to_comments.rb new file mode 100644 index 000000000..cf31a92e7 --- /dev/null +++ b/db/migrate/20180129190931_add_valuation_flag_to_comments.rb @@ -0,0 +1,5 @@ +class AddValuationFlagToComments < ActiveRecord::Migration + def change + add_column :comments, :valuation, :boolean, default: false + end +end diff --git a/db/migrate/20180129190950_add_index_to_valuation_comments.rb b/db/migrate/20180129190950_add_index_to_valuation_comments.rb new file mode 100644 index 000000000..2816d15b0 --- /dev/null +++ b/db/migrate/20180129190950_add_index_to_valuation_comments.rb @@ -0,0 +1,7 @@ +class AddIndexToValuationComments < ActiveRecord::Migration + disable_ddl_transaction! + + def change + add_index :comments, :valuation, algorithm: :concurrently + end +end diff --git a/db/schema.rb b/db/schema.rb index 219707f69..a6fc6ef88 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180119073228) do +ActiveRecord::Schema.define(version: 20180129190950) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -234,7 +234,7 @@ ActiveRecord::Schema.define(version: 20180119073228) do t.string "commentable_type" t.text "body" t.string "subject" - t.integer "user_id", null: false + t.integer "user_id", null: false t.datetime "created_at" t.datetime "updated_at" t.datetime "hidden_at" @@ -247,7 +247,8 @@ ActiveRecord::Schema.define(version: 20180119073228) do t.integer "cached_votes_down", default: 0 t.datetime "confirmed_hide_at" t.string "ancestry" - t.integer "confidence_score", default: 0, null: false + t.integer "confidence_score", default: 0, null: false + t.boolean "valuation", default: false end add_index "comments", ["ancestry"], name: "index_comments_on_ancestry", using: :btree @@ -257,6 +258,7 @@ ActiveRecord::Schema.define(version: 20180119073228) do add_index "comments", ["commentable_id", "commentable_type"], name: "index_comments_on_commentable_id_and_commentable_type", using: :btree add_index "comments", ["hidden_at"], name: "index_comments_on_hidden_at", using: :btree add_index "comments", ["user_id"], name: "index_comments_on_user_id", using: :btree + add_index "comments", ["valuation"], name: "index_comments_on_valuation", using: :btree create_table "communities", force: :cascade do |t| t.datetime "created_at", null: false From 56fc5c958336016e4dab4b9083992c3288d27be7 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 29 Jan 2018 21:53:38 +0100 Subject: [PATCH 38/46] Filter internal valuation comments from public api Why: Internal valuation comments are only for admins and valuators, not for the public view. How: Adding a `not_valuations` scope and use it at the `public_for_api` one --- app/models/comment.rb | 5 ++++- spec/factories.rb | 4 ++++ spec/models/comment_spec.rb | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/comment.rb b/app/models/comment.rb index 50f6cef66..0651b3442 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -33,7 +33,8 @@ class Comment < ActiveRecord::Base end scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) } scope :public_for_api, -> do - where(%{(comments.commentable_type = 'Debate' and comments.commentable_id in (?)) or + not_valuations + .where(%{(comments.commentable_type = 'Debate' and comments.commentable_id in (?)) or (comments.commentable_type = 'Proposal' and comments.commentable_id in (?)) or (comments.commentable_type = 'Poll' and comments.commentable_id in (?))}, Debate.public_for_api.pluck(:id), @@ -50,6 +51,8 @@ class Comment < ActiveRecord::Base scope :sort_by_oldest, -> { order(created_at: :asc) } scope :sort_descendants_by_oldest, -> { order(created_at: :asc) } + scope :not_valuations, -> { where(valuation: false) } + after_create :call_after_commented def self.build(commentable, user, body, p_id = nil) diff --git a/spec/factories.rb b/spec/factories.rb index f9ffd1ef6..fe9bccd6c 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -465,6 +465,10 @@ FactoryBot.define do trait :with_confidence_score do before(:save) { |d| d.calculate_confidence_score } end + + trait :valuation do + valuation true + end end factory :legacy_legislation do diff --git a/spec/models/comment_spec.rb b/spec/models/comment_spec.rb index fb55c6a81..837464527 100644 --- a/spec/models/comment_spec.rb +++ b/spec/models/comment_spec.rb @@ -187,5 +187,11 @@ describe Comment do expect(described_class.public_for_api).not_to include(comment) end + + it "does not return internal valuation comments" do + valuation_comment = create(:comment, :valuation) + + expect(described_class.public_for_api).not_to include(valuation_comment) + end end end From 767fd04bdfe957f43dce4a3e73c273dda27a1631 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 29 Jan 2018 21:55:51 +0100 Subject: [PATCH 39/46] Add valuation comments relation at Budget Investment Why: Budget Investments already has an existing `comments` relation that is on use. We need to keep that relation unaltered after adding the internal valuation comments, that means scoping the relation to only public comments (non valuation ones) so existing code using it will remain working as expected. A new second relation will be needed to explicitly ask for valuation comments only where needed, again scoping to valuation comments. How: Adding a second `valuations` relationship and filtering on both with the new `valuation` flag from Comment model. --- app/models/budget/investment.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 58674be9b..7129c40dc 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -34,7 +34,10 @@ class Budget has_many :valuator_assignments, dependent: :destroy has_many :valuators, through: :valuator_assignments - has_many :comments, as: :commentable + + has_many :comments, -> {where(valuation: false)}, as: :commentable, class_name: 'Comment' + has_many :valuations, -> {where(valuation: true)}, as: :commentable, class_name: 'Comment' + has_many :milestones validates :title, presence: true From dff966d9b3700cdf3dae1f75da97954d97c284c5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 29 Jan 2018 22:12:55 +0100 Subject: [PATCH 40/46] Show valuation comment thread @ Valuation show/edit Why: Budget Investment's valuators should be able to see internal valuation comments thread at both show and edit views. How: At Valuation::BudgetInvestmentsController: * Include CommentableActions to gain access to the entire feature, with required resource_model & resource_name methods. * Add the only possible order (oldest to newest) * Load comments on both show & edit actions, passing `valuations` flag to the CommentTree in order to only list those. At CommentTree: * Use `valuations` flag as instance variable to decide wich comment threat to load: valuations (if relation exists) or comments. --- .../budget_investments_controller.rb | 25 +++++++++++++++++++ .../_written_by_valuators.html.erb | 8 ++++++ .../budget_investments/edit.html.erb | 8 ++++++ lib/comment_tree.rb | 14 ++++++++--- 4 files changed, 52 insertions(+), 3 deletions(-) diff --git a/app/controllers/valuation/budget_investments_controller.rb b/app/controllers/valuation/budget_investments_controller.rb index c8d61215b..643ccbc74 100644 --- a/app/controllers/valuation/budget_investments_controller.rb +++ b/app/controllers/valuation/budget_investments_controller.rb @@ -1,11 +1,14 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController include FeatureFlags + include CommentableActions + feature_flag :budgets before_action :restrict_access_to_assigned_items, only: [:show, :edit, :valuate] before_action :load_budget before_action :load_investment, only: [:show, :edit, :valuate] + has_orders %w{oldest}, only: [:show, :edit] has_filters %w{valuating valuation_finished}, only: :index load_and_authorize_resource :investment, class: "Budget::Investment" @@ -36,8 +39,30 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController end end + def show + load_comments + end + + def edit + load_comments + end + private + def load_comments + @commentable = @investment + @comment_tree = CommentTree.new(@commentable, params[:page], @current_order, valuations: true) + set_comment_flags(@comment_tree.comments) + end + + def resource_model + Budget::Investment + end + + def resource_name + resource_model.parameterize('_') + end + def load_budget @budget = Budget.find(params[:budget_id]) end diff --git a/app/views/valuation/budget_investments/_written_by_valuators.html.erb b/app/views/valuation/budget_investments/_written_by_valuators.html.erb index 9dc5a8e8c..965f2b059 100644 --- a/app/views/valuation/budget_investments/_written_by_valuators.html.erb +++ b/app/views/valuation/budget_investments/_written_by_valuators.html.erb @@ -51,3 +51,11 @@

<%= t("valuation.budget_investments.show.internal_comments") %>

<%= explanation_field @investment.internal_comments %> <% end %> + +
+ <% unless @comment_tree.nil? %> + <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, + comment_flags: @comment_flags, + display_comments_count: false } %> + <% end %> +
diff --git a/app/views/valuation/budget_investments/edit.html.erb b/app/views/valuation/budget_investments/edit.html.erb index 651f91c5a..5ae5ae5dd 100644 --- a/app/views/valuation/budget_investments/edit.html.erb +++ b/app/views/valuation/budget_investments/edit.html.erb @@ -103,6 +103,14 @@
<% end %> +
+ <% unless @comment_tree.nil? %> + <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, + comment_flags: @comment_flags, + display_comments_count: false } %> + <% end %> +
+

<%= @investment.title %>

<%= safe_html_with_links @investment.description %> diff --git a/lib/comment_tree.rb b/lib/comment_tree.rb index f2eadb8ab..a67a0ccc3 100644 --- a/lib/comment_tree.rb +++ b/lib/comment_tree.rb @@ -4,16 +4,24 @@ class CommentTree attr_accessor :root_comments, :comments, :commentable, :page, :order - def initialize(commentable, page, order = 'confidence_score') + def initialize(commentable, page, order = 'confidence_score', valuations: false) @commentable = commentable @page = page @order = order - + @valuations = valuations @comments = root_comments + root_descendants end def root_comments - commentable.comments.roots.send("sort_by_#{order}").page(page).per(ROOT_COMMENTS_PER_PAGE).for_render + base_comments.roots.send("sort_by_#{order}").page(page).per(ROOT_COMMENTS_PER_PAGE).for_render + end + + def base_comments + if @valuations && commentable.respond_to?('valuations') + commentable.valuations + else + commentable.comments + end end def root_descendants From 149c81371b1142e129c72291d1053d5de06e1540 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 29 Jan 2018 22:14:03 +0100 Subject: [PATCH 41/46] Allow valuation internal comments to be created How: Using a local variable at partials to set a hidden true/false value for `valuation` parameter on the comment creation form. Allowing that new param at the comment controller and using it when building a new Comment. --- app/controllers/comments_controller.rb | 5 +++-- app/models/comment.rb | 7 ++++--- app/views/comments/_comment.html.erb | 9 +++++++-- app/views/comments/_comment_tree.html.erb | 9 ++++++--- app/views/comments/_commentable_tree.html.erb | 8 ++++++-- app/views/comments/_form.html.erb | 1 + .../_written_by_valuators.html.erb | 3 ++- .../valuation/budget_investments/edit.html.erb | 3 ++- spec/features/comments/budget_investments_spec.rb | 15 ++++++++++----- 9 files changed, 41 insertions(+), 19 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 98357e96e..0f5cb680b 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -45,12 +45,13 @@ class CommentsController < ApplicationController def comment_params params.require(:comment).permit(:commentable_type, :commentable_id, :parent_id, - :body, :as_moderator, :as_administrator) + :body, :as_moderator, :as_administrator, :valuation) end def build_comment @comment = Comment.build(@commentable, current_user, comment_params[:body], - comment_params[:parent_id].presence) + comment_params[:parent_id].presence, + comment_params[:valuation]) check_for_special_comments end diff --git a/app/models/comment.rb b/app/models/comment.rb index 0651b3442..3c58f966b 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -55,11 +55,12 @@ class Comment < ActiveRecord::Base after_create :call_after_commented - def self.build(commentable, user, body, p_id = nil) - new commentable: commentable, + def self.build(commentable, user, body, p_id = nil, valuation = false) + new(commentable: commentable, user_id: user.id, body: body, - parent_id: p_id + parent_id: p_id, + valuation: valuation) end def self.find_commentable(c_type, c_id) diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 8d45b5469..a5d84166e 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,4 +1,5 @@ <% comment_flags ||= @comment_flags %> +<% valuation = local_assigns.fetch(:valuation, false) %> <% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags)] do %>
  • @@ -88,7 +89,10 @@ <%= render 'comments/actions', comment: comment %> - <%= render 'comments/form', {commentable: comment.commentable, parent_id: comment.id, toggeable: true} %> + <%= render 'comments/form', {commentable: comment.commentable, + parent_id: comment.id, + toggeable: true, + valuation: valuation } %> <% end %>
<% end %> @@ -98,7 +102,8 @@
    <% child_comments_of(comment).each do |child| %>
  • - <%= render 'comments/comment', comment: child %> + <%= render 'comments/comment', { comment: child, + valuation: valuation } %>
  • <% end %>
diff --git a/app/views/comments/_comment_tree.html.erb b/app/views/comments/_comment_tree.html.erb index eb4b20fe5..436c50904 100644 --- a/app/views/comments/_comment_tree.html.erb +++ b/app/views/comments/_comment_tree.html.erb @@ -1,5 +1,5 @@ <% commentable = comment_tree.commentable %> - +<% valuation = local_assigns.fetch(:valuation, false) %> <% cache [locale_and_user_status, comment_tree.order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count, comment_flags] do %>
@@ -27,7 +27,8 @@ <% else %> <%= render 'comments/form', { commentable: commentable, parent_id: nil, - toggeable: false } %> + toggeable: false, + valuation: valuation } %> <% end %> <% else %>
@@ -39,7 +40,9 @@ <% end %> <% comment_tree.root_comments.each do |comment| %> - <%= render 'comments/comment', {comment: comment, comment_flags: comment_flags} %> + <%= render 'comments/comment', { comment: comment, + comment_flags: comment_flags, + valuation: valuation } %> <% end %> <%= paginate comment_tree.root_comments %>
diff --git a/app/views/comments/_commentable_tree.html.erb b/app/views/comments/_commentable_tree.html.erb index 6970e64f4..b7af4365a 100644 --- a/app/views/comments/_commentable_tree.html.erb +++ b/app/views/comments/_commentable_tree.html.erb @@ -10,7 +10,10 @@ <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> <% if user_signed_in? %> - <%= render 'comments/form', {commentable: @investment, parent_id: nil, toggeable: false} %> + <%= render 'comments/form', { commentable: @investment, + parent_id: nil, + toggeable: false, + valuation: local_assigns.fetch(:valuation, false) } %> <% else %>
@@ -22,7 +25,8 @@ <% end %> <% @comment_tree.root_comments.each do |comment| %> - <%= render 'comments/comment', comment: comment %> + <%= render 'comments/comment', { comment: comment, + valuation: local_assigns.fetch(:valuation, false) } %> <% end %> <%= paginate @comment_tree.root_comments %>
diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 80cd7e2da..8ceefdd59 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -7,6 +7,7 @@ <%= f.hidden_field :commentable_type, value: commentable.class.name %> <%= f.hidden_field :commentable_id, value: commentable.id %> <%= f.hidden_field :parent_id, value: parent_id %> + <%= f.hidden_field :valuation, value: local_assigns.fetch(:valuation, false) %> <%= f.submit comment_button_text(parent_id, commentable), class: "button", id: "publish_comment" %> diff --git a/app/views/valuation/budget_investments/_written_by_valuators.html.erb b/app/views/valuation/budget_investments/_written_by_valuators.html.erb index 965f2b059..eb2d0e81d 100644 --- a/app/views/valuation/budget_investments/_written_by_valuators.html.erb +++ b/app/views/valuation/budget_investments/_written_by_valuators.html.erb @@ -56,6 +56,7 @@ <% unless @comment_tree.nil? %> <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags, - display_comments_count: false } %> + display_comments_count: false, + valuation: true } %> <% end %>
diff --git a/app/views/valuation/budget_investments/edit.html.erb b/app/views/valuation/budget_investments/edit.html.erb index 5ae5ae5dd..7d3350fe6 100644 --- a/app/views/valuation/budget_investments/edit.html.erb +++ b/app/views/valuation/budget_investments/edit.html.erb @@ -107,7 +107,8 @@ <% unless @comment_tree.nil? %> <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags, - display_comments_count: false } %> + display_comments_count: false, + valuation: true } %> <% end %>
diff --git a/spec/features/comments/budget_investments_spec.rb b/spec/features/comments/budget_investments_spec.rb index 4afb1e680..bae63e4ec 100644 --- a/spec/features/comments/budget_investments_spec.rb +++ b/spec/features/comments/budget_investments_spec.rb @@ -7,16 +7,19 @@ feature 'Commenting Budget::Investments' do scenario 'Index' do 3.times { create(:comment, commentable: investment) } + valuation_comment = create(:comment, :valuation, commentable: investment, subject: 'Not viable') visit budget_investment_path(investment.budget, investment) expect(page).to have_css('.comment', count: 3) + expect(page).not_to have_content('Not viable') - comment = Comment.last - within first('.comment') do - expect(page).to have_content comment.user.name - expect(page).to have_content I18n.l(comment.created_at, format: :datetime) - expect(page).to have_content comment.body + within("#comments") do + Comment.not_valuations.last(3).each do |comment| + expect(page).to have_content comment.user.name + expect(page).to have_content I18n.l(comment.created_at, format: :datetime) + expect(page).to have_content comment.body + end end end @@ -24,6 +27,7 @@ feature 'Commenting Budget::Investments' do parent_comment = create(:comment, commentable: investment) first_child = create(:comment, commentable: investment, parent: parent_comment) second_child = create(:comment, commentable: investment, parent: parent_comment) + valuation_comment = create(:comment, :valuation, commentable: investment, subject: 'Not viable') visit comment_path(parent_comment) @@ -31,6 +35,7 @@ feature 'Commenting Budget::Investments' do expect(page).to have_content parent_comment.body expect(page).to have_content first_child.body expect(page).to have_content second_child.body + expect(page).not_to have_content('Not viable') expect(page).to have_link "Go back to #{investment.title}", href: budget_investment_path(investment.budget, investment) From 26cf91c61a9883f8d727de1b6cef65ab5d8c7a5a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 Jan 2018 02:55:21 +0100 Subject: [PATCH 42/46] Create valuation comments creation ability Why: Only admins or valuators (for those investments they've assigned) can create internal valuation comments on them. How: * Creating a new `comment_valuation` ability for admins and valuators in the same manner the `valuate` ability works. * Adding a validation at Comment model for those with `valuation` flag active that checks if the author can make a valuation comment on the commentable, as well as the respective active record error messages. This will prevent comments from being created at a controller level as well. * Improving comment factory trait `valuation` to have an associated investment, author that is a valuator and setting the valuator on the valuators list of the investment --- app/models/abilities/administrator.rb | 2 +- app/models/abilities/valuator.rb | 4 ++-- app/models/comment.rb | 6 ++++++ config/locales/en/activerecord.yml | 4 ++++ config/locales/es/activerecord.yml | 4 ++++ spec/factories.rb | 6 ++++++ 6 files changed, 23 insertions(+), 3 deletions(-) diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 53b49dfb4..7af50446a 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -55,7 +55,7 @@ module Abilities can [:read, :create, :update, :destroy], Budget::Group can [:read, :create, :update, :destroy], Budget::Heading can [:hide, :update, :toggle_selection], Budget::Investment - can :valuate, Budget::Investment + can [:valuate, :comment_valuation], Budget::Investment can :create, Budget::ValuatorAssignment can [:search, :edit, :update, :create, :index, :destroy], Banner diff --git a/app/models/abilities/valuator.rb b/app/models/abilities/valuator.rb index 614869665..449a42410 100644 --- a/app/models/abilities/valuator.rb +++ b/app/models/abilities/valuator.rb @@ -5,8 +5,8 @@ module Abilities def initialize(user) valuator = user.valuator can [:read, :update, :valuate], SpendingProposal - can [:read, :update, :valuate], Budget::Investment, id: valuator.investment_ids - cannot [:update, :valuate], Budget::Investment, budget: { phase: 'finished' } + can [:read, :update, :valuate, :comment_valuation], Budget::Investment, id: valuator.investment_ids + cannot [:update, :valuate, :comment_valuation], Budget::Investment, budget: { phase: 'finished' } end end end diff --git a/app/models/comment.rb b/app/models/comment.rb index 3c58f966b..d9329d3c0 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -20,6 +20,7 @@ class Comment < ActiveRecord::Base validates :commentable_type, inclusion: { in: COMMENTABLE_TYPES } validate :validate_body_length + validate :comment_valuation, if: -> { valuation } belongs_to :commentable, -> { with_hidden }, polymorphic: true, counter_cache: true belongs_to :user, -> { with_hidden } @@ -133,4 +134,9 @@ class Comment < ActiveRecord::Base validator.validate(self) end + def comment_valuation + unless author.can?(:comment_valuation, commentable) + errors.add(:valuation, :cannot_comment_valuation) + end + end end diff --git a/config/locales/en/activerecord.yml b/config/locales/en/activerecord.yml index 81b25dcad..bb402946c 100644 --- a/config/locales/en/activerecord.yml +++ b/config/locales/en/activerecord.yml @@ -296,6 +296,10 @@ en: image: image_width: "Width must be %{required_width}px" image_height: "Height must be %{required_height}px" + comment: + attributes: + valuation: + cannot_comment_valuation: 'You cannot comment a valuation' messages: record_invalid: "Validation failed: %{errors}" restrict_dependent_destroy: diff --git a/config/locales/es/activerecord.yml b/config/locales/es/activerecord.yml index b604224cf..176e575cb 100644 --- a/config/locales/es/activerecord.yml +++ b/config/locales/es/activerecord.yml @@ -292,6 +292,10 @@ es: image: image_width: "Debe tener %{required_width}px de ancho" image_height: "Debe tener %{required_height}px de alto" + comment: + attributes: + valuation: + cannot_comment_valuation: 'No puedes comentar una evaluación' messages: record_invalid: 'Error de validación: %{errors}' restrict_dependent_destroy: diff --git a/spec/factories.rb b/spec/factories.rb index fe9bccd6c..8d299bcd8 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -468,6 +468,12 @@ FactoryBot.define do trait :valuation do valuation true + association :commentable, factory: :budget_investment + before :create do |valuation| + valuator = create(:valuator) + valuation.author = valuator.user + valuation.commentable.valuators << valuator + end end end From 1c3924b5275bddb53db1f28ae33ad9f35ba57c5b Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 Jan 2018 03:19:36 +0100 Subject: [PATCH 43/46] Hide comment voting at valuation comment threads --- app/views/comments/_comment.html.erb | 10 +++++++--- app/views/comments/_comment_tree.html.erb | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index a5d84166e..5de5b6c24 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,5 +1,6 @@ <% comment_flags ||= @comment_flags %> <% valuation = local_assigns.fetch(:valuation, false) %> +<% allow_votes = local_assigns.fetch(:allow_votes, true) %> <% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags)] do %>
  • @@ -68,9 +69,11 @@
-
- <%= render 'comments/votes', comment: comment %> -
+ <% if allow_votes %> +
+ <%= render 'comments/votes', comment: comment %> +
+ <% end %> <% if comment.children.size > 0 %> <%= link_to "", class: "js-toggle-children relative", data: {'id': "#{dom_id(comment)}"} do %> @@ -104,6 +107,7 @@
  • <%= render 'comments/comment', { comment: child, valuation: valuation } %> + allow_votes: allow_votes } %>
  • <% end %> diff --git a/app/views/comments/_comment_tree.html.erb b/app/views/comments/_comment_tree.html.erb index 436c50904..6b0bdc296 100644 --- a/app/views/comments/_comment_tree.html.erb +++ b/app/views/comments/_comment_tree.html.erb @@ -42,7 +42,8 @@ <% comment_tree.root_comments.each do |comment| %> <%= render 'comments/comment', { comment: comment, comment_flags: comment_flags, - valuation: valuation } %> + valuation: valuation, + allow_votes: !valuation } %> <% end %> <%= paginate comment_tree.root_comments %>
    From a4718f65553c66eeebd47a5f9085cc7a5d940e94 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 Jan 2018 15:22:07 +0100 Subject: [PATCH 44/46] Add Budget Investment valuation comments feature spec --- .../budget_investments_valuation_spec.rb | 300 ++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 spec/features/comments/budget_investments_valuation_spec.rb diff --git a/spec/features/comments/budget_investments_valuation_spec.rb b/spec/features/comments/budget_investments_valuation_spec.rb new file mode 100644 index 000000000..28b235d30 --- /dev/null +++ b/spec/features/comments/budget_investments_valuation_spec.rb @@ -0,0 +1,300 @@ +require 'rails_helper' + +feature 'Internal valuation comments on Budget::Investments' do + let(:user) { create(:user) } + let(:valuator_user) { create(:valuator).user } + let(:admin_user) { create(:administrator).user } + let(:budget) { create(:budget, :valuating) } + let(:investment) { create(:budget_investment, budget: budget) } + + background do + Setting['feature.budgets'] = true + investment.valuators << valuator_user.valuator + login_as(valuator_user) + end + + after do + Setting['feature.budgets'] = nil + end + + context 'Show valuation comments' do + context 'Show valuation comments without public comments' do + background do + public_comment = create(:comment, commentable: investment, body: 'Public comment') + create(:comment, commentable: investment, author: valuator_user, + body: 'Public valuator comment') + create(:comment, commentable: investment, author: admin_user, parent: public_comment) + + valuator_valuation = create(:comment, :valuation, commentable: investment, + author: valuator_user, + body: 'Valuator Valuation') + create(:comment, :valuation, commentable: investment, author: admin_user, + body: 'Admin Valuation') + admin_response = create(:comment, :valuation, commentable: investment, author: admin_user, + body: 'Admin Valuation response', + parent: valuator_valuation) + create(:comment, :valuation, commentable: investment, author: admin_user, + body: 'Valuator Valuation response', parent: admin_response) + end + + scenario 'Valuation Show page without public comments' do + visit valuation_budget_budget_investment_path(budget, investment) + + expect(page).not_to have_content('Comment as admin') + expect(page).not_to have_content('Public comment') + expect(page).not_to have_content('Public valuator comment') + expect(page).to have_content('Leave your comment') + expect(page).to have_content('Valuator Valuation') + expect(page).to have_content('Admin Valuation') + expect(page).to have_content('Admin Valuation response') + expect(page).to have_content('Valuator Valuation response') + end + + scenario 'Valuation Edit page without public comments' do + visit edit_valuation_budget_budget_investment_path(budget, investment) + + expect(page).not_to have_content('Comment as admin') + expect(page).not_to have_content('Public comment') + expect(page).not_to have_content('Public valuator comment') + expect(page).to have_content('Leave your comment') + expect(page).to have_content('Valuator Valuation') + expect(page).to have_content('Admin Valuation') + expect(page).to have_content('Admin Valuation response') + expect(page).to have_content('Valuator Valuation response') + end + end + + scenario 'Collapsable comments', :js do + parent_comment = create(:comment, :valuation, author: valuator_user, body: "Main comment", + commentable: investment) + child_comment = create(:comment, :valuation, author: valuator_user, body: "First child", + commentable: investment, parent: parent_comment) + grandchild_comment = create(:comment, :valuation, author: valuator_user, parent: child_comment, + body: "Last child", commentable: investment) + + visit valuation_budget_budget_investment_path(budget, investment) + + expect(page).to have_css('.comment', count: 3) + + find("#comment_#{child_comment.id}_children_arrow").trigger('click') + + expect(page).to have_css('.comment', count: 2) + expect(page).not_to have_content grandchild_comment.body + + find("#comment_#{child_comment.id}_children_arrow").trigger('click') + + expect(page).to have_css('.comment', count: 3) + expect(page).to have_content grandchild_comment.body + + find("#comment_#{parent_comment.id}_children_arrow").trigger('click') + + expect(page).to have_css('.comment', count: 1) + expect(page).not_to have_content child_comment.body + expect(page).not_to have_content grandchild_comment.body + end + + scenario 'Comment order' do + create(:comment, :valuation, commentable: investment, + author: valuator_user, + body: 'Valuator Valuation', + created_at: Time.current - 1) + admin_valuation = create(:comment, :valuation, commentable: investment, + author: admin_user, + body: 'Admin Valuation', + created_at: Time.current - 2) + + visit valuation_budget_budget_investment_path(budget, investment) + + expect(admin_valuation.body).to appear_before('Valuator Valuation') + end + + scenario 'Turns links into html links' do + create(:comment, :valuation, author: admin_user, commentable: investment, + body: 'Check http://rubyonrails.org/') + + visit valuation_budget_budget_investment_path(budget, investment) + + within first('.comment') do + expect(page).to have_content('Check http://rubyonrails.org/') + expect(page).to have_link('http://rubyonrails.org/', href: 'http://rubyonrails.org/') + expect(find_link('http://rubyonrails.org/')[:rel]).to eq('nofollow') + expect(find_link('http://rubyonrails.org/')[:target]).to eq('_blank') + end + end + + scenario 'Sanitizes comment body for security' do + comment_with_js = " "\ + "click me http://www.url.com" + create(:comment, :valuation, author: admin_user, commentable: investment, + body: comment_with_js) + + visit valuation_budget_budget_investment_path(budget, investment) + + within first('.comment') do + expect(page).to have_content("click me http://www.url.com") + expect(page).to have_link('http://www.url.com', href: 'http://www.url.com') + expect(page).not_to have_link('click me') + end + end + + scenario 'Paginated comments' do + per_page = 10 + (per_page + 2).times do + create(:comment, :valuation, commentable: investment, author: valuator_user) + end + + visit valuation_budget_budget_investment_path(budget, investment) + + expect(page).to have_css('.comment', count: per_page) + within("ul.pagination") do + expect(page).to have_content("1") + expect(page).to have_content("2") + expect(page).not_to have_content("3") + click_link "Next", exact: false + end + + expect(page).to have_css('.comment', count: 2) + end + end + + context 'Valuation comment creation' do + scenario 'Normal users cannot create valuation comments altering public comments form', :js do + logout + login_as(user) + visit budget_investment_path(investment.budget, investment) + + fill_in "comment-body-budget_investment_#{investment.id}", with: 'HACKERMAN IS HERE' + find(:xpath, "//input[@id='comment_valuation']", visible: false).set('true') + click_button 'Publish comment' + + visit budget_investment_path(investment.budget, investment) + expect(page).not_to have_content('HACKERMAN IS HERE') + + visit valuation_budget_budget_investment_path(budget, investment) + expect(page).not_to have_content('HACKERMAN IS HERE') + end + + scenario 'Create comment', :js do + visit valuation_budget_budget_investment_path(budget, investment) + + fill_in "comment-body-budget_investment_#{investment.id}", with: 'Have you thought about...?' + click_button 'Publish comment' + + within "#comments" do + expect(page).to have_content 'Have you thought about...?' + end + end + + scenario 'Errors on create without comment text', :js do + visit valuation_budget_budget_investment_path(budget, investment) + + click_button 'Publish comment' + + expect(page).to have_content "Can't be blank" + end + + scenario 'Reply to existing comment', :js do + comment = create(:comment, :valuation, author: admin_user, commentable: investment) + + login_as(valuator_user) + visit valuation_budget_budget_investment_path(budget, investment) + + click_link "Reply" + + within "#js-comment-form-comment_#{comment.id}" do + fill_in "comment-body-comment_#{comment.id}", with: 'It will be done next week.' + click_button 'Publish reply' + end + + within "#comment_#{comment.id}" do + expect(page).to have_content 'It will be done next week.' + end + + expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true) + end + + scenario 'Errors on reply without comment text', :js do + comment = create(:comment, :valuation, author: admin_user, commentable: investment) + + visit valuation_budget_budget_investment_path(budget, investment) + + click_link "Reply" + + within "#js-comment-form-comment_#{comment.id}" do + click_button 'Publish reply' + expect(page).to have_content "Can't be blank" + end + + end + + scenario "Multiple nested replies", :js do + parent = create(:comment, :valuation, author: valuator_user, commentable: investment) + + 7.times do + create(:comment, :valuation, author: admin_user, commentable: investment, parent: parent) + parent = parent.children.first + end + + visit valuation_budget_budget_investment_path(budget, investment) + expect(page).to have_css(".comment.comment.comment.comment.comment.comment.comment.comment") + + expect(page).to have_no_css('.comment-votes') + expect(page).to have_no_css('.js-flag-actions') + end + end + + scenario "Erasing a comment's author" do + comment = create(:comment, :valuation, author: valuator_user, commentable: investment, + body: "this should be visible") + comment.user.erase + + visit valuation_budget_budget_investment_path(budget, investment) + within "#comment_#{comment.id}" do + expect(page).to have_content('User deleted') + expect(page).to have_content('this should be visible') + end + end + + feature "Administrators" do + scenario "can create valuation comment as an administrator", :js do + login_as(admin_user) + visit valuation_budget_budget_investment_path(budget, investment) + + fill_in "comment-body-budget_investment_#{investment.id}", with: "I am your Admin!" + check "comment-as-administrator-budget_investment_#{investment.id}" + click_button "Publish comment" + + within "#comments" do + expect(page).to have_content "I am your Admin!" + expect(page).to have_content "Administrator ##{admin_user.administrator.id}" + expect(page).to have_css "div.is-admin" + expect(page).to have_css "img.admin-avatar" + end + end + + scenario "can create valuation reply as an administrator", :js do + comment = create(:comment, :valuation, author: valuator_user, commentable: investment) + + login_as(admin_user) + visit valuation_budget_budget_investment_path(budget, investment) + + click_link "Reply" + + within "#js-comment-form-comment_#{comment.id}" do + fill_in "comment-body-comment_#{comment.id}", with: "Top of the world!" + check "comment-as-administrator-comment_#{comment.id}" + click_button 'Publish reply' + end + + within "#comment_#{comment.id}" do + expect(page).to have_content "Top of the world!" + expect(page).to have_content "Administrator ##{admin_user.administrator.id}" + expect(page).to have_css "div.is-admin" + expect(page).to have_css "img.admin-avatar" + end + + expect(page).not_to have_selector("#js-comment-form-comment_#{comment.id}", visible: true) + end + end + +end From 033c197580a2fdc97d0a0165b8f0341fbb28a41e Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 30 Jan 2018 19:19:26 +0100 Subject: [PATCH 45/46] Disallow comment flagging when showing valuations --- app/views/comments/_actions.html.erb | 8 +++++--- app/views/comments/_comment.html.erb | 9 ++++++--- app/views/comments/_comment_tree.html.erb | 3 ++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/views/comments/_actions.html.erb b/app/views/comments/_actions.html.erb index 80302a70a..2852fa09d 100644 --- a/app/views/comments/_actions.html.erb +++ b/app/views/comments/_actions.html.erb @@ -1,6 +1,8 @@ - - <%= render 'comments/flag_actions', comment: comment %> - +<% if local_assigns.fetch(:allow_flagging, true) %> + + <%= render 'comments/flag_actions', comment: comment %> + +<% end %> <% if can? :hide, comment %> diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index 5de5b6c24..f57876030 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,6 +1,7 @@ <% comment_flags ||= @comment_flags %> <% valuation = local_assigns.fetch(:valuation, false) %> <% allow_votes = local_assigns.fetch(:allow_votes, true) %> +<% allow_flagging = local_assigns.fetch(:allow_flagging, true) %> <% cache [locale_and_user_status(comment), comment, commentable_cache_key(comment.commentable), comment.author, (comment_flags[comment.id] if comment_flags)] do %>
    • @@ -90,7 +91,8 @@ <%= link_to(comment_link_text(comment), "", class: "js-add-comment-link", data: {'id': dom_id(comment)}) %> - <%= render 'comments/actions', comment: comment %> + <%= render 'comments/actions', { comment: comment, + allow_flagging: allow_flagging } %> <%= render 'comments/form', {commentable: comment.commentable, parent_id: comment.id, @@ -106,8 +108,9 @@ <% child_comments_of(comment).each do |child| %>
    • <%= render 'comments/comment', { comment: child, - valuation: valuation } %> - allow_votes: allow_votes } %> + valuation: valuation, + allow_votes: allow_votes, + allow_flagging: allow_flagging } %>
    • <% end %>
    diff --git a/app/views/comments/_comment_tree.html.erb b/app/views/comments/_comment_tree.html.erb index 6b0bdc296..885b500b8 100644 --- a/app/views/comments/_comment_tree.html.erb +++ b/app/views/comments/_comment_tree.html.erb @@ -43,7 +43,8 @@ <%= render 'comments/comment', { comment: comment, comment_flags: comment_flags, valuation: valuation, - allow_votes: !valuation } %> + allow_votes: !valuation, + allow_flagging: !valuation } %> <% end %> <%= paginate comment_tree.root_comments %>
    From 4ec30a908207ca8e779a62577a6d8644fe47fc59 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 31 Jan 2018 01:46:47 +0100 Subject: [PATCH 46/46] Avoid using comments_count counter_cache at Investment As Budget::Investment has two relationships over commentable polymorphic relationship, the counter_cache is counting the sum of both comments and valuations. We don't show valuations count anywhere, only the (public) comments so we just use comments.count in this case --- app/models/budget/investment.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 7129c40dc..f909a9746 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -89,6 +89,10 @@ class Budget before_validation :set_responsible_name before_validation :set_denormalized_ids + def comments_count + comments.count + end + def url budget_investment_path(budget, self) end