From f2927c8eb26b9e1f46b1258f8b6ba85ba63d85ee Mon Sep 17 00:00:00 2001 From: iagirre Date: Thu, 25 Jan 2018 09:25:11 +0100 Subject: [PATCH 01/44] Add alert to the delete button of 'My activity' section so that users don't delete their investmentes accidentally --- app/views/users/_budget_investment.html.erb | 3 ++- config/locales/en/general.yml | 1 + config/locales/es/general.yml | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/users/_budget_investment.html.erb b/app/views/users/_budget_investment.html.erb index 00a1eab20..41e10fb6f 100644 --- a/app/views/users/_budget_investment.html.erb +++ b/app/views/users/_budget_investment.html.erb @@ -5,7 +5,8 @@ <% if can? :destroy, budget_investment %> <%= link_to t('shared.delete'), budget_investment_path(budget_investment.budget, budget_investment), - method: :delete, class: "button hollow alert expanded" %> + method: :delete, class: "button hollow alert expanded", + data: {confirm: "#{t('users.show.delete_alert')}"} %> <% end %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 205db683c..e154d0d20 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -740,6 +740,7 @@ en: no_private_messages: "This user doesn't accept private messages." private_activity: This user decided to keep the activity list private. send_private_message: "Send private message" + delete_alert: "Are you sure you want to delete your investment project? This action can't be undone" proposals: send_notification: "Send notification" retire: "Retire" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 7ac16c170..7882e4088 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -739,6 +739,7 @@ es: no_private_messages: "Este usuario no acepta mensajes privados." private_activity: Este usuario ha decidido mantener en privado su lista de actividades. send_private_message: "Enviar un mensaje privado" + delete_alert: "¿Estás seguro de que deseas borrar tu proyecto de gasto? Esta acción no se puede deshacer" proposals: send_notification: "Enviar notificación" retire: "Retirar" From b3dec1897e42c1625f2c04d518723b2dffcbba47 Mon Sep 17 00:00:00 2001 From: iagirre Date: Thu, 25 Jan 2018 16:44:52 +0100 Subject: [PATCH 02/44] Feature spec to test that the budget_investment is not been deleted if the user dismisses the confirm dialog --- spec/features/users_spec.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index 14615379e..21206f6b5 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -114,6 +114,29 @@ feature 'Users' do end end + scenario "Show alert when user wants to delete a budget investment", :js do + user = create(:user, :level_two) + budget = create(:budget, phase: 'accepting') + budget_investment = create(:budget_investment, author_id: user.id, budget: budget) + + login_as(user) + visit user_path(user) + + expect(page).to have_link budget_investment.title + + within("#budget_investment_#{budget_investment.id}") do + page.driver.browser.dismiss_confirm + click_link 'Delete' + end + expect(page).to have_link budget_investment.title + + within("#budget_investment_#{budget_investment.id}") do + page.driver.browser.accept_confirm + click_link 'Delete' + end + expect(page).not_to have_link budget_investment.title + end + end feature 'Public activity' do From 2e82442dbf00ddc1f33a8967f2da811abc49c51d Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 6 Feb 2018 23:35:30 +0100 Subject: [PATCH 03/44] Update unreleased section of changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 521eec1e7..03b197a01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Deprecated ### Removed ### Fixed +- Improve spec boot time and clean up logs https://github.com/consul/consul/pull/2444 + ### Security ## [0.13.0](https://github.com/consul/consul/compare/v0.12...v0.13) - 2018-02-05 From 9579a751ab181c9edd8c5d78cf47e98db96ef876 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 7 Feb 2018 02:03:17 +0100 Subject: [PATCH 04/44] Improve flaky issue template --- .github/ISSUE_TEMPLATE/flakies.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/flakies.md b/.github/ISSUE_TEMPLATE/flakies.md index e30a0ca84..d7fde88a5 100644 --- a/.github/ISSUE_TEMPLATE/flakies.md +++ b/.github/ISSUE_TEMPLATE/flakies.md @@ -43,3 +43,10 @@ After executing rspec you can see the seed used, add it as an option to rspec, f ### Other things to watch for - Time related issues (current time, two time or date comparisons with miliseconds/time when its not needed) - https://semaphoreci.com/community/tutorials/how-to-deal-with-and-eliminate-flaky-tests + +### Final thoughts +The true objective of this issue is not "to fix" a flaky spec, but to change a spec that randomly fails into one that we can trust when it passes (or fails). + +That means you've to think "What are we testing here?" and "Can we test the same thing in another way?" or "Are we already testing this somewhere else at least partially?". + +Sometimes the fix is to re-write the entire tests with a different approach, or to extend an existing spec. Tests are sometimes written without taking a look at other tests files neither near scenarios. From dac5b7c9a28670530c7906c60d190bf86ef1ea91 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 7 Feb 2018 19:09:30 +0100 Subject: [PATCH 05/44] Adds missing polls button on help page --- app/views/pages/help/_menu.html.erb | 5 +++++ config/locales/en/pages.yml | 1 + config/locales/es/pages.yml | 1 + 3 files changed, 7 insertions(+) diff --git a/app/views/pages/help/_menu.html.erb b/app/views/pages/help/_menu.html.erb index 0a1b7ff85..fdc4d2c13 100644 --- a/app/views/pages/help/_menu.html.erb +++ b/app/views/pages/help/_menu.html.erb @@ -16,6 +16,11 @@ <%= link_to t("pages.help.menu.budgets"), "#budgets", class: "button hollow expanded" %> <% end %> + <% if feature?(:polls) %> +
  • + <%= link_to t("pages.help.menu.polls"), "#polls", class: "button hollow expanded" %> +
  • + <% end %>
  • <%= link_to t("pages.help.menu.other"), "#other", class: "button hollow expanded" %>
  • diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index 3692052d1..349fe705c 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -11,6 +11,7 @@ en: debates: "Debates" proposals: "Proposals" budgets: "Participatory budgets" + polls: "Polls" other: "Other information of interest" debates: title: "Debates" diff --git a/config/locales/es/pages.yml b/config/locales/es/pages.yml index 0667bdfd8..72a114863 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -11,6 +11,7 @@ es: debates: "Debates" proposals: "Propuestas" budgets: "Presupuestos participativos" + polls: "Votaciones" other: "Otra información de interés" debates: title: "Debates" From 80f97b3ca6bad691d7e50b5f5a5273f30bca6a42 Mon Sep 17 00:00:00 2001 From: iagirre Date: Thu, 8 Feb 2018 08:21:59 +0100 Subject: [PATCH 06/44] The flaky test has been modified completely to test the functionality described. JS has been avoided because it was one of the problems involved and it wasn't completely necessary. --- spec/features/emails_spec.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/features/emails_spec.rb b/spec/features/emails_spec.rb index 02892ef18..dd19f2a0b 100644 --- a/spec/features/emails_spec.rb +++ b/spec/features/emails_spec.rb @@ -492,11 +492,15 @@ feature 'Emails' do end context "Users without email" do - scenario "should not receive emails", :js do + scenario "should not receive emails" do user = create(:user, :verified, email_on_comment: true) proposal = create(:proposal, author: user) + + user_commenting = create(:user) + comment = create(:comment, commentable: proposal, user: user_commenting) user.update(email: nil) - comment_on(proposal) + + Mailer.comment(comment).deliver_now expect { open_last_email }.to raise_error "No email has been sent!" end From ae25fdfc15544db3d137bdc057631ba977e2cf7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Fuentes?= Date: Wed, 7 Feb 2018 16:00:05 +0100 Subject: [PATCH 07/44] fix for the flaky --- spec/features/budgets/investments_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index b41d8a712..49af7b870 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -564,12 +564,12 @@ feature 'Budget Investments' do (Kaminari.config.default_per_page * 1.3).to_i.times { create(:budget_investment, heading: heading) } in_browser(:one) do - visit budget_investments_path(budget, heading: heading) + visit budget_investments_path(budget, heading: heading, random_seed: '0.8') @first_user_investments_order = investments_order end in_browser(:two) do - visit budget_investments_path(budget, heading: heading) + visit budget_investments_path(budget, heading: heading, random_seed: '-0.1') @second_user_investments_order = investments_order end From ebebbdf07871ce4cfc0d42dd5b96811b26ecaa7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Fuentes?= Date: Thu, 8 Feb 2018 09:39:18 +0100 Subject: [PATCH 08/44] Added bigger pool for random seeds, now with a 9 * 10e-07 % of chance of appearing, also added test to cover edge cases (case in fact, the coincidence of the seeds it's correct) Conflicts: app/controllers/budgets/investments_controller.rb --- .../budgets/investments_controller.rb | 2 +- spec/features/budgets/investments_spec.rb | 26 ++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 2913ea260..902eaf50f 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -95,7 +95,7 @@ module Budgets def set_random_seed if params[:order] == 'random' || params[:order].blank? - seed = rand(-100..100) / 100.0 + seed = params[:random_seed] || session[:random_seed] || rand(-100000..100000) params[:random_seed] ||= Float(seed) rescue 0 else params[:random_seed] = nil diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index 49af7b870..a606721db 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -560,16 +560,19 @@ feature 'Budget Investments' do expect(current_url).to include('page=1') end - scenario 'Each user as a different and consistent random budget investment order', :js do + scenario 'Each user has a different and consistent random budget investment order when random_seed is disctint', :js do (Kaminari.config.default_per_page * 1.3).to_i.times { create(:budget_investment, heading: heading) } + r1 = 1 + r2 = 2 + in_browser(:one) do - visit budget_investments_path(budget, heading: heading, random_seed: '0.8') + visit budget_investments_path(budget, heading: heading, random_seed: r1) @first_user_investments_order = investments_order end in_browser(:two) do - visit budget_investments_path(budget, heading: heading, random_seed: '-0.1') + visit budget_investments_path(budget, heading: heading, random_seed: r2) @second_user_investments_order = investments_order end @@ -596,6 +599,23 @@ feature 'Budget Investments' do end end + scenario 'Each user has a equal and consistent budget investment order when the random_seed is equal', :js do + (Kaminari.config.default_per_page * 1.3).to_i.times { create(:budget_investment, heading: heading) } + + in_browser(:one) do + visit budget_investments_path(budget, heading: heading, random_seed: '1') + @first_user_investments_order = investments_order + end + + in_browser(:two) do + visit budget_investments_path(budget, heading: heading, random_seed: '1') + @second_user_investments_order = investments_order + end + + expect(@first_user_investments_order).to eq(@second_user_investments_order) + + end + def investments_order all(".budget-investment h3").collect {|i| i.text } end From dbf4ec971695b6b4a9997fb15f02b3e2b55710d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Fuentes?= Date: Thu, 8 Feb 2018 10:17:29 +0100 Subject: [PATCH 09/44] changed test, fixed variable instead os us the let option --- spec/features/comments/legislation_annotations_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/features/comments/legislation_annotations_spec.rb b/spec/features/comments/legislation_annotations_spec.rb index 96161c377..637cf1b1c 100644 --- a/spec/features/comments/legislation_annotations_spec.rb +++ b/spec/features/comments/legislation_annotations_spec.rb @@ -137,7 +137,8 @@ feature 'Commenting legislation questions' do end scenario 'Turns links into html links' do - create :comment, commentable: legislation_annotation, body: 'Built with http://rubyonrails.org/' + legislation_annotation = create :legislation_annotation, author: user + legislation_annotation.comments << create(:comment, body: 'Built with http://rubyonrails.org/') visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, From 31cece096b66e82cbc799e6780e0c1d46d711a6d Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 8 Feb 2018 18:23:29 +0100 Subject: [PATCH 10/44] Verify manager & moderator sample users in dev_seeds --- db/dev_seeds.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index aff3759ee..408180254 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -124,9 +124,15 @@ section "Creating Users" do moderator = create_user('mod@consul.dev', 'mod') moderator.create_moderator + moderator.update(residence_verified_at: Time.current, + confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", + verified_at: Time.current, document_number: unique_document_number) manager = create_user('manager@consul.dev', 'manager') manager.create_manager + manager.update(residence_verified_at: Time.current, + confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", + verified_at: Time.current, document_number: unique_document_number) valuator = create_user('valuator@consul.dev', 'valuator') valuator.create_valuator @@ -154,7 +160,6 @@ section "Creating Users" do document_number: unique_document_number, document_type: "1") verified = create_user('verified@consul.dev', 'verified') - verified.update(residence_verified_at: Time.current, confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1", verified_at: Time.current, document_number: unique_document_number) From 2154a614c230cf8f3223c93c93fd518bd0f1b6c1 Mon Sep 17 00:00:00 2001 From: decabeza Date: Thu, 8 Feb 2018 19:06:41 +0100 Subject: [PATCH 11/44] Adds new legislation processes section on help page --- app/views/pages/help/_menu.html.erb | 5 +++++ app/views/pages/help/_processes.html.erb | 20 ++++++++++++++++++++ app/views/pages/help/index.html.erb | 4 ++++ config/locales/en/pages.yml | 7 +++++++ config/locales/es/pages.yml | 7 +++++++ 5 files changed, 43 insertions(+) create mode 100644 app/views/pages/help/_processes.html.erb diff --git a/app/views/pages/help/_menu.html.erb b/app/views/pages/help/_menu.html.erb index fdc4d2c13..b9e5c3074 100644 --- a/app/views/pages/help/_menu.html.erb +++ b/app/views/pages/help/_menu.html.erb @@ -21,6 +21,11 @@ <%= link_to t("pages.help.menu.polls"), "#polls", class: "button hollow expanded" %> <% end %> + <% if feature?(:legislation) %> +
  • + <%= link_to t("pages.help.menu.processes"), "#processes", class: "button hollow expanded" %> +
  • + <% end %>
  • <%= link_to t("pages.help.menu.other"), "#other", class: "button hollow expanded" %>
  • diff --git a/app/views/pages/help/_processes.html.erb b/app/views/pages/help/_processes.html.erb new file mode 100644 index 000000000..f1be22747 --- /dev/null +++ b/app/views/pages/help/_processes.html.erb @@ -0,0 +1,20 @@ +
    +
    +

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

    + +

    + <% link = link_to(t("pages.help.processes.link"), legislation_processes_path) %> + <%= t("pages.help.processes.description", link: link).html_safe %> +

    +
      +
    • + <% link = link_to(t("pages.help.processes.link"), legislation_processes_path) %> + <% sign_up_link = t("pages.help.processes.sign_up", org: setting['org_name']) %> + <% sign_up = link_to(sign_up_link, new_user_registration_path) %> + <%= t("pages.help.processes.feature", link: link, sign_up: sign_up).html_safe %> +
    • +
    +
    +
    diff --git a/app/views/pages/help/index.html.erb b/app/views/pages/help/index.html.erb index 3ab4ae595..c4ec61d40 100644 --- a/app/views/pages/help/index.html.erb +++ b/app/views/pages/help/index.html.erb @@ -33,6 +33,10 @@ <% if feature?(:polls) %> <%= render "pages/help/polls" %> <% end %> + + <% if feature?(:legislation) %> + <%= render "pages/help/processes" %> + <% end %>
    <%= render "pages/help/sidebar" %> diff --git a/config/locales/en/pages.yml b/config/locales/en/pages.yml index 349fe705c..3c605016f 100644 --- a/config/locales/en/pages.yml +++ b/config/locales/en/pages.yml @@ -13,6 +13,7 @@ en: budgets: "Participatory budgets" polls: "Polls" other: "Other information of interest" + processes: "Processes" debates: title: "Debates" 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." @@ -48,6 +49,12 @@ en: 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." + processes: + title: "Processes" + description: "In the %{link} section, citizens participate in the drafting and modification of regulations affecting the city and can give their opinion on municipal policies in previous debates." + link: "processes" + feature: "To participate in a process you have to %{sign_up} and check the %{link} page periodically to see which regulations and policies are being discussed and consulted." + sign_up: "sign up on %{org}" 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 72a114863..76808faf6 100644 --- a/config/locales/es/pages.yml +++ b/config/locales/es/pages.yml @@ -13,6 +13,7 @@ es: budgets: "Presupuestos participativos" polls: "Votaciones" other: "Otra información de interés" + processes: "Procesos legislativos" debates: title: "Debates" 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." @@ -48,6 +49,12 @@ es: 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 son vinculantes para el gobierno municipal." + processes: + title: "Procesos legislativos" + description: "En la sección de %{link} la ciudadanía participa en la elaboración y modificación de normativa que afecta a la ciudad y puede dar su opinión sobre las políticas municipales en debates previos." + link: "procesos legislativos" + feature: "Para participar en un proceso hay que %{sign_up} y consultar la página de %{link} periódicamente para saber qué normativas y políticas se están debatiendo y consultando." + sign_up: "registrarse en %{org}" faq: title: "¿Problemas técnicos?" description: "Lee las preguntas frecuentes y resuelve tus dudas." From fe071fcf384f898b917219609da557a9ced4c409 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 9 Feb 2018 12:17:08 +0100 Subject: [PATCH 12/44] Update unreleased section of changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03b197a01..48e1f86f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,11 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased](https://github.com/consul/consul/compare/v0.13...consul:master) ### Added +- Missing polls button on help page https://github.com/consul/consul/pull/2452 +- New legislation processes section on help page https://github.com/consul/consul/pull/2452 + ### Changed ### Deprecated ### Removed ### Fixed - Improve spec boot time and clean up logs https://github.com/consul/consul/pull/2444 +- Fix flaky spec: random investments order scenario https://github.com/consul/consul/pull/2454 ### Security From 910d49d18ced027dd637d7bf96db7d0609195ff4 Mon Sep 17 00:00:00 2001 From: Vicente Mendoza Date: Tue, 6 Feb 2018 12:22:46 +0100 Subject: [PATCH 13/44] Focus the search of the button --- spec/features/officing/residence_spec.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spec/features/officing/residence_spec.rb b/spec/features/officing/residence_spec.rb index 69ffd9d21..67f84d6d6 100644 --- a/spec/features/officing/residence_spec.rb +++ b/spec/features/officing/residence_spec.rb @@ -51,7 +51,10 @@ feature 'Residence' do click_link "Validate document" end - click_button 'Validate document' + within("#new_residence") do + click_button "Validate document" + end + expect(page).to have_content(/\d errors? prevented the verification of this document/) end From 207069f7379ef2cf8b2497c54ee6545a3453190a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 9 Feb 2018 13:47:04 +0100 Subject: [PATCH 14/44] Update unreleased section of changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 48e1f86f7..bd3dbcc0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,7 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Removed ### Fixed - Improve spec boot time and clean up logs https://github.com/consul/consul/pull/2444 -- Fix flaky spec: random investments order scenario https://github.com/consul/consul/pull/2454 +- Flaky spec: random investments order scenario https://github.com/consul/consul/pull/2454 ### Security From 0857d3be1f828daf49dc54777dbdcd39771884d3 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 9 Feb 2018 13:47:19 +0100 Subject: [PATCH 15/44] Update unreleased section of changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd3dbcc0a..e3436da11 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Fixed - Improve spec boot time and clean up logs https://github.com/consul/consul/pull/2444 - Flaky spec: random investments order scenario https://github.com/consul/consul/pull/2454 +- Flaky spec: users without email should not receive emails https://github.com/consul/consul/pull/2453 ### Security From 86a174fba083d56d6827113831169be6206995ed Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 9 Feb 2018 13:47:26 +0100 Subject: [PATCH 16/44] Update unreleased section of changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3436da11..0721c89ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Improve spec boot time and clean up logs https://github.com/consul/consul/pull/2444 - Flaky spec: random investments order scenario https://github.com/consul/consul/pull/2454 - Flaky spec: users without email should not receive emails https://github.com/consul/consul/pull/2453 +- Flaky spec: missing comment on legislation annotation https://github.com/consul/consul/pull/2455 ### Security From 90636daf87ac4fd06b5541bb3f38eb811513edd2 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Fri, 9 Feb 2018 13:53:21 +0100 Subject: [PATCH 17/44] Update unreleased section of changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0721c89ff..fe7dbf8bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Flaky spec: random investments order scenario https://github.com/consul/consul/pull/2454 - Flaky spec: users without email should not receive emails https://github.com/consul/consul/pull/2453 - Flaky spec: missing comment on legislation annotation https://github.com/consul/consul/pull/2455 +- Flaky spec: Residence Assigned officers error https://github.com/consul/consul/pull/2458 ### Security From 5b16d395e7c74ed469aa74cbf93b25508303c4ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Fuentes?= Date: Thu, 25 Jan 2018 17:10:39 +0100 Subject: [PATCH 18/44] Added logic to not show invetment links is the budget phase isn't reviewing_ballots or finished --- app/helpers/budgets_helper.rb | 4 ++++ app/views/budgets/index.html.erb | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index 4c73f52da..90e986dad 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -1,5 +1,9 @@ module BudgetsHelper + def show_links_to_budget_investments(budget) + ['reviewing_ballots', 'finished'].include? budget.phase + end + def heading_name_and_price_html(heading, budget) content_tag :div do concat(heading.name + ' ') diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index 810c505ae..dffa56e1d 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -89,14 +89,19 @@

    - <%= link_to budget_investments_path(current_budget.id) do %> - <%= t("budgets.index.investment_proyects") %> - <% end %>
    + <% show_links = show_links_to_budget_investments(current_budget) %> + <% if show_links %> + <%= link_to budget_investments_path(current_budget.id) do %> + <%= t("budgets.index.investment_proyects") %> + <% end %>
    + <% end %> <%= 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 %> - <%= t("budgets.index.not_selected_investment_proyects") %> + <% if show_links %> + <%= link_to budget_investments_path(budget_id: current_budget.id, filter: 'unselected') do %> + <%= t("budgets.index.not_selected_investment_proyects") %> + <% end %> <% end %>

    <% end %> From 6871193cbc6f17d6ee8f63b9d9c2ccc04304f1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Fuentes?= Date: Thu, 25 Jan 2018 17:12:07 +0100 Subject: [PATCH 19/44] Added test to bugets/index to ensure the correcto showing of the investment links over ths changes of the buget's phase --- spec/features/budgets/budgets_spec.rb | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/spec/features/budgets/budgets_spec.rb b/spec/features/budgets/budgets_spec.rb index 71ae6805a..00db07feb 100644 --- a/spec/features/budgets/budgets_spec.rb +++ b/spec/features/budgets/budgets_spec.rb @@ -77,6 +77,46 @@ feature 'Budgets' do expect(page).not_to have_css('div#map') end end + + scenario 'Show investment links only on balloting or later' do + + budget = create(:budget) + group = create(:budget_group, budget: budget) + heading = create(:budget_heading, group: group) + + ['reviewing_ballots', 'finished'].each do |phase| + budget.update(phase: phase) + + visit budgets_path + + expect(page).to have_content(I18n.t("budgets.index.investment_proyects")) + expect(page).to have_content(I18n.t("budgets.index.unfeasible_investment_proyects")) + expect(page).to have_content(I18n.t("budgets.index.not_selected_investment_proyects")) + end + end + + scenario 'Not show investment links earlier of balloting ' do + + budget = create(:budget) + group = create(:budget_group, budget: budget) + heading = create(:budget_heading, group: group) + phases_without_links = ['drafting','informing'] + allowed_phase_list = ['reviewing_ballots', 'finished'] + not_allowed_phase_list = Budget::Phase::PHASE_KINDS - + phases_without_links - + allowed_phase_list + + not_allowed_phase_list.each do |phase| + budget.update(phase: phase) + + visit budgets_path + + expect(page).not_to have_content(I18n.t("budgets.index.investment_proyects")) + expect(page).to have_content(I18n.t("budgets.index.unfeasible_investment_proyects")) + expect(page).not_to have_content(I18n.t("budgets.index.not_selected_investment_proyects")) + end + end + end scenario 'Index shows only published phases' do From ecdbc4a3f7ed9428c8b369f9beba7292f959d4bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20Fuentes?= Date: Fri, 26 Jan 2018 12:06:42 +0100 Subject: [PATCH 20/44] added balloting to the list of phases allowed to see all the links --- app/helpers/budgets_helper.rb | 2 +- spec/features/budgets/budgets_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index 90e986dad..7b48cad1a 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -1,7 +1,7 @@ module BudgetsHelper def show_links_to_budget_investments(budget) - ['reviewing_ballots', 'finished'].include? budget.phase + ['balloting', 'reviewing_ballots', 'finished'].include? budget.phase end def heading_name_and_price_html(heading, budget) diff --git a/spec/features/budgets/budgets_spec.rb b/spec/features/budgets/budgets_spec.rb index 00db07feb..d391dc9be 100644 --- a/spec/features/budgets/budgets_spec.rb +++ b/spec/features/budgets/budgets_spec.rb @@ -4,6 +4,7 @@ feature 'Budgets' do let(:budget) { create(:budget) } let(:level_two_user) { create(:user, :level_two) } + let(:allowed_phase_list) { ['balloting', 'reviewing_ballots', 'finished'] } context 'Index' do @@ -84,7 +85,7 @@ feature 'Budgets' do group = create(:budget_group, budget: budget) heading = create(:budget_heading, group: group) - ['reviewing_ballots', 'finished'].each do |phase| + allowed_phase_list.each do |phase| budget.update(phase: phase) visit budgets_path @@ -101,7 +102,6 @@ feature 'Budgets' do group = create(:budget_group, budget: budget) heading = create(:budget_heading, group: group) phases_without_links = ['drafting','informing'] - allowed_phase_list = ['reviewing_ballots', 'finished'] not_allowed_phase_list = Budget::Phase::PHASE_KINDS - phases_without_links - allowed_phase_list From 13314a1d957254017943e713132c5d8ebdaacc32 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 16:04:40 +0100 Subject: [PATCH 21/44] Update unreleased section of changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe7dbf8bc..26827c51e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - New legislation processes section on help page https://github.com/consul/consul/pull/2452 ### Changed +- Show investment links only on phase balloting or later https://github.com/consul/consul/pull/2386 + ### Deprecated ### Removed ### Fixed From bd10285431c88b3748137cf87b6ef5c699f9d96a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 16:30:07 +0100 Subject: [PATCH 22/44] Fix line length at budget investments helper --- app/helpers/budget_investments_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/helpers/budget_investments_helper.rb b/app/helpers/budget_investments_helper.rb index 72263b83e..01e293c3a 100644 --- a/app/helpers/budget_investments_helper.rb +++ b/app/helpers/budget_investments_helper.rb @@ -1,6 +1,8 @@ module BudgetInvestmentsHelper def budget_investments_sorting_options - Budget::Investment::SORTING_OPTIONS.map { |so| [t("admin.budget_investments.index.sort_by.#{so}"), so] } + Budget::Investment::SORTING_OPTIONS.map do |so| + [t("admin.budget_investments.index.sort_by.#{so}"), so] + end end def budget_investments_advanced_filters(params) From 2341a2f70b8c84bab33b2cefa79f0858ddbcb509 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 16:36:14 +0100 Subject: [PATCH 23/44] Add by_budget scope to Investment and use it --- app/controllers/admin/budget_investments_controller.rb | 2 +- app/helpers/budgets_helper.rb | 2 +- app/models/budget/investment.rb | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/admin/budget_investments_controller.rb b/app/controllers/admin/budget_investments_controller.rb index 2e5c17329..9f885f474 100644 --- a/app/controllers/admin/budget_investments_controller.rb +++ b/app/controllers/admin/budget_investments_controller.rb @@ -101,7 +101,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController end def load_investment - @investment = Budget::Investment.where(budget_id: @budget.id).find(params[:id]) + @investment = Budget::Investment.by_budget(@budget).find(params[:id]) end def load_admins diff --git a/app/helpers/budgets_helper.rb b/app/helpers/budgets_helper.rb index 7b48cad1a..85a727600 100644 --- a/app/helpers/budgets_helper.rb +++ b/app/helpers/budgets_helper.rb @@ -57,7 +57,7 @@ module BudgetsHelper end def investment_tags_select_options(budget) - Budget::Investment.where(budget_id: budget).tags_on(:valuation).order(:name).select(:name).distinct + Budget::Investment.by_budget(budget).tags_on(:valuation).order(:name).select(:name).distinct end def budget_published?(budget) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index bcc354cc8..a95f30f15 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -81,6 +81,7 @@ class Budget scope :by_admin, ->(admin_id) { where(administrator_id: admin_id) } scope :by_tag, ->(tag_name) { tagged_with(tag_name) } scope :by_valuator, ->(valuator_id) { where("budget_valuator_assignments.valuator_id = ?", valuator_id).joins(:valuator_assignments) } + scope :by_budget, ->(budget) { where(budget: budget) } scope :for_render, -> { includes(:heading) } @@ -103,7 +104,7 @@ class Budget def self.scoped_filter(params, current_filter) budget = Budget.find_by(id: params[:budget_id]) || Budget.find_by(slug: params[:budget_id]) - results = Investment.where(budget_id: budget.id) + results = Investment.by_budget(budget) results = limit_results(budget, params, results) if params[:max_per_heading].present? results = results.where(group_id: params[:group_id]) if params[:group_id].present? From 6d9926441eaf920dd12090288342915aa01246c8 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 16:39:27 +0100 Subject: [PATCH 24/44] Reverse investment scoped filter for budget by slug and then id --- app/models/budget/investment.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index a95f30f15..c5d4d775d 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -103,7 +103,7 @@ class Budget end def self.scoped_filter(params, current_filter) - budget = Budget.find_by(id: params[:budget_id]) || Budget.find_by(slug: params[:budget_id]) + budget = Budget.find_by(slug: params[:budget_id]) || Budget.find_by(id: params[:budget_id]) results = Investment.by_budget(budget) results = limit_results(budget, params, results) if params[:max_per_heading].present? From 189fa5ba5065ef5d2044b1029e81c7f0c8c04ea5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 16:42:54 +0100 Subject: [PATCH 25/44] Fixes advanced filters link position --- app/views/admin/budget_investments/_advanced_filters.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/budget_investments/_advanced_filters.html.erb b/app/views/admin/budget_investments/_advanced_filters.html.erb index b9f5a9e6d..017d8e63f 100644 --- a/app/views/admin/budget_investments/_advanced_filters.html.erb +++ b/app/views/admin/budget_investments/_advanced_filters.html.erb @@ -1,6 +1,6 @@ <%= link_to "#advanced_filters_content", data: {toggle: "advanced_filters"}, - class: "advanced-filters float-right" do %> + class: "advanced-filters float-right clear" do %> <%= t("admin.budget_investments.index.advanced_filters") %> <% end %> From 089ccdae7c34f112200de66674d596247665067a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 16:58:00 +0100 Subject: [PATCH 26/44] Fix html alignments --- app/views/moderation/comments/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/moderation/comments/index.html.erb b/app/views/moderation/comments/index.html.erb index fd52d4a66..e391d9e5e 100644 --- a/app/views/moderation/comments/index.html.erb +++ b/app/views/moderation/comments/index.html.erb @@ -26,7 +26,7 @@ <%= t("moderation.comments.index.headers.comment") %> - <%= t("moderation.comments.index.headers.moderate") %> + <%= t("moderation.comments.index.headers.moderate") %> @@ -34,7 +34,7 @@ <%= comment.commentable_type.constantize.model_name.human %> - - <%= link_to comment.commentable.title, commentable_path(comment) %> + <%= link_to comment.commentable.title, commentable_path(comment) %>
    <%= l comment.updated_at.to_date %>  •  From 29157884879ce89112d68e2cbcf1f5ec6febbf96 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 18:20:15 +0100 Subject: [PATCH 27/44] Add budget id to finished budgets list on budget index --- app/views/budgets/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index dffa56e1d..849b00021 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -137,7 +137,7 @@
    -
    +
    <%= link_to t("budgets.index.see_results"), budget_results_path(budget.id), class: "button expanded" %> From 9f47bce7f594de4ddaba83991465585e819f9a46 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 18:22:45 +0100 Subject: [PATCH 28/44] Improve budget index info page with classes --- app/views/budgets/index.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index 849b00021..ff3065b53 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -57,13 +57,13 @@
    -
    +
    <% current_budget.groups.each do |group| %> -

    <%= group.name %>

    +

    <%= group.name %>

      <% group.headings.order_by_group_name.each do |heading| %>
    • From a46e9f756a1c36e850047dccd6f5a2f9428b537f Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 18:23:38 +0100 Subject: [PATCH 29/44] Fix end's indentations at budget index page --- app/views/budgets/index.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/budgets/index.html.erb b/app/views/budgets/index.html.erb index ff3065b53..936d71123 100644 --- a/app/views/budgets/index.html.erb +++ b/app/views/budgets/index.html.erb @@ -44,8 +44,8 @@ sign_up: link_to(t("budgets.investments.index.sidebar.sign_up"), new_user_registration_path)).html_safe %>
    + <% end %> <% end %> - <% end %> <% if current_budget.finished? || (current_budget.balloting? && can?(:read_results, current_budget)) %> From 86a60a8b7c2080e9be2d814bf53fe22fef0e098e Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 19:14:53 +0100 Subject: [PATCH 30/44] Fix space & comma typo --- app/views/legislation/proposals/new.html.erb | 2 +- app/views/proposals/new.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/legislation/proposals/new.html.erb b/app/views/legislation/proposals/new.html.erb index 72051825e..e6da71dba 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 help_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/proposals/new.html.erb b/app/views/proposals/new.html.erb index df48c7754..879820f17 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 help_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 %>
    From 9abbf874f2849c1cc00e6024e93ba15a6ee714bb Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 19:34:30 +0100 Subject: [PATCH 31/44] Enable rubocop-rspec RSpec/InstanceVariable cop --- .rubocop.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0c56b53fc..5f0fd20be 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -102,7 +102,7 @@ RSpec/InstanceSpy: Enabled: true RSpec/InstanceVariable: - Enabled: false + Enabled: true RSpec/InvalidPredicateMatcher: Enabled: true From 9aa6d646d418335d09d61c8e689add352598d8a7 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 19:34:54 +0100 Subject: [PATCH 32/44] Remove usage of instance variables at specs --- .../features/admin/budget_investments_spec.rb | 184 +++++++++--------- 1 file changed, 91 insertions(+), 93 deletions(-) diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index cc2d54c00..18b82cf9e 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -2,11 +2,14 @@ require 'rails_helper' feature 'Admin budget investments' do + let(:budget) { create(:budget) } + let(:administrator) do + create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org')) + end + background do admin = create(:administrator) login_as(admin.user) - - @budget = create(:budget) end context "Feature flag" do @@ -28,8 +31,8 @@ feature 'Admin budget investments' do context "Index" do scenario 'Displaying investments' do - budget_investment = create(:budget_investment, budget: @budget, cached_votes_up: 77) - visit admin_budget_budget_investments_path(budget_id: @budget.id) + budget_investment = create(:budget_investment, budget: budget, cached_votes_up: 77) + visit admin_budget_budget_investments_path(budget_id: budget.id) expect(page).to have_content(budget_investment.title) expect(page).to have_content(budget_investment.heading.name) expect(page).to have_content(budget_investment.id) @@ -52,9 +55,9 @@ feature 'Admin budget investments' do end scenario 'Displaying assignments info' do - budget_investment1 = create(:budget_investment, budget: @budget) - budget_investment2 = create(:budget_investment, budget: @budget) - budget_investment3 = create(:budget_investment, budget: @budget) + budget_investment1 = create(:budget_investment, budget: budget) + budget_investment2 = create(:budget_investment, budget: budget) + budget_investment3 = create(:budget_investment, budget: budget) valuator1 = create(:valuator, user: create(:user, username: 'Olga'), description: 'Valuator Olga') valuator2 = create(:valuator, user: create(:user, username: 'Miriam'), description: 'Valuator Miriam') @@ -64,7 +67,7 @@ feature 'Admin budget investments' do budget_investment2.valuator_ids = [valuator1.id, valuator2.id] budget_investment3.update(administrator_id: admin.id) - visit admin_budget_budget_investments_path(budget_id: @budget.id) + visit admin_budget_budget_investments_path(budget_id: budget.id) within("#budget_investment_#{budget_investment1.id}") do expect(page).to have_content("No admin assigned") @@ -84,18 +87,18 @@ feature 'Admin budget investments' do end scenario "Filtering by budget heading", :js do - group1 = create(:budget_group, name: "Streets", budget: @budget) - group2 = create(:budget_group, name: "Parks", budget: @budget) + group1 = create(:budget_group, name: "Streets", budget: budget) + group2 = create(:budget_group, name: "Parks", budget: budget) group1_heading1 = create(:budget_heading, group: group1, name: "Main Avenue") group1_heading2 = create(:budget_heading, group: group1, name: "Mercy Street") group2_heading1 = create(:budget_heading, group: group2, name: "Central Park") - create(:budget_investment, title: "Realocate visitors", budget: @budget, group: group1, heading: group1_heading1) - create(:budget_investment, title: "Change name", budget: @budget, group: group1, heading: group1_heading2) - create(:budget_investment, title: "Plant trees", budget: @budget, group: group2, heading: group2_heading1) + create(:budget_investment, title: "Realocate visitors", budget: budget, group: group1, heading: group1_heading1) + create(:budget_investment, title: "Change name", budget: budget, group: group1, heading: group1_heading2) + create(:budget_investment, title: "Plant trees", budget: budget, group: group2, heading: group2_heading1) - visit admin_budget_budget_investments_path(budget_id: @budget.id) + visit admin_budget_budget_investments_path(budget_id: budget.id) expect(page).to have_link("Realocate visitors") expect(page).to have_link("Change name") @@ -130,10 +133,10 @@ feature 'Admin budget investments' do user = create(:user, username: 'Admin 1') administrator = create(:administrator, user: user) - create(:budget_investment, title: "Realocate visitors", budget: @budget, administrator: administrator) - create(:budget_investment, title: "Destroy the city", budget: @budget) + create(:budget_investment, title: "Realocate visitors", budget: budget, administrator: administrator) + create(:budget_investment, title: "Destroy the city", budget: budget) - visit admin_budget_budget_investments_path(budget_id: @budget.id) + visit admin_budget_budget_investments_path(budget_id: budget.id) expect(page).to have_link("Realocate visitors") expect(page).to have_link("Destroy the city") @@ -159,12 +162,12 @@ feature 'Admin budget investments' do user = create(:user) valuator = create(:valuator, user: user, description: 'Valuator 1') - budget_investment = create(:budget_investment, title: "Realocate visitors", budget: @budget) + budget_investment = create(:budget_investment, title: "Realocate visitors", budget: budget) budget_investment.valuators << valuator - create(:budget_investment, title: "Destroy the city", budget: @budget) + create(:budget_investment, title: "Destroy the city", budget: budget) - visit admin_budget_budget_investments_path(budget_id: @budget.id) + visit admin_budget_budget_investments_path(budget_id: budget.id) expect(page).to have_link("Realocate visitors") expect(page).to have_link("Destroy the city") @@ -193,13 +196,13 @@ feature 'Admin budget investments' do 'under_valuation' => 'Under valuation', 'valuation_finished' => 'Valuation finished' } - visit admin_budget_budget_investments_path(budget_id: @budget.id) + visit admin_budget_budget_investments_path(budget_id: budget.id) expect(page).not_to have_link(filters_links.values.first) filters_links.keys.drop(1).each { |filter| expect(page).to have_link(filters_links[filter]) } filters_links.each_pair do |current_filter, link| - visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: current_filter) + visit admin_budget_budget_investments_path(budget_id: budget.id, filter: current_filter) expect(page).not_to have_link(link) @@ -210,55 +213,55 @@ feature 'Admin budget investments' do end scenario "Filtering by assignment status" do - assigned = create(:budget_investment, title: "Assigned idea", budget: @budget, administrator: create(:administrator)) - valuating = create(:budget_investment, title: "Evaluating...", budget: @budget) + assigned = create(:budget_investment, title: "Assigned idea", budget: budget, administrator: create(:administrator)) + valuating = create(:budget_investment, title: "Evaluating...", budget: budget) valuating.valuators.push(create(:valuator)) - visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'without_admin') + visit admin_budget_budget_investments_path(budget_id: budget.id, filter: 'without_admin') expect(page).to have_content("Evaluating...") expect(page).not_to have_content("Assigned idea") - visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'without_valuator') + visit admin_budget_budget_investments_path(budget_id: budget.id, filter: 'without_valuator') expect(page).to have_content("Assigned idea") expect(page).not_to have_content("Evaluating...") end scenario "Filtering by valuation status" do - valuating = create(:budget_investment, budget: @budget, title: "Ongoing valuation", administrator: create(:administrator)) - valuated = create(:budget_investment, budget: @budget, title: "Old idea", valuation_finished: true) + valuating = create(:budget_investment, budget: budget, title: "Ongoing valuation", administrator: create(:administrator)) + valuated = create(:budget_investment, budget: budget, title: "Old idea", valuation_finished: true) valuating.valuators.push(create(:valuator)) valuated.valuators.push(create(:valuator)) - visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'under_valuation') + visit admin_budget_budget_investments_path(budget_id: budget.id, filter: 'under_valuation') expect(page).to have_content("Ongoing valuation") expect(page).not_to have_content("Old idea") - visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'valuation_finished') + visit admin_budget_budget_investments_path(budget_id: budget.id, filter: 'valuation_finished') expect(page).not_to have_content("Ongoing valuation") expect(page).to have_content("Old idea") - visit admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'all') + visit admin_budget_budget_investments_path(budget_id: budget.id, filter: 'all') expect(page).to have_content("Ongoing valuation") expect(page).to have_content("Old idea") end scenario "Filtering by tag" do - create(:budget_investment, budget: @budget, title: 'Educate the children', tag_list: 'Education') - create(:budget_investment, budget: @budget, title: 'More schools', tag_list: 'Education') - create(:budget_investment, budget: @budget, title: 'More hospitals', tag_list: 'Health') + create(:budget_investment, budget: budget, title: 'Educate the children', tag_list: 'Education') + create(:budget_investment, budget: budget, title: 'More schools', tag_list: 'Education') + create(:budget_investment, budget: budget, title: 'More hospitals', tag_list: 'Health') - visit admin_budget_budget_investments_path(budget_id: @budget.id) + visit admin_budget_budget_investments_path(budget_id: budget.id) expect(page).to have_css(".budget_investment", count: 3) expect(page).to have_content("Educate the children") expect(page).to have_content("More schools") expect(page).to have_content("More hospitals") - visit admin_budget_budget_investments_path(budget_id: @budget.id, tag_name: 'Education') + visit admin_budget_budget_investments_path(budget_id: budget.id, tag_name: 'Education') expect(page).not_to have_content("More hospitals") expect(page).to have_css(".budget_investment", count: 2) @@ -267,8 +270,8 @@ feature 'Admin budget investments' do end scenario "Filtering by tag, display only valuation tags" do - investment1 = create(:budget_investment, budget: @budget, tag_list: 'Education') - investment2 = create(:budget_investment, budget: @budget, tag_list: 'Health') + investment1 = create(:budget_investment, budget: budget, tag_list: 'Education') + investment2 = create(:budget_investment, budget: budget, tag_list: 'Health') investment1.set_tag_list_on(:valuation, 'Teachers') investment2.set_tag_list_on(:valuation, 'Hospitals') @@ -276,14 +279,14 @@ feature 'Admin budget investments' do investment1.save investment2.save - visit admin_budget_budget_investments_path(budget_id: @budget.id) + visit admin_budget_budget_investments_path(budget_id: budget.id) expect(page).to have_select("tag_name", options: ["All tags", "Hospitals", "Teachers"]) end scenario "Filtering by tag, display only valuation tags of the current budget" do new_budget = create(:budget) - investment1 = create(:budget_investment, budget: @budget, tag_list: 'Roads') + investment1 = create(:budget_investment, budget: budget, tag_list: 'Roads') investment2 = create(:budget_investment, budget: new_budget, tag_list: 'Accessibility') investment1.set_tag_list_on(:valuation, 'Roads') @@ -292,15 +295,15 @@ feature 'Admin budget investments' do investment1.save investment2.save - visit admin_budget_budget_investments_path(budget_id: @budget.id) + visit admin_budget_budget_investments_path(budget_id: budget.id) expect(page).to have_select("tag_name", options: ["All tags", "Roads"]) expect(page).not_to have_select("tag_name", options: ["All tags", "Accessibility"]) end scenario "Limiting by max number of investments per heading", :js do - group_1 = create(:budget_group, budget: @budget) - group_2 = create(:budget_group, budget: @budget) + group_1 = create(:budget_group, budget: budget) + group_2 = create(:budget_group, budget: budget) parks = create(:budget_heading, group: group_1) roads = create(:budget_heading, group: group_2) streets = create(:budget_heading, group: group_2) @@ -317,7 +320,7 @@ feature 'Admin budget investments' do create(:budget_investment, heading: streets, cached_votes_up: n, title: "Street with #{n} supports") end - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) [2, 4, 90, 100, 200, 300].each do |n| expect(page).to have_link("Park with #{n} supports") @@ -357,72 +360,67 @@ feature 'Admin budget investments' do context 'Search' do background do - @budget = create(:budget) - @investment_1 = create(:budget_investment, title: "Some investment", budget: @budget) - @investment_2 = create(:budget_investment, title: "Some other investment", budget: @budget) + create(:budget_investment, title: 'Some investment', budget: budget) + create(:budget_investment, title: 'Some other investment', budget: budget, id: 999999) end scenario "Search investments by title" do - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) - expect(page).to have_content(@investment_1.title) - expect(page).to have_content(@investment_2.title) + expect(page).to have_content('Some investment') + expect(page).to have_content('Some other investment') fill_in 'title_or_id', with: 'Some investment' click_button 'Search' - expect(page).to have_content(@investment_1.title) - expect(page).not_to have_content(@investment_2.title) + expect(page).to have_content('Some investment') + expect(page).not_to have_content('Some other investment') end scenario 'Search investments by ID' do - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) - expect(page).to have_content(@investment_1.title) - expect(page).to have_content(@investment_2.title) + expect(page).to have_content('Some investment') + expect(page).to have_content('Some other investment') - fill_in 'title_or_id', with: @investment_2.id + fill_in 'title_or_id', with: 999999 click_button 'Search' - expect(page).to have_content(@investment_2.title) - expect(page).not_to have_content(@investment_1.title) + expect(page).to have_content('Some other investment') + expect(page).not_to have_content('Some investment') end end context 'Sorting' do background do - @budget = create(:budget) - @investment_1 = create(:budget_investment, title: "BBBB", cached_votes_up: 50, budget: @budget) - @investment_2 = create(:budget_investment, title: "AAAA", cached_votes_up: 25, budget: @budget) - @investment_3 = create(:budget_investment, title: "CCCC", cached_votes_up: 10, budget: @budget) + create(:budget_investment, title: 'B First Investment', cached_votes_up: 50, budget: budget) + create(:budget_investment, title: 'A Second Investment', cached_votes_up: 25, budget: budget) + create(:budget_investment, title: 'C Third Investment', cached_votes_up: 10, budget: budget) end scenario 'Sort by ID' do - visit admin_budget_budget_investments_path(@budget, sort_by: 'id') + visit admin_budget_budget_investments_path(budget, sort_by: 'id') - expect(@investment_1.title).to appear_before(@investment_2.title) - expect(@investment_2.title).to appear_before(@investment_3.title) + expect('B First Investment').to appear_before('A Second Investment') + expect('A Second Investment').to appear_before('C Third Investment') end scenario 'Sort by title' do - visit admin_budget_budget_investments_path(@budget, sort_by: 'title') + visit admin_budget_budget_investments_path(budget, sort_by: 'title') - expect(@investment_2.title).to appear_before(@investment_1.title) - expect(@investment_1.title).to appear_before(@investment_3.title) + expect('A Second Investment').to appear_before('B First Investment') + expect('B First Investment').to appear_before('C Third Investment') end scenario 'Sort by supports' do - visit admin_budget_budget_investments_path(@budget, sort_by: 'supports') + visit admin_budget_budget_investments_path(budget, sort_by: 'supports') - expect(@investment_3.title).to appear_before(@investment_2.title) - expect(@investment_2.title).to appear_before(@investment_1.title) + expect('C Third Investment').to appear_before('A Second Investment') + expect('A Second Investment').to appear_before('B First Investment') end end context 'Show' do - background do - @administrator = create(:administrator, user: create(:user, username: 'Ana', email: 'ana@admins.org')) - end scenario 'Show the investment details' do valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@valuators.org')) @@ -431,7 +429,7 @@ feature 'Admin budget investments' do price_first_year: 1000, feasibility: "unfeasible", unfeasibility_explanation: 'It is impossible', - administrator: @administrator) + administrator: administrator) budget_investment.valuators << valuator visit admin_budget_budget_investments_path(budget_investment.budget) @@ -461,7 +459,7 @@ feature 'Admin budget investments' do finished_budget = create(:budget, :finished) budget_investment = create(:budget_investment, budget: finished_budget, - administrator: @administrator) + administrator: administrator) visit admin_budget_budget_investments_path(budget_investment.budget) click_link budget_investment.title @@ -698,15 +696,15 @@ feature 'Admin budget investments' do context "Selecting" do - let!(:unfeasible_bi) { create(:budget_investment, :unfeasible, budget: @budget, title: "Unfeasible project") } - let!(:feasible_bi) { create(:budget_investment, :feasible, budget: @budget, title: "Feasible project") } - let!(:feasible_vf_bi) { create(:budget_investment, :feasible, :finished, budget: @budget, title: "Feasible, VF project") } - let!(:selected_bi) { create(:budget_investment, :selected, budget: @budget, title: "Selected project") } - let!(:winner_bi) { create(:budget_investment, :winner, budget: @budget, title: "Winner project") } - let!(:undecided_bi) { create(:budget_investment, :undecided, budget: @budget, title: "Undecided project") } + let!(:unfeasible_bi) { create(:budget_investment, :unfeasible, budget: budget, title: "Unfeasible project") } + let!(:feasible_bi) { create(:budget_investment, :feasible, budget: budget, title: "Feasible project") } + let!(:feasible_vf_bi) { create(:budget_investment, :feasible, :finished, budget: budget, title: "Feasible, VF project") } + let!(:selected_bi) { create(:budget_investment, :selected, budget: budget, title: "Selected project") } + let!(:winner_bi) { create(:budget_investment, :winner, budget: budget, title: "Winner project") } + let!(:undecided_bi) { create(:budget_investment, :undecided, budget: budget, title: "Undecided project") } scenario "Filtering by valuation and selection", :js do - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) within('#filter-subnav') { click_link 'Valuation finished' } expect(page).not_to have_content(unfeasible_bi.title) @@ -744,7 +742,7 @@ feature 'Admin budget investments' do end scenario "Aggregating results", :js do - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) click_link 'Advanced filters' within('#advanced_filters') { find(:css, "#advanced_filters_[value='undecided']").set(true) } @@ -769,7 +767,7 @@ feature 'Admin budget investments' do end scenario "Showing the selection buttons", :js do - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) within("#budget_investment_#{unfeasible_bi.id}") do expect(page).not_to have_link('Select') @@ -793,7 +791,7 @@ feature 'Admin budget investments' do end scenario "Selecting an investment", :js do - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) within("#budget_investment_#{feasible_vf_bi.id}") do click_link('Select') @@ -811,7 +809,7 @@ feature 'Admin budget investments' do end scenario "Unselecting an investment", :js do - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) click_link 'Advanced filters' within('#advanced_filters') { find(:css, "#advanced_filters_[value='selected']").set(true) } click_button 'Filter' @@ -825,7 +823,7 @@ feature 'Admin budget investments' do expect(page).not_to have_content(selected_bi.title) expect(page).to have_content('There is 1 investment') - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) within("#budget_investment_#{selected_bi.id}") do expect(page).to have_link('Select') @@ -837,7 +835,7 @@ feature 'Admin budget investments' do context "Selecting csv" do scenario "Downloading CSV file" do - investment = create(:budget_investment, :feasible, budget: @budget, + investment = create(:budget_investment, :feasible, budget: budget, price: 100) valuator = create(:valuator, user: create(:user, username: 'Rachel', email: 'rachel@val.org')) @@ -846,7 +844,7 @@ feature 'Admin budget investments' do admin = create(:administrator, user: create(:user, username: 'Gema')) investment.update(administrator_id: admin.id) - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) click_link "Download current selection" @@ -871,12 +869,12 @@ feature 'Admin budget investments' do end scenario "Downloading CSV file with applied filter" do - investment1 = create(:budget_investment, :unfeasible, budget: @budget, + investment1 = create(:budget_investment, :unfeasible, budget: budget, title: 'compatible') - investment2 = create(:budget_investment, :finished, budget: @budget, + investment2 = create(:budget_investment, :finished, budget: budget, title: 'finished') - visit admin_budget_budget_investments_path(@budget) + visit admin_budget_budget_investments_path(budget) within('#filter-subnav') { click_link 'Valuation finished' } click_link "Download current selection" From b3b28e21d093898f398c816945c944ea51bdd595 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 20:44:02 +0100 Subject: [PATCH 33/44] Fix translation indentation on investments partial --- app/views/admin/budget_investments/_investments.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/budget_investments/_investments.html.erb b/app/views/admin/budget_investments/_investments.html.erb index 72578c33b..4522ce48e 100644 --- a/app/views/admin/budget_investments/_investments.html.erb +++ b/app/views/admin/budget_investments/_investments.html.erb @@ -71,7 +71,7 @@ <%= t("admin.budget_investments.index.feasibility.#{investment.feasibility}", - price: investment.formatted_price) %> + price: investment.formatted_price) %> <%= investment.valuation_finished? ? t("shared.yes"): t("shared.no") %> From 5de51b5f3c73bb224c9a6776b241ab3c3b0a7791 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 20:59:20 +0100 Subject: [PATCH 34/44] Enable rubocop Performance/Caller cop without issues --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 5f0fd20be..ac6d3ec62 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -25,6 +25,9 @@ Metrics/LineLength: Layout/IndentationConsistency: EnforcedStyle: rails +Performance/Caller: + Enabled: true + RSpec/AlignLeftLetBrace: Enabled: false From fc88e1ef7926c626b4639ee9a539e637ac14584d Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 21:03:38 +0100 Subject: [PATCH 35/44] Enable rubocop Bundler cops without issues --- .rubocop.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index ac6d3ec62..bffea1f75 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -25,6 +25,15 @@ Metrics/LineLength: Layout/IndentationConsistency: EnforcedStyle: rails +Bundler/DuplicatedGem: + Enabled: true + +Bundler/InsecureProtocolSource: + Enabled: true + +Bundler/OrderedGems: + Enabled: true + Performance/Caller: Enabled: true From 537e6e175d153c205d6febd2650a57d555161072 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 21:03:50 +0100 Subject: [PATCH 36/44] Enable rubocop Gemspec cops without issues --- .rubocop.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index bffea1f75..d3a52e36c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -34,6 +34,15 @@ Bundler/InsecureProtocolSource: Bundler/OrderedGems: Enabled: true +Gemspec/DuplicatedAssignment: + Enabled: true + +Gemspec/OrderedDependencies: + Enabled: true + +Gemspec/RequiredRubyVersion: + Enabled: true + Performance/Caller: Enabled: true From 45e4222aa567c2d7514306c46553bc004beca897 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 21:08:48 +0100 Subject: [PATCH 37/44] Update rubocop_todo.yml --- .rubocop_todo.yml | 779 +--------------------------------------------- 1 file changed, 15 insertions(+), 764 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 09015e346..f291eb538 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,112 +1,11 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-01-06 19:20:18 +0100 using RuboCop version 0.52.1. +# on 2018-02-10 21:08:01 +0100 using RuboCop version 0.52.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. -# Offense count: 40 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. -# SupportedHashRocketStyles: key, separator, table -# SupportedColonStyles: key, separator, table -# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit -Layout/AlignHash: - Exclude: - - 'spec/controllers/legislation/annotations_controller_spec.rb' - - 'spec/features/admin/banners_spec.rb' - -# Offense count: 64 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: with_first_parameter, with_fixed_indentation -Layout/AlignParameters: - Enabled: false - -# Offense count: 11 -# Cop supports --auto-correct. -Layout/ClosingParenthesisIndentation: - Exclude: - - 'spec/features/site_customization/custom_pages_spec.rb' - - 'spec/models/legislation/annotation_spec.rb' - - 'spec/rails_helper.rb' - -# Offense count: 37 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: leading, trailing -Layout/DotPosition: - Exclude: - - 'app/controllers/admin/poll/officer_assignments_controller.rb' - - 'app/controllers/admin/poll/polls_controller.rb' - - 'app/controllers/admin/poll/recounts_controller.rb' - - 'app/controllers/officing/residence_controller.rb' - - 'app/controllers/officing/results_controller.rb' - - 'app/models/poll/officer.rb' - - 'app/models/tag_cloud.rb' - - 'app/models/verification/management/managed_user.rb' - - 'lib/merged_comment_tree.rb' - -# Offense count: 8 -# Cop supports --auto-correct. -Layout/EmptyLineAfterMagicComment: - Exclude: - - 'bin/rspec' - - 'bin/spring' - - 'spec/features/debates_spec.rb' - - 'spec/features/proposal_ballots_spec.rb' - - 'spec/features/proposals_spec.rb' - - 'spec/mailers/devise_mailer_spec.rb' - - 'spec/models/debate_spec.rb' - - 'spec/models/proposal_spec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundMethodBody: - Exclude: - - 'lib/graph_ql/api_types_creator.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Exclude: - - 'spec/factories.rb' - - 'spec/models/proposal_spec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: consistent, special_for_inner_method_call, special_for_inner_method_call_in_parentheses -Layout/FirstParameterIndentation: - Exclude: - - 'app/controllers/users_controller.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_brackets -Layout/IndentArray: - EnforcedStyle: consistent - -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: special_inside_parentheses, consistent, align_braces -Layout/IndentHash: - Exclude: - - 'spec/controllers/legislation/annotations_controller_spec.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: auto_detection, squiggly, active_support, powerpack, unindent -Layout/IndentHeredoc: - Exclude: - - 'spec/factories.rb' - - 'spec/models/legislation/draft_version_spec.rb' - # Offense count: 10 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. @@ -118,673 +17,13 @@ Layout/IndentationConsistency: - 'spec/models/legislation/draft_version_spec.rb' - 'spec/models/proposal_spec.rb' -# Offense count: 59 -# Cop supports --auto-correct. -# Configuration parameters: Width, IgnoredPatterns. -Layout/IndentationWidth: - Enabled: false - -# Offense count: 6 -# Cop supports --auto-correct. -Layout/LeadingCommentSpace: - Exclude: - - 'Capfile' - - 'app/controllers/budgets/ballot/lines_controller.rb' - - 'spec/features/budgets/ballots_spec.rb' - - 'spec/features/comments/poll_questions_spec.rb' - - 'spec/support/common_actions.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineArrayBraceLayout: - Exclude: - - 'app/controllers/valuation/budget_investments_controller.rb' - - 'app/controllers/valuation/spending_proposals_controller.rb' - - 'app/helpers/search_helper.rb' - -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineHashBraceLayout: - Exclude: - - 'app/controllers/valuation/budget_investments_controller.rb' - - 'app/controllers/valuation/spending_proposals_controller.rb' - - 'app/models/budget/investment.rb' - - 'app/models/debate.rb' - - 'app/models/proposal.rb' - - 'app/models/spending_proposal.rb' - -# Offense count: 17 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: symmetrical, new_line, same_line -Layout/MultilineMethodCallBraceLayout: - Exclude: - - 'app/controllers/legislation/annotations_controller.rb' - - 'app/controllers/users_controller.rb' - - 'app/models/comment.rb' - - 'app/models/organization.rb' - - 'app/models/user.rb' - - 'spec/features/site_customization/custom_pages_spec.rb' - - 'spec/models/legislation/annotation_spec.rb' - - 'spec/rails_helper.rb' - -# Offense count: 59 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented, indented_relative_to_receiver -Layout/MultilineMethodCallIndentation: - Exclude: - - 'app/controllers/admin/poll/officer_assignments_controller.rb' - - 'app/controllers/admin/poll/polls_controller.rb' - - 'app/controllers/admin/poll/recounts_controller.rb' - - 'app/controllers/officing/residence_controller.rb' - - 'app/controllers/officing/results_controller.rb' - - 'app/models/poll/officer.rb' - - 'app/models/tag_cloud.rb' - - 'app/models/verification/management/managed_user.rb' - - 'lib/merged_comment_tree.rb' - - 'spec/models/comment_spec.rb' - - 'spec/models/debate_spec.rb' - - 'spec/models/proposal_spec.rb' - - 'spec/models/user_spec.rb' - -# Offense count: 5 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, IndentationWidth. -# SupportedStyles: aligned, indented -Layout/MultilineOperationIndentation: - Exclude: - - 'app/helpers/users_helper.rb' - - 'app/helpers/valuation_helper.rb' - - 'app/models/user.rb' - - 'app/models/verification/letter.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Layout/SpaceAfterColon: - Exclude: - - 'spec/features/admin/site_customization/pages_spec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Exclude: - - 'spec/factories.rb' - -# Offense count: 33 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBrackets: space, no_space -Layout/SpaceInsideArrayLiteralBrackets: - Exclude: - - 'app/controllers/valuation/budget_investments_controller.rb' - - 'app/controllers/valuation/spending_proposals_controller.rb' - - 'app/helpers/admin_helper.rb' - - 'app/helpers/budgets_helper.rb' - - 'app/helpers/geozones_helper.rb' - - 'app/helpers/proposals_helper.rb' - - 'app/helpers/valuation_helper.rb' - - 'app/models/budget/investment.rb' - - 'app/models/budget/investment/milestone.rb' - - 'app/models/legislation/process.rb' - - 'app/models/legislation/proposal.rb' - - 'app/models/poll/question/answer.rb' - - 'app/models/proposal.rb' - - 'spec/factories.rb' - - 'spec/lib/graphql_spec.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Layout/SpaceInsideRangeLiteral: - Exclude: - - 'app/models/legislation/annotation.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceInsideReferenceBrackets: - Exclude: - - 'app/helpers/settings_helper.rb' - -# Offense count: 39 -Lint/AmbiguousBlockAssociation: - Exclude: - - 'spec/controllers/comments_controller_spec.rb' - - 'spec/controllers/debates_controller_spec.rb' - - 'spec/controllers/legislation/annotations_controller_spec.rb' - - 'spec/controllers/legislation/answers_controller_spec.rb' - - 'spec/lib/cache_spec.rb' - - 'spec/models/comment_spec.rb' - - 'spec/models/debate_spec.rb' - - 'spec/models/proposal_spec.rb' - - 'spec/models/user_spec.rb' - - 'spec/shared/models/map_validations.rb' - -# Offense count: 3 -Lint/DuplicateMethods: - Exclude: - - 'app/models/budget/result.rb' - - 'lib/comment_tree.rb' - - 'lib/email_digest.rb' - -# Offense count: 2 -Lint/HandleExceptions: - Exclude: - - 'app/controllers/legislation/annotations_controller.rb' - - 'spec/lib/graphql_spec.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: runtime_error, standard_error -Lint/InheritException: - Exclude: - - 'app/controllers/concerns/feature_flags.rb' - -# Offense count: 1 -Lint/LiteralAsCondition: - Exclude: - - 'app/models/budget/investment.rb' - -# Offense count: 3 -# Cop supports --auto-correct. -Lint/StringConversionInInterpolation: - Exclude: - - 'app/models/poll/partial_result.rb' - -# Offense count: 15 -# Cop supports --auto-correct. -# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. -Lint/UnusedBlockArgument: - Exclude: - - 'app/controllers/admin/spending_proposals_controller.rb' - - 'app/models/ahoy/data_source.rb' - - 'lib/graph_ql/api_types_creator.rb' - - 'lib/graph_ql/query_type_creator.rb' - - 'spec/controllers/concerns/has_orders_spec.rb' - - 'spec/factories.rb' - - 'spec/spec_helper.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods. -Lint/UnusedMethodArgument: - Exclude: - - 'app/controllers/organizations/registrations_controller.rb' - - 'app/controllers/users/registrations_controller.rb' - - 'app/mailers/mailer.rb' - - 'app/models/abilities/everyone.rb' - -# Offense count: 335 -Lint/UselessAssignment: - Enabled: false - -# Offense count: 2 -Lint/Void: - Exclude: - - 'app/controllers/polls_controller.rb' - - 'app/models/setting.rb' - -# Offense count: 86 -Metrics/AbcSize: - Max: 77 - -# Offense count: 513 -# Configuration parameters: CountComments, ExcludedMethods. -Metrics/BlockLength: - Max: 1242 - -# Offense count: 11 -# Configuration parameters: CountComments. -Metrics/ClassLength: - Max: 266 - -# Offense count: 13 -Metrics/CyclomaticComplexity: - Max: 10 - -# Offense count: 25 +# Offense count: 1225 # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. # URISchemes: http, https Metrics/LineLength: Max: 248 -# Offense count: 71 -# Configuration parameters: CountComments. -Metrics/MethodLength: - Max: 68 - -# Offense count: 1 -# Configuration parameters: CountComments. -Metrics/ModuleLength: - Max: 273 - -# Offense count: 3 -# Configuration parameters: CountKeywordArgs. -Metrics/ParameterLists: - Max: 7 - -# Offense count: 8 -Metrics/PerceivedComplexity: - Max: 11 - -# Offense count: 10 -Naming/AccessorMethodName: - Exclude: - - 'app/controllers/application_controller.rb' - - 'app/controllers/concerns/commentable_actions.rb' - - 'app/controllers/management/proposals_controller.rb' - - 'app/controllers/management/spending_proposals_controller.rb' - - 'app/controllers/proposals_controller.rb' - - 'lib/merged_comment_tree.rb' - -# Offense count: 2 -# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. -# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS -Naming/FileName: - Exclude: - - 'Capfile' - - 'Gemfile' - -# Offense count: 10 -# Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist, MethodDefinitionMacros. -# NamePrefix: is_, has_, have_ -# NamePrefixBlacklist: is_, has_, have_ -# NameWhitelist: is_a? -# MethodDefinitionMacros: define_method, define_singleton_method -Naming/PredicateName: - Exclude: - - 'spec/**/*' - - 'app/controllers/concerns/has_filters.rb' - - 'app/controllers/concerns/has_orders.rb' - - 'app/helpers/banners_helper.rb' - - 'app/helpers/debates_helper.rb' - - 'app/models/budget/ballot.rb' - - 'app/models/user.rb' - -# Offense count: 95 -# Configuration parameters: EnforcedStyle. -# SupportedStyles: snake_case, normalcase, non_integer -Naming/VariableNumber: - Enabled: false - -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect. -Performance/HashEachMethods: - Exclude: - - 'app/models/ahoy/data_source.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -Performance/RedundantMatch: - Exclude: - - 'app/controllers/valuation/budget_investments_controller.rb' - - 'app/controllers/valuation/spending_proposals_controller.rb' - - 'app/helpers/embed_videos_helper.rb' - -# Offense count: 18 -# Cop supports --auto-correct. -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/FindBy: - Exclude: - - 'app/models/budget/ballot.rb' - - 'app/models/concerns/relationable.rb' - - 'app/models/geozone.rb' - - 'app/models/legislation/question.rb' - - 'app/models/officing/residence.rb' - - 'app/models/poll/booth.rb' - - 'app/models/poll/voter.rb' - - 'app/models/setting.rb' - - 'app/models/signature.rb' - - 'app/models/user.rb' - - 'app/models/verification/email.rb' - - 'app/models/verification/management/email.rb' - - 'app/models/verification/residence.rb' - -# Offense count: 1 -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/HasAndBelongsToMany: - Exclude: - - 'app/models/poll.rb' - -# Offense count: 52 -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/HasManyOrHasOneDependent: - Enabled: false - -# Offense count: 37 -# Cop supports --auto-correct. -# Configuration parameters: Include. -# Include: spec/**/*, test/**/* -Rails/HttpPositionalArguments: - Exclude: - - 'spec/controllers/admin/api/stats_controller_spec.rb' - - 'spec/controllers/concerns/has_filters_spec.rb' - - 'spec/controllers/concerns/has_orders_spec.rb' - - 'spec/controllers/debates_controller_spec.rb' - - 'spec/controllers/graphql_controller_spec.rb' - - 'spec/controllers/legislation/annotations_controller_spec.rb' - - 'spec/controllers/legislation/answers_controller_spec.rb' - - 'spec/controllers/management/sessions_controller_spec.rb' - - 'spec/controllers/pages_controller_spec.rb' - - 'spec/controllers/users/registrations_controller_spec.rb' - -# Offense count: 71 -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/InverseOf: - Enabled: false - -# Offense count: 28 -# Configuration parameters: Include. -# Include: app/controllers/**/*.rb -Rails/LexicallyScopedActionFilter: - Exclude: - - 'app/controllers/admin/banners_controller.rb' - - 'app/controllers/admin/poll/officer_assignments_controller.rb' - - 'app/controllers/admin/poll/polls_controller.rb' - - 'app/controllers/admin/tags_controller.rb' - - 'app/controllers/concerns/search.rb' - - 'app/controllers/debates_controller.rb' - - 'app/controllers/legislation/proposals_controller.rb' - - 'app/controllers/management/proposals_controller.rb' - - 'app/controllers/moderation/comments_controller.rb' - - 'app/controllers/moderation/debates_controller.rb' - - 'app/controllers/moderation/proposals_controller.rb' - - 'app/controllers/proposals_controller.rb' - - 'app/controllers/users/registrations_controller.rb' - - 'app/controllers/valuation/budget_investments_controller.rb' - - 'app/controllers/valuation/spending_proposals_controller.rb' - -# Offense count: 19 -Rails/OutputSafety: - Exclude: - - 'app/controllers/admin/legislation/draft_versions_controller.rb' - - 'app/controllers/admin/legislation/processes_controller.rb' - - 'app/controllers/admin/legislation/questions_controller.rb' - - 'app/controllers/budgets/investments_controller.rb' - - 'app/controllers/direct_uploads_controller.rb' - - 'app/controllers/spending_proposals_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/helpers/documents_helper.rb' - - 'app/helpers/text_with_links_helper.rb' - - 'app/helpers/valuation_helper.rb' - -# Offense count: 7 -# Cop supports --auto-correct. -Rails/Presence: - Exclude: - - 'app/controllers/concerns/commentable_actions.rb' - - 'app/controllers/users/sessions_controller.rb' - - 'app/helpers/welcome_helper.rb' - - 'app/models/legislation/proposal.rb' - - 'app/models/proposal.rb' - - 'app/models/valuator.rb' - -# Offense count: 72 -# Configuration parameters: Blacklist. -# Blacklist: decrement!, decrement_counter, increment!, increment_counter, toggle!, touch, update_all, update_attribute, update_column, update_columns, update_counters -Rails/SkipsModelValidations: - Enabled: false - -# Offense count: 4 -# Configuration parameters: Environments. -# Environments: development, test, production -Rails/UnknownEnv: - Exclude: - - 'lib/census_api.rb' - - 'lib/sms_api.rb' - -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: braces, no_braces, context_dependent -Style/BracesAroundHashParameters: - Exclude: - - 'app/models/concerns/searchable.rb' - - 'spec/features/budgets/investments_spec.rb' - - 'spec/features/proposals_spec.rb' - -# Offense count: 126 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. -# SupportedStyles: nested, compact -Style/ClassAndModuleChildren: - Enabled: false - -# Offense count: 5 -Style/ClassVars: - Exclude: - - 'app/models/concerns/measurable.rb' - - 'app/models/organization.rb' - - 'app/models/user.rb' - -# Offense count: 8 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. -# SupportedStyles: assign_to_condition, assign_inside_condition -Style/ConditionalAssignment: - Exclude: - - 'app/controllers/admin/poll/booth_assignments_controller.rb' - - 'app/controllers/admin/poll/questions_controller.rb' - - 'app/controllers/comments_controller.rb' - - 'app/controllers/management/spending_proposals_controller.rb' - - 'app/controllers/spending_proposals_controller.rb' - - 'app/controllers/verification/sms_controller.rb' - - 'lib/graph_ql/api_types_creator.rb' - -# Offense count: 19 -Style/DateTime: - Exclude: - - 'app/models/user.rb' - - 'spec/controllers/admin/api/stats_controller_spec.rb' - - 'spec/factories.rb' - - 'spec/features/admin/banners_spec.rb' - - 'spec/models/ahoy/data_source_spec.rb' - -# Offense count: 1 -Style/DoubleNegation: - Exclude: - - 'app/models/flag.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -Style/Encoding: - Exclude: - - 'spec/features/debates_spec.rb' - - 'spec/features/proposal_ballots_spec.rb' - - 'spec/features/proposals_spec.rb' - - 'spec/mailers/devise_mailer_spec.rb' - - 'spec/models/debate_spec.rb' - - 'spec/models/proposal_spec.rb' - -# Offense count: 61 -# Configuration parameters: MinBodyLength. -Style/GuardClause: - Enabled: false - -# Offense count: 49 -# Cop supports --auto-correct. -Style/IfUnlessModifier: - Enabled: false - -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: line_count_dependent, lambda, literal -Style/Lambda: - Exclude: - - 'app/models/comment.rb' - - 'app/models/concerns/followable.rb' - - 'app/models/direct_message.rb' - - 'lib/graph_ql/api_types_creator.rb' - -# Offense count: 10 -Style/MixinUsage: - Exclude: - - 'lib/census_api.rb' - - 'lib/local_census.rb' - - 'spec/features/comments/budget_investments_spec.rb' - - 'spec/features/comments/debates_spec.rb' - - 'spec/features/comments/legislation_annotations_spec.rb' - - 'spec/features/comments/legislation_questions_spec.rb' - - 'spec/features/comments/polls_spec.rb' - - 'spec/features/comments/proposals_spec.rb' - - 'spec/features/comments/topics_spec.rb' - - 'spec/rails_helper.rb' - -# Offense count: 1 -Style/MultilineBlockChain: - Exclude: - - 'app/controllers/valuation/spending_proposals_controller.rb' - -# Offense count: 1 -# Cop supports --auto-correct. -Style/MultilineIfThen: - Exclude: - - 'app/controllers/management/users_controller.rb' - -# Offense count: 13 -# Cop supports --auto-correct. -Style/MutableConstant: - Exclude: - - 'app/models/activity.rb' - - 'app/models/budget/reclassified_vote.rb' - - 'app/models/legislation/draft_version.rb' - - 'app/models/poll/partial_result.rb' - - 'app/models/proposal.rb' - - 'app/models/signature_sheet.rb' - - 'app/models/site_customization/content_block.rb' - - 'app/models/site_customization/image.rb' - - 'app/models/site_customization/page.rb' - - 'lib/graph_ql/api_types_creator.rb' - - 'lib/tag_sanitizer.rb' - - 'lib/wysiwyg_sanitizer.rb' - -# Offense count: 54 -# Cop supports --auto-correct. -# Configuration parameters: Strict. -Style/NumericLiterals: - MinDigits: 9 - -# Offense count: 20 -# Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. -# SupportedStyles: predicate, comparison -Style/NumericPredicate: - Exclude: - - 'spec/**/*' - - 'app/controllers/users_controller.rb' - - 'app/controllers/valuation/spending_proposals_controller.rb' - - 'app/helpers/banners_helper.rb' - - 'app/helpers/debates_helper.rb' - - 'app/helpers/votes_helper.rb' - - 'app/models/budget/ballot.rb' - - 'app/models/concerns/conflictable.rb' - - 'app/models/concerns/taggable.rb' - - 'app/models/debate.rb' - - 'app/models/lock.rb' - - 'app/models/user.rb' - - 'app/models/verification/management/email.rb' - - 'lib/score_calculator.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Style/ParallelAssignment: - Exclude: - - 'lib/active_model/dates.rb' - - 'spec/support/common_actions.rb' - -# Offense count: 4 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: compact, exploded -Style/RaiseArgs: - Exclude: - - 'app/controllers/management/base_controller.rb' - - 'app/controllers/users/omniauth_callbacks_controller.rb' - - 'app/controllers/valuation/budget_investments_controller.rb' - - 'app/controllers/valuation/spending_proposals_controller.rb' - -# Offense count: 2 -# Cop supports --auto-correct. -Style/RedundantBegin: - Exclude: - - 'app/controllers/graphql_controller.rb' - - 'app/models/legislation/annotation.rb' - -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, AllowInnerSlashes. -# SupportedStyles: slashes, percent_r, mixed -Style/RegexpLiteral: - Exclude: - - 'app/controllers/related_contents_controller.rb' - - 'app/helpers/embed_videos_helper.rb' - - 'app/models/poll/question/answer/video.rb' - - 'spec/customization_engine_spec.rb' - -# Offense count: 6 -# Cop supports --auto-correct. -Style/RescueModifier: - Exclude: - - 'app/controllers/budgets/investments_controller.rb' - - 'app/controllers/concerns/search.rb' - - 'app/controllers/verification/sms_controller.rb' - - 'app/models/concerns/measurable.rb' - # Offense count: 11 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: implicit, explicit -Style/RescueStandardError: - Exclude: - - 'app/controllers/graphql_controller.rb' - - 'app/controllers/related_contents_controller.rb' - - 'app/helpers/locales_helper.rb' - - 'app/models/legislation/annotation.rb' - - 'lib/local_census.rb' - - 'lib/manager_authenticator.rb' - - 'lib/tasks/emails.rake' - - 'spec/shared/features/nested_documentable.rb' - - 'spec/shared/features/nested_imageable.rb' - -# Offense count: 15 -# Cop supports --auto-correct. -# Configuration parameters: ConvertCodeThatCanStartToReturnNil. -Style/SafeNavigation: - Exclude: - - 'app/controllers/legislation/draft_versions_controller.rb' - - 'app/controllers/sandbox_controller.rb' - - 'app/controllers/verification/letter_controller.rb' - - 'app/helpers/users_helper.rb' - - 'app/models/concerns/galleryable.rb' - - 'app/models/concerns/imageable.rb' - - 'app/models/legislation/proposal.rb' - - 'app/models/proposal.rb' - - 'app/models/signature.rb' - - 'app/models/user.rb' - -# Offense count: 31 -# Cop supports --auto-correct. -# Configuration parameters: WordRegex. -# SupportedStyles: percent, brackets -Style/WordArray: - EnforcedStyle: percent - MinSize: 8 - -# Offense count: 10 RSpec/DescribeClass: Exclude: - 'spec/customization_engine_spec.rb' @@ -794,6 +33,7 @@ RSpec/DescribeClass: - 'spec/lib/graphql_spec.rb' - 'spec/lib/tasks/communities_spec.rb' - 'spec/lib/tasks/dev_seed_spec.rb' + - 'spec/lib/tasks/map_location_spec.rb' - 'spec/lib/tasks/settings_spec.rb' - 'spec/models/abilities/organization_spec.rb' - 'spec/views/welcome/index.html.erb_spec.rb' @@ -806,8 +46,19 @@ RSpec/DescribedClass: - 'spec/controllers/concerns/has_filters_spec.rb' - 'spec/controllers/concerns/has_orders_spec.rb' +# Offense count: 6 +RSpec/ExpectActual: + Exclude: + - 'spec/routing/**/*' + - 'spec/features/admin/budget_investments_spec.rb' + +# Offense count: 830 +# Configuration parameters: AssignmentOnly. +RSpec/InstanceVariable: + Enabled: false + # Offense count: 1 # Configuration parameters: IgnoreSymbolicNames. RSpec/VerifiedDoubles: Exclude: - - 'spec/models/verification/management/email_spec.rb' \ No newline at end of file + - 'spec/models/verification/management/email_spec.rb' From a419b36ff378decc22ab6f1140555e2f1ca2dc54 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 21:13:03 +0100 Subject: [PATCH 38/44] Enable rubocop Security cops without issues --- .rubocop.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index d3a52e36c..65af3b3af 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -206,4 +206,16 @@ RSpec/VerifiedDoubles: Enabled: true RSpec/VoidExpect: - Enabled: true \ No newline at end of file + Enabled: true + +Security/Eval: + Enabled: true + +Security/JSONLoad: + Enabled: true + +Security/MarshalLoad: + Enabled: true + +Security/YAMLLoad: + Enabled: true From 307fe18c5927c4b4788e5b0231b8eadd341aec5e Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 21:17:56 +0100 Subject: [PATCH 39/44] Enable rubocop Performance cops without issues --- .rubocop.yml | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 65af3b3af..340b672f4 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -46,6 +46,75 @@ Gemspec/RequiredRubyVersion: Performance/Caller: Enabled: true +Performance/CaseWhenSplat: + Enabled: true + +Performance/Casecmp: + Enabled: true + +Performance/CompareWithBlock: + Enabled: true + +Performance/Count: + Enabled: true + +Performance/Detect: + Enabled: true + +Performance/DoubleStartEndWith: + Enabled: true + +Performance/EndWith: + Enabled: true + +Performance/FixedSize: + Enabled: true + +Performance/FlatMap: + Enabled: true + +Performance/LstripRstrip: + Enabled: true + +Performance/RangeInclude: + Enabled: true + +Performance/RedundantBlockCall: + Enabled: true + +Performance/RedundantMerge: + Enabled: true + +Performance/RedundantSortBy: + Enabled: true + +Performance/RegexpMatch: + Enabled: true + +Performance/ReverseEach: + Enabled: true + +Performance/Sample: + Enabled: true + +Performance/Size: + Enabled: true + +Performance/StartWith: + Enabled: true + +Performance/StringReplacement: + Enabled: true + +Performance/TimesMap: + Enabled: true + +Performance/UnfreezeString: + Enabled: true + +Performance/UriDefaultParser: + Enabled: true + RSpec/AlignLeftLetBrace: Enabled: false From 57743df197b99ef8f7080a13dbb2999a84972be2 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 21:22:47 +0100 Subject: [PATCH 40/44] Enable rubocop Performance/HashEachMethods cop & fix issues --- .rubocop.yml | 3 +++ app/models/ahoy/data_source.rb | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 340b672f4..00acb14ea 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -73,6 +73,9 @@ Performance/FixedSize: Performance/FlatMap: Enabled: true +Performance/HashEachMethods: + Enabled: true + Performance/LstripRstrip: Enabled: true diff --git a/app/models/ahoy/data_source.rb b/app/models/ahoy/data_source.rb index 9195d0ff1..ba8a2cf14 100644 --- a/app/models/ahoy/data_source.rb +++ b/app/models/ahoy/data_source.rb @@ -10,12 +10,12 @@ module Ahoy # chart def add(name, collection) collections.push data: collection, name: name - collection.each{ |k, v| add_key k } + collection.each_key{ |key| add_key key } end def build data = { x: [] } - keys.each do |k| + shared_keys.each do |k| # Add the key with a valid date format data[:x].push k.strftime("%Y-%m-%d") @@ -36,12 +36,12 @@ module Ahoy @collections ||= [] end - def keys - @keys ||= [] + def shared_keys + @shared_keys ||= [] end def add_key(key) - keys.push(key) unless keys.include? key + shared_keys.push(key) unless shared_keys.include? key end end From 3f91e920f652f40337d8d3bb1d8f9b8a04bccf10 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 21:26:02 +0100 Subject: [PATCH 41/44] Enable rubocop Performance/RedundantMatch cop & fix issues Some cop offenses have been stashed into rubocop_todo.yml for now --- .rubocop.yml | 3 +++ .rubocop_todo.yml | 9 ++++++++- app/helpers/embed_videos_helper.rb | 4 ++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 00acb14ea..0cf7bafb6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -85,6 +85,9 @@ Performance/RangeInclude: Performance/RedundantBlockCall: Enabled: true +Performance/RedundantMatch: + Enabled: true + Performance/RedundantMerge: Enabled: true diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index f291eb538..f3a40d8ab 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2018-02-10 21:08:01 +0100 using RuboCop version 0.52.1. +# on 2018-02-10 21:25:09 +0100 using RuboCop version 0.52.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -23,6 +23,13 @@ Layout/IndentationConsistency: Metrics/LineLength: Max: 248 +# Offense count: 4 +# Cop supports --auto-correct. +Performance/RedundantMatch: + Exclude: + - 'app/controllers/valuation/budget_investments_controller.rb' + - 'app/controllers/valuation/spending_proposals_controller.rb' + # Offense count: 11 RSpec/DescribeClass: Exclude: diff --git a/app/helpers/embed_videos_helper.rb b/app/helpers/embed_videos_helper.rb index f1750bf8b..823659cca 100644 --- a/app/helpers/embed_videos_helper.rb +++ b/app/helpers/embed_videos_helper.rb @@ -6,9 +6,9 @@ module EmbedVideosHelper def embedded_video_code link = @proposal.video_url title = t('proposals.show.embed_video_title', proposal: @proposal.title) - if link.match(/vimeo.*/) + if link =~ /vimeo.*/ server = "Vimeo" - elsif link.match(/youtu*.*/) + elsif link =~ /youtu*.*/ server = "YouTube" end From 664db2306c84e7280fe09b571a25876c1d8d4d36 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sat, 10 Feb 2018 21:28:36 +0100 Subject: [PATCH 42/44] Enable rubocop Rails cops without issues --- .rubocop.yml | 123 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 120 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 0cf7bafb6..7acef0837 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -16,9 +16,6 @@ AllCops: # to ignore them, so only the ones explicitly set in this file are enabled. DisabledByDefault: true -Rails: - Enabled: true - Metrics/LineLength: Max: 100 @@ -121,6 +118,126 @@ Performance/UnfreezeString: Performance/UriDefaultParser: Enabled: true +Rails/ActionFilter: + Enabled: true + +Rails/ActiveSupportAliases: + Enabled: true + +Rails/ApplicationJob: + Enabled: true + +Rails/ApplicationRecord: + Enabled: true + +Rails/Blank: + Enabled: true + +Rails/CreateTableWithTimestamps: + Enabled: true + +Rails/Date: + Enabled: true + +Rails/Delegate: + Enabled: true + +Rails/DelegateAllowBlank: + Enabled: true + +Rails/DynamicFindBy: + Enabled: true + +Rails/EnumUniqueness: + Enabled: true + +Rails/EnvironmentComparison: + Enabled: true + +Rails/Exit: + Enabled: true + +Rails/FilePath: + Enabled: true + +Rails/FindBy: + Enabled: true + +Rails/FindEach: + Enabled: true + +Rails/HasAndBelongsToMany: + Enabled: true + +Rails/HasManyOrHasOneDependent: + Enabled: true + +Rails/HttpPositionalArguments: + Enabled: true + +Rails/InverseOf: + Enabled: true + +Rails/LexicallyScopedActionFilter: + Enabled: true + +Rails/NotNullColumn: + Enabled: true + +Rails/Output: + Enabled: true + +Rails/OutputSafety: + Enabled: true + +Rails/PluralizationGrammar: + Enabled: true + +Rails/Presence: + Enabled: true + +Rails/Present: + Enabled: true + +Rails/ReadWriteAttribute: + Enabled: true + +Rails/RedundantReceiverInWithOptions: + Enabled: true + +Rails/RelativeDateConstant: + Enabled: true + +Rails/RequestReferer: + Enabled: true + +Rails/ReversibleMigration: + Enabled: true + +Rails/SafeNavigation: + Enabled: true + +Rails/SaveBang: + Enabled: true + +Rails/ScopeArgs: + Enabled: true + +Rails/SkipsModelValidations: + Enabled: true + +Rails/TimeZone: + Enabled: true + +Rails/UniqBeforePluck: + Enabled: true + +Rails/UnknownEnv: + Enabled: true + +Rails/Validation: + Enabled: true + RSpec/AlignLeftLetBrace: Enabled: false From 43559981eb441fa0985e0e16b37abf0d25acd72e Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sun, 11 Feb 2018 10:33:51 +0100 Subject: [PATCH 43/44] Enable rubocop Layout/EndOfLine cop with LF --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 7acef0837..0ff2d3154 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -22,6 +22,9 @@ Metrics/LineLength: Layout/IndentationConsistency: EnforcedStyle: rails +Layout/EndOfLine: + EnforcedStyle: lf + Bundler/DuplicatedGem: Enabled: true From d00be604b7b17eecad172e2a1184fa594e9a44a0 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sun, 11 Feb 2018 23:37:56 +0100 Subject: [PATCH 44/44] Update byebug version to 10.0.0 --- Gemfile | 2 +- Gemfile.lock | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index c5789447a..55d9a5284 100644 --- a/Gemfile +++ b/Gemfile @@ -60,7 +60,7 @@ end group :development, :test do gem 'bullet', '~> 5.7.0' - gem 'byebug', '~> 9.1.0' + gem 'byebug', '~> 10.0.0' gem 'factory_bot_rails', '~> 4.8.2' gem 'faker', '~> 1.8.7' gem 'i18n-tasks', '~> 0.9.20' diff --git a/Gemfile.lock b/Gemfile.lock index e243e58ee..40a1071d9 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -71,7 +71,7 @@ GEM bullet (5.7.1) activesupport (>= 3.0.0) uniform_notifier (~> 1.11.0) - byebug (9.1.0) + byebug (10.0.0) cancancan (2.1.2) capistrano (3.10.1) airbrussh (>= 1.0.0) @@ -497,7 +497,7 @@ DEPENDENCIES ancestry (~> 3.0.1) browser (~> 2.5.2) bullet (~> 5.7.0) - byebug (~> 9.1.0) + byebug (~> 10.0.0) cancancan (~> 2.1.2) capistrano (~> 3.10.1) capistrano-bundler (~> 1.2)