From 44b5403db55788345f30dd37fb1487ef232a7782 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 23 Jun 2017 18:19:43 +0200 Subject: [PATCH 01/75] improves styles and texts of share proposal view --- app/assets/stylesheets/layout.scss | 12 +++++++++-- app/views/proposals/share.html.erb | 32 +++++++++++++++++------------- config/locales/en.yml | 9 +++++---- config/locales/es.yml | 11 +++++----- spec/features/proposals_spec.rb | 2 +- 5 files changed, 40 insertions(+), 26 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 4359a2a31..2bca33bf5 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -806,7 +806,7 @@ form { } } - [type]:not([type=submit]):not([type=file]):not([type=checkbox]):not([type=radio]) { + [type]:not([type=submit]):not([type=file]):not([type=checkbox]):not([type=radio]):not(.close-button) { background: #f8f8f8; height: $line-height * 2; margin-bottom: rem-calc(16); @@ -893,7 +893,7 @@ form { .callout { font-size: $small-font-size; - a { + a:not(.button) { font-weight: bold; text-decoration: underline; } @@ -945,6 +945,14 @@ form { } } +.callout { + + &.highlight, + &.light { + border: 0; + } +} + // 08. User account // ---------------- diff --git a/app/views/proposals/share.html.erb b/app/views/proposals/share.html.erb index 5755e6225..f86882401 100644 --- a/app/views/proposals/share.html.erb +++ b/app/views/proposals/share.html.erb @@ -12,35 +12,39 @@ <% cache [locale_and_user_status(@proposal), @proposal, @proposal.author, Flag.flagged?(current_user, @proposal), @proposal_votes] do %>
-
+

<%= t("proposals.proposal.created") %>

-

<%= @proposal.title %>

- <%= t("proposals.show.code") %> - <%= @proposal.code %> + <%= t("proposals.proposal.share.guide") %>
+ <%= t("proposals.proposal.share.edit") %>

-

<%= t("proposals.proposal.share.guide").html_safe %>

- <%= render partial: 'shared/social_share', locals: { title: @proposal.title, url: proposal_url(@proposal) } %> -
- <% if @proposal_improvement_path.present? %> -

<%= t('proposals.proposal.improve_info', improve_info_link: link_to(t('proposals.proposal.improve_info_link'), @proposal_improvement_path)).html_safe %>

+
+

<%= t("proposals.proposal.improve_info") %>

+ <%= link_to t("proposals.proposal.improve_info_link"), @proposal_improvement_path, class: "button" %> +
<% end %> -

- <%= link_to proposal_path(@proposal), class: 'proposal' do %> - <%= t("proposals.proposal.share.view_proposal") %> - <% end %> -

+
+ <%= link_to t("proposals.proposal.share.view_proposal"), proposal_path(@proposal) %> +
+
+
+
+

+ <%= @proposal.title %>
+ <%= t("proposals.show.code") %> <%= @proposal.code %> +

+
diff --git a/config/locales/en.yml b/config/locales/en.yml index 7da965fe4..dac7bc3be 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -357,12 +357,13 @@ en: notice: retired: Proposal retired proposal: - created: "You've created a new proposal!" + created: "You've created a proposal!" share: - guide: "Now you can share it through Twitter, Facebook, Google+, Telegram or Whatsapp (if you're using a mobile device) so people can start supporting.

Before it gets shared you'll be able to change the text as you like." + guide: "Now you can share it so people can start supporting." + edit: "Before it gets shared you'll be able to change the text as you like." view_proposal: Not now, go to my proposal - improve_info: "You can also %{improve_info_link} about improving your campaign" - improve_info_link: see more information + improve_info: "Improve your campaign and get more supports" + improve_info_link: "See more information" already_supported: You have already supported this proposal. Share it! comments: one: 1 comment diff --git a/config/locales/es.yml b/config/locales/es.yml index 07c653669..5494ca497 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -357,12 +357,13 @@ es: notice: retired: Propuesta retirada proposal: - created: "¡Has creado una nueva propuesta!" + created: "¡Has creado una propuesta!" share: - guide: "Ahora puedes compartirla en Twitter, Facebook, Google+, Telegram o Whatsapp (si utilizas un dispositivo móvil) para que la gente empieze a apoyarla.

Antes de que se publique el texto en las redes sociales podrás modificarlo a tu gusto" - view_proposal: "Ahora no, ver mi propuesta" - improve_info: "También puedes %{improve_info_link} de como mejorar tu campaña" - improve_info_link: ver más información + guide: "Compártela para que la gente empieze a apoyarla." + edit: "Antes de que se publique podrás modificar el texto a tu gusto." + view_proposal: "Ahora no, ir a mi propuesta" + improve_info: "Mejora tu campaña y consigue más apoyos" + improve_info_link: "Ver más información" already_supported: "¡Ya has apoyado esta propuesta, compártela!" comments: one: 1 Comentario diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index bd7cafee1..16d928f4e 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -175,7 +175,7 @@ feature 'Proposals' do click_button 'Create proposal' expect(page).to have_content 'Proposal created successfully.' - expect(page).to have_content 'You can also see more information about improving your campaign' + expect(page).to have_content 'Improve your campaign and get more supports' click_link 'Not now, go to my proposal' From beeb5412d714dbdd0e102aab576b7985f9ba0792 Mon Sep 17 00:00:00 2001 From: taitus Date: Tue, 20 Jun 2017 15:37:03 +0200 Subject: [PATCH 02/75] New Checkpoint model. Update factories. Model specs. --- app/models/budget/investment.rb | 1 + app/models/budget/investment/checkpoint.rb | 10 ++++++++ ...31_create_budget_investment_checkpoints.rb | 11 +++++++++ db/schema.rb | 16 +++++++++---- spec/factories.rb | 6 +++++ .../budget/investment/checkpoint_spec.rb | 23 +++++++++++++++++++ spec/models/budget/investment_spec.rb | 1 - 7 files changed, 63 insertions(+), 5 deletions(-) create mode 100644 app/models/budget/investment/checkpoint.rb create mode 100644 db/migrate/20170620132731_create_budget_investment_checkpoints.rb create mode 100644 spec/models/budget/investment/checkpoint_spec.rb diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index b3b51996c..10d822b36 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -20,6 +20,7 @@ class Budget has_many :valuator_assignments, dependent: :destroy has_many :valuators, through: :valuator_assignments has_many :comments, as: :commentable + has_many :checkpoints validates :title, presence: true validates :author, presence: true diff --git a/app/models/budget/investment/checkpoint.rb b/app/models/budget/investment/checkpoint.rb new file mode 100644 index 000000000..6bc4229c6 --- /dev/null +++ b/app/models/budget/investment/checkpoint.rb @@ -0,0 +1,10 @@ +class Budget + class Investment + class Checkpoint < ActiveRecord::Base + belongs_to :investment + + validates :title, presence: true + validates :investment, presence: true + end + end +end diff --git a/db/migrate/20170620132731_create_budget_investment_checkpoints.rb b/db/migrate/20170620132731_create_budget_investment_checkpoints.rb new file mode 100644 index 000000000..22081f319 --- /dev/null +++ b/db/migrate/20170620132731_create_budget_investment_checkpoints.rb @@ -0,0 +1,11 @@ +class CreateBudgetInvestmentCheckpoints < ActiveRecord::Migration + def change + create_table :budget_investment_checkpoints do |t| + t.integer :investment_id + t.string "title", limit: 80 + t.text "description" + + t.timestamps null: false + end + end +end diff --git a/db/schema.rb b/db/schema.rb index 8fae3e8dd..a5d7ecbb5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170613203256) do +ActiveRecord::Schema.define(version: 20170620132731) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -114,6 +114,14 @@ ActiveRecord::Schema.define(version: 20170613203256) do add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree + create_table "budget_investment_checkpoints", force: :cascade do |t| + t.integer "investment_id" + t.string "title", limit: 80 + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "budget_investments", force: :cascade do |t| t.integer "author_id" t.integer "administrator_id" @@ -413,8 +421,8 @@ ActiveRecord::Schema.define(version: 20170613203256) do t.date "allegations_end_date" t.date "result_publication_date" t.datetime "hidden_at" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.text "summary" t.boolean "debate_phase_enabled", default: false t.boolean "allegations_phase_enabled", default: false @@ -924,7 +932,7 @@ ActiveRecord::Schema.define(version: 20170613203256) do t.boolean "email_digest", default: true t.boolean "email_on_direct_message", default: true t.boolean "official_position_badge", default: false - t.datetime "password_changed_at", default: '2016-12-21 17:55:08', null: false + t.datetime "password_changed_at", default: '2017-06-20 13:30:34', null: false t.boolean "created_from_signature", default: false t.integer "failed_email_digests_count", default: 0 t.text "former_users_data_log", default: "" diff --git a/spec/factories.rb b/spec/factories.rb index 42c8dbfc5..6401616e7 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -322,6 +322,12 @@ FactoryGirl.define do reason "unfeasible" end + factory :budget_investment_checkpoint, class: 'Budget::Investment::Checkpoint' do + association :investment, factory: :budget_investment + sequence(:title) { |n| "Budget Investment Checkpoint #{n} title" } + description 'Checkpoint description' + end + factory :vote do association :votable, factory: :debate association :voter, factory: :user diff --git a/spec/models/budget/investment/checkpoint_spec.rb b/spec/models/budget/investment/checkpoint_spec.rb new file mode 100644 index 000000000..fe40a58bb --- /dev/null +++ b/spec/models/budget/investment/checkpoint_spec.rb @@ -0,0 +1,23 @@ +require 'rails_helper' + +describe "Budget::Investment::Checkpoint" do + + describe "Validations" do + let(:checkpoint) { build(:budget_investment_checkpoint) } + + it "should be valid" do + expect(checkpoint).to be_valid + end + + it "should not be valid without a title" do + checkpoint.title = nil + expect(checkpoint).to_not be_valid + end + + it "should not be valid without an investment" do + checkpoint.investment_id = nil + expect(checkpoint).to_not be_valid + end + end + +end diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 2290abba9..c5af04ea1 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -486,7 +486,6 @@ describe Budget::Investment do end - describe 'Permissions' do let(:budget) { create(:budget) } let(:group) { create(:budget_group, budget: budget) } From f220952883bd072811dd353a46d3f7a0e579ffde Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 22 Jun 2017 13:25:17 +0200 Subject: [PATCH 03/75] Add CRUD Milestone on Admin::BudgetInvestment. Rename Checkpoint to Milestone. --- ...budget_investment_milestones_controller.rb | 55 +++++++++++++++ app/models/budget/investment.rb | 2 +- .../{checkpoint.rb => milestone.rb} | 6 +- .../_form.html.erb | 7 ++ .../edit.html.erb | 5 ++ .../budget_investment_milestones/new.html.erb | 10 +++ .../budget_investments/_milestones.html.erb | 32 +++++++++ .../admin/budget_investments/show.html.erb | 9 +++ config/locales/activerecord.en.yml | 6 ++ config/locales/activerecord.es.yml | 6 ++ config/locales/admin.en.yml | 19 +++++ config/locales/admin.es.yml | 19 +++++ config/routes.rb | 2 + ...31_create_budget_investment_milestones.rb} | 4 +- db/schema.rb | 4 +- spec/factories.rb | 6 +- .../budget_investment_milestones_spec.rb | 70 +++++++++++++++++++ .../features/admin/budget_investments_spec.rb | 2 +- .../budget/investment/checkpoint_spec.rb | 23 ------ .../budget/investment/milestone_spec.rb | 23 ++++++ 20 files changed, 277 insertions(+), 33 deletions(-) create mode 100644 app/controllers/admin/budget_investment_milestones_controller.rb rename app/models/budget/investment/{checkpoint.rb => milestone.rb} (63%) create mode 100644 app/views/admin/budget_investment_milestones/_form.html.erb create mode 100644 app/views/admin/budget_investment_milestones/edit.html.erb create mode 100644 app/views/admin/budget_investment_milestones/new.html.erb create mode 100644 app/views/admin/budget_investments/_milestones.html.erb rename db/migrate/{20170620132731_create_budget_investment_checkpoints.rb => 20170620132731_create_budget_investment_milestones.rb} (57%) create mode 100644 spec/features/admin/budget_investment_milestones_spec.rb delete mode 100644 spec/models/budget/investment/checkpoint_spec.rb create mode 100644 spec/models/budget/investment/milestone_spec.rb diff --git a/app/controllers/admin/budget_investment_milestones_controller.rb b/app/controllers/admin/budget_investment_milestones_controller.rb new file mode 100644 index 000000000..a4b8acc5d --- /dev/null +++ b/app/controllers/admin/budget_investment_milestones_controller.rb @@ -0,0 +1,55 @@ +class Admin::BudgetInvestmentMilestonesController < Admin::BaseController + + before_action :load_budget_investment, only: [:index, :new, :create, :edit, :update, :destroy] + before_action :load_budget_investment_milestone, only: [:edit, :update, :destroy] + + def index + end + + def new + @milestone = Budget::Investment::Milestone.new + end + + def create + @milestone = Budget::Investment::Milestone.new(milestone_params) + @milestone.investment = @investment + if @milestone.save + redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.create.notice') + else + render :new + end + end + + def edit + end + + def update + if @milestone.update(milestone_params) + redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.update.notice') + else + render :edit + end + end + + def destroy + @milestone.destroy + redirect_to admin_budget_budget_investment_path(@investment.budget, @investment), notice: t('admin.milestones.delete.notice') + end + + private + + def milestone_params + params.require(:budget_investment_milestone) + .permit(:title, :description, :budget_investment_id) + end + + def load_budget_investment + @investment = Budget::Investment.find params[:budget_investment_id] + end + + def load_budget_investment_milestone + @milestone = Budget::Investment::Milestone.find params[:id] + end + + +end diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 10d822b36..e13678cdb 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -20,7 +20,7 @@ class Budget has_many :valuator_assignments, dependent: :destroy has_many :valuators, through: :valuator_assignments has_many :comments, as: :commentable - has_many :checkpoints + has_many :milestones validates :title, presence: true validates :author, presence: true diff --git a/app/models/budget/investment/checkpoint.rb b/app/models/budget/investment/milestone.rb similarity index 63% rename from app/models/budget/investment/checkpoint.rb rename to app/models/budget/investment/milestone.rb index 6bc4229c6..9ecbe4dc3 100644 --- a/app/models/budget/investment/checkpoint.rb +++ b/app/models/budget/investment/milestone.rb @@ -1,10 +1,14 @@ class Budget class Investment - class Checkpoint < ActiveRecord::Base + class Milestone < ActiveRecord::Base belongs_to :investment validates :title, presence: true validates :investment, presence: true + + def self.title_max_length + 80 + end end end end diff --git a/app/views/admin/budget_investment_milestones/_form.html.erb b/app/views/admin/budget_investment_milestones/_form.html.erb new file mode 100644 index 000000000..5f8af9d33 --- /dev/null +++ b/app/views/admin/budget_investment_milestones/_form.html.erb @@ -0,0 +1,7 @@ +<%= form_for [:admin, @investment.budget, @investment, @milestone] do |f| %> + + <%= f.text_field :title, maxlength: Budget::Investment::Milestone.title_max_length %> + <%= f.text_area :description %> + + <%= f.submit nil, class: "button success" %> +<% end %> diff --git a/app/views/admin/budget_investment_milestones/edit.html.erb b/app/views/admin/budget_investment_milestones/edit.html.erb new file mode 100644 index 000000000..c72cd840a --- /dev/null +++ b/app/views/admin/budget_investment_milestones/edit.html.erb @@ -0,0 +1,5 @@ +<%= back_link_to admin_budget_budget_investment_path(@investment.budget, @investment) %> + +

<%= t("admin.milestones.edit.title") %>

+ +<%= render '/admin/budget_investment_milestones/form' %> diff --git a/app/views/admin/budget_investment_milestones/new.html.erb b/app/views/admin/budget_investment_milestones/new.html.erb new file mode 100644 index 000000000..7e065a605 --- /dev/null +++ b/app/views/admin/budget_investment_milestones/new.html.erb @@ -0,0 +1,10 @@ +
+ +
+ <%= back_link_to admin_budget_budget_investment_path(@investment.budget, @investment) %> + +

<%= t("admin.milestones.new.creating") %>

+ + <%= render "form" %> +
+
diff --git a/app/views/admin/budget_investments/_milestones.html.erb b/app/views/admin/budget_investments/_milestones.html.erb new file mode 100644 index 000000000..8fe5154af --- /dev/null +++ b/app/views/admin/budget_investments/_milestones.html.erb @@ -0,0 +1,32 @@ +<% if @investment.milestones.any? %> + + + + + + + + + + + <% @investment.milestones.each do |milestone| %> + + + + + + + <% end %> + +
<%= t("admin.milestones.index.table_id") %><%= t("admin.milestones.index.table_title") %><%= t("admin.milestones.index.table_description") %><%= t("admin.milestones.index.table_actions") %>
+ <%= milestone.id %> + + <%= link_to milestone.title, edit_admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone) %> + + <%= milestone.description %> + + <%= link_to t("admin.milestones.index.delete"), admin_budget_budget_investment_budget_investment_milestone_path(@investment.budget, @investment, milestone), + method: :delete, + class: 'button hollow alert expanded' %> +
+<% end %> diff --git a/app/views/admin/budget_investments/show.html.erb b/app/views/admin/budget_investments/show.html.erb index a58110c94..f220c0955 100644 --- a/app/views/admin/budget_investments/show.html.erb +++ b/app/views/admin/budget_investments/show.html.erb @@ -47,3 +47,12 @@ <%= link_to t("admin.budget_investments.show.edit_dossier"), edit_valuation_budget_budget_investment_path(@budget, @investment) %>

+
+ +

<%= t("admin.budget_investments.show.milestone") %>

+ +<%= render 'admin/budget_investments/milestones' %> + +

+ <%= link_to t("admin.budget_investments.show.new_milestone"), new_admin_budget_budget_investment_budget_investment_milestone_path(@budget, @investment) %> +

diff --git a/config/locales/activerecord.en.yml b/config/locales/activerecord.en.yml index 0af387a50..d45c569d4 100644 --- a/config/locales/activerecord.en.yml +++ b/config/locales/activerecord.en.yml @@ -10,6 +10,9 @@ en: budget/investment: one: "Investment" other: "Investments" + budget/investment/milestone: + one: "milestone" + other: "milestones" comment: one: "Comment" other: "Comments" @@ -98,6 +101,9 @@ en: title: "Title" location: "Location" organization_name: "If you are proposing in the name of a collective/organization, write its name" + budget/investment/milestone: + title: "Title" + description: "Description" comment: body: "Comment" user: "User" diff --git a/config/locales/activerecord.es.yml b/config/locales/activerecord.es.yml index b2b5fc20e..86bb76c87 100644 --- a/config/locales/activerecord.es.yml +++ b/config/locales/activerecord.es.yml @@ -10,6 +10,9 @@ es: budget/investment: one: "Proyecto de inversión" other: "Proyectos de inversión" + budget/investment/milestone: + one: "seguimiento" + other: "seguimientos" comment: one: "Comentario" other: "Comentarios" @@ -96,6 +99,9 @@ es: comment: body: "Comentario" user: "Usuario" + budget/investment/milestone: + title: "Título" + description: "Descripción" debate: author: "Autor" description: "Opinión" diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index bbd8dd1bd..96dc32a8b 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -151,6 +151,8 @@ en: edit_dossier: Edit dossier tags: Tags undefined: Undefined + milestone: Milestone + new_milestone: Create new milestone edit: classification: Clasification assigned_valuators: Valuators @@ -160,6 +162,23 @@ en: tags_placeholder: "Write the tags you want separated by commas (,)" undefined: Undefined search_unfeasible: Search unfeasible + milestones: + index: + table_id: "ID" + table_title: "Title" + table_description: "Description" + table_actions: "Actions" + delete: "Delete milestone" + new: + creating: Create milestone + edit: + title: Edit milestone + create: + notice: New milestone created successfully! + update: + notice: Milestone updated successfully + delete: + notice: Milestone successfully deleted comments: index: filter: Filter diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index a3c6a99b9..405f70152 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -151,6 +151,8 @@ es: edit_dossier: Editar informe tags: Etiquetas undefined: Sin definir + milestone: Seguimiento + new_milestone: Crear nuevo seguimiento edit: classification: Clasificación assigned_valuators: Evaluadores @@ -160,6 +162,23 @@ es: tags_placeholder: "Escribe las etiquetas que desees separadas por comas (,)" undefined: Sin definir search_unfeasible: Buscar inviables + milestones: + index: + table_id: "ID" + table_title: "Título" + table_description: "Descripción" + table_actions: "Acciones" + delete: "Eliminar seguimiento" + new: + creating: Crear seguimiento + edit: + title: Editar seguimiento + create: + notice: Nuevo seguimiento creado con éxito! + update: + notice: Seguimiento actualizado + delete: + notice: Seguimiento borrado correctamente comments: index: filter: Filtro diff --git a/config/routes.rb b/config/routes.rb index 5c5284a91..e436244a1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -199,10 +199,12 @@ Rails.application.routes.draw do end resources :budget_investments, only: [:index, :show, :edit, :update] do + resources :budget_investment_milestones member { patch :toggle_selection } end end + resources :signature_sheets, only: [:index, :new, :create, :show] resources :banners, only: [:index, :new, :create, :edit, :update, :destroy] do diff --git a/db/migrate/20170620132731_create_budget_investment_checkpoints.rb b/db/migrate/20170620132731_create_budget_investment_milestones.rb similarity index 57% rename from db/migrate/20170620132731_create_budget_investment_checkpoints.rb rename to db/migrate/20170620132731_create_budget_investment_milestones.rb index 22081f319..199d8e70e 100644 --- a/db/migrate/20170620132731_create_budget_investment_checkpoints.rb +++ b/db/migrate/20170620132731_create_budget_investment_milestones.rb @@ -1,6 +1,6 @@ -class CreateBudgetInvestmentCheckpoints < ActiveRecord::Migration +class CreateBudgetInvestmentMilestones < ActiveRecord::Migration def change - create_table :budget_investment_checkpoints do |t| + create_table :budget_investment_milestones do |t| t.integer :investment_id t.string "title", limit: 80 t.text "description" diff --git a/db/schema.rb b/db/schema.rb index a5d7ecbb5..4cfa7229f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -114,7 +114,7 @@ ActiveRecord::Schema.define(version: 20170620132731) do add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree - create_table "budget_investment_checkpoints", force: :cascade do |t| + create_table "budget_investment_milestones", force: :cascade do |t| t.integer "investment_id" t.string "title", limit: 80 t.text "description" @@ -932,7 +932,7 @@ ActiveRecord::Schema.define(version: 20170620132731) do t.boolean "email_digest", default: true t.boolean "email_on_direct_message", default: true t.boolean "official_position_badge", default: false - t.datetime "password_changed_at", default: '2017-06-20 13:30:34', null: false + t.datetime "password_changed_at", default: '2017-06-22 11:21:30', null: false t.boolean "created_from_signature", default: false t.integer "failed_email_digests_count", default: 0 t.text "former_users_data_log", default: "" diff --git a/spec/factories.rb b/spec/factories.rb index 6401616e7..1d842e299 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -322,10 +322,10 @@ FactoryGirl.define do reason "unfeasible" end - factory :budget_investment_checkpoint, class: 'Budget::Investment::Checkpoint' do + factory :budget_investment_milestone, class: 'Budget::Investment::Milestone' do association :investment, factory: :budget_investment - sequence(:title) { |n| "Budget Investment Checkpoint #{n} title" } - description 'Checkpoint description' + sequence(:title) { |n| "Budget Investment Milestone #{n} title" } + description 'Milestone description' end factory :vote do diff --git a/spec/features/admin/budget_investment_milestones_spec.rb b/spec/features/admin/budget_investment_milestones_spec.rb new file mode 100644 index 000000000..1550f05e6 --- /dev/null +++ b/spec/features/admin/budget_investment_milestones_spec.rb @@ -0,0 +1,70 @@ +require 'rails_helper' + +feature 'Admin budget investment milestones' do + + background do + admin = create(:administrator) + login_as(admin.user) + + @investment = create(:budget_investment) + end + + context "Index" do + scenario 'Displaying milestones' do + milestone = create(:budget_investment_milestone, investment: @investment) + + visit admin_budget_budget_investment_path(@investment.budget, @investment) + + expect(page).to have_content("Milestone") + expect(page).to have_content(milestone.title) + expect(page).to have_content(milestone.id) + end + end + + context "New" do + scenario "Add milestone" do + visit admin_budget_budget_investment_path(@investment.budget, @investment) + + click_link 'Create new milestone' + + fill_in 'budget_investment_milestone_title', with: 'New title milestone' + fill_in 'budget_investment_milestone_description', with: 'New description milestone' + + click_button 'Create milestone' + + expect(page).to have_content 'New title milestone' + expect(page).to have_content 'New description milestone' + end + end + + context "Edit" do + scenario "Change title and description" do + milestone = create(:budget_investment_milestone, investment: @investment) + + visit admin_budget_budget_investment_path(@investment.budget, @investment) + + click_link milestone.title + + fill_in 'budget_investment_milestone_title', with: 'Changed title' + fill_in 'budget_investment_milestone_description', with: 'Changed description' + + click_button 'Update milestone' + + expect(page).to have_content 'Changed title' + expect(page).to have_content 'Changed description' + end + end + + context "Delete" do + scenario "Remove milestone" do + milestone = create(:budget_investment_milestone, investment: @investment, title: "Title will it remove") + + visit admin_budget_budget_investment_path(@investment.budget, @investment) + + click_link "Delete milestone" + + expect(page).to_not have_content 'Title will it remove' + end + end + +end diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index 52c008c18..c50a05f32 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -27,7 +27,7 @@ feature 'Admin budget investments' do context "Index" do - scenario 'Displaying investmentss' 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) expect(page).to have_content(budget_investment.title) diff --git a/spec/models/budget/investment/checkpoint_spec.rb b/spec/models/budget/investment/checkpoint_spec.rb deleted file mode 100644 index fe40a58bb..000000000 --- a/spec/models/budget/investment/checkpoint_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'rails_helper' - -describe "Budget::Investment::Checkpoint" do - - describe "Validations" do - let(:checkpoint) { build(:budget_investment_checkpoint) } - - it "should be valid" do - expect(checkpoint).to be_valid - end - - it "should not be valid without a title" do - checkpoint.title = nil - expect(checkpoint).to_not be_valid - end - - it "should not be valid without an investment" do - checkpoint.investment_id = nil - expect(checkpoint).to_not be_valid - end - end - -end diff --git a/spec/models/budget/investment/milestone_spec.rb b/spec/models/budget/investment/milestone_spec.rb new file mode 100644 index 000000000..5fc749d36 --- /dev/null +++ b/spec/models/budget/investment/milestone_spec.rb @@ -0,0 +1,23 @@ +require 'rails_helper' + +describe "Budget::Investment::Milestone" do + + describe "Validations" do + let(:milestone) { build(:budget_investment_milestone) } + + it "should be valid" do + expect(milestone).to be_valid + end + + it "should not be valid without a title" do + milestone.title = nil + expect(milestone).to_not be_valid + end + + it "should not be valid without an investment" do + milestone.investment_id = nil + expect(milestone).to_not be_valid + end + end + +end From 87eeb45584104afce06e58d06ffd2761f3c3dab3 Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 22 Jun 2017 14:04:26 +0200 Subject: [PATCH 04/75] Rename Seguimiento to Hito. --- config/locales/activerecord.es.yml | 4 ++-- config/locales/admin.es.yml | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/config/locales/activerecord.es.yml b/config/locales/activerecord.es.yml index 86bb76c87..678053f84 100644 --- a/config/locales/activerecord.es.yml +++ b/config/locales/activerecord.es.yml @@ -11,8 +11,8 @@ es: one: "Proyecto de inversión" other: "Proyectos de inversión" budget/investment/milestone: - one: "seguimiento" - other: "seguimientos" + one: "hito" + other: "hitos" comment: one: "Comentario" other: "Comentarios" diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 405f70152..2b0b68a1c 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -152,7 +152,7 @@ es: tags: Etiquetas undefined: Sin definir milestone: Seguimiento - new_milestone: Crear nuevo seguimiento + new_milestone: Crear nuevo hito edit: classification: Clasificación assigned_valuators: Evaluadores @@ -168,17 +168,17 @@ es: table_title: "Título" table_description: "Descripción" table_actions: "Acciones" - delete: "Eliminar seguimiento" + delete: "Eliminar hito" new: - creating: Crear seguimiento + creating: Crear hito edit: - title: Editar seguimiento + title: Editar hito create: - notice: Nuevo seguimiento creado con éxito! + notice: Nuevo hito creado con éxito! update: - notice: Seguimiento actualizado + notice: Hito actualizado delete: - notice: Seguimiento borrado correctamente + notice: Hito borrado correctamente comments: index: filter: Filtro From c58371a5fe4f9e28a6c23dc3d38793bf84964a8f Mon Sep 17 00:00:00 2001 From: taitus Date: Thu, 22 Jun 2017 17:04:21 +0200 Subject: [PATCH 05/75] Add milestones to investments show. --- .../budgets/investments/_comments.html.erb | 41 +++++++++++++++++++ .../investments/_filter_subnav.html.erb | 22 ++++++++++ .../budgets/investments/_milestones.html.erb | 16 ++++++++ app/views/budgets/investments/show.html.erb | 9 +++- config/locales/budgets.en.yml | 5 ++- config/locales/budgets.es.yml | 3 ++ spec/features/budgets/investments_spec.rb | 32 +++++++++++++++ 7 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 app/views/budgets/investments/_comments.html.erb create mode 100644 app/views/budgets/investments/_filter_subnav.html.erb create mode 100644 app/views/budgets/investments/_milestones.html.erb diff --git a/app/views/budgets/investments/_comments.html.erb b/app/views/budgets/investments/_comments.html.erb new file mode 100644 index 000000000..bc5ad6540 --- /dev/null +++ b/app/views/budgets/investments/_comments.html.erb @@ -0,0 +1,41 @@ +<% commentable = comment_tree.commentable %> +<% current_order = comment_tree.order %> + +<% cache [locale_and_user_status, current_order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count, comment_flags] do %> +
+
+
+ + <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> + + <% if user_signed_in? %> + <% if comments_closed_for_commentable?(commentable) %> +
+
+ <%= comments_closed_text(commentable) %> +
+ <% elsif require_verified_resident_for_commentable?(commentable, current_user) %> +
+
+ <%= t("comments.verified_only", verify_account: link_to(t("comments.verify_account"), verification_path )).html_safe %> +
+ <% else %> + <%= render 'comments/form', {commentable: commentable, parent_id: nil, toggeable: false} %> + <% end %> + <% else %> +
+
+ <%= t("debates.show.login_to_comment", + signin: link_to(t("votes.signin"), new_user_session_path), + signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %> +
+ <% end %> + + <% comment_tree.root_comments.each do |comment| %> + <%= render 'comments/comment', {comment: comment, comment_flags: comment_flags} %> + <% end %> + <%= paginate comment_tree.root_comments %> +
+
+
+<% end %> diff --git a/app/views/budgets/investments/_filter_subnav.html.erb b/app/views/budgets/investments/_filter_subnav.html.erb new file mode 100644 index 000000000..7fc87fc82 --- /dev/null +++ b/app/views/budgets/investments/_filter_subnav.html.erb @@ -0,0 +1,22 @@ +
+
+
    +
  • + <%= link_to "#tab-comments" do %> +

    + <%= t("budgets.investments.show.comments_tab") %> + (<%= @investment.comments_count %>) +

    + <% end %> +
  • +
  • + <%= link_to "#tab-milestones" do %> +

    + <%= t("budgets.investments.show.milestones_tab") %> + (<%= @investment.milestones.count %>) +

    + <% end %> +
  • +
+
+
diff --git a/app/views/budgets/investments/_milestones.html.erb b/app/views/budgets/investments/_milestones.html.erb new file mode 100644 index 000000000..36787e0eb --- /dev/null +++ b/app/views/budgets/investments/_milestones.html.erb @@ -0,0 +1,16 @@ +
+
+
+ <% if @investment.milestones.blank? %> +
+ <%= t('budgets.investments.show.no_milestones') %> +
+ <% end %> + + <% @investment.milestones.each do |milestone| %> +

<%= milestone.title %>

+

<%= milestone.description %>

+ <% end %> +
+
+
diff --git a/app/views/budgets/investments/show.html.erb b/app/views/budgets/investments/show.html.erb index 73861697e..dede17d66 100644 --- a/app/views/budgets/investments/show.html.erb +++ b/app/views/budgets/investments/show.html.erb @@ -10,4 +10,11 @@ ballot: @ballot } %> -<%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %> +
+ <%= render "budgets/investments/filter_subnav" %> + <%= render "budgets/investments/milestones" %> + +
+ <%= render partial: 'budgets/investments/comments', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %> +
+
diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index 905ccce7e..15fb814d6 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -93,6 +93,9 @@ en: supports: Supports votes: Votes price: Price + comments_tab: Comments + milestones_tab: Milestones + no_milestones: Don't have defined milestones wrong_price_format: Only integer numbers investment: add: Vote @@ -131,4 +134,4 @@ en: price: Cost amount_available: Available budget accepted: "Accepted spending proposal: " - discarded: "Discarded spending proposal: " \ No newline at end of file + discarded: "Discarded spending proposal: " diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index 38f8601e8..fce746e39 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -93,6 +93,9 @@ es: supports: Apoyos votes: Votos price: Coste + comments_tab: Comentarios + milestones_tab: Seguimiento + no_milestones: No hay hitos definidos wrong_price_format: Solo puede incluir caracteres numéricos investment: add: Votar diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index e131973da..c8ad40bfb 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -389,6 +389,38 @@ feature 'Budget Investments' do expect(page).to have_content(investment.unfeasibility_explanation) end + scenario "Show milestones", :js do + user = create(:user) + login_as(user) + + investment = create(:budget_investment) + milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show") + + visit budget_investment_path(budget_id: investment.budget.id, id: investment.id) + + find("#tab-milestones-label").trigger('click') + + within("#tab-milestones") do + expect(page).to have_content(milestone.title) + expect(page).to have_content(milestone.description) + end + end + + scenario "Show no_milestones text", :js do + user = create(:user) + login_as(user) + + investment = create(:budget_investment) + + visit budget_investment_path(budget_id: investment.budget.id, id: investment.id) + + find("#tab-milestones-label").trigger('click') + + within("#tab-milestones") do + expect(page).to have_content("Don't have defined milestones") + end + end + context "Destroy" do scenario "Admin cannot destroy budget investments" do From 30f6fa9ae6c5536cc356362233d6b51da853dbde Mon Sep 17 00:00:00 2001 From: Alessandro Cuoghi Date: Thu, 22 Jun 2017 21:42:40 +0200 Subject: [PATCH 06/75] Created timeline for desktop version. --- app/assets/stylesheets/participation.scss | 53 +++++++++++++++++++ .../budgets/investments/_milestones.html.erb | 18 +++++-- 2 files changed, 66 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index a9cde9f55..a54e6b0e4 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -494,6 +494,59 @@ } } +#tab-milestones{ + .timeline ul li { + list-style-type: none; + position: relative; + width: 1px; + margin: 0 auto; + padding-top: 50px; + background: #dfe2e5; + &:before{ + content: ''; + position: absolute; + left: 50%; + top:0; + transform: translateX(-50%); + width: 20px; + height: 20px; + border-radius: 50%; + background: inherit; + background: #179c87; + } + &:nth-child(odd) div { + text-align: right; + left: -515px; + top:-20px; + &:before { + left: -15px; + } + } + &:nth-child(even) div { + left: 15px; + top:-20px; + &:before { + right: -15px; + } + } + div { + position: relative; + + padding: 10px; + width: 30vw; + width: 500px; + h3{ + font-size: 1.2rem; + margin-bottom:0; + } + strong{ + color:#c9c9c9; + font-size: 0.9rem; + } + } + } +} + // 04. List participation // ---------------------- diff --git a/app/views/budgets/investments/_milestones.html.erb b/app/views/budgets/investments/_milestones.html.erb index 36787e0eb..53e161ab9 100644 --- a/app/views/budgets/investments/_milestones.html.erb +++ b/app/views/budgets/investments/_milestones.html.erb @@ -6,11 +6,19 @@ <%= t('budgets.investments.show.no_milestones') %>
<% end %> - - <% @investment.milestones.each do |milestone| %> -

<%= milestone.title %>

-

<%= milestone.description %>

- <% end %> +
+ +
From 7db98486fe5bacc58908df5f7de442dd18d9ffeb Mon Sep 17 00:00:00 2001 From: Alessandro Cuoghi Date: Fri, 23 Jun 2017 12:38:40 +0200 Subject: [PATCH 07/75] Timeline: Responisve version. Change green color with purple. Aligned title to bullet. --- app/assets/stylesheets/participation.scss | 123 +++++++++++------- .../budgets/investments/_milestones.html.erb | 2 +- 2 files changed, 80 insertions(+), 45 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index a54e6b0e4..c67e6c3a2 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -495,53 +495,88 @@ } #tab-milestones{ - .timeline ul li { - list-style-type: none; + .timeline ul{ position: relative; - width: 1px; - margin: 0 auto; - padding-top: 50px; - background: #dfe2e5; - &:before{ - content: ''; - position: absolute; - left: 50%; - top:0; - transform: translateX(-50%); - width: 20px; - height: 20px; - border-radius: 50%; - background: inherit; - background: #179c87; - } - &:nth-child(odd) div { - text-align: right; - left: -515px; - top:-20px; - &:before { - left: -15px; - } - } - &:nth-child(even) div { - left: 15px; - top:-20px; - &:before { - right: -15px; - } - } - div { + margin-top:rem-calc(40); + li { position: relative; - - padding: 10px; - width: 30vw; - width: 500px; - h3{ - font-size: 1.2rem; - margin-bottom:0; + width:0; + margin: 0 auto; + &:before{ + content: ''; + position: absolute; + top:rem-calc(5); + transform: translateX(-50%); + width: rem-calc(20); + height: rem-calc(20); + border-radius: 50%; + background: $budget; + z-index: 2; } - strong{ - color:#c9c9c9; - font-size: 0.9rem; + &:after{ + content: ''; + width: 1px; + background: $light-gray; + bottom: 100%; + height: 100%; + position: absolute; + top: rem-calc(25); + z-index: 1; + } + div { + position: relative; + padding: rem-calc(3) rem-calc(10); + h3{ + font-size: 1.2rem; + margin-bottom:0; + } + strong{ + color:$text-light; + font-size: 0.9rem; + } + } + + &:nth-child(odd), + &:nth-child(even){ + div{ + @include breakpoint(medium) { + width: rem-calc(300) + } + @include breakpoint(large) { + width: rem-calc(450) + } + } + } + + &:nth-child(odd){ + div{ + text-align: right; + @include breakpoint(medium) { + margin-left:rem-calc(-315); + } + @include breakpoint(large) { + margin-left:rem-calc(-465); + } + } + } + + &:nth-child(even) div { + left: rem-calc(15); + } + } + } + + @include breakpoint(small only) { + .timeline ul{ + li{ + width: 100%; + &:nth-child(odd), + &:nth-child(even){ + div{ + text-align: left; + left:rem-calc(15); + } + } } } } diff --git a/app/views/budgets/investments/_milestones.html.erb b/app/views/budgets/investments/_milestones.html.erb index 53e161ab9..59a445b7c 100644 --- a/app/views/budgets/investments/_milestones.html.erb +++ b/app/views/budgets/investments/_milestones.html.erb @@ -7,7 +7,7 @@ <% end %>
-
    +
      <% @investment.milestones.each do |milestone| %>
    • From 2fe663ef8f6aa7c0e3c9030cc63f098fec1cb1c9 Mon Sep 17 00:00:00 2001 From: taitus Date: Fri, 23 Jun 2017 13:18:13 +0200 Subject: [PATCH 08/75] Fix syntax and indentation errors. --- .../budgets/investments/_filter_subnav.html.erb | 12 ++++++------ spec/factories.rb | 2 +- spec/features/budgets/investments_spec.rb | 6 ++---- spec/models/budget/investment/milestone_spec.rb | 6 +++--- 4 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/views/budgets/investments/_filter_subnav.html.erb b/app/views/budgets/investments/_filter_subnav.html.erb index 7fc87fc82..a46c33b2d 100644 --- a/app/views/budgets/investments/_filter_subnav.html.erb +++ b/app/views/budgets/investments/_filter_subnav.html.erb @@ -10,12 +10,12 @@ <% end %>
    • - <%= link_to "#tab-milestones" do %> -

      - <%= t("budgets.investments.show.milestones_tab") %> - (<%= @investment.milestones.count %>) -

      - <% end %> + <%= link_to "#tab-milestones" do %> +

      + <%= t("budgets.investments.show.milestones_tab") %> + (<%= @investment.milestones.count %>) +

      + <% end %>
    diff --git a/spec/factories.rb b/spec/factories.rb index 1d842e299..07e6c2c3e 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -324,7 +324,7 @@ FactoryGirl.define do factory :budget_investment_milestone, class: 'Budget::Investment::Milestone' do association :investment, factory: :budget_investment - sequence(:title) { |n| "Budget Investment Milestone #{n} title" } + sequence(:title) { |n| "Budget investment milestone #{n} title" } description 'Milestone description' end diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index c8ad40bfb..c795984c7 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -391,11 +391,10 @@ feature 'Budget Investments' do scenario "Show milestones", :js do user = create(:user) - login_as(user) - investment = create(:budget_investment) milestone = create(:budget_investment_milestone, investment: investment, title: "New text to show") + login_as(user) visit budget_investment_path(budget_id: investment.budget.id, id: investment.id) find("#tab-milestones-label").trigger('click') @@ -408,10 +407,9 @@ feature 'Budget Investments' do scenario "Show no_milestones text", :js do user = create(:user) - login_as(user) - investment = create(:budget_investment) + login_as(user) visit budget_investment_path(budget_id: investment.budget.id, id: investment.id) find("#tab-milestones-label").trigger('click') diff --git a/spec/models/budget/investment/milestone_spec.rb b/spec/models/budget/investment/milestone_spec.rb index 5fc749d36..32f040eaf 100644 --- a/spec/models/budget/investment/milestone_spec.rb +++ b/spec/models/budget/investment/milestone_spec.rb @@ -5,16 +5,16 @@ describe "Budget::Investment::Milestone" do describe "Validations" do let(:milestone) { build(:budget_investment_milestone) } - it "should be valid" do + it "Should be valid" do expect(milestone).to be_valid end - it "should not be valid without a title" do + it "Should not be valid without a title" do milestone.title = nil expect(milestone).to_not be_valid end - it "should not be valid without an investment" do + it "Should not be valid without an investment" do milestone.investment_id = nil expect(milestone).to_not be_valid end From eeb9c95d1a856bb529c397a50bb4e55f9c2a7aa6 Mon Sep 17 00:00:00 2001 From: taitus Date: Fri, 23 Jun 2017 13:18:54 +0200 Subject: [PATCH 09/75] Missing validate new form milestone spec on Admin. --- .../admin/budget_investment_milestones_spec.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/spec/features/admin/budget_investment_milestones_spec.rb b/spec/features/admin/budget_investment_milestones_spec.rb index 1550f05e6..208cc61a0 100644 --- a/spec/features/admin/budget_investment_milestones_spec.rb +++ b/spec/features/admin/budget_investment_milestones_spec.rb @@ -35,6 +35,21 @@ feature 'Admin budget investment milestones' do expect(page).to have_content 'New title milestone' expect(page).to have_content 'New description milestone' end + + scenario "Show validation errors on milestone form" do + visit admin_budget_budget_investment_path(@investment.budget, @investment) + + click_link 'Create new milestone' + + fill_in 'budget_investment_milestone_description', with: 'New description milestone' + + click_button 'Create milestone' + + within "#new_budget_investment_milestone" do + expect(page).to have_content "can't be blank" + expect(page).to have_content 'New description milestone' + end + end end context "Edit" do From 4613855df84150426a6e7a9da7b44f5d5cff0e8f Mon Sep 17 00:00:00 2001 From: taitus Date: Fri, 23 Jun 2017 16:01:11 +0200 Subject: [PATCH 10/75] Refactor tab-milestones inside participation.scss and passed scss-lint test --- app/assets/stylesheets/participation.scss | 170 ++++++++++-------- .../budgets/investments/_milestones.html.erb | 2 +- 2 files changed, 93 insertions(+), 79 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index c67e6c3a2..76d947c2b 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -494,94 +494,108 @@ } } -#tab-milestones{ - .timeline ul{ + +.tab-milestones ul { + position: relative; + margin-top: rem-calc(40); + + li { position: relative; - margin-top:rem-calc(40); - li { - position: relative; - width:0; - margin: 0 auto; - &:before{ - content: ''; - position: absolute; - top:rem-calc(5); - transform: translateX(-50%); - width: rem-calc(20); - height: rem-calc(20); - border-radius: 50%; - background: $budget; - z-index: 2; - } - &:after{ - content: ''; - width: 1px; - background: $light-gray; - bottom: 100%; - height: 100%; - position: absolute; - top: rem-calc(25); - z-index: 1; - } - div { - position: relative; - padding: rem-calc(3) rem-calc(10); - h3{ - font-size: 1.2rem; - margin-bottom:0; - } - strong{ - color:$text-light; - font-size: 0.9rem; - } - } - - &:nth-child(odd), - &:nth-child(even){ - div{ - @include breakpoint(medium) { - width: rem-calc(300) - } - @include breakpoint(large) { - width: rem-calc(450) - } - } - } - - &:nth-child(odd){ - div{ - text-align: right; - @include breakpoint(medium) { - margin-left:rem-calc(-315); - } - @include breakpoint(large) { - margin-left:rem-calc(-465); - } - } - } - - &:nth-child(even) div { - left: rem-calc(15); - } - } + width: 0; + margin: 0 auto; } + li::before { + content: ''; + position: absolute; + top: rem-calc(5); + transform: translateX(-50%); + width: rem-calc(20); + height: rem-calc(20); + border-radius: 50%; + background: $budget; + z-index: 2; + } + + li::after { + content: ''; + width: 1px; + background: $light-gray; + bottom: 100%; + height: 100%; + position: absolute; + top: rem-calc(25); + z-index: 1; + } +} + +.tab-milestones ul div { + position: relative; + padding: rem-calc(3) rem-calc(10); + + h3 { + font-size: 1.2rem; + margin-bottom: 0; + } + + strong { + color: $text-light; + font-size: 0.9rem; + } +} + +.tab-milestones .timeline ul li:nth-child(odd), +.tab-milestones .timeline ul li:nth-child(even) { + + div { + @include breakpoint(medium) { + width: rem-calc(300); + } + + @include breakpoint(large) { + width: rem-calc(450); + } + } +} + +.tab-milestones .timeline ul li:nth-child(odd) { + div { + text-align: right; + + @include breakpoint(medium) { + margin-left: rem-calc(-315); + } + + @include breakpoint(large) { + margin-left: rem-calc(-465); + } + } +} + +.tab-milestones .timeline ul li:nth-child(even) { + div { + left: rem-calc(15); + } +} + +.tab-milestones { @include breakpoint(small only) { - .timeline ul{ - li{ - width: 100%; - &:nth-child(odd), - &:nth-child(even){ - div{ - text-align: left; - left:rem-calc(15); - } + + .timeline ul li { + width: 100%; + + &:nth-child(odd), + &:nth-child(even) { + div { + text-align: left; + left: rem-calc(15); } } } } } + // 04. List participation // ---------------------- diff --git a/app/views/budgets/investments/_milestones.html.erb b/app/views/budgets/investments/_milestones.html.erb index 59a445b7c..8a45fc3ae 100644 --- a/app/views/budgets/investments/_milestones.html.erb +++ b/app/views/budgets/investments/_milestones.html.erb @@ -1,4 +1,4 @@ -
    +
    <% if @investment.milestones.blank? %> From 167df1656730d0aca744ab4dee66ba24bbcc2388 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sun, 25 Jun 2017 01:37:42 +0200 Subject: [PATCH 11/75] Fix Github Pull Request template Why: * The template tried to specify a placeholder for the title, but instead it was used as first line in the description * The template tried to specify a guide for each section with a `>` character to imply it was a comment, but people didn't remove it How: * Removing the first line specifying the title placeholder that has no use * Changing the `>` character on each section guide for a `-` that can be easily reused for enumerations --- .github/PULL_REQUEST_TEMPLATE | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE index 64c1da1be..ff14fef2f 100644 --- a/.github/PULL_REQUEST_TEMPLATE +++ b/.github/PULL_REQUEST_TEMPLATE @@ -1,5 +1,3 @@ -PR_TITLE_GOES_HERE - Where ===== * **Related Issue:** LINK_OR_#_REF @@ -7,24 +5,24 @@ Where What ==== -> Whats the objective of this changes ? +- Whats the objective of this changes ? How === -> How you implemented/achieved the objective ? +- How you implemented/achieved the objective ? Screenshots =========== -> If changes affect UI just show them drag&dropping images here +- If changes affect UI just show them drag&dropping images here Test ==== -> Is manual test needed or you just increased/fixed coverage? +- Is manual test needed or you just increased/fixed coverage? Deployment ========== -> Any details to remember when this feature is deployed? +- Any details to remember when this feature is deployed? Warnings ======== -> Some caveats or important things to notice? +- Some caveats or important things to notice? From e0d11d6b2a14567b07db40512473ed80674b22cd Mon Sep 17 00:00:00 2001 From: taitus Date: Sun, 25 Jun 2017 11:06:05 +0200 Subject: [PATCH 12/75] Fix create comment on budget investment spec. --- spec/features/comments/budget_investments_spec.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spec/features/comments/budget_investments_spec.rb b/spec/features/comments/budget_investments_spec.rb index b36f51b8f..7f36106a2 100644 --- a/spec/features/comments/budget_investments_spec.rb +++ b/spec/features/comments/budget_investments_spec.rb @@ -166,9 +166,12 @@ feature 'Commenting Budget::Investments' do fill_in "comment-body-budget_investment_#{investment.id}", with: 'Have you thought about...?' click_button 'Publish comment' + within "#tab-comments-label" do + expect(page).to have_content 'Comments (1)' + end + within "#comments" do expect(page).to have_content 'Have you thought about...?' - expect(page).to have_content 'Comments (1)' end end @@ -489,4 +492,4 @@ feature 'Commenting Budget::Investments' do end end -end \ No newline at end of file +end From d2e08d1a0cc21ca31ab6ceb2e22f5266af6b8c08 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:43:07 +0200 Subject: [PATCH 13/75] Remove unused param on both method and call, using class variable instead --- app/controllers/users/omniauth_callbacks_controller.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index cbe43390b..ef1ef31de 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -30,7 +30,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController identity = Identity.first_or_create_from_oauth(auth) @user = current_user || identity.user || User.first_or_initialize_for_oauth(auth) - if save_user(@user) + if save_user identity.update(user: @user) sign_in_and_redirect @user, event: :authentication set_flash_message(:notice, :success, kind: "#{provider}".capitalize) if is_navigational_format? @@ -40,8 +40,8 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController end end - def save_user(user) + def save_user @user.save || @user.save_requiring_finish_signup end -end \ No newline at end of file +end From 47648aa32a7326b3d5df6112a35bb20bee0f5d1a Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:44:04 +0200 Subject: [PATCH 14/75] Remove rubocop Rails/Date from rubocop_todo list since offenses where solved --- .rubocop_todo.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 19e3a59a6..29bc78d7e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -86,14 +86,6 @@ Performance/RedundantMatch: - 'app/controllers/valuation/spending_proposals_controller.rb' - 'app/helpers/embed_videos_helper.rb' -# Offense count: 2 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: strict, flexible -Rails/Date: - Exclude: - - 'app/controllers/concerns/commentable_actions.rb' - - 'app/models/direct_message.rb' - # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: Whitelist. From 6529e37ae8f552280e95ae5d427d14e4f41de4ce Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:44:24 +0200 Subject: [PATCH 15/75] Fix all rubocop Rails/PluralizationGrammar issues and remove the file list form rubocop_todo file --- .rubocop_todo.yml | 9 --------- spec/controllers/comments_controller_spec.rb | 2 +- .../legislation/annotations_controller_spec.rb | 2 +- spec/controllers/legislation/answers_controller_spec.rb | 2 +- spec/factories.rb | 6 +++--- spec/features/admin/banners_spec.rb | 2 +- spec/features/comments/legislation_questions_spec.rb | 2 +- spec/features/debates_spec.rb | 4 ++-- spec/features/legislation/questions_spec.rb | 2 +- spec/features/proposals_spec.rb | 4 ++-- spec/models/legislation/process_spec.rb | 2 +- spec/models/poll/officer_spec.rb | 4 ++-- spec/models/residence_spec.rb | 2 +- 13 files changed, 17 insertions(+), 26 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 29bc78d7e..c27549feb 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -130,15 +130,6 @@ Rails/OutputSafety: - 'app/helpers/users_helper.rb' - 'app/helpers/valuation_helper.rb' -# Offense count: 6 -# Cop supports --auto-correct. -Rails/PluralizationGrammar: - Exclude: - - 'spec/features/admin/banners_spec.rb' - - 'spec/features/debates_spec.rb' - - 'spec/features/proposals_spec.rb' - - 'spec/models/residence_spec.rb' - # Offense count: 11 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: strict, flexible diff --git a/spec/controllers/comments_controller_spec.rb b/spec/controllers/comments_controller_spec.rb index abd2577c2..d06e1900f 100644 --- a/spec/controllers/comments_controller_spec.rb +++ b/spec/controllers/comments_controller_spec.rb @@ -4,7 +4,7 @@ describe CommentsController do describe 'POST create' do before(:each) do - @process = create(:legislation_process, debate_start_date: Date.current - 3.day, debate_end_date: Date.current + 2.days) + @process = create(:legislation_process, debate_start_date: Date.current - 3.days, debate_end_date: Date.current + 2.days) @question = create(:legislation_question, process: @process, title: "Question 1") @user = create(:user, :level_two) @unverified_user = create(:user) diff --git a/spec/controllers/legislation/annotations_controller_spec.rb b/spec/controllers/legislation/annotations_controller_spec.rb index 5b1fd3d39..51425a1f2 100644 --- a/spec/controllers/legislation/annotations_controller_spec.rb +++ b/spec/controllers/legislation/annotations_controller_spec.rb @@ -4,7 +4,7 @@ describe Legislation::AnnotationsController do describe 'POST create' do before(:each) do - @process = create(:legislation_process, allegations_start_date: Date.current - 3.day, allegations_end_date: Date.current + 2.days) + @process = create(:legislation_process, allegations_start_date: Date.current - 3.days, allegations_end_date: Date.current + 2.days) @draft_version = create(:legislation_draft_version, :published, process: @process, title: "Version 1") @final_version = create(:legislation_draft_version, :published, :final_version, process: @process, title: "Final version") @user = create(:user, :level_two) diff --git a/spec/controllers/legislation/answers_controller_spec.rb b/spec/controllers/legislation/answers_controller_spec.rb index 77d037478..569ea2879 100644 --- a/spec/controllers/legislation/answers_controller_spec.rb +++ b/spec/controllers/legislation/answers_controller_spec.rb @@ -4,7 +4,7 @@ describe Legislation::AnswersController do describe 'POST create' do before(:each) do - @process = create(:legislation_process, debate_start_date: Date.current - 3.day, debate_end_date: Date.current + 2.days) + @process = create(:legislation_process, debate_start_date: Date.current - 3.days, debate_end_date: Date.current + 2.days) @question = create(:legislation_question, process: @process, title: "Question 1") @question_option = create(:legislation_question_option, question: @question, value: "Yes") @user = create(:user, :level_two) diff --git a/spec/factories.rb b/spec/factories.rb index 42c8dbfc5..987c53ca9 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -632,7 +632,7 @@ FactoryGirl.define do end_date Date.current + 8.days debate_start_date Date.current + 2.days debate_end_date Date.current + 4.days - draft_publication_date Date.current + 5.day + draft_publication_date Date.current + 5.days allegations_start_date Date.current + 5.days allegations_end_date Date.current + 7.days result_publication_date Date.current + 8.days @@ -643,7 +643,7 @@ FactoryGirl.define do end_date Date.current - 2.days debate_start_date Date.current - 12.days debate_end_date Date.current - 9.days - draft_publication_date Date.current - 8.day + draft_publication_date Date.current - 8.days allegations_start_date Date.current - 8.days allegations_end_date Date.current - 4.days result_publication_date Date.current - 2.days @@ -653,7 +653,7 @@ FactoryGirl.define do start_date Date.current - 5.days end_date Date.current + 5.days debate_start_date Date.current - 5.days - debate_end_date Date.current + 1.days + debate_end_date Date.current + 1.day draft_publication_date Date.current + 1.day allegations_start_date Date.current + 2.days allegations_end_date Date.current + 3.days diff --git a/spec/features/admin/banners_spec.rb b/spec/features/admin/banners_spec.rb index 70d9f7621..28a105bed 100644 --- a/spec/features/admin/banners_spec.rb +++ b/spec/features/admin/banners_spec.rb @@ -29,7 +29,7 @@ feature 'Admin banners magement' do target_url: "http://www.url.com", style: "banner-style.banner-three", image: "banner-img.banner-three", - post_started_at: (Time.current - 1.days), + post_started_at: (Time.current - 1.day), post_ended_at: (Time.current + 10.days)) @banner4 = create(:banner, title: "Banner number four", diff --git a/spec/features/comments/legislation_questions_spec.rb b/spec/features/comments/legislation_questions_spec.rb index 35521e89b..c10b12f55 100644 --- a/spec/features/comments/legislation_questions_spec.rb +++ b/spec/features/comments/legislation_questions_spec.rb @@ -192,7 +192,7 @@ feature 'Commenting legislation questions' do end scenario "Can't create comments if debate phase is not open", :js do - process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current - 1.days) + process.update_attributes(debate_start_date: Date.current - 2.days, debate_end_date: Date.current - 1.day) login_as(user) visit legislation_process_question_path(legislation_question.process, legislation_question) diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index 6914a55f7..4d48508f2 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -629,7 +629,7 @@ feature 'Debates' do click_link "Advanced search" select "Customized", from: "js-advanced-search-date-min" fill_in "advanced_search_date_min", with: 7.days.ago - fill_in "advanced_search_date_max", with: 1.days.ago + fill_in "advanced_search_date_max", with: 1.day.ago click_button "Filter" within("#debates") do @@ -709,7 +709,7 @@ feature 'Debates' do select "Customized", from: "js-advanced-search-date-min" fill_in "advanced_search_date_min", with: 7.days.ago - fill_in "advanced_search_date_max", with: 1.days.ago + fill_in "advanced_search_date_max", with: 1.day.ago click_button "Filter" within "#js-advanced-search" do diff --git a/spec/features/legislation/questions_spec.rb b/spec/features/legislation/questions_spec.rb index 77503b5a9..17d55c16c 100644 --- a/spec/features/legislation/questions_spec.rb +++ b/spec/features/legislation/questions_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' feature 'Legislation' do context 'process debate page' do before(:each) do - @process = create(:legislation_process, debate_start_date: Date.current - 3.day, debate_end_date: Date.current + 2.days) + @process = create(:legislation_process, debate_start_date: Date.current - 3.days, debate_end_date: Date.current + 2.days) create(:legislation_question, process: @process, title: "Question 1") create(:legislation_question, process: @process, title: "Question 2") create(:legislation_question, process: @process, title: "Question 3") diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 16d928f4e..9d8584839 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -1025,7 +1025,7 @@ feature 'Proposals' do click_link "Advanced search" select "Customized", from: "js-advanced-search-date-min" fill_in "advanced_search_date_min", with: 7.days.ago - fill_in "advanced_search_date_max", with: 1.days.ago + fill_in "advanced_search_date_max", with: 1.day.ago click_button "Filter" expect(page).to have_content("There are 2 citizen proposals") @@ -1108,7 +1108,7 @@ feature 'Proposals' do select "Customized", from: "js-advanced-search-date-min" fill_in "advanced_search_date_min", with: 7.days.ago.to_date - fill_in "advanced_search_date_max", with: 1.days.ago.to_date + fill_in "advanced_search_date_max", with: 1.day.ago.to_date click_button "Filter" expect(page).to have_content("citizen proposals cannot be found") diff --git a/spec/models/legislation/process_spec.rb b/spec/models/legislation/process_spec.rb index f14e81c8e..33460832b 100644 --- a/spec/models/legislation/process_spec.rb +++ b/spec/models/legislation/process_spec.rb @@ -71,7 +71,7 @@ RSpec.describe Legislation::Process, type: :model do describe "filter scopes" do before(:each) do @process_1 = create(:legislation_process, start_date: Date.current - 2.days, end_date: Date.current + 1.day) - @process_2 = create(:legislation_process, start_date: Date.current + 1.days, end_date: Date.current + 3.days) + @process_2 = create(:legislation_process, start_date: Date.current + 1.day, end_date: Date.current + 3.days) @process_3 = create(:legislation_process, start_date: Date.current - 4.days, end_date: Date.current - 3.days) end diff --git a/spec/models/poll/officer_spec.rb b/spec/models/poll/officer_spec.rb index 83bdbecc2..1764f7200 100644 --- a/spec/models/poll/officer_spec.rb +++ b/spec/models/poll/officer_spec.rb @@ -48,7 +48,7 @@ describe :officer do poll_1 = create(:poll, ends_at: 1.day.ago) poll_2 = create(:poll, ends_at: 10.days.from_now) - poll_3 = create(:poll, ends_at: 10.day.ago) + poll_3 = create(:poll, ends_at: 10.days.ago) [poll_1, poll_2, poll_3].each do |p| create(:poll_officer_assignment, officer: officer, booth_assignment: create(:poll_booth_assignment, poll: p)) @@ -108,7 +108,7 @@ describe :officer do poll_1 = create(:poll, ends_at: 1.day.ago) poll_2 = create(:poll, ends_at: 10.days.from_now) - poll_3 = create(:poll, ends_at: 10.day.ago) + poll_3 = create(:poll, ends_at: 10.days.ago) [poll_1, poll_2, poll_3].each do |p| create(:poll_officer_assignment, officer: officer, booth_assignment: create(:poll_booth_assignment, poll: p), final: true) diff --git a/spec/models/residence_spec.rb b/spec/models/residence_spec.rb index 6841f636b..98b939084 100644 --- a/spec/models/residence_spec.rb +++ b/spec/models/residence_spec.rb @@ -25,7 +25,7 @@ describe Verification::Residence do end it "should validate user has allowed age" do - residence = Verification::Residence.new({"date_of_birth(3i)"=>"1", "date_of_birth(2i)"=>"1", "date_of_birth(1i)"=>"#{5.year.ago.year}"}) + residence = Verification::Residence.new({"date_of_birth(3i)"=>"1", "date_of_birth(2i)"=>"1", "date_of_birth(1i)"=>"#{5.years.ago.year}"}) expect(residence).to_not be_valid expect(residence.errors[:date_of_birth]).to include("You don't have the required age to participate") end From d759aca522b1174dffbfb8d843ee3a3fc8281f13 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:47:53 +0200 Subject: [PATCH 16/75] Fix all Rails/TimeZone rubocop issues and remove files from rubocop_todo list --- .rubocop_todo.yml | 9 --------- lib/score_calculator.rb | 2 +- .../admin/api/stats_controller_spec.rb | 18 +++++++++--------- spec/lib/graphql_spec.rb | 10 +++++----- spec/models/ahoy/data_source_spec.rb | 6 +++--- 5 files changed, 18 insertions(+), 27 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c27549feb..c9a834849 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -130,15 +130,6 @@ Rails/OutputSafety: - 'app/helpers/users_helper.rb' - 'app/helpers/valuation_helper.rb' -# Offense count: 11 -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: strict, flexible -Rails/TimeZone: - Exclude: - - 'lib/score_calculator.rb' - - 'spec/controllers/admin/api/stats_controller_spec.rb' - - 'spec/models/ahoy/data_source_spec.rb' - # Offense count: 7 # Cop supports --auto-correct. # Configuration parameters: Include. diff --git a/lib/score_calculator.rb b/lib/score_calculator.rb index 32086392a..0b68c025a 100644 --- a/lib/score_calculator.rb +++ b/lib/score_calculator.rb @@ -1,6 +1,6 @@ module ScoreCalculator - EPOC = Time.new(2015, 6, 15) + EPOC = Time.new(2015, 6, 15).in_time_zone COMMENT_WEIGHT = 1.0/5 # 1 positive vote / x comments TIME_UNIT = 24.hours.to_f diff --git a/spec/controllers/admin/api/stats_controller_spec.rb b/spec/controllers/admin/api/stats_controller_spec.rb index 7ba63ffb3..e032014d7 100644 --- a/spec/controllers/admin/api/stats_controller_spec.rb +++ b/spec/controllers/admin/api/stats_controller_spec.rb @@ -17,9 +17,9 @@ describe Admin::Api::StatsController do context 'events present' do before :each do - time_1 = DateTime.parse("2015-01-01") - time_2 = DateTime.parse("2015-01-02") - time_3 = DateTime.parse("2015-01-03") + time_1 = DateTime.parse("2015-01-01").in_time_zone + time_2 = DateTime.parse("2015-01-02").in_time_zone + time_3 = DateTime.parse("2015-01-03").in_time_zone create :ahoy_event, name: 'foo', time: time_1 create :ahoy_event, name: 'foo', time: time_1 @@ -52,8 +52,8 @@ describe Admin::Api::StatsController do context 'visits present' do it 'should return visits formated for working with c3.js' do - time_1 = DateTime.parse("2015-01-01") - time_2 = DateTime.parse("2015-01-02") + time_1 = DateTime.parse("2015-01-01").in_time_zone + time_2 = DateTime.parse("2015-01-02").in_time_zone create :visit, started_at: time_1 create :visit, started_at: time_1 @@ -71,8 +71,8 @@ describe Admin::Api::StatsController do context 'visits and events present' do it 'should return combined events and visits formated for working with c3.js' do - time_1 = DateTime.parse("2015-01-01") - time_2 = DateTime.parse("2015-01-02") + time_1 = DateTime.parse("2015-01-01").in_time_zone + time_2 = DateTime.parse("2015-01-02").in_time_zone create :ahoy_event, name: 'foo', time: time_1 create :ahoy_event, name: 'foo', time: time_2 @@ -94,8 +94,8 @@ describe Admin::Api::StatsController do context 'budget investments present' do it 'should return budget investments formated for working with c3.js' do - time_1 = DateTime.parse("2017-04-01") - time_2 = DateTime.parse("2017-04-02") + time_1 = DateTime.parse("2017-04-01").in_time_zone + time_2 = DateTime.parse("2017-04-02").in_time_zone budget_investment1 = create(:budget_investment, budget: @budget, created_at: time_1) budget_investment2 = create(:budget_investment, budget: @budget, created_at: time_2) diff --git a/spec/lib/graphql_spec.rb b/spec/lib/graphql_spec.rb index 725cc109a..b3b8b377f 100644 --- a/spec/lib/graphql_spec.rb +++ b/spec/lib/graphql_spec.rb @@ -321,7 +321,7 @@ describe 'ConsulSchema' do it 'does not include hidden comments' do visible_comment = create(:comment) - hidden_comment = create(:comment, hidden_at: Time.now) + hidden_comment = create(:comment, hidden_at: Time.current) response = execute('{ comments { edges { node { body } } } }') received_comments = extract_fields(response, 'comments', 'body') @@ -331,7 +331,7 @@ describe 'ConsulSchema' do it 'does not include comments from hidden proposals' do visible_proposal = create(:proposal) - hidden_proposal = create(:proposal, hidden_at: Time.now) + hidden_proposal = create(:proposal, hidden_at: Time.current) visible_proposal_comment = create(:comment, commentable: visible_proposal) hidden_proposal_comment = create(:comment, commentable: hidden_proposal) @@ -344,7 +344,7 @@ describe 'ConsulSchema' do it 'does not include comments from hidden debates' do visible_debate = create(:debate) - hidden_debate = create(:debate, hidden_at: Time.now) + hidden_debate = create(:debate, hidden_at: Time.current) visible_debate_comment = create(:comment, commentable: visible_debate) hidden_debate_comment = create(:comment, commentable: hidden_debate) @@ -567,7 +567,7 @@ describe 'ConsulSchema' do it 'does not include votes of hidden proposals' do visible_proposal = create(:proposal) - hidden_proposal = create(:proposal, hidden_at: Time.now) + hidden_proposal = create(:proposal, hidden_at: Time.current) visible_proposal_vote = create(:vote, votable: visible_proposal) hidden_proposal_vote = create(:vote, votable: hidden_proposal) @@ -580,7 +580,7 @@ describe 'ConsulSchema' do it 'does not include votes of hidden comments' do visible_comment = create(:comment) - hidden_comment = create(:comment, hidden_at: Time.now) + hidden_comment = create(:comment, hidden_at: Time.current) visible_comment_vote = create(:vote, votable: visible_comment) hidden_comment_vote = create(:vote, votable: hidden_comment) diff --git a/spec/models/ahoy/data_source_spec.rb b/spec/models/ahoy/data_source_spec.rb index deb1fd056..cea416498 100644 --- a/spec/models/ahoy/data_source_spec.rb +++ b/spec/models/ahoy/data_source_spec.rb @@ -3,9 +3,9 @@ require 'rails_helper' describe Ahoy::DataSource do describe '#build' do before :each do - time_1 = DateTime.parse("2015-01-01") - time_2 = DateTime.parse("2015-01-02") - time_3 = DateTime.parse("2015-01-03") + time_1 = DateTime.parse("2015-01-01").in_time_zone + time_2 = DateTime.parse("2015-01-02").in_time_zone + time_3 = DateTime.parse("2015-01-03").in_time_zone create :ahoy_event, name: 'foo', time: time_1 create :ahoy_event, name: 'foo', time: time_1 From 8d84ed712a748bd4e44154d8af0bcfe25a11339b Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:49:44 +0200 Subject: [PATCH 17/75] Fix all Rails/Validation rubocop issues and remove files from rubocop_todo list --- .rubocop_todo.yml | 11 ----------- app/models/budget/investment.rb | 4 ++-- app/models/comment.rb | 2 +- app/models/officing/residence.rb | 6 +++--- app/models/spending_proposal.rb | 2 +- app/models/verification/residence.rb | 8 ++++---- app/models/verification/sms.rb | 2 +- 7 files changed, 12 insertions(+), 23 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c9a834849..654a80644 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -130,17 +130,6 @@ Rails/OutputSafety: - 'app/helpers/users_helper.rb' - 'app/helpers/valuation_helper.rb' -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/Validation: - Exclude: - - 'app/models/comment.rb' - - 'app/models/spending_proposal.rb' - - 'app/models/verification/residence.rb' - - 'app/models/verification/sms.rb' - # Offense count: 9 Style/AccessorMethodName: Exclude: diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index b3b51996c..9d38d06d3 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -25,8 +25,8 @@ class Budget validates :author, presence: true validates :description, presence: true validates :heading_id, presence: true - validates_presence_of :unfeasibility_explanation, if: :unfeasibility_explanation_required? - validates_presence_of :price, if: :price_required? + validates :unfeasibility_explanation, presence: { if: :unfeasibility_explanation_required? } + validates :price, presence: { if: :price_required? } validates :title, length: { in: 4..Budget::Investment.title_max_length } validates :description, length: { maximum: Budget::Investment.description_max_length } diff --git a/app/models/comment.rb b/app/models/comment.rb index ffa02d09c..522b7324b 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -13,7 +13,7 @@ class Comment < ActiveRecord::Base validates :body, presence: true validates :user, presence: true - validates_inclusion_of :commentable_type, in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] + validates :commentable_type, inclusion: { in: ["Debate", "Proposal", "Budget::Investment", "Poll::Question", "Legislation::Question", "Legislation::Annotation"] } validate :validate_body_length diff --git a/app/models/officing/residence.rb b/app/models/officing/residence.rb index 92333cc80..1714bbf0e 100644 --- a/app/models/officing/residence.rb +++ b/app/models/officing/residence.rb @@ -6,9 +6,9 @@ class Officing::Residence before_validation :call_census_api - validates_presence_of :document_number - validates_presence_of :document_type - validates_presence_of :year_of_birth + validates :document_number, presence: true + validates :document_type, presence: true + validates :year_of_birth, presence: true validate :allowed_age validate :residence_in_madrid diff --git a/app/models/spending_proposal.rb b/app/models/spending_proposal.rb index 223e9adfe..a37446117 100644 --- a/app/models/spending_proposal.rb +++ b/app/models/spending_proposal.rb @@ -15,7 +15,7 @@ class SpendingProposal < ActiveRecord::Base validates :title, presence: true validates :author, presence: true validates :description, presence: true - validates_presence_of :feasible_explanation, if: :feasible_explanation_required? + validates :feasible_explanation, presence: { if: :feasible_explanation_required? } validates :title, length: { in: 4..SpendingProposal.title_max_length } validates :description, length: { maximum: SpendingProposal.description_max_length } diff --git a/app/models/verification/residence.rb b/app/models/verification/residence.rb index bafff129b..e1b2f6363 100644 --- a/app/models/verification/residence.rb +++ b/app/models/verification/residence.rb @@ -7,10 +7,10 @@ class Verification::Residence before_validation :call_census_api - validates_presence_of :document_number - validates_presence_of :document_type - validates_presence_of :date_of_birth - validates_presence_of :postal_code + validates :document_number, presence: true + validates :document_type, presence: true + validates :date_of_birth, presence: true + validates :postal_code, presence: true validates :terms_of_service, acceptance: { allow_nil: false } validates :postal_code, length: { is: 5 } diff --git a/app/models/verification/sms.rb b/app/models/verification/sms.rb index 1a013f1d8..7c1a1bfa6 100644 --- a/app/models/verification/sms.rb +++ b/app/models/verification/sms.rb @@ -3,7 +3,7 @@ class Verification::Sms attr_accessor :user, :phone, :confirmation_code - validates_presence_of :phone + validates :phone, presence: true validates :phone, format: { with: /\A[\d \+]+\z/ } validate :uniqness_phone From 391b32e1659e3e845f3d160a14c148e431b49486 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:50:41 +0200 Subject: [PATCH 18/75] Remove all Layout/BlockEndNewline rubocop issues and files from rubocop_todo list --- .rubocop_todo.yml | 7 ------- app/models/banner.rb | 5 ++--- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 654a80644..34e62f027 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -165,13 +165,6 @@ Layout/AlignParameters: - 'spec/models/user_spec.rb' - 'spec/rails_helper.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/BlockEndNewline: - Exclude: - - 'app/models/banner.rb' - - 'spec/features/users_auth_spec.rb' - # Offense count: 19 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/app/models/banner.rb b/app/models/banner.rb index c4f2295e6..2764785d1 100644 --- a/app/models/banner.rb +++ b/app/models/banner.rb @@ -12,9 +12,8 @@ class Banner < ActiveRecord::Base validates :post_started_at, presence: true validates :post_ended_at, presence: true - scope :with_active, -> {where("post_started_at <= ?", Time.current). - where("post_ended_at >= ?", Time.current) } + scope :with_active, -> { where("post_started_at <= ?", Time.current).where("post_ended_at >= ?", Time.current) } - scope :with_inactive,-> {where("post_started_at > ? or post_ended_at < ?", Time.current, Time.current) } + scope :with_inactive, -> { where("post_started_at > ? or post_ended_at < ?", Time.current, Time.current) } end From 78efccc19729ac580a513b9f174f1895e97dbdae Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:51:58 +0200 Subject: [PATCH 19/75] Fix all Layout/EmptyLinesAroundAccessModifier rubocop issues and remove files from rubocop_todo list --- .rubocop_todo.yml | 6 ------ app/controllers/admin/poll/polls_controller.rb | 1 + app/controllers/legislation/answers_controller.rb | 1 + app/controllers/officing/final_recounts_controller.rb | 1 + app/controllers/officing/recounts_controller.rb | 1 + app/controllers/users_controller.rb | 1 + 6 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 34e62f027..fefe65c66 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -246,12 +246,6 @@ Layout/EmptyLines: - 'spec/features/verification/verified_user_spec.rb' - 'spec/support/verifiable.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Layout/EmptyLinesAroundAccessModifier: - Exclude: - - 'app/controllers/users_controller.rb' - # Offense count: 29 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index eda5736b0..6046ffb48 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -67,6 +67,7 @@ class Admin::Poll::PollsController < Admin::BaseController end private + def load_geozones @geozones = Geozone.all.order(:name) end diff --git a/app/controllers/legislation/answers_controller.rb b/app/controllers/legislation/answers_controller.rb index 6d3c33580..02946013b 100644 --- a/app/controllers/legislation/answers_controller.rb +++ b/app/controllers/legislation/answers_controller.rb @@ -26,6 +26,7 @@ class Legislation::AnswersController < Legislation::BaseController end private + def answer_params params.require(:legislation_answer).permit( :legislation_question_option_id, diff --git a/app/controllers/officing/final_recounts_controller.rb b/app/controllers/officing/final_recounts_controller.rb index e381240e7..8be6e1a91 100644 --- a/app/controllers/officing/final_recounts_controller.rb +++ b/app/controllers/officing/final_recounts_controller.rb @@ -28,6 +28,7 @@ class Officing::FinalRecountsController < Officing::BaseController end private + def load_poll @poll = Poll.expired.find(params[:poll_id]) end diff --git a/app/controllers/officing/recounts_controller.rb b/app/controllers/officing/recounts_controller.rb index 1c66e57fd..9e3989c05 100644 --- a/app/controllers/officing/recounts_controller.rb +++ b/app/controllers/officing/recounts_controller.rb @@ -27,6 +27,7 @@ class Officing::RecountsController < Officing::BaseController end private + def load_poll @poll = Poll.find(params[:poll_id]) end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9bd98aedd..07ff645e6 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -10,6 +10,7 @@ class UsersController < ApplicationController end private + def set_activity_counts @activity_counts = HashWithIndifferentAccess.new( proposals: Proposal.where(author_id: @user.id).count, From ee9d3cd7e31304848f71a9b959fe5dd237db3ecd Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 19:32:07 +0200 Subject: [PATCH 20/75] Add a scenario for the Calculate Budgets winner investment feature on admin budget spec --- spec/features/admin/budgets_spec.rb | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 760817c26..4f78f3edf 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -109,6 +109,33 @@ feature 'Admin budgets' do end + context "Calculate Budget's Winner Investments" do + + scenario 'For a Budget in reviewing balloting' do + budget = create(:budget, phase: 'reviewing_ballots') + group = create(:budget_group, budget: budget) + heading = create(:budget_heading, group: group, price: 4) + unselected_investment = create(:budget_investment, :unselected, heading: heading, price: 1, ballot_lines_count: 3) + winner_investment = create(:budget_investment, :winner, heading: heading, price: 3, ballot_lines_count: 2) + selected_investment = create(:budget_investment, :selected, heading: heading, price: 2, ballot_lines_count: 1) + + visit edit_admin_budget_path(budget) + click_link 'Calculate Winner Investments' + expect(page).to have_content 'Winners being calculated, it may take a minute.' + expect(page).to have_content winner_investment.title + expect(page).not_to have_content unselected_investment.title + expect(page).not_to have_content selected_investment.title + end + + scenario 'For a finished Budget' do + budget = create(:budget, phase: 'finished') + + visit edit_admin_budget_path(budget) + expect(page).not_to have_content 'Calculate Winner Investments' + end + + end + context 'Manage groups and headings' do scenario 'Create group', :js do From 154cdac33233b7bdfe09b51b43e08d4a1e4ad9ef Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 19:39:28 +0200 Subject: [PATCH 21/75] Add calculate_winners on Admin Budget controller, route and ability for admins --- app/controllers/admin/budgets_controller.rb | 11 ++++++++--- app/models/abilities/administrator.rb | 2 +- app/models/budget.rb | 6 +++++- app/models/budget/result.rb | 7 +++---- config/routes.rb | 4 ++++ 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/app/controllers/admin/budgets_controller.rb b/app/controllers/admin/budgets_controller.rb index 0b373c0bd..b37351028 100644 --- a/app/controllers/admin/budgets_controller.rb +++ b/app/controllers/admin/budgets_controller.rb @@ -14,10 +14,15 @@ class Admin::BudgetsController < Admin::BaseController @budget = Budget.includes(groups: :headings).find(params[:id]) end - def new - end + def new; end - def edit + def edit; end + + def calculate_winners + return unless @budget.balloting_process? + @budget.headings.each { |heading| Budget::Result.new(@budget, heading).calculate_winners } + redirect_to admin_budget_budget_investments_path(budget_id: @budget.id, filter: 'winners'), + notice: I18n.t("admin.budgets.winners.calculated") end def update diff --git a/app/models/abilities/administrator.rb b/app/models/abilities/administrator.rb index 1aba9dd7c..9d779299d 100644 --- a/app/models/abilities/administrator.rb +++ b/app/models/abilities/administrator.rb @@ -44,7 +44,7 @@ module Abilities can [:read, :update, :valuate, :destroy, :summary], SpendingProposal - can [:index, :read, :new, :create, :update, :destroy], Budget + can [:index, :read, :new, :create, :update, :destroy, :calculate_winners], Budget can [:read, :create, :update, :destroy], Budget::Group can [:read, :create, :update, :destroy], Budget::Heading can [:hide, :update, :toggle_selection], Budget::Investment diff --git a/app/models/budget.rb b/app/models/budget.rb index a5932921c..bc7231f29 100644 --- a/app/models/budget.rb +++ b/app/models/budget.rb @@ -67,8 +67,12 @@ class Budget < ActiveRecord::Base phase == "finished" end + def balloting_process? + balloting? || reviewing_ballots? + end + def balloting_or_later? - balloting? || reviewing_ballots? || finished? + balloting_process? || finished? end def on_hold? diff --git a/app/models/budget/result.rb b/app/models/budget/result.rb index f29bc72cc..f835bce0c 100644 --- a/app/models/budget/result.rb +++ b/app/models/budget/result.rb @@ -12,11 +12,10 @@ class Budget reset_winners investments.each do |investment| @current_investment = investment - if inside_budget? - set_winner - end + set_winner if inside_budget? end end + handle_asynchronously :calculate_winners def investments heading.investments.selected.sort_by_ballots @@ -52,4 +51,4 @@ class Budget end end -end \ No newline at end of file +end diff --git a/config/routes.rb b/config/routes.rb index 5c5284a91..6d0f2959c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -193,6 +193,10 @@ Rails.application.routes.draw do end resources :budgets do + member do + put :calculate_winners + end + resources :budget_groups do resources :budget_headings do end From 57ba414a34161c58e9a70c856995865cdec887f1 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 19:50:04 +0200 Subject: [PATCH 22/75] Add button on Admin Budget edit form to call calculate winners if budget is reviewing_ballots --- app/views/admin/budgets/_form.html.erb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app/views/admin/budgets/_form.html.erb b/app/views/admin/budgets/_form.html.erb index 5d323b45c..58a56d564 100644 --- a/app/views/admin/budgets/_form.html.erb +++ b/app/views/admin/budgets/_form.html.erb @@ -16,5 +16,15 @@ <%= f.select :currency_symbol, budget_currency_symbol_select_options %>
    - <%= f.submit nil, class: "button success" %> +
    + <%= f.submit nil, class: "button success" %> + <% if @budget.balloting_process? %> +
    + <%= link_to t("admin.budgets.winners.calculate"), + calculate_winners_admin_budget_path(@budget), + method: :put, + class: "button hollow" %> +
    + <% end %> +
    <% end %> From 47c0b25f9c85a6bc33f3176ed4bc996f68236d7b Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 19:50:42 +0200 Subject: [PATCH 23/75] Add text translations for both admin budget winners calculate and calculated texts --- config/locales/admin.en.yml | 3 +++ config/locales/admin.es.yml | 3 +++ config/locales/admin.fr.yml | 3 +++ config/locales/admin.nl.yml | 3 +++ 4 files changed, 12 insertions(+) diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index bbd8dd1bd..095e99555 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -101,6 +101,9 @@ en: no_heading: This group has no assigned heading. table_heading: Heading table_amount: Amount + winners: + calculate: Calculate Winner Investments + calculated: Winners being calculated, it may take a minute. budget_investments: index: heading_filter_all: All headings diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index a3c6a99b9..f3e6134eb 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -101,6 +101,9 @@ es: no_heading: Este grupo no tiene ninguna partida asignada. table_heading: Partida table_amount: Cantidad + winners: + calculate: Calcular propuestas ganadoras + calculated: Calculando ganadoras, puede tardar un minuto. budget_investments: index: heading_filter_all: Todas las partidas diff --git a/config/locales/admin.fr.yml b/config/locales/admin.fr.yml index 8100a95a6..549ddd813 100644 --- a/config/locales/admin.fr.yml +++ b/config/locales/admin.fr.yml @@ -101,6 +101,9 @@ fr: no_heading: Ce groupe n'a pas de rubrique assignée. table_heading: Rubrique table_amount: Montant + winners: + calculate: Calculate Winner Investments + calculated: Winners being calculated, it may take a minute. budget_investments: index: heading_filter_all: Toutes les rubriques diff --git a/config/locales/admin.nl.yml b/config/locales/admin.nl.yml index 40b21ed32..e401952c9 100755 --- a/config/locales/admin.nl.yml +++ b/config/locales/admin.nl.yml @@ -102,6 +102,9 @@ nl: no_heading: This group has no assigned heading. table_heading: Heading table_amount: Amount + winners: + calculate: Calculate Winner Investments + calculated: Winners being calculated, it may take a minute. budget_investments: index: heading_filter_all: All headings From 6d941f8b5203d2d2d43587ee2a969c36756ef738 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:08:35 +0200 Subject: [PATCH 24/75] Add population integer attribute to Budget::Heading model table --- .../20170621180611_add_population_to_budget_headings.rb | 5 +++++ db/schema.rb | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20170621180611_add_population_to_budget_headings.rb diff --git a/db/migrate/20170621180611_add_population_to_budget_headings.rb b/db/migrate/20170621180611_add_population_to_budget_headings.rb new file mode 100644 index 000000000..b17673397 --- /dev/null +++ b/db/migrate/20170621180611_add_population_to_budget_headings.rb @@ -0,0 +1,5 @@ +class AddPopulationToBudgetHeadings < ActiveRecord::Migration + def change + add_column :budget_headings, :population, :integer, default: 0 + end +end diff --git a/db/schema.rb b/db/schema.rb index 8fae3e8dd..64b81a350 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170613203256) do +ActiveRecord::Schema.define(version: 20170621180611) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -110,6 +110,7 @@ ActiveRecord::Schema.define(version: 20170613203256) do t.integer "group_id" t.string "name", limit: 50 t.integer "price", limit: 8 + t.integer "population", default: 0 end add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree From 51f897565409fc049bfec84511ad5c181a4633b5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:21:32 +0200 Subject: [PATCH 25/75] Increase admin budget spec feature to check Budget Heading creation allows to set population value --- spec/features/admin/budgets_spec.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/spec/features/admin/budgets_spec.rb b/spec/features/admin/budgets_spec.rb index 760817c26..57cf1ec16 100644 --- a/spec/features/admin/budgets_spec.rb +++ b/spec/features/admin/budgets_spec.rb @@ -156,6 +156,7 @@ feature 'Admin budgets' do fill_in 'budget_heading_name', with: 'District 9 reconstruction' fill_in 'budget_heading_price', with: '6785' + fill_in 'budget_heading_population', with: '100500' click_button 'Save heading' end @@ -167,6 +168,7 @@ feature 'Admin budgets' do expect(page).to have_content 'District 9 reconstruction' expect(page).to have_content '6785' + expect(page).to have_content '100500' end end From 8cd7c685dc17f41585ae308a2440717e5bfd88ba Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:22:37 +0200 Subject: [PATCH 26/75] Add population to allowed params on admin budget heading controller --- app/controllers/admin/budget_headings_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/admin/budget_headings_controller.rb b/app/controllers/admin/budget_headings_controller.rb index 56903b744..eea93716f 100644 --- a/app/controllers/admin/budget_headings_controller.rb +++ b/app/controllers/admin/budget_headings_controller.rb @@ -12,7 +12,7 @@ class Admin::BudgetHeadingsController < Admin::BaseController private def budget_heading_params - params.require(:budget_heading).permit(:name, :price, :geozone_id) + params.require(:budget_heading).permit(:name, :price, :population) end -end \ No newline at end of file +end From d77355de0d74ef8b8a4a8377abb46583841774d1 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:23:14 +0200 Subject: [PATCH 27/75] Add population field to admin Budget Heading form and headings list table --- app/views/admin/budgets/_group.html.erb | 15 ++++++++++++++- ...621180611_add_population_to_budget_headings.rb | 2 +- db/schema.rb | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/views/admin/budgets/_group.html.erb b/app/views/admin/budgets/_group.html.erb index 6193fe287..8537fa477 100644 --- a/app/views/admin/budgets/_group.html.erb +++ b/app/views/admin/budgets/_group.html.erb @@ -1,7 +1,7 @@ - @@ -21,6 +21,7 @@ + @@ -45,6 +46,15 @@ placeholder: t("admin.budgets.form.amount") %> +
    +
    + + <%= f.text_field :population, + label: false, + maxlength: 8, + placeholder: t("admin.budgets.form.population") %> +
    +
    <%= f.submit t("admin.budgets.form.save_heading"), class: "button success" %> <% end %> @@ -60,6 +70,9 @@ + <% end %> diff --git a/db/migrate/20170621180611_add_population_to_budget_headings.rb b/db/migrate/20170621180611_add_population_to_budget_headings.rb index b17673397..fe723bc98 100644 --- a/db/migrate/20170621180611_add_population_to_budget_headings.rb +++ b/db/migrate/20170621180611_add_population_to_budget_headings.rb @@ -1,5 +1,5 @@ class AddPopulationToBudgetHeadings < ActiveRecord::Migration def change - add_column :budget_headings, :population, :integer, default: 0 + add_column :budget_headings, :population, :integer, default: nil end end diff --git a/db/schema.rb b/db/schema.rb index 64b81a350..dbdcc318d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -110,7 +110,7 @@ ActiveRecord::Schema.define(version: 20170621180611) do t.integer "group_id" t.string "name", limit: 50 t.integer "price", limit: 8 - t.integer "population", default: 0 + t.integer "population" end add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree From 9f05cda5c307a24108a2ed25dd9dc6072444a4f5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 20:23:34 +0200 Subject: [PATCH 28/75] Add text translations for new population field on Budget Heading for admin panel --- config/locales/admin.en.yml | 2 ++ config/locales/admin.es.yml | 2 ++ config/locales/admin.fr.yml | 2 ++ config/locales/admin.nl.yml | 2 ++ 4 files changed, 8 insertions(+) diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index bbd8dd1bd..5821fd99d 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -97,10 +97,12 @@ en: heading: Heading name add_heading: Add heading amount: Amount + population: Population save_heading: Save heading no_heading: This group has no assigned heading. table_heading: Heading table_amount: Amount + table_population: Population budget_investments: index: heading_filter_all: All headings diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index a3c6a99b9..488935f06 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -97,10 +97,12 @@ es: heading: Nombre de la partida add_heading: Añadir partida amount: Cantidad + population: Población save_heading: Guardar partida no_heading: Este grupo no tiene ninguna partida asignada. table_heading: Partida table_amount: Cantidad + table_population: Población budget_investments: index: heading_filter_all: Todas las partidas diff --git a/config/locales/admin.fr.yml b/config/locales/admin.fr.yml index 8100a95a6..4db6d1915 100644 --- a/config/locales/admin.fr.yml +++ b/config/locales/admin.fr.yml @@ -97,10 +97,12 @@ fr: heading: Nom de la rubrique add_heading: Ajouter une rubrique amount: Montant + population: Population save_heading: Sauvegarder la rubrique no_heading: Ce groupe n'a pas de rubrique assignée. table_heading: Rubrique table_amount: Montant + table_population: Population budget_investments: index: heading_filter_all: Toutes les rubriques diff --git a/config/locales/admin.nl.yml b/config/locales/admin.nl.yml index 40b21ed32..b97e0a9c2 100755 --- a/config/locales/admin.nl.yml +++ b/config/locales/admin.nl.yml @@ -98,10 +98,12 @@ nl: heading: Heading name add_heading: Add heading amount: Amount + population: Population save_heading: Save heading no_heading: This group has no assigned heading. table_heading: Heading table_amount: Amount + table_population: Population budget_investments: index: heading_filter_all: All headings From 9504958a0804deb3cc48474024bd03bc4929726f Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 26 Jun 2017 11:10:30 +0200 Subject: [PATCH 29/75] Disable Style/SymbolArray rubocop cop after core discussion about it --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index 58cf10d34..cbb1bd0fb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -31,6 +31,9 @@ Style/FrozenStringLiteralComment: Style/PercentLiteralDelimiters: Enabled: false +Style/SymbolArray: + Enabled: false + Layout/EmptyLinesAroundClassBody: Enabled: false From 64ff75c3840cbfde2c6ed62e42fc6f63f8e86728 Mon Sep 17 00:00:00 2001 From: taitus Date: Mon, 26 Jun 2017 13:08:28 +0200 Subject: [PATCH 30/75] Add displaying no_milestones text on admin --- app/models/interest.rb | 5 +++++ app/views/admin/budget_investments/_milestones.html.erb | 4 ++++ config/locales/admin.en.yml | 1 + config/locales/admin.es.yml | 1 + spec/features/admin/budget_investment_milestones_spec.rb | 7 +++++++ 5 files changed, 18 insertions(+) create mode 100644 app/models/interest.rb diff --git a/app/models/interest.rb b/app/models/interest.rb new file mode 100644 index 000000000..278c5fcab --- /dev/null +++ b/app/models/interest.rb @@ -0,0 +1,5 @@ +class Interest < ActiveRecord::Base + belongs_to :user + belongs_to :interestable, polymorphic: true + +end diff --git a/app/views/admin/budget_investments/_milestones.html.erb b/app/views/admin/budget_investments/_milestones.html.erb index 8fe5154af..4338dabfd 100644 --- a/app/views/admin/budget_investments/_milestones.html.erb +++ b/app/views/admin/budget_investments/_milestones.html.erb @@ -29,4 +29,8 @@ <% end %>
    + <%= group.name %> <%= link_to t("admin.budgets.form.add_heading"), "#", class: "button float-right js-toggle-link", data: { "toggle-selector" => "#group-#{group.id}-new-heading-form" } %>
    <%= t("admin.budgets.form.table_heading") %> <%= t("admin.budgets.form.table_amount") %><%= t("admin.budgets.form.table_population") %>
    <%= heading.price %> + <%= heading.population %> +
    +<% else %> +

    + <%= t('admin.milestones.index.no_milestones') %> +

    <% end %> diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml index 96dc32a8b..baca6b270 100755 --- a/config/locales/admin.en.yml +++ b/config/locales/admin.en.yml @@ -169,6 +169,7 @@ en: table_description: "Description" table_actions: "Actions" delete: "Delete milestone" + no_milestones: "Don't have defined milestones" new: creating: Create milestone edit: diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml index 2b0b68a1c..f47bd19a8 100644 --- a/config/locales/admin.es.yml +++ b/config/locales/admin.es.yml @@ -169,6 +169,7 @@ es: table_description: "Descripción" table_actions: "Acciones" delete: "Eliminar hito" + no_milestones: "No hay hitos definidos" new: creating: Crear hito edit: diff --git a/spec/features/admin/budget_investment_milestones_spec.rb b/spec/features/admin/budget_investment_milestones_spec.rb index 208cc61a0..9bcb78479 100644 --- a/spec/features/admin/budget_investment_milestones_spec.rb +++ b/spec/features/admin/budget_investment_milestones_spec.rb @@ -19,6 +19,13 @@ feature 'Admin budget investment milestones' do expect(page).to have_content(milestone.title) expect(page).to have_content(milestone.id) end + + scenario 'Displaying no_milestones text' do + visit admin_budget_budget_investment_path(@investment.budget, @investment) + + expect(page).to have_content("Milestone") + expect(page).to have_content("Don't have defined milestones") + end end context "New" do From 0222d61e1eb5165d8e4e10addef16fdb53378e93 Mon Sep 17 00:00:00 2001 From: taitus Date: Mon, 26 Jun 2017 13:52:23 +0200 Subject: [PATCH 31/75] Remove interest.rb --- app/models/interest.rb | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 app/models/interest.rb diff --git a/app/models/interest.rb b/app/models/interest.rb deleted file mode 100644 index 278c5fcab..000000000 --- a/app/models/interest.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Interest < ActiveRecord::Base - belongs_to :user - belongs_to :interestable, polymorphic: true - -end From fee9e99d37403aba308dce562647338bc93f8970 Mon Sep 17 00:00:00 2001 From: taitus Date: Mon, 26 Jun 2017 13:20:09 +0200 Subject: [PATCH 32/75] Add translation to published milestone. Fix test --- app/views/budgets/investments/_milestones.html.erb | 2 +- config/locales/budgets.en.yml | 1 + config/locales/budgets.es.yml | 1 + spec/features/budgets/investments_spec.rb | 1 + 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/views/budgets/investments/_milestones.html.erb b/app/views/budgets/investments/_milestones.html.erb index 8a45fc3ae..b848c5bc5 100644 --- a/app/views/budgets/investments/_milestones.html.erb +++ b/app/views/budgets/investments/_milestones.html.erb @@ -12,7 +12,7 @@
  • <%= milestone.title %>

    - Publicado el <%= milestone.created_at.strftime("%d/%m/%Y") %> + <%= t("budgets.investments.show.milestone_publish_date", publish_date: milestone.created_at.strftime("%d/%m/%Y")) %>

    <%= milestone.description %>

  • diff --git a/config/locales/budgets.en.yml b/config/locales/budgets.en.yml index 15fb814d6..75a56c919 100644 --- a/config/locales/budgets.en.yml +++ b/config/locales/budgets.en.yml @@ -96,6 +96,7 @@ en: comments_tab: Comments milestones_tab: Milestones no_milestones: Don't have defined milestones + milestone_publish_date: "Published %{publish_date}" wrong_price_format: Only integer numbers investment: add: Vote diff --git a/config/locales/budgets.es.yml b/config/locales/budgets.es.yml index fce746e39..4c35d8902 100644 --- a/config/locales/budgets.es.yml +++ b/config/locales/budgets.es.yml @@ -96,6 +96,7 @@ es: comments_tab: Comentarios milestones_tab: Seguimiento no_milestones: No hay hitos definidos + milestone_publish_date: "Publicado el %{publish_date}" wrong_price_format: Solo puede incluir caracteres numéricos investment: add: Votar diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index c795984c7..f8110b614 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -402,6 +402,7 @@ feature 'Budget Investments' do within("#tab-milestones") do expect(page).to have_content(milestone.title) expect(page).to have_content(milestone.description) + expect(page).to have_content("Published #{milestone.created_at.strftime("%d/%m/%Y")}") end end From 3ab9d8ce18c8e2ef6f8f3d937c515579118184da Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 26 Jun 2017 15:44:32 +0200 Subject: [PATCH 33/75] adds color contrast checker link on readme files --- README.md | 2 ++ README_ES.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/README.md b/README.md index a9ec82550..b4eee154a 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,8 @@ If you add SCSS code you can check it with: scss-lint ``` +To maintain accesibility level, if you add new colors use a [Color contrast checker](http://webaim.org/resources/contrastchecker/) (WCAG AA is mandatory, WCAG AAA is recommended) + If you work on Coffeescript code you can check it with [coffeelint](http://www.coffeelint.org/) (install with `npm install -g coffeelint`) : ``` diff --git a/README_ES.md b/README_ES.md index 81a7ba465..5f2f4843d 100644 --- a/README_ES.md +++ b/README_ES.md @@ -65,6 +65,8 @@ Si añades código SCSS puedes revisarlo con: scss-lint ``` +Para mantener el nivel de accesibilidad, si añades colores nuevos utiliza un [Comprobador de contraste de color](http://webaim.org/resources/contrastchecker/) (WCAG AA es obligatorio, WCAG AAA es recomendable) + Si trabajas en código coffeescript puedes revisarlo con [coffeelint](http://www.coffeelint.org/) (instalalo con `npm install -g coffeelint`) : ``` From 4db83e73059443ce77aa2a891fab9b6cb3b42d7e Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 26 Jun 2017 16:37:55 +0200 Subject: [PATCH 34/75] makes milestones textarea form bigger --- app/views/admin/budget_investment_milestones/_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/admin/budget_investment_milestones/_form.html.erb b/app/views/admin/budget_investment_milestones/_form.html.erb index 5f8af9d33..95237c2ca 100644 --- a/app/views/admin/budget_investment_milestones/_form.html.erb +++ b/app/views/admin/budget_investment_milestones/_form.html.erb @@ -1,7 +1,7 @@ <%= form_for [:admin, @investment.budget, @investment, @milestone] do |f| %> <%= f.text_field :title, maxlength: Budget::Investment::Milestone.title_max_length %> - <%= f.text_area :description %> + <%= f.text_area :description, rows: 5 %> <%= f.submit nil, class: "button success" %> <% end %> From c793202a33fb78cd2961c42ffca0f139dd491591 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 26 Jun 2017 16:40:33 +0200 Subject: [PATCH 35/75] improves color contrast on milestone date --- app/assets/stylesheets/participation.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 76d947c2b..6318e2c24 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -539,7 +539,7 @@ } strong { - color: $text-light; + color: $text-medium; font-size: 0.9rem; } } From fac913edde459f1201c469b005d4f393c489f341 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 26 Jun 2017 16:41:32 +0200 Subject: [PATCH 36/75] removes empty lines on scss --- app/assets/stylesheets/participation.scss | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 6318e2c24..8773e4111 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -494,7 +494,6 @@ } } - .tab-milestones ul { position: relative; margin-top: rem-calc(40); @@ -595,7 +594,6 @@ } } - // 04. List participation // ---------------------- From a2caffef1811c515006213f060b2c680486cfa8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Mon, 26 Jun 2017 16:26:46 +0200 Subject: [PATCH 37/75] defaults to EN docs --- CODE_OF_CONDUCT_EN.md => CODE_OF_CONDUCT.md | 0 CONTRIBUTING_EN.md => CONTRIBUTING.md | 2 +- README.md | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename CODE_OF_CONDUCT_EN.md => CODE_OF_CONDUCT.md (100%) rename CONTRIBUTING_EN.md => CONTRIBUTING.md (96%) diff --git a/CODE_OF_CONDUCT_EN.md b/CODE_OF_CONDUCT.md similarity index 100% rename from CODE_OF_CONDUCT_EN.md rename to CODE_OF_CONDUCT.md diff --git a/CONTRIBUTING_EN.md b/CONTRIBUTING.md similarity index 96% rename from CONTRIBUTING_EN.md rename to CONTRIBUTING.md index 2c5f6a591..2ebf8082f 100644 --- a/CONTRIBUTING_EN.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ ## Code of conduct -The team members and the project's community adopts an inclusive Code of Conduct that you can read in the [CODE_OF_CONDUCT_EN.md](CODE_OF_CONDUCT_EN.md) file. +The team members and the project's community adopts an inclusive Code of Conduct that you can read in the [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) file. ## Report an issue diff --git a/README.md b/README.md index a9ec82550..37f28e086 100644 --- a/README.md +++ b/README.md @@ -100,4 +100,4 @@ Code published under AFFERO GPL v3 (see [LICENSE-AGPLv3.txt](LICENSE-AGPLv3.txt) ## Contributions -See [CONTRIBUTING_EN.md](CONTRIBUTING_EN.md) +See [CONTRIBUTING.md](CONTRIBUTING.md) From 1912d57dc7120c44b04b0d32089e531e0f5d0cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Mon, 26 Jun 2017 16:31:23 +0200 Subject: [PATCH 38/75] adds Berto to core team --- CONTRIBUTING.md | 9 +++++---- CONTRIBUTING_ES.md | 5 +++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 2ebf8082f..3147d1e4a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,15 +1,16 @@ # How to Contribute to this Project -## Team members +## Core team members -* Raimond Garcia [github](https://github.com/voodoorai2000) | [twitter](https://twitter.com/voodoorai2000) +* Raimond García [github](https://github.com/voodoorai2000) | [twitter](https://twitter.com/voodoorai2000) * Juanjo Bazán [github](https://github.com/xuanxu) | [twitter](https://twitter.com/xuanxu) * Enrique García Cota [github](https://github.com/kikito) | [twitter](https://twitter.com/otikik) -* Alberto Garcia Cabeza [github](https://github.com/decabeza) | [twitter](https://twitter.com/decabeza) +* Alberto García Cabeza [github](https://github.com/decabeza) | [twitter](https://twitter.com/decabeza) +* Alberto Calderón [github](https://github.com/bertocq) | [twitter](https://twitter.com/bertocq) ## Code of conduct -The team members and the project's community adopts an inclusive Code of Conduct that you can read in the [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) file. +The core team members and the project's community adopts an inclusive Code of Conduct that you can read in the [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) file. ## Report an issue diff --git a/CONTRIBUTING_ES.md b/CONTRIBUTING_ES.md index 6be8be9cd..b981bc408 100644 --- a/CONTRIBUTING_ES.md +++ b/CONTRIBUTING_ES.md @@ -2,10 +2,11 @@ ## Miembros del equipo -* Raimond Garcia [github](https://github.com/voodoorai2000) | [twitter](https://twitter.com/voodoorai2000) +* Raimond García [github](https://github.com/voodoorai2000) | [twitter](https://twitter.com/voodoorai2000) * Juanjo Bazán [github](https://github.com/xuanxu) | [twitter](https://twitter.com/xuanxu) * Enrique García Cota [github](https://github.com/kikito) | [twitter](https://twitter.com/otikik) -* Alberto Garcia Cabeza [github](https://github.com/decabeza) | [twitter](https://twitter.com/decabeza) +* Alberto García Cabeza [github](https://github.com/decabeza) | [twitter](https://twitter.com/decabeza) +* Alberto Calderón [github](https://github.com/bertocq) | [twitter](https://twitter.com/bertocq) ## Código de conducta From 8bcf6e1a60877ee0ceb7f2cbfdf623779508fedd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Mon, 26 Jun 2017 16:46:47 +0200 Subject: [PATCH 39/75] adds changelog --- CHANGELOG.md | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..a487eadb4 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,38 @@ +### 0.9 - 2017-06-15 + +* New features + * Budgets + * Basic polls + * Collaborative legistlation + * Custom pages + * GraphQL API + * Improved admin section +* Enhancements + * Improved admin section + * Rails 4.2.8 + * Ruby 2.3.2 +* Bug fixes + * CKEditor locale compilation fixed + * Fixed bugs in mobile layouts +* Deprecations + * SpendingProposals are deprecated now in favor of Budgets + +### 0.8 - 2016-07-21 + +* New features + * Support for customization schema, vía specific custom files, assets and folders +* Enhancements + * Rails 2.4.7 + * Ruby 2.3.1 +* Bug fixes + * Fixed bug causing errors on user deletion + +### 0.7 - 2016-04-25 + +* New features + * Debates + * Proposals + * Basic Spending Proposals +* Enhancements + * Rails 2.4.6 + * Ruby 2.2.3 \ No newline at end of file From 67f49a5f8ec14fd25fe92f4b7b45bccf3431411b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Mon, 26 Jun 2017 16:50:36 +0200 Subject: [PATCH 40/75] updates phantoms recommended version --- README.md | 2 +- README_ES.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 37f28e086..918dfb5ff 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Run the app locally: bin/rails s ``` -Prerequisites for testing: install PhantomJS >= 1.9.8 +Prerequisites for testing: install PhantomJS >= 2.1.1 Run the tests with: diff --git a/README_ES.md b/README_ES.md index 81a7ba465..4bb11f58e 100644 --- a/README_ES.md +++ b/README_ES.md @@ -51,7 +51,7 @@ Para ejecutar la aplicación en local: bin/rails s ``` -Prerequisitos para los tests: tener instalado PhantomJS >= 1.9.8 +Prerequisitos para los tests: tener instalado PhantomJS >= 2.1.1 Para ejecutar los tests: From ffff527862ea1892c4188c4f09052198a9280468 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 26 Jun 2017 16:51:53 +0200 Subject: [PATCH 41/75] avoids qualifying elements in selectors --- app/assets/stylesheets/participation.scss | 16 ++++++++++------ .../budgets/investments/_milestones.html.erb | 6 ++++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 8773e4111..51c34a38c 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -528,7 +528,7 @@ } } -.tab-milestones ul div { +.tab-milestones ul .milestone-content { position: relative; padding: rem-calc(3) rem-calc(10); @@ -537,7 +537,7 @@ margin-bottom: 0; } - strong { + .milestone-date { color: $text-medium; font-size: 0.9rem; } @@ -546,7 +546,8 @@ .tab-milestones .timeline ul li:nth-child(odd), .tab-milestones .timeline ul li:nth-child(even) { - div { + .milestone-content { + @include breakpoint(medium) { width: rem-calc(300); } @@ -558,7 +559,8 @@ } .tab-milestones .timeline ul li:nth-child(odd) { - div { + + .milestone-content { text-align: right; @include breakpoint(medium) { @@ -572,7 +574,8 @@ } .tab-milestones .timeline ul li:nth-child(even) { - div { + + .milestone-content { left: rem-calc(15); } } @@ -585,7 +588,8 @@ &:nth-child(odd), &:nth-child(even) { - div { + + .milestone-content { text-align: left; left: rem-calc(15); } diff --git a/app/views/budgets/investments/_milestones.html.erb b/app/views/budgets/investments/_milestones.html.erb index b848c5bc5..87cd1cdd6 100644 --- a/app/views/budgets/investments/_milestones.html.erb +++ b/app/views/budgets/investments/_milestones.html.erb @@ -10,9 +10,11 @@
      <% @investment.milestones.each do |milestone| %>
    • -
      +

      <%= milestone.title %>

      - <%= t("budgets.investments.show.milestone_publish_date", publish_date: milestone.created_at.strftime("%d/%m/%Y")) %> + + <%= t("budgets.investments.show.milestone_publish_date", publish_date: milestone.created_at.strftime("%d/%m/%Y")) %> +

      <%= milestone.description %>

    • From 6bb434f0ddcd9ef8da4bd0ff9429aea71fd84e64 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 26 Jun 2017 17:06:02 +0200 Subject: [PATCH 42/75] improves css units --- app/assets/stylesheets/participation.scss | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 51c34a38c..4f12979af 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -507,11 +507,11 @@ li::before { content: ''; position: absolute; - top: rem-calc(5); + top: 5px; transform: translateX(-50%); width: rem-calc(20); height: rem-calc(20); - border-radius: 50%; + border-radius: rem-calc(20); background: $budget; z-index: 2; } @@ -523,23 +523,22 @@ bottom: 100%; height: 100%; position: absolute; - top: rem-calc(25); + top: 25px; z-index: 1; } } .tab-milestones ul .milestone-content { position: relative; - padding: rem-calc(3) rem-calc(10); + padding: $line-height / 6 $line-height / 2; h3 { - font-size: 1.2rem; margin-bottom: 0; } .milestone-date { color: $text-medium; - font-size: 0.9rem; + font-size: $small-font-size; } } @@ -576,7 +575,7 @@ .tab-milestones .timeline ul li:nth-child(even) { .milestone-content { - left: rem-calc(15); + left: 15px; } } @@ -591,7 +590,7 @@ .milestone-content { text-align: left; - left: rem-calc(15); + left: 15px; } } } From 4b3d585ecd73024a7eb710c4dc76d8e7594acecd Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 26 Jun 2017 17:07:50 +0200 Subject: [PATCH 43/75] =?UTF-8?q?changes=20css=20attributes=20to=20alphabe?= =?UTF-8?q?tical=20order=20=F0=9F=A4=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/assets/stylesheets/participation.scss | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/participation.scss b/app/assets/stylesheets/participation.scss index 4f12979af..8af8071ea 100644 --- a/app/assets/stylesheets/participation.scss +++ b/app/assets/stylesheets/participation.scss @@ -495,42 +495,42 @@ } .tab-milestones ul { - position: relative; margin-top: rem-calc(40); + position: relative; li { + margin: 0 auto; position: relative; width: 0; - margin: 0 auto; } li::before { + background: $budget; + border-radius: rem-calc(20); content: ''; + height: rem-calc(20); position: absolute; top: 5px; transform: translateX(-50%); width: rem-calc(20); - height: rem-calc(20); - border-radius: rem-calc(20); - background: $budget; z-index: 2; } li::after { - content: ''; - width: 1px; background: $light-gray; bottom: 100%; + content: ''; height: 100%; position: absolute; top: 25px; + width: 1px; z-index: 1; } } .tab-milestones ul .milestone-content { - position: relative; padding: $line-height / 6 $line-height / 2; + position: relative; h3 { margin-bottom: 0; @@ -589,8 +589,8 @@ &:nth-child(even) { .milestone-content { - text-align: left; left: 15px; + text-align: left; } } } From cf81c740b18bcaabf03cbceab7551355bab76671 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 22:31:25 +0200 Subject: [PATCH 44/75] Fix Style/ZeroLengthPredicate rubocop issue and remove file list from rubocop_todo --- .rubocop_todo.yml | 6 ------ app/models/concerns/verification.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fefe65c66..566c762d6 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -706,9 +706,3 @@ Style/VariableNumber: Style/WordArray: EnforcedStyle: percent MinSize: 3 - -# Offense count: 1 -# Cop supports --auto-correct. -Style/ZeroLengthPredicate: - Exclude: - - 'app/models/concerns/verification.rb' diff --git a/app/models/concerns/verification.rb b/app/models/concerns/verification.rb index 4eb933204..88458a03d 100644 --- a/app/models/concerns/verification.rb +++ b/app/models/concerns/verification.rb @@ -47,7 +47,7 @@ module Verification end def failed_residence_verification? - !residence_verified? && failed_census_calls.size > 0 + !residence_verified? && !failed_census_calls.empty? end def no_phone_available? From 80bcf38dc5fc9fd3a7fdedb8c261db1cdb16398d Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 22:32:11 +0200 Subject: [PATCH 45/75] Fix all Layout/TrailingWhitespace rubocop issues and remove from rubocop_todo list --- .rubocop_todo.yml | 6 ------ app/models/geozone.rb | 2 +- app/models/organization.rb | 2 +- spec/models/abilities/common_spec.rb | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 566c762d6..9c480cc5a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -674,12 +674,6 @@ Style/SymbolProc: - 'lib/manager_authenticator.rb' - 'spec/factories.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/TrailingWhitespace: - Exclude: - - 'app/controllers/admin/api/stats_controller.rb' - # Offense count: 31 # Cop supports --auto-correct. Style/UnneededInterpolation: diff --git a/app/models/geozone.rb b/app/models/geozone.rb index ad0fe9cd5..a52ab5d15 100644 --- a/app/models/geozone.rb +++ b/app/models/geozone.rb @@ -1,7 +1,7 @@ class Geozone < ActiveRecord::Base include Graphqlable - + has_many :proposals has_many :spending_proposals has_many :debates diff --git a/app/models/organization.rb b/app/models/organization.rb index 94ef986a1..f3f8956d5 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -1,7 +1,7 @@ class Organization < ActiveRecord::Base include Graphqlable - + belongs_to :user, touch: true validates :name, presence: true diff --git a/spec/models/abilities/common_spec.rb b/spec/models/abilities/common_spec.rb index 7c02f50fd..f5e3a6599 100644 --- a/spec/models/abilities/common_spec.rb +++ b/spec/models/abilities/common_spec.rb @@ -197,7 +197,7 @@ describe "Abilities::Common" do it { should_not be_able_to(:vote, investment_in_accepting_budget) } it { should be_able_to(:vote, investment_in_selecting_budget) } it { should_not be_able_to(:vote, investment_in_balloting_budget) } - + it { should_not be_able_to(:destroy, investment_in_accepting_budget) } it { should_not be_able_to(:destroy, investment_in_reviewing_budget) } it { should_not be_able_to(:destroy, investment_in_selecting_budget) } From a76033fb728725498bf31b3c1d8cb6daba753d82 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 22:32:53 +0200 Subject: [PATCH 46/75] Fix all Style/StringLiteralsInInterpolation rubocop issues and remove from rubocop_todo list --- .rubocop_todo.yml | 9 --------- app/controllers/stats_controller.rb | 2 +- app/models/proposal.rb | 2 +- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9c480cc5a..95ef3ba6b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -653,15 +653,6 @@ Layout/SpaceInsidePercentLiteralDelimiters: Exclude: - 'app/models/activity.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: single_quotes, double_quotes -Style/StringLiteralsInInterpolation: - Exclude: - - 'app/controllers/stats_controller.rb' - - 'app/models/proposal.rb' - # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index ab6bedd6e..cd2efac6b 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -23,6 +23,6 @@ class StatsController < ApplicationController private def daily_cache(key, &block) - Rails.cache.fetch("public_stats/#{Time.current.strftime("%Y-%m-%d")}/#{key}", &block) + Rails.cache.fetch("public_stats/#{Time.current.strftime('%Y-%m-%d')}/#{key}", &block) end end diff --git a/app/models/proposal.rb b/app/models/proposal.rb index f37dff3d5..a35b29459 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -128,7 +128,7 @@ class Proposal < ActiveRecord::Base end def code - "#{Setting["proposal_code_prefix"]}-#{created_at.strftime('%Y-%m')}-#{id}" + "#{Setting['proposal_code_prefix']}-#{created_at.strftime('%Y-%m')}-#{id}" end def after_commented From b074090e924fcc8cfabc728a5c713bcad49779d1 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 22:33:35 +0200 Subject: [PATCH 47/75] Fix Layout/SpaceInsidePercentLiteralDelimiters rubocop issue and remove from rubocop todo list --- .rubocop_todo.yml | 6 ------ app/models/activity.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 95ef3ba6b..148e3b4b2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -647,12 +647,6 @@ Layout/SpaceInsideParens: - 'spec/features/proposals_spec.rb' - 'spec/models/abilities/moderator_spec.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/SpaceInsidePercentLiteralDelimiters: - Exclude: - - 'app/models/activity.rb' - # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. diff --git a/app/models/activity.rb b/app/models/activity.rb index 0fc35ad11..58a91cd18 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -2,7 +2,7 @@ class Activity < ActiveRecord::Base belongs_to :actionable, -> { with_hidden }, polymorphic: true belongs_to :user, -> { with_hidden } - VALID_ACTIONS = %w( hide block restore valuate ) + VALID_ACTIONS = %w(hide block restore valuate) validates :action, inclusion: {in: VALID_ACTIONS} From 6562d8b9d887c6624e5bb72060ca79ccd3a7d367 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 22:34:16 +0200 Subject: [PATCH 48/75] Fix all Layout/SpaceBeforeFirstArg rubocop issues and remove from rubocop_todo list --- .rubocop_todo.yml | 7 ------- spec/factories.rb | 2 +- spec/features/tags/budget_investments_spec.rb | 2 +- spec/models/budget/investment_spec.rb | 8 ++++---- 4 files changed, 6 insertions(+), 13 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 148e3b4b2..701bacf1a 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -620,13 +620,6 @@ Layout/SpaceBeforeComma: - 'spec/controllers/management/sessions_controller_spec.rb' - 'spec/controllers/management/users_controller_spec.rb' -# Offense count: 2 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Layout/SpaceBeforeFirstArg: - Exclude: - - 'spec/factories.rb' - # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/spec/factories.rb b/spec/factories.rb index 31a14ed50..3e7b1b674 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -99,7 +99,7 @@ FactoryGirl.define do factory :verified_user do document_number - document_type 'dni' + document_type 'dni' end factory :debate do diff --git a/spec/features/tags/budget_investments_spec.rb b/spec/features/tags/budget_investments_spec.rb index 4c978c740..1269b0a21 100644 --- a/spec/features/tags/budget_investments_spec.rb +++ b/spec/features/tags/budget_investments_spec.rb @@ -87,7 +87,7 @@ feature 'Tags' do select 'Health: More hospitals', from: 'budget_investment_heading_id' fill_in 'budget_investment_title', with: 'Build a skyscraper' fill_in_ckeditor 'budget_investment_description', with: 'If I had a gym near my place I could go do Zumba' - check 'budget_investment_terms_of_service' + check 'budget_investment_terms_of_service' find('.js-add-tag-link', text: 'Education').click click_button 'Create Investment' diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index c5af04ea1..3f1e89d60 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -591,10 +591,10 @@ describe Budget::Investment do least_voted2 = create(:budget_investment, cached_votes_up: 1) - expect(Budget::Investment.sort_by_confidence_score.first).to eq most_voted2 - expect(Budget::Investment.sort_by_confidence_score.second).to eq most_voted - expect(Budget::Investment.sort_by_confidence_score.third).to eq least_voted2 - expect(Budget::Investment.sort_by_confidence_score.fourth).to eq least_voted + expect(Budget::Investment.sort_by_confidence_score.first).to eq most_voted2 + expect(Budget::Investment.sort_by_confidence_score.second).to eq most_voted + expect(Budget::Investment.sort_by_confidence_score.third).to eq least_voted2 + expect(Budget::Investment.sort_by_confidence_score.fourth).to eq least_voted end end end From 9763931f55f9e91f6148f326c6727cf064a3a987 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 22:34:50 +0200 Subject: [PATCH 49/75] Fix all Layout/SpaceBeforeComma rubocop issues and remove from rubocop_todo list --- .rubocop_todo.yml | 8 -------- app/controllers/legislation/answers_controller.rb | 2 +- app/models/proposal.rb | 2 +- spec/controllers/management/sessions_controller_spec.rb | 6 +++--- spec/controllers/management/users_controller_spec.rb | 4 ++-- 5 files changed, 7 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 701bacf1a..94a40cd2d 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -612,14 +612,6 @@ Layout/SpaceAroundEqualsInParameterDefault: Layout/SpaceAroundOperators: Enabled: false -# Offense count: 6 -# Cop supports --auto-correct. -Layout/SpaceBeforeComma: - Exclude: - - 'app/models/proposal.rb' - - 'spec/controllers/management/sessions_controller_spec.rb' - - 'spec/controllers/management/users_controller_spec.rb' - # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/app/controllers/legislation/answers_controller.rb b/app/controllers/legislation/answers_controller.rb index 02946013b..36f87de1f 100644 --- a/app/controllers/legislation/answers_controller.rb +++ b/app/controllers/legislation/answers_controller.rb @@ -19,7 +19,7 @@ class Legislation::AnswersController < Legislation::BaseController end else respond_to do |format| - format.js { render json: {} , status: :not_found } + format.js { render json: {}, status: :not_found } format.html { redirect_to legislation_process_question_path(@process, @question), alert: t('legislation.questions.participation.phase_not_open') } end end diff --git a/app/models/proposal.rb b/app/models/proposal.rb index a35b29459..926cbe1ee 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -39,7 +39,7 @@ class Proposal < ActiveRecord::Base before_save :calculate_hot_score, :calculate_confidence_score scope :for_render, -> { includes(:tags) } - scope :sort_by_hot_score , -> { reorder(hot_score: :desc) } + scope :sort_by_hot_score, -> { reorder(hot_score: :desc) } scope :sort_by_confidence_score, -> { reorder(confidence_score: :desc) } scope :sort_by_created_at, -> { reorder(created_at: :desc) } scope :sort_by_most_commented, -> { reorder(comments_count: :desc) } diff --git a/spec/controllers/management/sessions_controller_spec.rb b/spec/controllers/management/sessions_controller_spec.rb index d2d6b5f8b..ec8f762d9 100644 --- a/spec/controllers/management/sessions_controller_spec.rb +++ b/spec/controllers/management/sessions_controller_spec.rb @@ -5,15 +5,15 @@ describe Management::SessionsController do describe 'Sign in' do it "should deny access if wrong manager credentials" do allow_any_instance_of(ManagerAuthenticator).to receive(:auth).and_return(false) - expect { get :create, login: "nonexistent" , clave_usuario: "wrong"}.to raise_error CanCan::AccessDenied + expect { get :create, login: "nonexistent", clave_usuario: "wrong"}.to raise_error CanCan::AccessDenied expect(session[:manager]).to be_nil end it "should redirect to management root path if authorized manager with right credentials" do - manager = {login: "JJB033", user_key: "31415926" , date: "20151031135905"} + manager = {login: "JJB033", user_key: "31415926", date: "20151031135905"} allow_any_instance_of(ManagerAuthenticator).to receive(:auth).and_return(manager) - get :create, login: "JJB033" , clave_usuario: "31415926", fecha_conexion: "20151031135905" + get :create, login: "JJB033", clave_usuario: "31415926", fecha_conexion: "20151031135905" expect(response).to be_redirect expect(session[:manager][:login]).to eq "JJB033" end diff --git a/spec/controllers/management/users_controller_spec.rb b/spec/controllers/management/users_controller_spec.rb index ed73aa053..e57ff7b15 100644 --- a/spec/controllers/management/users_controller_spec.rb +++ b/spec/controllers/management/users_controller_spec.rb @@ -4,13 +4,13 @@ describe Management::UsersController do describe 'logout' do it "should remove user data from the session" do - session[:manager] = {user_key: "31415926" , date: "20151031135905", login: "JJB033"} + session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"} session[:document_type] = "1" session[:document_number] = "12345678Z" get :logout - expect(session[:manager]).to eq({user_key: "31415926" , date: "20151031135905", login: "JJB033"}) + expect(session[:manager]).to eq({user_key: "31415926", date: "20151031135905", login: "JJB033"}) expect(session[:document_type]).to be_nil expect(session[:document_number]).to be_nil expect(response).to be_redirect From 01263050a6845bf49916e611c8a7983744f161ac Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 22:35:28 +0200 Subject: [PATCH 50/75] Fix Layout/SpaceAfterNot rubocop issue and remove from rubocop_todo list --- .rubocop_todo.yml | 6 ------ app/models/flag.rb | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 94a40cd2d..d4f17c2d2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -578,12 +578,6 @@ Layout/SpaceAfterComma: - 'spec/models/abilities/moderator_spec.rb' - 'spec/models/verification/management/email_spec.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Layout/SpaceAfterNot: - Exclude: - - 'app/models/flag.rb' - # Offense count: 20 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/app/models/flag.rb b/app/models/flag.rb index 735ef89e9..824175b07 100644 --- a/app/models/flag.rb +++ b/app/models/flag.rb @@ -23,7 +23,7 @@ class Flag < ActiveRecord::Base def self.flagged?(user, flaggable) return false unless user - !! by_user_and_flaggable(user, flaggable).try(:first) + !!by_user_and_flaggable(user, flaggable).try(:first) end end From c862543e6fe283476cf00c53dcaeab4c47e36265 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 22:36:13 +0200 Subject: [PATCH 51/75] Remove Layout/SpaceAfterColon from rubocop_todo list, offense no longer present --- .rubocop_todo.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index d4f17c2d2..a80651235 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -557,12 +557,6 @@ Style/RescueModifier: - 'app/controllers/concerns/commentable_actions.rb' - 'app/controllers/verification/sms_controller.rb' -# Offense count: 2 -# Cop supports --auto-correct. -Layout/SpaceAfterColon: - Exclude: - - 'spec/models/user_spec.rb' - # Offense count: 14 # Cop supports --auto-correct. Layout/SpaceAfterComma: From e6dd33bd66bac1982be61b3d5fe12a8f8d2cd47c Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 21 Jun 2017 22:37:06 +0200 Subject: [PATCH 52/75] Fix all Layout/SpaceAfterComma issues and remove from rubocop_todo list --- .rubocop_todo.yml | 15 --------------- app/controllers/admin/users_controller.rb | 2 +- app/models/ahoy/data_source.rb | 2 +- app/models/concerns/search_cache.rb | 2 +- app/models/concerns/taggable.rb | 2 +- app/models/spending_proposal.rb | 2 +- app/models/user.rb | 2 +- spec/features/admin/poll/polls_spec.rb | 2 +- spec/features/management/users_spec.rb | 4 ++-- .../features/valuation/budget_investments_spec.rb | 4 ++-- .../features/valuation/spending_proposals_spec.rb | 4 ++-- spec/lib/census_api_spec.rb | 2 +- spec/models/abilities/moderator_spec.rb | 2 +- spec/models/budget/investment_spec.rb | 2 +- spec/models/verification/management/email_spec.rb | 2 +- 15 files changed, 17 insertions(+), 32 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index a80651235..6e17b627b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -557,21 +557,6 @@ Style/RescueModifier: - 'app/controllers/concerns/commentable_actions.rb' - 'app/controllers/verification/sms_controller.rb' -# Offense count: 14 -# Cop supports --auto-correct. -Layout/SpaceAfterComma: - Exclude: - - 'app/models/ahoy/data_source.rb' - - 'app/models/banner.rb' - - 'app/models/concerns/search_cache.rb' - - 'app/models/concerns/taggable.rb' - - 'app/models/spending_proposal.rb' - - 'app/models/user.rb' - - 'spec/features/valuation/spending_proposals_spec.rb' - - 'spec/lib/census_api_spec.rb' - - 'spec/models/abilities/moderator_spec.rb' - - 'spec/models/verification/management/email_spec.rb' - # Offense count: 20 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/app/controllers/admin/users_controller.rb b/app/controllers/admin/users_controller.rb index d1dd1c79c..e36a6a4f0 100644 --- a/app/controllers/admin/users_controller.rb +++ b/app/controllers/admin/users_controller.rb @@ -4,7 +4,7 @@ class Admin::UsersController < Admin::BaseController def index if params[:search] s = params[:search] - @users = User.where("username ILIKE ? OR email ILIKE ? OR document_number ILIKE ?", "%#{s}%","%#{s}%","%#{s}%").page(params[:page]) + @users = User.where("username ILIKE ? OR email ILIKE ? OR document_number ILIKE ?", "%#{s}%", "%#{s}%", "%#{s}%").page(params[:page]) else @users = @users.page(params[:page]) end diff --git a/app/models/ahoy/data_source.rb b/app/models/ahoy/data_source.rb index 2d52063bb..5c69af755 100644 --- a/app/models/ahoy/data_source.rb +++ b/app/models/ahoy/data_source.rb @@ -10,7 +10,7 @@ module Ahoy # chart def add(name, collection) collections.push data: collection, name: name - collection.each{ |k,v| add_key k } + collection.each{ |k, v| add_key k } end def build diff --git a/app/models/concerns/search_cache.rb b/app/models/concerns/search_cache.rb index a5b7acb5f..cf4d04f16 100644 --- a/app/models/concerns/search_cache.rb +++ b/app/models/concerns/search_cache.rb @@ -14,7 +14,7 @@ module SearchCache def searchable_values_sql searchable_values - .select{ |k,_| k.present? } + .select{ |k, _| k.present? } .collect{ |value, weight| set_tsvector(value, weight) } .join(" || ") end diff --git a/app/models/concerns/taggable.rb b/app/models/concerns/taggable.rb index 9126e271a..57a30414d 100644 --- a/app/models/concerns/taggable.rb +++ b/app/models/concerns/taggable.rb @@ -9,7 +9,7 @@ module Taggable def tag_list_with_limit(limit = nil) return tags if limit.blank? - tags.sort{|a,b| b.taggings_count <=> a.taggings_count}[0, limit] + tags.sort{|a, b| b.taggings_count <=> a.taggings_count}[0, limit] end def tags_count_out_of_limit(limit = nil) diff --git a/app/models/spending_proposal.rb b/app/models/spending_proposal.rb index a37446117..874533931 100644 --- a/app/models/spending_proposal.rb +++ b/app/models/spending_proposal.rb @@ -44,7 +44,7 @@ class SpendingProposal < ActiveRecord::Base end def self.filter_params(params) - params.select{|x,_| %w{geozone_id administrator_id tag_name valuator_id}.include? x.to_s } + params.select{|x, _| %w{geozone_id administrator_id tag_name valuator_id}.include? x.to_s } end def self.scoped_filter(params, current_filter) diff --git a/app/models/user.rb b/app/models/user.rb index 219671349..3da726c6e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -74,7 +74,7 @@ class User < ActiveRecord::Base username: auth.info.name || auth.uid, email: oauth_email, oauth_email: oauth_email, - password: Devise.friendly_token[0,20], + password: Devise.friendly_token[0, 20], terms_of_service: '1', confirmed_at: oauth_email_confirmed ? DateTime.current : nil ) diff --git a/spec/features/admin/poll/polls_spec.rb b/spec/features/admin/poll/polls_spec.rb index d2041a583..4508e5bba 100644 --- a/spec/features/admin/poll/polls_spec.rb +++ b/spec/features/admin/poll/polls_spec.rb @@ -356,7 +356,7 @@ feature 'Admin polls' do question_2.valid_answers.each_with_index do |answer, i| within("#question_#{question_2.id}_#{i}_result") do expect(page).to have_content(answer) - expect(page).to have_content([0,15][i]) + expect(page).to have_content([0, 15][i]) end end diff --git a/spec/features/management/users_spec.rb b/spec/features/management/users_spec.rb index e7c43f4a9..cdb0ec879 100644 --- a/spec/features/management/users_spec.rb +++ b/spec/features/management/users_spec.rb @@ -29,7 +29,7 @@ feature 'Users' do expect(user).to be_level_three_verified expect(user).to be_residence_verified expect(user).to_not be_confirmed - expect(user.date_of_birth).to have_content (Date.new(1980,12,31)) + expect(user.date_of_birth).to have_content (Date.new(1980, 12, 31)) sent_token = /.*confirmation_token=(.*)".*/.match(ActionMailer::Base.deliveries.last.body.to_s)[1] visit user_confirmation_path(confirmation_token: sent_token) @@ -69,7 +69,7 @@ feature 'Users' do expect(user).to be_level_three_verified expect(user).to be_residence_verified expect(user).to be_confirmed - expect(user.date_of_birth).to have_content (Date.new(1980,12,31)) + expect(user.date_of_birth).to have_content (Date.new(1980, 12, 31)) end scenario 'Delete a level 2 user account from document verification page', :js do diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb index b74213d7e..23d084347 100644 --- a/spec/features/valuation/budget_investments_spec.rb +++ b/spec/features/valuation/budget_investments_spec.rb @@ -289,9 +289,9 @@ feature 'Valuation budget investments' do end scenario 'Feasibility selection makes proper fields visible', :js do - feasible_fields = ['Price (€)','Cost during the first year (€)','Price explanation','Time scope'] + feasible_fields = ['Price (€)', 'Cost during the first year (€)', 'Price explanation', 'Time scope'] unfeasible_fields = ['Feasibility explanation'] - any_feasibility_fields = ['Valuation finished','Internal comments'] + any_feasibility_fields = ['Valuation finished', 'Internal comments'] undecided_fields = feasible_fields + unfeasible_fields + any_feasibility_fields visit edit_valuation_budget_budget_investment_path(@budget, @investment) diff --git a/spec/features/valuation/spending_proposals_spec.rb b/spec/features/valuation/spending_proposals_spec.rb index e19c4fb41..5b8bc34cf 100644 --- a/spec/features/valuation/spending_proposals_spec.rb +++ b/spec/features/valuation/spending_proposals_spec.rb @@ -311,9 +311,9 @@ feature 'Valuation spending proposals' do end scenario 'Feasibility selection makes proper fields visible', :js do - feasible_true_fields = ['Price (€)','Cost during the first year (€)','Price explanation','Time scope'] + feasible_true_fields = ['Price (€)', 'Cost during the first year (€)', 'Price explanation', 'Time scope'] feasible_false_fields = ['Feasibility explanation'] - feasible_any_fields = ['Valuation finished','Internal comments'] + feasible_any_fields = ['Valuation finished', 'Internal comments'] feasible_nil_fields = feasible_true_fields + feasible_false_fields + feasible_any_fields visit edit_valuation_spending_proposal_path(@spending_proposal) diff --git a/spec/lib/census_api_spec.rb b/spec/lib/census_api_spec.rb index fb14f39c5..274101f22 100644 --- a/spec/lib/census_api_spec.rb +++ b/spec/lib/census_api_spec.rb @@ -39,7 +39,7 @@ describe CensusApi do response = api.call(1, "123456") expect(response).to be_valid - expect(response.date_of_birth).to eq(Date.new(1980,1,1)) + expect(response.date_of_birth).to eq(Date.new(1980, 1, 1)) end it "returns the last failed response" do diff --git a/spec/models/abilities/moderator_spec.rb b/spec/models/abilities/moderator_spec.rb index 332f69450..6fab62d73 100644 --- a/spec/models/abilities/moderator_spec.rb +++ b/spec/models/abilities/moderator_spec.rb @@ -48,7 +48,7 @@ describe "Abilities::Moderator" do describe "hiding, reviewing and restoring" do let(:ignored_comment) { create(:comment, :with_ignored_flag) } let(:ignored_debate) { create(:debate, :with_ignored_flag) } - let(:ignored_proposal) { create(:proposal,:with_ignored_flag) } + let(:ignored_proposal) { create(:proposal, :with_ignored_flag) } it { should be_able_to(:hide, comment) } it { should be_able_to(:hide_in_moderation_screen, comment) } diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 3f1e89d60..3b16bb033 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -249,7 +249,7 @@ describe Budget::Investment do by_valuator = Budget::Investment.by_valuator(valuator1.id) expect(by_valuator.size).to eq(2) - expect(by_valuator.sort).to eq([investment1,investment3].sort) + expect(by_valuator.sort).to eq([investment1, investment3].sort) end end diff --git a/spec/models/verification/management/email_spec.rb b/spec/models/verification/management/email_spec.rb index 924f63501..652c094ba 100644 --- a/spec/models/verification/management/email_spec.rb +++ b/spec/models/verification/management/email_spec.rb @@ -39,7 +39,7 @@ describe Verification::Management::Email do allow(validation).to receive(:user).and_return user expect(mail).to receive(:deliver_later) - expect(Devise.token_generator).to receive(:generate).with(User, :email_verification_token).and_return(["1","2"]) + expect(Devise.token_generator).to receive(:generate).with(User, :email_verification_token).and_return(["1", "2"]) expect(Mailer).to receive(:email_verification).with(user, user.email, "2", "1", "1234").and_return(mail) validation.save From d7b8777395b1a8dd04c6b32931c1eb71e7b7cdd8 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 26 Jun 2017 18:03:40 +0200 Subject: [PATCH 53/75] Fix all Layout/SpaceAroundEqualsInParameterDefault rubocop issues from rubocop_todo list --- .rubocop_todo.yml | 22 ---------------------- app/helpers/cache_keys_helper.rb | 4 ++-- app/helpers/proposals_helper.rb | 2 +- app/helpers/spending_proposals_helper.rb | 2 +- app/helpers/stats_helper.rb | 8 ++++---- app/helpers/tracks_helper.rb | 2 +- app/helpers/valuation_helper.rb | 2 +- app/mailers/devise_mailer.rb | 2 +- app/models/comment.rb | 2 +- app/models/officing/residence.rb | 2 +- app/models/tag_cloud.rb | 2 +- app/models/verification/residence.rb | 2 +- lib/acts_as_paranoid_aliases.rb | 2 +- lib/manager_authenticator.rb | 2 +- spec/support/common_actions.rb | 4 ++-- 15 files changed, 19 insertions(+), 41 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 6e17b627b..bfc783e4e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -557,28 +557,6 @@ Style/RescueModifier: - 'app/controllers/concerns/commentable_actions.rb' - 'app/controllers/verification/sms_controller.rb' -# Offense count: 20 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: space, no_space -Layout/SpaceAroundEqualsInParameterDefault: - Exclude: - - 'app/helpers/cache_keys_helper.rb' - - 'app/helpers/proposals_helper.rb' - - 'app/helpers/spending_proposals_helper.rb' - - 'app/helpers/stats_helper.rb' - - 'app/helpers/tracks_helper.rb' - - 'app/helpers/valuation_helper.rb' - - 'app/mailers/devise_mailer.rb' - - 'app/models/comment.rb' - - 'app/models/tag_cloud.rb' - - 'app/models/verification/residence.rb' - - 'lib/acts_as_paranoid_aliases.rb' - - 'lib/capistrano/template.rb' - - 'lib/census_api.rb' - - 'lib/manager_authenticator.rb' - - 'spec/support/common_actions.rb' - # Offense count: 66 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment. diff --git a/app/helpers/cache_keys_helper.rb b/app/helpers/cache_keys_helper.rb index 566b3cd81..75fc4a0ea 100644 --- a/app/helpers/cache_keys_helper.rb +++ b/app/helpers/cache_keys_helper.rb @@ -1,11 +1,11 @@ module CacheKeysHelper - def locale_and_user_status(authorable=nil) + def locale_and_user_status(authorable = nil) @cache_key_user ||= calculate_user_status(authorable) "#{I18n.locale}/#{@cache_key_user}" end - def calculate_user_status(authorable=nil) + def calculate_user_status(authorable = nil) user_status = "user" if user_signed_in? diff --git a/app/helpers/proposals_helper.rb b/app/helpers/proposals_helper.rb index 578cd1d8e..37425d573 100644 --- a/app/helpers/proposals_helper.rb +++ b/app/helpers/proposals_helper.rb @@ -18,7 +18,7 @@ module ProposalsHelper end end - def namespaced_proposal_path(proposal, options={}) + def namespaced_proposal_path(proposal, options = {}) @namespace_proposal_path ||= namespace case @namespace_proposal_path when "management" diff --git a/app/helpers/spending_proposals_helper.rb b/app/helpers/spending_proposals_helper.rb index 26026952f..81d16e5fd 100644 --- a/app/helpers/spending_proposals_helper.rb +++ b/app/helpers/spending_proposals_helper.rb @@ -4,7 +4,7 @@ module SpendingProposalsHelper ActsAsTaggableOn::Tag.spending_proposal_tags.pluck(:name) end - def namespaced_spending_proposal_path(spending_proposal, options={}) + def namespaced_spending_proposal_path(spending_proposal, options = {}) @namespace_spending_proposal_path ||= namespace case @namespace_spending_proposal_path when "management" diff --git a/app/helpers/stats_helper.rb b/app/helpers/stats_helper.rb index d8eff0ac2..19b54a5a2 100644 --- a/app/helpers/stats_helper.rb +++ b/app/helpers/stats_helper.rb @@ -1,27 +1,27 @@ module StatsHelper - def events_chart_tag(events, opt={}) + def events_chart_tag(events, opt = {}) events = events.join(',') if events.is_a? Array opt[:data] ||= {} opt[:data][:graph] = admin_api_stats_path(events: events) content_tag :div, "", opt end - def visits_chart_tag(opt={}) + def visits_chart_tag(opt = {}) events = events.join(',') if events.is_a? Array opt[:data] ||= {} opt[:data][:graph] = admin_api_stats_path(visits: true) content_tag :div, "", opt end - def spending_proposals_chart_tag(opt={}) + def spending_proposals_chart_tag(opt = {}) events = events.join(',') if events.is_a? Array opt[:data] ||= {} opt[:data][:graph] = admin_api_stats_path(spending_proposals: true) content_tag :div, "", opt end - def budget_investments_chart_tag(opt={}) + def budget_investments_chart_tag(opt = {}) events = events.join(',') if events.is_a? Array opt[:data] ||= {} opt[:data][:graph] = admin_api_stats_path(budget_investments: true) diff --git a/app/helpers/tracks_helper.rb b/app/helpers/tracks_helper.rb index 557d71802..0d6793e08 100644 --- a/app/helpers/tracks_helper.rb +++ b/app/helpers/tracks_helper.rb @@ -1,6 +1,6 @@ module TracksHelper - def track_event(data={}) + def track_event(data = {}) track_data = "" prefix = " data-track-event-" data.each do |key, value| diff --git a/app/helpers/valuation_helper.rb b/app/helpers/valuation_helper.rb index ded5fa0ed..4913b3d00 100644 --- a/app/helpers/valuation_helper.rb +++ b/app/helpers/valuation_helper.rb @@ -1,6 +1,6 @@ module ValuationHelper - def valuator_select_options(valuator=nil) + def valuator_select_options(valuator = nil) if valuator.present? Valuator.where.not(id: valuator.id).order("description ASC").order("users.email ASC").includes(:user).collect { |v| [ v.description_or_email, v.id ] }.prepend([valuator.description_or_email, valuator.id]) else diff --git a/app/mailers/devise_mailer.rb b/app/mailers/devise_mailer.rb index 6c053cb52..a914477fe 100644 --- a/app/mailers/devise_mailer.rb +++ b/app/mailers/devise_mailer.rb @@ -5,7 +5,7 @@ class DeviseMailer < Devise::Mailer protected - def devise_mail(record, action, opts={}) + def devise_mail(record, action, opts = {}) I18n.with_locale record.locale do super(record, action, opts) end diff --git a/app/models/comment.rb b/app/models/comment.rb index 522b7324b..fa9db729f 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -44,7 +44,7 @@ class Comment < ActiveRecord::Base after_create :call_after_commented - def self.build(commentable, user, body, p_id=nil) + def self.build(commentable, user, body, p_id = nil) new commentable: commentable, user_id: user.id, body: body, diff --git a/app/models/officing/residence.rb b/app/models/officing/residence.rb index 1714bbf0e..63250d041 100644 --- a/app/models/officing/residence.rb +++ b/app/models/officing/residence.rb @@ -13,7 +13,7 @@ class Officing::Residence validate :allowed_age validate :residence_in_madrid - def initialize(attrs={}) + def initialize(attrs = {}) super clean_document_number end diff --git a/app/models/tag_cloud.rb b/app/models/tag_cloud.rb index 107ecbf1a..b0882af82 100644 --- a/app/models/tag_cloud.rb +++ b/app/models/tag_cloud.rb @@ -2,7 +2,7 @@ class TagCloud attr_accessor :resource_model, :scope - def initialize(resource_model, scope=nil) + def initialize(resource_model, scope = nil) @resource_model = resource_model @scope = scope end diff --git a/app/models/verification/residence.rb b/app/models/verification/residence.rb index e1b2f6363..00f729d2c 100644 --- a/app/models/verification/residence.rb +++ b/app/models/verification/residence.rb @@ -17,7 +17,7 @@ class Verification::Residence validate :allowed_age validate :document_number_uniqueness - def initialize(attrs={}) + def initialize(attrs = {}) self.date_of_birth = parse_date('date_of_birth', attrs) attrs = remove_date('date_of_birth', attrs) super diff --git a/lib/acts_as_paranoid_aliases.rb b/lib/acts_as_paranoid_aliases.rb index cf0c0bac8..17587fca8 100644 --- a/lib/acts_as_paranoid_aliases.rb +++ b/lib/acts_as_paranoid_aliases.rb @@ -25,7 +25,7 @@ module ActsAsParanoidAliases update_attribute(:confirmed_hide_at, Time.current) end - def restore(opts={}) + def restore(opts = {}) return false unless hidden? super(opts) update_attribute(:confirmed_hide_at, nil) diff --git a/lib/manager_authenticator.rb b/lib/manager_authenticator.rb index bd61d97a5..8f8d453f7 100644 --- a/lib/manager_authenticator.rb +++ b/lib/manager_authenticator.rb @@ -1,6 +1,6 @@ class ManagerAuthenticator - def initialize(data={}) + def initialize(data = {}) @manager = {login: data[:login], user_key: data[:clave_usuario], date: data[:fecha_conexion]}.with_indifferent_access end diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 327943931..209ddf800 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -1,6 +1,6 @@ module CommonActions - def sign_up(email='manuela@consul.dev', password='judgementday') + def sign_up(email = 'manuela@consul.dev', password = 'judgementday') visit '/' click_link 'Register' @@ -109,7 +109,7 @@ module CommonActions SCRIPT end - def error_message(resource_model=nil) + def error_message(resource_model = nil) resource_model ||= "(.*)" /\d errors? prevented this #{resource_model} from being saved:/ end From f6fe9cc7d27adce263fec35fe815e15e5991db33 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 26 Jun 2017 18:04:20 +0200 Subject: [PATCH 54/75] Fix all Layout/SpaceAroundOperators rubocop issues and remove file list from rubocop_todo list --- .rubocop_todo.yml | 6 ----- .../budgets/investments_controller.rb | 2 +- .../budgets/investments_controller.rb | 2 +- app/helpers/ballots_helper.rb | 2 +- app/helpers/embed_videos_helper.rb | 2 +- app/helpers/officing_helper.rb | 2 +- app/helpers/poll_recounts_helper.rb | 2 +- app/helpers/verification_helper.rb | 2 +- app/models/budget/investment.rb | 4 +-- app/models/comment.rb | 2 +- app/models/concerns/conflictable.rb | 2 +- app/models/legislation/annotation.rb | 2 +- lib/score_calculator.rb | 4 +-- lib/sms_api.rb | 2 +- .../admin/api/stats_controller_spec.rb | 10 +++---- .../annotations_controller_spec.rb | 26 +++++++++---------- spec/factories.rb | 4 +-- .../comments/budget_investments_spec.rb | 2 +- spec/features/comments/debates_spec.rb | 2 +- .../comments/legislation_annotations_spec.rb | 6 ++--- .../comments/legislation_questions_spec.rb | 2 +- spec/features/comments/proposals_spec.rb | 2 +- spec/features/legacy_legislation_spec.rb | 4 +-- .../legislation/draft_versions_spec.rb | 22 ++++++++-------- .../valuation/budget_investments_spec.rb | 6 ++--- .../valuation/spending_proposals_spec.rb | 4 +-- spec/helpers/proposals_helper_spec.rb | 8 +++--- spec/models/ahoy/data_source_spec.rb | 4 +-- spec/models/debate_spec.rb | 2 +- spec/models/legislation/annotation_spec.rb | 6 ++--- spec/models/poll/officer_spec.rb | 4 +-- spec/models/poll/voter_spec.rb | 8 +++--- spec/models/residence_spec.rb | 6 ++--- spec/models/user_spec.rb | 2 +- 34 files changed, 80 insertions(+), 86 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index bfc783e4e..27b209449 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -557,12 +557,6 @@ Style/RescueModifier: - 'app/controllers/concerns/commentable_actions.rb' - 'app/controllers/verification/sms_controller.rb' -# Offense count: 66 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment. -Layout/SpaceAroundOperators: - Enabled: false - # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles. diff --git a/app/controllers/budgets/investments_controller.rb b/app/controllers/budgets/investments_controller.rb index 469b09255..ea782d47c 100644 --- a/app/controllers/budgets/investments_controller.rb +++ b/app/controllers/budgets/investments_controller.rb @@ -93,7 +93,7 @@ module Budgets def set_random_seed if params[:order] == 'random' || params[:order].blank? - params[:random_seed] ||= rand(99)/100.0 + params[:random_seed] ||= rand(99) / 100.0 seed = Float(params[:random_seed]) rescue 0 Budget::Investment.connection.execute("select setseed(#{seed})") else diff --git a/app/controllers/management/budgets/investments_controller.rb b/app/controllers/management/budgets/investments_controller.rb index 652d2b9a7..1fdf33911 100644 --- a/app/controllers/management/budgets/investments_controller.rb +++ b/app/controllers/management/budgets/investments_controller.rb @@ -20,7 +20,7 @@ class Management::Budgets::InvestmentsController < Management::BaseController @investment.author = managed_user if @investment.save - notice= t('flash.actions.create.notice', resource_name: Budget::Investment.model_name.human, count: 1) + notice = t('flash.actions.create.notice', resource_name: Budget::Investment.model_name.human, count: 1) redirect_to management_budget_investment_path(@budget, @investment), notice: notice else render :new diff --git a/app/helpers/ballots_helper.rb b/app/helpers/ballots_helper.rb index ece1be9fa..8bdc5f231 100644 --- a/app/helpers/ballots_helper.rb +++ b/app/helpers/ballots_helper.rb @@ -1,7 +1,7 @@ module BallotsHelper def progress_bar_width(amount_available, amount_spent) - (amount_spent/amount_available.to_f * 100).to_s + "%" + (amount_spent / amount_available.to_f * 100).to_s + "%" end end \ No newline at end of file diff --git a/app/helpers/embed_videos_helper.rb b/app/helpers/embed_videos_helper.rb index cb077ef36..1034a7a59 100644 --- a/app/helpers/embed_videos_helper.rb +++ b/app/helpers/embed_videos_helper.rb @@ -11,7 +11,7 @@ module EmbedVideosHelper if server == "Vimeo" reg_exp = /vimeo.*(staffpicks\/|channels\/|videos\/|video\/|\/)([^#\&\?]*).*/ - src = "https://player.vimeo.com/video/" + src = "https://player.vimeo.com/video/" elsif server == "YouTube" reg_exp = /youtu.*(be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/ src = "https://www.youtube.com/embed/" diff --git a/app/helpers/officing_helper.rb b/app/helpers/officing_helper.rb index f5bdb26ea..8ee97cf52 100644 --- a/app/helpers/officing_helper.rb +++ b/app/helpers/officing_helper.rb @@ -13,7 +13,7 @@ module OfficingHelper officer_assignments.each do |oa| options << [oa.booth_assignment.booth.name.to_s, oa.id] end - options.sort! {|x, y| x[0]<=>y[0]} + options.sort! {|x, y| x[0] <=> y[0]} options_for_select(options, params[:oa]) end diff --git a/app/helpers/poll_recounts_helper.rb b/app/helpers/poll_recounts_helper.rb index c47402163..60e3da6d7 100644 --- a/app/helpers/poll_recounts_helper.rb +++ b/app/helpers/poll_recounts_helper.rb @@ -9,7 +9,7 @@ module PollRecountsHelper end def booth_assignment_sum_final_recounts(ba) - ba.final_recounts.any? ? ba.final_recounts.to_a.sum(&:count) :nil + ba.final_recounts.any? ? ba.final_recounts.to_a.sum(&:count) : nil end end \ No newline at end of file diff --git a/app/helpers/verification_helper.rb b/app/helpers/verification_helper.rb index 62be1a5a8..44f921264 100644 --- a/app/helpers/verification_helper.rb +++ b/app/helpers/verification_helper.rb @@ -18,7 +18,7 @@ module VerificationHelper data_to_mask = match[2] email_provider = match[3] - data_to_display + "*"*data_to_mask.size + "@" + email_provider + data_to_display + "*" * data_to_mask.size + "@" + email_provider end end diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 1460cf437..7ba0548e2 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -205,8 +205,8 @@ class Budget end def should_show_aside? - (budget.selecting? && !unfeasible?) || - (budget.balloting? && feasible?) || + (budget.selecting? && !unfeasible?) || + (budget.balloting? && feasible?) || (budget.valuating? && !unfeasible?) end diff --git a/app/models/comment.rb b/app/models/comment.rb index fa9db729f..5c7f4dd4e 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -64,7 +64,7 @@ class Comment < ActiveRecord::Base end def author=(author) - self.user= author + self.user = author end def total_votes diff --git a/app/models/concerns/conflictable.rb b/app/models/concerns/conflictable.rb index a1926aa36..b362ef1d1 100644 --- a/app/models/concerns/conflictable.rb +++ b/app/models/concerns/conflictable.rb @@ -3,7 +3,7 @@ module Conflictable def conflictive? return false unless flags_count > 0 && cached_votes_up > 0 - cached_votes_up/flags_count.to_f < 5 + cached_votes_up / flags_count.to_f < 5 end end diff --git a/app/models/legislation/annotation.rb b/app/models/legislation/annotation.rb index 92fa9dd86..f2d419200 100644 --- a/app/models/legislation/annotation.rb +++ b/app/models/legislation/annotation.rb @@ -35,7 +35,7 @@ class Legislation::Annotation < ActiveRecord::Base selector_end = "/html/body/#{range_end}" el_end = doc.at_xpath(selector_end) - remainder_el_start = el_start.text[0 .. range_start_offset-1] unless range_start_offset.zero? + remainder_el_start = el_start.text[0 .. range_start_offset - 1] unless range_start_offset.zero? remainder_el_end = el_end.text[range_end_offset .. -1] self.context = "#{remainder_el_start}#{quote}#{remainder_el_end}" diff --git a/lib/score_calculator.rb b/lib/score_calculator.rb index 0b68c025a..4f4e21e85 100644 --- a/lib/score_calculator.rb +++ b/lib/score_calculator.rb @@ -1,7 +1,7 @@ module ScoreCalculator EPOC = Time.new(2015, 6, 15).in_time_zone - COMMENT_WEIGHT = 1.0/5 # 1 positive vote / x comments + COMMENT_WEIGHT = 1.0 / 5 # 1 positive vote / x comments TIME_UNIT = 24.hours.to_f def self.hot_score(date, votes_total, votes_up, comments_count) @@ -13,7 +13,7 @@ module ScoreCalculator sign = score <=> 0 seconds = ((date || Time.current) - EPOC).to_f - (((offset * sign) + (seconds/TIME_UNIT)) * 10000000).round + (((offset * sign) + (seconds / TIME_UNIT)) * 10000000).round end def self.confidence_score(votes_total, votes_up) diff --git a/lib/sms_api.rb b/lib/sms_api.rb index de0e2c312..9b866fc87 100644 --- a/lib/sms_api.rb +++ b/lib/sms_api.rb @@ -38,7 +38,7 @@ class SMSApi end def stubbed_response - {:respuesta_sms=>{:identificador_mensaje=>"1234567", :fecha_respuesta=>"Thu, 20 Aug 2015 16:28:05 +0200", :respuesta_pasarela=>{:codigo_pasarela=>"0000", :descripcion_pasarela=>"Operación ejecutada correctamente."}, :respuesta_servicio_externo=>{:codigo_respuesta=>"1000", :texto_respuesta=>"Success"}}} + {:respuesta_sms => {:identificador_mensaje => "1234567", :fecha_respuesta => "Thu, 20 Aug 2015 16:28:05 +0200", :respuesta_pasarela => {:codigo_pasarela => "0000", :descripcion_pasarela => "Operación ejecutada correctamente."}, :respuesta_servicio_externo => {:codigo_respuesta => "1000", :texto_respuesta => "Success"}}} end end diff --git a/spec/controllers/admin/api/stats_controller_spec.rb b/spec/controllers/admin/api/stats_controller_spec.rb index e032014d7..8dd948086 100644 --- a/spec/controllers/admin/api/stats_controller_spec.rb +++ b/spec/controllers/admin/api/stats_controller_spec.rb @@ -36,7 +36,7 @@ describe Admin::Api::StatsController do expect(response).to be_ok data = JSON.parse(response.body) - expect(data).to eq "x"=>["2015-01-01", "2015-01-02"], "Foo"=>[2, 1] + expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [2, 1] end it 'should return combined comma separated events formated for working with c3.js' do @@ -46,7 +46,7 @@ describe Admin::Api::StatsController do expect(response).to be_ok data = JSON.parse(response.body) - expect(data).to eq "x"=>["2015-01-01", "2015-01-02", "2015-01-03"], "Foo"=>[2, 1, 0], "Bar"=>[1, 0, 2] + expect(data).to eq "x" => ["2015-01-01", "2015-01-02", "2015-01-03"], "Foo" => [2, 1, 0], "Bar" => [1, 0, 2] end end @@ -65,7 +65,7 @@ describe Admin::Api::StatsController do expect(response).to be_ok data = JSON.parse(response.body) - expect(data).to eq "x"=>["2015-01-01", "2015-01-02"], "Visits"=>[2, 1] + expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Visits" => [2, 1] end end @@ -88,7 +88,7 @@ describe Admin::Api::StatsController do expect(response).to be_ok data = JSON.parse(response.body) - expect(data).to eq "x"=>["2015-01-01", "2015-01-02"], "Foo"=>[1, 2], "Visits"=>[2, 1] + expect(data).to eq "x" => ["2015-01-01", "2015-01-02"], "Foo" => [1, 2], "Visits" => [2, 1] end end @@ -107,7 +107,7 @@ describe Admin::Api::StatsController do expect(response).to be_ok data = JSON.parse(response.body) - expect(data).to eq "x"=>["2017-04-01", "2017-04-02"], "Budget Investments"=>[1, 2] + expect(data).to eq "x" => ["2017-04-01", "2017-04-02"], "Budget Investments" => [1, 2] end end end diff --git a/spec/controllers/legislation/annotations_controller_spec.rb b/spec/controllers/legislation/annotations_controller_spec.rb index 51425a1f2..834ec046f 100644 --- a/spec/controllers/legislation/annotations_controller_spec.rb +++ b/spec/controllers/legislation/annotations_controller_spec.rb @@ -16,8 +16,8 @@ describe Legislation::AnnotationsController do post :create, process_id: @process.id, draft_version_id: @draft_version.id, legislation_annotation: { - "quote"=>"ipsum", - "ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], + "quote" => "ipsum", + "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}], "text": "una anotacion" } expect(Ahoy::Event.where(name: :legislation_annotation_created).count).to eq 1 @@ -30,8 +30,8 @@ describe Legislation::AnnotationsController do post :create, process_id: @process.id, draft_version_id: @final_version.id, legislation_annotation: { - "quote"=>"ipsum", - "ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], + "quote" => "ipsum", + "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}], "text": "una anotacion" } @@ -45,8 +45,8 @@ describe Legislation::AnnotationsController do xhr :post, :create, process_id: @process.id, draft_version_id: @draft_version.id, legislation_annotation: { - "quote"=>"ipsum", - "ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], + "quote" => "ipsum", + "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}], "text": "una anotacion" } end.to change { @draft_version.annotations.count }.by(1) @@ -60,8 +60,8 @@ describe Legislation::AnnotationsController do xhr :post, :create, process_id: @process.id, draft_version_id: @draft_version.id, legislation_annotation: { - "quote"=>"ipsum", - "ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], + "quote" => "ipsum", + "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}], "text": "una anotacion" } end.to_not change { @draft_version.annotations.count } @@ -74,8 +74,8 @@ describe Legislation::AnnotationsController do xhr :post, :create, process_id: @process.id, draft_version_id: @draft_version.id, legislation_annotation: { - "quote"=>"ipsum", - "ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}].to_json, + "quote" => "ipsum", + "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}].to_json, "text": "una anotacion" } end.to change { @draft_version.annotations.count }.by(1) @@ -83,7 +83,7 @@ describe Legislation::AnnotationsController do it 'should create a new comment on an existing annotation when range is the same' do annotation = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", - ranges: [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], + ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}], range_start: "/p[1]", range_start_offset: 6, range_end: "/p[1]", range_end_offset: 11) sign_in @user @@ -91,8 +91,8 @@ describe Legislation::AnnotationsController do xhr :post, :create, process_id: @process.id, draft_version_id: @draft_version.id, legislation_annotation: { - "quote"=>"ipsum", - "ranges"=>[{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}], + "quote" => "ipsum", + "ranges" => [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}], "text": "una anotacion" } end.to_not change { @draft_version.annotations.count } diff --git a/spec/factories.rb b/spec/factories.rb index 3e7b1b674..a93d911ed 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -378,7 +378,7 @@ FactoryGirl.define do factory :annotation do quote "ipsum" text "Loremp ipsum dolor" - ranges [{"start"=>"/div[1]", "startOffset"=>5, "end"=>"/div[1]", "endOffset"=>10}] + ranges [{"start" => "/div[1]", "startOffset" => 5, "end" => "/div[1]", "endOffset" => 10}] legacy_legislation user end @@ -701,7 +701,7 @@ LOREM_IPSUM author factory: :user quote "ipsum" text "a comment" - ranges [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}] + ranges [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}] range_start "/p[1]" range_start_offset 6 range_end "/p[1]" diff --git a/spec/features/comments/budget_investments_spec.rb b/spec/features/comments/budget_investments_spec.rb index 7f36106a2..73e1b0869 100644 --- a/spec/features/comments/budget_investments_spec.rb +++ b/spec/features/comments/budget_investments_spec.rb @@ -395,7 +395,7 @@ feature 'Commenting Budget::Investments' do end scenario "can not comment as a moderator" do - admin = create(:administrator) + admin = create(:administrator) login_as(admin.user) visit budget_investment_path(investment.budget, investment) diff --git a/spec/features/comments/debates_spec.rb b/spec/features/comments/debates_spec.rb index 577ba6fd0..2a4d46ec3 100644 --- a/spec/features/comments/debates_spec.rb +++ b/spec/features/comments/debates_spec.rb @@ -407,7 +407,7 @@ feature 'Commenting debates' do end scenario "can not comment as a moderator" do - admin = create(:administrator) + admin = create(:administrator) login_as(admin.user) visit debate_path(debate) diff --git a/spec/features/comments/legislation_annotations_spec.rb b/spec/features/comments/legislation_annotations_spec.rb index b7e57039d..d8c539201 100644 --- a/spec/features/comments/legislation_annotations_spec.rb +++ b/spec/features/comments/legislation_annotations_spec.rb @@ -409,7 +409,7 @@ feature 'Commenting legislation questions' do end scenario "can not comment as a moderator" do - admin = create(:administrator) + admin = create(:administrator) login_as(admin.user) visit legislation_process_draft_version_annotation_path(legislation_annotation.draft_version.process, legislation_annotation.draft_version, legislation_annotation) @@ -510,8 +510,8 @@ feature 'Commenting legislation questions' do feature "Merged comment threads", :js do let!(:draft_version) { create(:legislation_draft_version, :published) } - let!(:annotation1) { create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>1, "end"=>"/p[1]", "endOffset"=>5}]) } - let!(:annotation2) { create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>1, "end"=>"/p[1]", "endOffset"=>10}]) } + let!(:annotation1) { create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5}]) } + let!(:annotation2) { create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 10}]) } background do login_as user diff --git a/spec/features/comments/legislation_questions_spec.rb b/spec/features/comments/legislation_questions_spec.rb index c10b12f55..4bdaed1ee 100644 --- a/spec/features/comments/legislation_questions_spec.rb +++ b/spec/features/comments/legislation_questions_spec.rb @@ -424,7 +424,7 @@ feature 'Commenting legislation questions' do end scenario "can not comment as a moderator" do - admin = create(:administrator) + admin = create(:administrator) login_as(admin.user) visit legislation_process_question_path(legislation_question.process, legislation_question) diff --git a/spec/features/comments/proposals_spec.rb b/spec/features/comments/proposals_spec.rb index 9f3d22966..ad088b79a 100644 --- a/spec/features/comments/proposals_spec.rb +++ b/spec/features/comments/proposals_spec.rb @@ -395,7 +395,7 @@ feature 'Commenting proposals' do end scenario "can not comment as a moderator" do - admin = create(:administrator) + admin = create(:administrator) login_as(admin.user) visit proposal_path(proposal) diff --git a/spec/features/legacy_legislation_spec.rb b/spec/features/legacy_legislation_spec.rb index e2f1ba915..5df3b8f76 100644 --- a/spec/features/legacy_legislation_spec.rb +++ b/spec/features/legacy_legislation_spec.rb @@ -77,8 +77,8 @@ feature 'Legacy Legislation' do scenario 'Search' do legacy_legislation = create(:legacy_legislation) - annotation1 = create(:annotation, legacy_legislation: legacy_legislation, text: "my annotation", ranges: [{"start"=>"/div[1]", "startOffset"=>5, "end"=>"/div[1]", "endOffset"=>10}]) - annotation2 = create(:annotation, legacy_legislation: legacy_legislation, text: "my other annotation", ranges: [{"start"=>"/div[1]", "startOffset"=>12, "end"=>"/div[1]", "endOffset"=>19}]) + annotation1 = create(:annotation, legacy_legislation: legacy_legislation, text: "my annotation", ranges: [{"start" => "/div[1]", "startOffset" => 5, "end" => "/div[1]", "endOffset" => 10}]) + annotation2 = create(:annotation, legacy_legislation: legacy_legislation, text: "my other annotation", ranges: [{"start" => "/div[1]", "startOffset" => 12, "end" => "/div[1]", "endOffset" => 19}]) visit legacy_legislation_path(legacy_legislation) diff --git a/spec/features/legislation/draft_versions_spec.rb b/spec/features/legislation/draft_versions_spec.rb index 7288c0cf0..c70a8f1a3 100644 --- a/spec/features/legislation/draft_versions_spec.rb +++ b/spec/features/legislation/draft_versions_spec.rb @@ -173,8 +173,8 @@ feature 'Legislation Draft Versions' do scenario 'View annotations and comments' do draft_version = create(:legislation_draft_version, :published) - annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>5, "end"=>"/p[1]", "endOffset"=>10}]) - annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>12, "end"=>"/p[1]", "endOffset"=>19}]) + annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 5, "end" => "/p[1]", "endOffset" => 10}]) + annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start" => "/p[1]", "startOffset" => 12, "end" => "/p[1]", "endOffset" => 19}]) comment = create(:comment, commentable: annotation1) visit legislation_process_draft_version_path(draft_version.process, draft_version) @@ -190,7 +190,7 @@ feature 'Legislation Draft Versions' do scenario "Publish new comment for an annotation from comments box" do draft_version = create(:legislation_draft_version, :published) - annotation = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}]) + annotation = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}]) visit legislation_process_draft_version_path(draft_version.process, draft_version) @@ -212,8 +212,8 @@ feature 'Legislation Draft Versions' do scenario 'View annotations and comments in an included range' do draft_version = create(:legislation_draft_version, :published) - annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>1, "end"=>"/p[1]", "endOffset"=>5}]) - annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start"=>"/p[1]", "startOffset"=>1, "end"=>"/p[1]", "endOffset"=>10}]) + annotation1 = create(:legislation_annotation, draft_version: draft_version, text: "my annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 5}]) + annotation2 = create(:legislation_annotation, draft_version: draft_version, text: "my other annotation", ranges: [{"start" => "/p[1]", "startOffset" => 1, "end" => "/p[1]", "endOffset" => 10}]) visit legislation_process_draft_version_path(draft_version.process, draft_version) @@ -232,8 +232,8 @@ feature 'Legislation Draft Versions' do context "Annotations page" do background do @draft_version = create(:legislation_draft_version, :published) - @annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum", ranges: [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}]) - @annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam", ranges: [{"start"=>"/p[3]", "startOffset"=>6, "end"=>"/p[3]", "endOffset"=>11}]) + @annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum", ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}]) + @annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam", ranges: [{"start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}]) end scenario "See all annotations for a draft version" do @@ -247,9 +247,9 @@ feature 'Legislation Draft Versions' do background do @process = create(:legislation_process) @draft_version_1 = create(:legislation_draft_version, :published, process: @process, title: "Version 1", body: "Text with quote for version 1") - @annotation_1 = create(:legislation_annotation, draft_version: @draft_version_1, text: "annotation for version 1", quote: "quote for version 1", ranges: [{"start"=>"/p[1]", "startOffset"=>11, "end"=>"/p[1]", "endOffset"=>30}]) + @annotation_1 = create(:legislation_annotation, draft_version: @draft_version_1, text: "annotation for version 1", quote: "quote for version 1", ranges: [{"start" => "/p[1]", "startOffset" => 11, "end" => "/p[1]", "endOffset" => 30}]) @draft_version_2 = create(:legislation_draft_version, :published, process: @process, title: "Version 2", body: "Text with quote for version 2") - @annotation_1 = create(:legislation_annotation, draft_version: @draft_version_2, text: "annotation for version 2", quote: "quote for version 2", ranges: [{"start"=>"/p[1]", "startOffset"=>11, "end"=>"/p[1]", "endOffset"=>30}]) + @annotation_1 = create(:legislation_annotation, draft_version: @draft_version_2, text: "annotation for version 2", quote: "quote for version 2", ranges: [{"start" => "/p[1]", "startOffset" => 11, "end" => "/p[1]", "endOffset" => 30}]) end scenario "without js" do @@ -278,8 +278,8 @@ feature 'Legislation Draft Versions' do context "Annotation comments page" do background do @draft_version = create(:legislation_draft_version, :published) - @annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum", ranges: [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[1]", "endOffset"=>11}]) - @annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam", ranges: [{"start"=>"/p[3]", "startOffset"=>6, "end"=>"/p[3]", "endOffset"=>11}]) + @annotation_1 = create(:legislation_annotation, draft_version: @draft_version, text: "my annotation", quote: "ipsum", ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[1]", "endOffset" => 11}]) + @annotation_2 = create(:legislation_annotation, draft_version: @draft_version, text: "my other annotation", quote: "audiam", ranges: [{"start" => "/p[3]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}]) end scenario "See one annotation with replies for a draft version" do diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb index 23d084347..7b1d48b8b 100644 --- a/spec/features/valuation/budget_investments_spec.rb +++ b/spec/features/valuation/budget_investments_spec.rb @@ -289,10 +289,10 @@ feature 'Valuation budget investments' do end scenario 'Feasibility selection makes proper fields visible', :js do - feasible_fields = ['Price (€)', 'Cost during the first year (€)', 'Price explanation', 'Time scope'] + feasible_fields = ['Price (€)', 'Cost during the first year (€)', 'Price explanation', 'Time scope'] unfeasible_fields = ['Feasibility explanation'] - any_feasibility_fields = ['Valuation finished', 'Internal comments'] - undecided_fields = feasible_fields + unfeasible_fields + any_feasibility_fields + any_feasibility_fields = ['Valuation finished', 'Internal comments'] + undecided_fields = feasible_fields + unfeasible_fields + any_feasibility_fields visit edit_valuation_budget_budget_investment_path(@budget, @investment) diff --git a/spec/features/valuation/spending_proposals_spec.rb b/spec/features/valuation/spending_proposals_spec.rb index 5b8bc34cf..2b2e06908 100644 --- a/spec/features/valuation/spending_proposals_spec.rb +++ b/spec/features/valuation/spending_proposals_spec.rb @@ -403,7 +403,7 @@ feature 'Valuation spending proposals' do end scenario "Summary table" do - scarlett = create(:valuator) + scarlett = create(:valuator) john = create(:valuator) finished_and_feasible1 = create(:spending_proposal, valuation_finished: true, feasible: true, price: '3000000') @@ -452,7 +452,7 @@ feature 'Valuation spending proposals' do scenario "Order by investment project count" do isabel = create(:valuator) john = create(:valuator) - scarlett = create(:valuator) + scarlett = create(:valuator) 3.times { create(:spending_proposal, valuators: [scarlett])} 1.times { create(:spending_proposal, valuators: [john])} diff --git a/spec/helpers/proposals_helper_spec.rb b/spec/helpers/proposals_helper_spec.rb index cee1ec648..d71178d9d 100644 --- a/spec/helpers/proposals_helper_spec.rb +++ b/spec/helpers/proposals_helper_spec.rb @@ -9,12 +9,12 @@ describe ProposalsHelper do end it "should be a between 1 and 100 if there are votes but less than needed" do - proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success/2) + proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success / 2) expect(progress_bar_percentage(proposal)).to eq 50 end it "should be 100 if there are more votes than needed" do - proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success*2) + proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success * 2) expect(progress_bar_percentage(proposal)).to eq 100 end end @@ -31,12 +31,12 @@ describe ProposalsHelper do end it "should be a between 1 and 100 if there are votes but less than needed" do - proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success/2) + proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success / 2) expect(supports_percentage(proposal)).to eq "50%" end it "should be 100 if there are more votes than needed" do - proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success*2) + proposal = create(:proposal, cached_votes_up: Proposal.votes_needed_for_success * 2) expect(supports_percentage(proposal)).to eq "100%" end diff --git a/spec/models/ahoy/data_source_spec.rb b/spec/models/ahoy/data_source_spec.rb index cea416498..863820710 100644 --- a/spec/models/ahoy/data_source_spec.rb +++ b/spec/models/ahoy/data_source_spec.rb @@ -23,14 +23,14 @@ describe Ahoy::DataSource do it 'should work with single data sources' do ds = Ahoy::DataSource.new ds.add 'foo', Ahoy::Event.where(name: 'foo').group_by_day(:time).count - expect(ds.build).to eq :x=>["2015-01-01", "2015-01-02"], "foo"=>[2, 1] + expect(ds.build).to eq :x => ["2015-01-01", "2015-01-02"], "foo" => [2, 1] end it 'should combine data sources' do ds = Ahoy::DataSource.new ds.add 'foo', Ahoy::Event.where(name: 'foo').group_by_day(:time).count ds.add 'bar', Ahoy::Event.where(name: 'bar').group_by_day(:time).count - expect(ds.build).to eq :x=>["2015-01-01", "2015-01-02", "2015-01-03"], "foo"=>[2, 1, 0], "bar"=>[1, 0, 2] + expect(ds.build).to eq :x => ["2015-01-01", "2015-01-02", "2015-01-03"], "foo" => [2, 1, 0], "bar" => [1, 0, 2] end end end diff --git a/spec/models/debate_spec.rb b/spec/models/debate_spec.rb index 612775ee4..8d24f9945 100644 --- a/spec/models/debate_spec.rb +++ b/spec/models/debate_spec.rb @@ -545,7 +545,7 @@ describe Debate do title_some_votes = create(:debate, title: 'stop corruption', cached_votes_up: 5) title_least_voted = create(:debate, title: 'stop corruption', cached_votes_up: 2) title_most_voted = create(:debate, title: 'stop corruption', cached_votes_up: 10) - description_most_voted = create(:debate, description: 'stop corruption', cached_votes_up: 10) + description_most_voted = create(:debate, description: 'stop corruption', cached_votes_up: 10) results = Debate.search('stop corruption') diff --git a/spec/models/legislation/annotation_spec.rb b/spec/models/legislation/annotation_spec.rb index 4cf5c6f59..0daca383a 100644 --- a/spec/models/legislation/annotation_spec.rb +++ b/spec/models/legislation/annotation_spec.rb @@ -17,7 +17,7 @@ RSpec.describe Legislation::Annotation, type: :model do Expetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id. His audiam", - ranges: [{"start"=>"/p[1]", "startOffset"=>6, "end"=>"/p[3]", "endOffset"=>11}] + ranges: [{"start" => "/p[1]", "startOffset" => 6, "end" => "/p[3]", "endOffset" => 11}] ) expect(annotation.context).to eq("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\n\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.\n\nHis audiamdeserunt in, eum ubique voluptatibus te. In reque dicta usu. Ne rebum dissentiet eam, vim omnis deseruisse id. Ullum deleniti vituperata at quo, insolens complectitur te eos, ea pri dico munere propriae. Vel ferri facilis ut, qui paulo ridens praesent ad. Possim alterum qui cu. Accusamus consulatu ius te, cu decore soleat appareat usu.") @@ -27,7 +27,7 @@ His audiam", annotation = create(:legislation_annotation, draft_version: draft_version, quote: "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo", - ranges: [{"start"=>"/p[1]", "startOffset"=>273, "end"=>"/p[2]", "endOffset"=>190}] + ranges: [{"start" => "/p[1]", "startOffset" => 273, "end" => "/p[2]", "endOffset" => 190}] ) expect(annotation.context).to eq("Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.\r\n\r\nExpetenda tincidunt in sed, ex partem placerat sea, porro commodo ex eam. His putant aeterno interesset at. Usu ea mundi tincidunt, omnium virtute aliquando ius ex. Ea aperiri sententiae duo. Usu nullam dolorum quaestio ei, sit vidit facilisis ea. Per ne impedit iracundia neglegentur. Consetetur neglegentur eum ut, vis animal legimus inimicus id.") @@ -39,7 +39,7 @@ His audiam", annotation = create(:legislation_annotation, draft_version: draft_version, quote: "By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish)", - ranges: [{"start"=>"/p[2]", "startOffset"=>127, "end"=>"/p[3]", "endOffset"=>223}] + ranges: [{"start" => "/p[2]", "startOffset" => 127, "end" => "/p[3]", "endOffset" => 223}] ) expect(annotation.context).to eq("The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users.\r\n\r\nWhen we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.") diff --git a/spec/models/poll/officer_spec.rb b/spec/models/poll/officer_spec.rb index 1764f7200..b096aebc3 100644 --- a/spec/models/poll/officer_spec.rb +++ b/spec/models/poll/officer_spec.rb @@ -32,7 +32,7 @@ describe :officer do poll_2 = create(:poll) booth_assignment_1 = create(:poll_booth_assignment, poll: poll_1) - booth_assignment_2 = create(:poll_booth_assignment, poll: poll_2) + booth_assignment_2 = create(:poll_booth_assignment, poll: poll_2) create(:poll_officer_assignment, booth_assignment: booth_assignment_1, officer: officer, date: poll_1.starts_at) create(:poll_officer_assignment, booth_assignment: booth_assignment_2, officer: officer, final: true) @@ -92,7 +92,7 @@ describe :officer do poll_2 = create(:poll) booth_assignment_1 = create(:poll_booth_assignment, poll: poll_1) - booth_assignment_2 = create(:poll_booth_assignment, poll: poll_2) + booth_assignment_2 = create(:poll_booth_assignment, poll: poll_2) create(:poll_officer_assignment, booth_assignment: booth_assignment_1, officer: officer, date: poll_1.starts_at) create(:poll_officer_assignment, booth_assignment: booth_assignment_2, officer: officer, final: true) diff --git a/spec/models/poll/voter_spec.rb b/spec/models/poll/voter_spec.rb index 752ac5bbc..c1c248550 100644 --- a/spec/models/poll/voter_spec.rb +++ b/spec/models/poll/voter_spec.rb @@ -33,7 +33,7 @@ describe :voter do user = create(:user, :level_two) voter1 = create(:poll_voter, user: user, poll: poll) - voter2 = build(:poll_voter, user: user, poll: poll) + voter2 = build(:poll_voter, user: user, poll: poll) expect(voter2).to_not be_valid expect(voter2.errors.messages[:document_number]).to eq(["User has already voted"]) @@ -43,7 +43,7 @@ describe :voter do user = create(:user, :level_two) voter1 = create(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment) - voter2 = build(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment) + voter2 = build(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment) expect(voter2).to_not be_valid expect(voter2.errors.messages[:document_number]).to eq(["User has already voted"]) @@ -56,7 +56,7 @@ describe :voter do user = create(:user, :level_two) voter1 = create(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment1) - voter2 = build(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment2) + voter2 = build(:poll_voter, user: user, poll: poll, booth_assignment: booth_assignment2) expect(voter2).to_not be_valid expect(voter2.errors.messages[:document_number]).to eq(["User has already voted"]) @@ -69,7 +69,7 @@ describe :voter do user = create(:user, :level_two) voter1 = create(:poll_voter, user: user, booth_assignment: booth_assignment1) - voter2 = build(:poll_voter, user: user, booth_assignment: booth_assignment2) + voter2 = build(:poll_voter, user: user, booth_assignment: booth_assignment2) expect(voter2).to be_valid end diff --git a/spec/models/residence_spec.rb b/spec/models/residence_spec.rb index 98b939084..d518c41af 100644 --- a/spec/models/residence_spec.rb +++ b/spec/models/residence_spec.rb @@ -13,19 +13,19 @@ describe Verification::Residence do describe "dates" do it "should be valid with a valid date of birth" do - residence = Verification::Residence.new({"date_of_birth(3i)"=>"1", "date_of_birth(2i)"=>"1", "date_of_birth(1i)"=>"1980"}) + residence = Verification::Residence.new({"date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "1980"}) expect(residence.errors[:date_of_birth].size).to eq(0) end it "should not be valid without a date of birth" do - residence = Verification::Residence.new({"date_of_birth(3i)"=>"", "date_of_birth(2i)"=>"", "date_of_birth(1i)"=>""}) + residence = Verification::Residence.new({"date_of_birth(3i)" => "", "date_of_birth(2i)" => "", "date_of_birth(1i)" => ""}) expect(residence).to_not be_valid expect(residence.errors[:date_of_birth]).to include("can't be blank") end end it "should validate user has allowed age" do - residence = Verification::Residence.new({"date_of_birth(3i)"=>"1", "date_of_birth(2i)"=>"1", "date_of_birth(1i)"=>"#{5.years.ago.year}"}) + residence = Verification::Residence.new({"date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "#{5.years.ago.year}"}) expect(residence).to_not be_valid expect(residence.errors[:date_of_birth]).to include("You don't have the required age to participate") end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2bf09f378..0ea321423 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -220,7 +220,7 @@ describe User do subject.username = nil expect(subject).to be_valid - subject.organization.name= nil + subject.organization.name = nil expect(subject).to_not be_valid end end From c4d90691b1b1a477dd387f00eaf0dbf9eebd211c Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 26 Jun 2017 18:05:14 +0200 Subject: [PATCH 55/75] Fix all Layout/SpaceInLambdaLiteral rubocop issues and remove files from rubocop_todo list --- .rubocop_todo.yml | 11 ----------- app/models/concerns/filterable.rb | 4 ++-- app/models/spending_proposal.rb | 6 +++--- app/models/user.rb | 2 +- app/models/verified_user.rb | 6 +++--- lib/graph_ql/api_types_creator.rb | 4 ++-- lib/graph_ql/query_type_creator.rb | 4 ++-- spec/controllers/concerns/has_orders_spec.rb | 2 +- 8 files changed, 14 insertions(+), 25 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 27b209449..9edcf605f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -557,17 +557,6 @@ Style/RescueModifier: - 'app/controllers/concerns/commentable_actions.rb' - 'app/controllers/verification/sms_controller.rb' -# Offense count: 9 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: require_no_space, require_space -Layout/SpaceInLambdaLiteral: - Exclude: - - 'app/models/concerns/filterable.rb' - - 'app/models/spending_proposal.rb' - - 'app/models/user.rb' - - 'app/models/verified_user.rb' - # Offense count: 8 # Cop supports --auto-correct. Layout/SpaceInsideParens: diff --git a/app/models/concerns/filterable.rb b/app/models/concerns/filterable.rb index 68e844782..c5402d9b2 100644 --- a/app/models/concerns/filterable.rb +++ b/app/models/concerns/filterable.rb @@ -2,8 +2,8 @@ module Filterable extend ActiveSupport::Concern included do - scope :by_official_level, -> (official_level) { where(users: { official_level: official_level }).joins(:author) } - scope :by_date_range, -> (date_range) { where(created_at: date_range) } + scope :by_official_level, ->(official_level) { where(users: { official_level: official_level }).joins(:author) } + scope :by_date_range, ->(date_range) { where(created_at: date_range) } end class_methods do diff --git a/app/models/spending_proposal.rb b/app/models/spending_proposal.rb index 874533931..b08d7533a 100644 --- a/app/models/spending_proposal.rb +++ b/app/models/spending_proposal.rb @@ -31,9 +31,9 @@ class SpendingProposal < ActiveRecord::Base scope :not_unfeasible, -> { where("feasible IS ? OR feasible = ?", nil, true) } scope :with_supports, -> { where('cached_votes_up > 0') } - scope :by_admin, -> (admin) { where(administrator_id: admin.presence) } - scope :by_tag, -> (tag_name) { tagged_with(tag_name) } - scope :by_valuator, -> (valuator) { where("valuation_assignments.valuator_id = ?", valuator.presence).joins(:valuation_assignments) } + scope :by_admin, ->(admin) { where(administrator_id: admin.presence) } + scope :by_tag, ->(tag_name) { tagged_with(tag_name) } + scope :by_valuator, ->(valuator) { where("valuation_assignments.valuator_id = ?", valuator.presence).joins(:valuation_assignments) } scope :for_render, -> { includes(:geozone) } diff --git a/app/models/user.rb b/app/models/user.rb index 3da726c6e..9f629009d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -56,7 +56,7 @@ class User < ActiveRecord::Base scope :officials, -> { where("official_level > 0") } scope :newsletter, -> { where(newsletter: true) } scope :for_render, -> { includes(:organization) } - scope :by_document, -> (document_type, document_number) { where(document_type: document_type, document_number: document_number) } + scope :by_document, ->(document_type, document_number) { where(document_type: document_type, document_number: document_number) } scope :email_digest, -> { where(email_digest: true) } scope :active, -> { where(erased_at: nil) } scope :erased, -> { where.not(erased_at: nil) } diff --git a/app/models/verified_user.rb b/app/models/verified_user.rb index b0c5afd0c..6b0ddb822 100644 --- a/app/models/verified_user.rb +++ b/app/models/verified_user.rb @@ -1,8 +1,8 @@ class VerifiedUser < ActiveRecord::Base - scope :by_user, -> (user) { where(document_number: user.document_number) } + scope :by_user, ->(user) { where(document_number: user.document_number) } - scope :by_email, -> (email) { where(email: email) } - scope :by_phone, -> (phone) { where(phone: phone) } + scope :by_email, ->(email) { where(email: email) } + scope :by_phone, ->(phone) { where(phone: phone) } def self.phone?(user) by_user(user).by_phone(user.unconfirmed_phone).first.present? diff --git a/lib/graph_ql/api_types_creator.rb b/lib/graph_ql/api_types_creator.rb index f8f78355e..9f55be3cc 100644 --- a/lib/graph_ql/api_types_creator.rb +++ b/lib/graph_ql/api_types_creator.rb @@ -42,7 +42,7 @@ module GraphQL field(field_name, SCALAR_TYPES[field_type], model.human_attribute_name(field_name)) when :singular_association field(field_name, -> { created_types[field_type] }) do - resolve -> (object, arguments, context) do + resolve ->(object, arguments, context) do association_target = object.send(field_name) association_target.present? ? field_type.public_for_api.find_by(id: association_target.id) : nil end @@ -50,7 +50,7 @@ module GraphQL when :multiple_association field_type = field_type.first connection(field_name, -> { created_types[field_type].connection_type }, max_page_size: 50, complexity: 1000) do - resolve -> (object, arguments, context) { object.send(field_name).public_for_api } + resolve ->(object, arguments, context) { object.send(field_name).public_for_api } end end end diff --git a/lib/graph_ql/query_type_creator.rb b/lib/graph_ql/query_type_creator.rb index 71beb8033..8f4a497ef 100644 --- a/lib/graph_ql/query_type_creator.rb +++ b/lib/graph_ql/query_type_creator.rb @@ -14,13 +14,13 @@ module GraphQL type created_type description model.graphql_field_description argument :id, !types.ID - resolve -> (object, arguments, context) { model.public_for_api.find_by(id: arguments['id'])} + resolve ->(object, arguments, context) { model.public_for_api.find_by(id: arguments['id'])} end end connection(model.graphql_pluralized_field_name, created_type.connection_type, max_page_size: 50, complexity: 1000) do description model.graphql_pluralized_field_description - resolve -> (object, arguments, context) { model.public_for_api } + resolve ->(object, arguments, context) { model.public_for_api } end end diff --git a/spec/controllers/concerns/has_orders_spec.rb b/spec/controllers/concerns/has_orders_spec.rb index 37d62fa84..fa2c49b07 100644 --- a/spec/controllers/concerns/has_orders_spec.rb +++ b/spec/controllers/concerns/has_orders_spec.rb @@ -7,7 +7,7 @@ describe 'HasOrders' do controller(FakeController) do include HasOrders has_orders ['created_at', 'votes_count', 'flags_count', 'relevance'], only: :index - has_orders -> (c) { ['votes_count', 'flags_count'] }, only: :new + has_orders ->(c) { ['votes_count', 'flags_count'] }, only: :new def index render text: "#{@current_order} (#{@valid_orders.join(' ')})" From 1c8e03986266efe3389c783f215200acfde93bdd Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 26 Jun 2017 18:06:01 +0200 Subject: [PATCH 56/75] Fix all Layout/SpaceInsideParens rubocop issues and remove files from rubocop_todo list --- .rubocop_todo.yml | 9 --------- app/models/user.rb | 2 +- lib/manager_authenticator.rb | 2 +- spec/features/proposals_spec.rb | 2 +- spec/models/abilities/moderator_spec.rb | 8 ++++---- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 9edcf605f..54a3f650f 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -557,15 +557,6 @@ Style/RescueModifier: - 'app/controllers/concerns/commentable_actions.rb' - 'app/controllers/verification/sms_controller.rb' -# Offense count: 8 -# Cop supports --auto-correct. -Layout/SpaceInsideParens: - Exclude: - - 'app/models/user.rb' - - 'lib/manager_authenticator.rb' - - 'spec/features/proposals_spec.rb' - - 'spec/models/abilities/moderator_spec.rb' - # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: IgnoredMethods. diff --git a/app/models/user.rb b/app/models/user.rb index 9f629009d..9df08c014 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -156,7 +156,7 @@ class User < ActiveRecord::Base def has_official_email? domain = Setting['email_domain_for_officials'] - email.present? && ( (email.end_with? "@#{domain}") || (email.end_with? ".#{domain}") ) + email.present? && ((email.end_with? "@#{domain}") || (email.end_with? ".#{domain}")) end def display_official_position_badge? diff --git a/lib/manager_authenticator.rb b/lib/manager_authenticator.rb index 8f8d453f7..11928e737 100644 --- a/lib/manager_authenticator.rb +++ b/lib/manager_authenticator.rb @@ -25,7 +25,7 @@ class ManagerAuthenticator parsed_response = parser.parse((response[:get_applications_user_list_response][:get_applications_user_list_return])) aplication_value = parsed_response["APLICACIONES"]["APLICACION"] # aplication_value from UWEB can be an array of hashes or a hash - aplication_value.include?( {"CLAVE_APLICACION" => application_key}) || aplication_value["CLAVE_APLICACION"] == application_key + aplication_value.include?({"CLAVE_APLICACION" => application_key}) || aplication_value["CLAVE_APLICACION"] == application_key rescue false end diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 9d8584839..cfe9cc918 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -99,7 +99,7 @@ feature 'Proposals' do end scenario "Show Vimeo video" do - proposal = create(:proposal, video_url: "https://vimeo.com/7232823" ) + proposal = create(:proposal, video_url: "https://vimeo.com/7232823") visit proposal_path(proposal) expect(page).to have_selector("div[id='js-embedded-video']") expect(page.html).to include 'https://player.vimeo.com/video/7232823' diff --git a/spec/models/abilities/moderator_spec.rb b/spec/models/abilities/moderator_spec.rb index 6fab62d73..f3135c8d9 100644 --- a/spec/models/abilities/moderator_spec.rb +++ b/spec/models/abilities/moderator_spec.rb @@ -35,14 +35,14 @@ describe "Abilities::Moderator" do let(:rejected_organization) { create(:organization, :rejected) } let(:verified_organization) { create(:organization, :verified) } - it { should be_able_to( :verify, pending_organization) } - it { should be_able_to( :reject, pending_organization) } + it { should be_able_to(:verify, pending_organization) } + it { should be_able_to(:reject, pending_organization) } it { should_not be_able_to(:verify, verified_organization) } - it { should be_able_to( :reject, verified_organization) } + it { should be_able_to(:reject, verified_organization) } it { should_not be_able_to(:reject, rejected_organization) } - it { should be_able_to( :verify, rejected_organization) } + it { should be_able_to(:verify, rejected_organization) } end describe "hiding, reviewing and restoring" do From c2b129bc0080907dc2b0a46abc92e314f0bb17a8 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 26 Jun 2017 18:06:27 +0200 Subject: [PATCH 57/75] =?UTF-8?q?updates=20very=20old=20foundation=20class?= =?UTF-8?q?=20=F0=9F=91=B4=F0=9F=8F=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/shared/_suggest.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_suggest.html.erb b/app/views/shared/_suggest.html.erb index d50f67056..b71b1e919 100644 --- a/app/views/shared/_suggest.html.erb +++ b/app/views/shared/_suggest.html.erb @@ -1,6 +1,6 @@
      <% if @search_terms && @resources.any? %> -
      +

      <%= t("shared.suggest.#{resource_name}.found", count: @resources.count, From ce7a67418b4ebf62adc292102793c39b34fa9a08 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 26 Jun 2017 18:50:28 +0200 Subject: [PATCH 58/75] Remove current_order variable assignament, only used once --- app/views/comments/_comment_tree.html.erb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/comments/_comment_tree.html.erb b/app/views/comments/_comment_tree.html.erb index c72bd8bcf..a43ad94fa 100644 --- a/app/views/comments/_comment_tree.html.erb +++ b/app/views/comments/_comment_tree.html.erb @@ -1,7 +1,6 @@ <% commentable = comment_tree.commentable %> -<% current_order = comment_tree.order %> -<% cache [locale_and_user_status, current_order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count, comment_flags] do %> +<% cache [locale_and_user_status, comment_tree.order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count, comment_flags] do %>

      From 6c386ffd95fb6c282a101451c734a79a6eb16fc6 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 26 Jun 2017 18:52:43 +0200 Subject: [PATCH 59/75] Make comments count display optional using a variable on comments comment_tree partial --- app/views/comments/_comment_tree.html.erb | 10 ++++++---- app/views/legislation/annotations/show.html.erb | 4 +++- app/views/legislation/questions/show.html.erb | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/app/views/comments/_comment_tree.html.erb b/app/views/comments/_comment_tree.html.erb index a43ad94fa..45b4aea03 100644 --- a/app/views/comments/_comment_tree.html.erb +++ b/app/views/comments/_comment_tree.html.erb @@ -4,10 +4,12 @@
      -

      - <%= comment_tree_title_text(commentable) %> - (<%= commentable.comments_count %>) -

      + <% if display_comments_count %> +

      + <%= comment_tree_title_text(commentable) %> + (<%= commentable.comments_count %>) +

      + <% end %> <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> diff --git a/app/views/legislation/annotations/show.html.erb b/app/views/legislation/annotations/show.html.erb index 65ce8e947..1854addb5 100644 --- a/app/views/legislation/annotations/show.html.erb +++ b/app/views/legislation/annotations/show.html.erb @@ -40,7 +40,9 @@
      - <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %> + <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, + comment_flags: @comment_flags, + display_comments_count: true } %>
      diff --git a/app/views/legislation/questions/show.html.erb b/app/views/legislation/questions/show.html.erb index ab1443628..7361ea8f4 100644 --- a/app/views/legislation/questions/show.html.erb +++ b/app/views/legislation/questions/show.html.erb @@ -42,6 +42,7 @@
      - <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %> - + <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, + comment_flags: @comment_flags, + display_comments_count: true } %>
From 79ecc5cfca0b5eeb51149d65c5b9f0fbbccc9607 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 26 Jun 2017 18:54:07 +0200 Subject: [PATCH 60/75] Use comments comment_tree partial without comments count display investments show page --- app/views/budgets/investments/show.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/budgets/investments/show.html.erb b/app/views/budgets/investments/show.html.erb index dede17d66..264e7b102 100644 --- a/app/views/budgets/investments/show.html.erb +++ b/app/views/budgets/investments/show.html.erb @@ -15,6 +15,8 @@ <%= render "budgets/investments/milestones" %>
- <%= render partial: 'budgets/investments/comments', locals: { comment_tree: @comment_tree, comment_flags: @comment_flags } %> + <%= render partial: '/comments/comment_tree', locals: { comment_tree: @comment_tree, + comment_flags: @comment_flags, + display_comments_count: false } %>
From 295f2bc32b493eed49b21311776ab864e7e36685 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 26 Jun 2017 18:54:20 +0200 Subject: [PATCH 61/75] Remove no longer needed specific budget investments comments partial --- .../budgets/investments/_comments.html.erb | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 app/views/budgets/investments/_comments.html.erb diff --git a/app/views/budgets/investments/_comments.html.erb b/app/views/budgets/investments/_comments.html.erb deleted file mode 100644 index bc5ad6540..000000000 --- a/app/views/budgets/investments/_comments.html.erb +++ /dev/null @@ -1,41 +0,0 @@ -<% commentable = comment_tree.commentable %> -<% current_order = comment_tree.order %> - -<% cache [locale_and_user_status, current_order, commentable_cache_key(commentable), comment_tree.comments, comment_tree.comment_authors, commentable.comments_count, comment_flags] do %> -
-
-
- - <%= render 'shared/wide_order_selector', i18n_namespace: "comments" %> - - <% if user_signed_in? %> - <% if comments_closed_for_commentable?(commentable) %> -
-
- <%= comments_closed_text(commentable) %> -
- <% elsif require_verified_resident_for_commentable?(commentable, current_user) %> -
-
- <%= t("comments.verified_only", verify_account: link_to(t("comments.verify_account"), verification_path )).html_safe %> -
- <% else %> - <%= render 'comments/form', {commentable: commentable, parent_id: nil, toggeable: false} %> - <% end %> - <% else %> -
-
- <%= t("debates.show.login_to_comment", - signin: link_to(t("votes.signin"), new_user_session_path), - signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %> -
- <% end %> - - <% comment_tree.root_comments.each do |comment| %> - <%= render 'comments/comment', {comment: comment, comment_flags: comment_flags} %> - <% end %> - <%= paginate comment_tree.root_comments %> -
-
-
-<% end %> From af7807ce9f9756f70e4fb55012394831b4ff282b Mon Sep 17 00:00:00 2001 From: decabeza Date: Tue, 27 Jun 2017 10:29:36 +0200 Subject: [PATCH 62/75] Updates custom note class to foundation help-text --- app/assets/stylesheets/layout.scss | 17 ----------- app/views/admin/poll/questions/_form.html.erb | 4 +-- app/views/admin/signature_sheets/new.html.erb | 4 +-- app/views/budgets/investments/_form.html.erb | 3 +- app/views/debates/_form.html.erb | 5 ++-- .../management/user_invites/new.html.erb | 6 ++-- .../organizations/registrations/new.html.erb | 6 ++-- app/views/proposals/_form.html.erb | 29 ++++++++++++------- app/views/shared/_suggest.html.erb | 24 ++++++++------- app/views/users/registrations/edit.html.erb | 12 +++++--- app/views/users/registrations/new.html.erb | 7 +++-- app/views/verification/residence/new.html.erb | 4 +-- app/views/verification/sms/new.html.erb | 6 ++-- config/locales/en.yml | 2 +- config/locales/es.yml | 2 +- config/locales/fr.yml | 4 +-- config/locales/nl.yml | 14 ++++----- config/locales/pt-BR.yml | 4 +-- 18 files changed, 81 insertions(+), 72 deletions(-) diff --git a/app/assets/stylesheets/layout.scss b/app/assets/stylesheets/layout.scss index 2bca33bf5..9673cdc88 100644 --- a/app/assets/stylesheets/layout.scss +++ b/app/assets/stylesheets/layout.scss @@ -825,23 +825,6 @@ form { margin: $line-height / 2 0 $line-height / 2 $line-height / 4; } - .note, - .note-marked { - display: block; - font-size: rem-calc(13); - margin-bottom: $line-height / 2; - } - - .note-marked { - background: #ff0; - display: inline-block; - - em { - background: #fff; - display: block; - } - } - .ckeditor { min-height: $line-height * 13; } diff --git a/app/views/admin/poll/questions/_form.html.erb b/app/views/admin/poll/questions/_form.html.erb index 0da36913a..959aa4ddf 100644 --- a/app/views/admin/poll/questions/_form.html.erb +++ b/app/views/admin/poll/questions/_form.html.erb @@ -17,8 +17,8 @@ <%= f.text_field :title, maxlength: Poll::Question.title_max_length %> <%= f.label :valid_answers %> -

<%= t("admin.questions.new.valid_answers_note") %>

- <%= f.text_field :valid_answers, label: false %> +

<%= t("admin.questions.new.valid_answers_note") %>

+ <%= f.text_field :valid_answers, label: false, aria: {describedby: "valid-answers-help-text"} %>
<%= f.cktext_area :description, diff --git a/app/views/admin/signature_sheets/new.html.erb b/app/views/admin/signature_sheets/new.html.erb index f471e1ea5..a1f2436bb 100644 --- a/app/views/admin/signature_sheets/new.html.erb +++ b/app/views/admin/signature_sheets/new.html.erb @@ -15,8 +15,8 @@
<%= f.label :document_numbers %> -

<%= t("admin.signature_sheets.new.document_numbers_note") %>

- <%= f.text_area :document_numbers, rows: "6", label: false %> +

<%= t("admin.signature_sheets.new.document_numbers_note") %>

+ <%= f.text_area :document_numbers, rows: "6", label: false, aria: {describedby: "document-numbers-help-text"} %> <%= f.submit(class: "button", value: t("admin.signature_sheets.new.submit")) %> <% end %> \ No newline at end of file diff --git a/app/views/budgets/investments/_form.html.erb b/app/views/budgets/investments/_form.html.erb index 28b47d726..94f6283e9 100644 --- a/app/views/budgets/investments/_form.html.erb +++ b/app/views/budgets/investments/_form.html.erb @@ -31,7 +31,7 @@
<%= f.label :tag_list, t("budgets.investments.form.tags_label") %> -

<%= t("budgets.investments.form.tags_instructions") %>

+

<%= t("budgets.investments.form.tags_instructions") %>

<%= f.label :category_tag_list, t("budgets.investments.form.tag_category_label") %> @@ -44,6 +44,7 @@ <%= f.text_field :tag_list, value: @investment.tag_list.to_s, label: false, placeholder: t("budgets.investments.form.tags_placeholder"), + aria: {describedby: "tags-list-help-text"}, class: 'js-tag-list' %>
diff --git a/app/views/debates/_form.html.erb b/app/views/debates/_form.html.erb index c88045f26..96a5337ca 100644 --- a/app/views/debates/_form.html.erb +++ b/app/views/debates/_form.html.erb @@ -17,11 +17,12 @@
<%= f.label :tag_list, t("debates.form.tags_label") %> -

<%= t("debates.form.tags_instructions") %>

+

<%= t("debates.form.tags_instructions") %>

<%= f.text_field :tag_list, value: @debate.tag_list.to_s, label: false, - placeholder: t("debates.form.tags_placeholder") %> + placeholder: t("debates.form.tags_placeholder"), + aria: {describedby: "tag-list-help-text"} %>
<% if @debate.new_record? %> diff --git a/app/views/management/user_invites/new.html.erb b/app/views/management/user_invites/new.html.erb index a49a84538..969ca8fdf 100644 --- a/app/views/management/user_invites/new.html.erb +++ b/app/views/management/user_invites/new.html.erb @@ -3,8 +3,10 @@ <%= form_tag management_user_invites_path do %> -

<%= t('management.user_invites.new.info') %>

- <%= text_area_tag "emails", nil, rows: 5, placeholder: t('management.user_invites.new.info') %> +

<%= t('management.user_invites.new.info') %>

+ <%= text_area_tag "emails", nil, rows: 5, + placeholder: t('management.user_invites.new.info'), + aria: {describedby: "emails-help-text"} %>
diff --git a/app/views/organizations/registrations/new.html.erb b/app/views/organizations/registrations/new.html.erb index e85bb5408..40d8c5d05 100644 --- a/app/views/organizations/registrations/new.html.erb +++ b/app/views/organizations/registrations/new.html.erb @@ -9,8 +9,10 @@ <%= f.fields_for :organization do |fo| %> <%= fo.text_field :name, autofocus: true, maxlength: Organization.name_max_length, placeholder: t("devise_views.organizations.registrations.new.organization_name_label") %> <%= fo.label :responsible_name %> -

<%= t("devise_views.organizations.registrations.new.responsible_name_note") %>

- <%= fo.text_field :responsible_name, placeholder: t("devise_views.organizations.registrations.new.responsible_name_label"), maxlength: Organization.responsible_name_max_length, label: false %> +

<%= t("devise_views.organizations.registrations.new.responsible_name_note") %>

+ <%= fo.text_field :responsible_name, placeholder: t("devise_views.organizations.registrations.new.responsible_name_label"), + maxlength: Organization.responsible_name_max_length, label: false, + aria: {describedby: "responsible-name-help-text"} %> <% end %> <%= f.email_field :email, placeholder: t("devise_views.organizations.registrations.new.email_label") %> diff --git a/app/views/proposals/_form.html.erb b/app/views/proposals/_form.html.erb index 3eda38cd1..232f65ac1 100644 --- a/app/views/proposals/_form.html.erb +++ b/app/views/proposals/_form.html.erb @@ -12,17 +12,21 @@
<%= f.label :question, t("proposals.form.proposal_question") %> - +

<%= t("proposals.form.proposal_question_example_html") %> - - <%= f.text_field :question, maxlength: Proposal.question_max_length, placeholder: t("proposals.form.proposal_question"), label: false %> +

+ <%= f.text_field :question, maxlength: Proposal.question_max_length, + placeholder: t("proposals.form.proposal_question"), + label: false, + aria: {describedby: "question-help-text"} %>
<%= f.label :summary, t("proposals.form.proposal_summary") %> -

<%= t("proposals.form.proposal_summary_note") %>

+

<%= t("proposals.form.proposal_summary_note") %>

<%= f.text_area :summary, rows: 4, maxlength: 200, label: false, - placeholder: t('proposals.form.proposal_summary') %> + placeholder: t('proposals.form.proposal_summary'), + aria: {describedby: "summary-help-text"} %>
@@ -33,8 +37,9 @@
<%= f.label :video_url, t("proposals.form.proposal_video_url") %> -

<%= t("proposals.form.proposal_video_url_note") %>

- <%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), label: false %> +

<%= t("proposals.form.proposal_video_url_note") %>

+ <%= f.text_field :video_url, placeholder: t("proposals.form.proposal_video_url"), label: false, + aria: {describedby: "video-url-help-text"} %>
@@ -49,7 +54,7 @@
<%= f.label :tag_list, t("proposals.form.tags_label") %> -

<%= t("proposals.form.tags_instructions") %>

+

<%= t("proposals.form.tags_instructions") %>

<%= f.label :category_tag_list, t("proposals.form.tag_category_label") %> @@ -62,14 +67,16 @@ <%= f.text_field :tag_list, value: @proposal.tag_list.to_s, label: false, placeholder: t("proposals.form.tags_placeholder"), - class: 'js-tag-list' %> + class: 'js-tag-list', + aria: {describedby: "tag-list-help-text"} %>
<% if current_user.unverified? %>
<%= f.label :responsible_name, t("proposals.form.proposal_responsible_name") %> -

<%= t("proposals.form.proposal_responsible_name_note") %>

- <%= f.text_field :responsible_name, placeholder: t("proposals.form.proposal_responsible_name"), label: false %> +

<%= t("proposals.form.proposal_responsible_name_note") %>

+ <%= f.text_field :responsible_name, placeholder: t("proposals.form.proposal_responsible_name"), label: false, + aria: {describedby: "responsible-name-help-text"} %>
<% end %> diff --git a/app/views/shared/_suggest.html.erb b/app/views/shared/_suggest.html.erb index b71b1e919..3164594fc 100644 --- a/app/views/shared/_suggest.html.erb +++ b/app/views/shared/_suggest.html.erb @@ -1,10 +1,12 @@
<% if @search_terms && @resources.any? %>
-

- <%= t("shared.suggest.#{resource_name}.found", - count: @resources.count, - query: @search_terms)%> +

+ + <%= t("shared.suggest.#{resource_name}.found", + count: @resources.count, + query: @search_terms)%> +

    @@ -14,11 +16,13 @@
<% if @resources.count > @limit %> -

- <%= t("shared.suggest.#{resource_name}.message", - count: @resources.count, - query: @search_terms, - limit: @limit) %> +

+ + <%= t("shared.suggest.#{resource_name}.message", + count: @resources.count, + query: @search_terms, + limit: @limit) %> + <%= link_to t("shared.suggest.#{resource_name}.see_all"), polymorphic_url(resource_model, search: @search_terms)%>

@@ -26,4 +30,4 @@
<% end %> -
\ No newline at end of file +
diff --git a/app/views/users/registrations/edit.html.erb b/app/views/users/registrations/edit.html.erb index bbf33ccfa..7d80efda3 100644 --- a/app/views/users/registrations/edit.html.erb +++ b/app/views/users/registrations/edit.html.erb @@ -18,8 +18,10 @@
<%= f.label :password, t("devise_views.users.registrations.edit.password_label") %> -

<%= t("devise_views.users.registrations.edit.leave_blank") %>

- <%= f.password_field :password, autocomplete: "off", label: false, placeholder: t("devise_views.users.registrations.edit.password_label") %> +

<%= t("devise_views.users.registrations.edit.leave_blank") %>

+ <%= f.password_field :password, autocomplete: "off", label: false, + placeholder: t("devise_views.users.registrations.edit.password_label"), + aria: {describedby: "password-help-text"} %>
@@ -29,8 +31,10 @@
<%= f.label :current_password, t("devise_views.users.registrations.edit.current_password_label") %> -

<%= t("devise_views.users.registrations.edit.need_current") %>

- <%= f.password_field :current_password, label: false, autocomplete: "off", placeholder: t("devise_views.users.registrations.edit.current_password_label") %> +

<%= t("devise_views.users.registrations.edit.need_current") %>

+ <%= f.password_field :current_password, label: false, autocomplete: "off", + placeholder: t("devise_views.users.registrations.edit.current_password_label"), + aria: {describedby: "current-password-help-text"} %>
diff --git a/app/views/users/registrations/new.html.erb b/app/views/users/registrations/new.html.erb index 3ae3156f7..8e702a5f1 100644 --- a/app/views/users/registrations/new.html.erb +++ b/app/views/users/registrations/new.html.erb @@ -18,8 +18,11 @@ <%= f.hidden_field :locale, value: I18n.locale %> <%= f.label :username %> -

<%= t("devise_views.users.registrations.new.username_note") %>

- <%= f.text_field :username, autofocus: true, maxlength: User.username_max_length, placeholder: t("devise_views.users.registrations.new.username_label"), label: false %> +

<%= t("devise_views.users.registrations.new.username_note") %>

+ <%= f.text_field :username, autofocus: true, maxlength: User.username_max_length, + placeholder: t("devise_views.users.registrations.new.username_label"), + label: false, + aria: {describedby: "username-help-text"} %> <%= f.invisible_captcha :family_name %> diff --git a/app/views/verification/residence/new.html.erb b/app/views/verification/residence/new.html.erb index 703e4b98f..2159d1a01 100644 --- a/app/views/verification/residence/new.html.erb +++ b/app/views/verification/residence/new.html.erb @@ -76,9 +76,9 @@
<%= f.label t("verification.residence.new.postal_code") %> -

<%= t("verification.residence.new.postal_code_note") %>

+

<%= t("verification.residence.new.postal_code_note") %>

- <%= f.text_field :postal_code, label: false %> + <%= f.text_field :postal_code, label: false, aria: {describedby: "postal-code-help-text"} %>
diff --git a/app/views/verification/sms/new.html.erb b/app/views/verification/sms/new.html.erb index 06f679e36..820ed01fa 100644 --- a/app/views/verification/sms/new.html.erb +++ b/app/views/verification/sms/new.html.erb @@ -31,8 +31,10 @@
<%= f.label :phone, t("verification.sms.new.phone"), class: "inline-block" %> <%= t("verification.sms.new.phone_format_html") %> -

<%= t("verification.sms.new.phone_note") %>

- <%= f.text_field :phone, label: false, placeholder: t("verification.sms.new.phone_placeholder") %> +

<%= t("verification.sms.new.phone_note") %>

+ <%= f.text_field :phone, label: false, + placeholder: t("verification.sms.new.phone_placeholder"), + aria: {describedby: "phone-help-text"} %>
<%= f.submit t("verification.sms.new.submit_button"), class: "button success" %> diff --git a/config/locales/en.yml b/config/locales/en.yml index dac7bc3be..33b457e32 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -298,7 +298,7 @@ en: geozone: Scope of operation proposal_external_url: Link to additional documentation proposal_question: Proposal question - proposal_question_example_html: Must be summarised in one question with a Yes or No answer. E.g. 'Do you agree with the pedestrianisation of Calle Mayor?' + proposal_question_example_html: "Must be summarised in one question with a Yes or No answer.
E.g. 'Do you agree with the pedestrianisation of Calle Mayor?'" proposal_responsible_name: Full name of the person submitting the proposal proposal_responsible_name_note: "(individually or as representative of a collective; will not be displayed publically)" proposal_summary: Proposal summary diff --git a/config/locales/es.yml b/config/locales/es.yml index 5494ca497..d38184647 100755 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -298,7 +298,7 @@ es: geozone: "Ámbito de actuación" proposal_external_url: Enlace a documentación adicional proposal_question: Pregunta de la propuesta - proposal_question_example_html: Debe ser resumida en una pregunta cuya respuesta sea Sí o No. Ej. '¿Está usted de acuerdo en peatonalizar la calle Mayor?' + proposal_question_example_html: "Debe ser resumida en una pregunta cuya respuesta sea Sí o No.
Ej. '¿Está usted de acuerdo en peatonalizar la calle Mayor?'" proposal_responsible_name: Nombre y apellidos de la persona que hace esta propuesta proposal_responsible_name_note: "(individualmente o como representante de un colectivo; no se mostrará públicamente)" proposal_summary: Resumen de la propuesta diff --git a/config/locales/fr.yml b/config/locales/fr.yml index b978f70e2..e4d0f9a51 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -1249,8 +1249,8 @@ fr: proposal_external_url: Lien vers de la documentation complémentaire proposal_question: Question proposée proposal_question_example_html: 'Doit être résumé par une question appelant - à une réponse par oui ou par non. Exemple : ''Êtes-vous d''accord avec - la piétonnisation de Calle Mayor?''' + à une réponse par oui ou par non.
Exemple : ''Êtes-vous d''accord avec + la piétonnisation de Calle Mayor?' proposal_responsible_name: Nom complet de la personne qui soumet la proposition proposal_responsible_name_note: "(individuellement ou comme représentant d'un collectif; ne sera pas public)" diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 48e1bcdc9..62221c280 100755 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -14,7 +14,7 @@ nl: phone_number_label: Telefoonnummer public_activity_label: Mijn activiteiten zijn publiek save_changes_submit: Sla veranderingen op - subscription_to_website_newsletter_label: Stuur me email met relevante informatie over de website + subscription_to_website_newsletter_label: Stuur me email met relevante informatie over de website email_on_direct_message_label: Stuur me email naar aanleiding van directe boodschappen email_digest_label: Stuur me een samenvatting van meldingen naar aanleiding van voorstellen official_position_badge_label: Show official position badge @@ -179,7 +179,7 @@ nl: conditions: Gebruiksvoorwaarden consul: Consul consul_url: https://github.com/consul/consul - contact_us: Voor tech support klik + contact_us: Voor tech support klik copyright: Consul, %{year} description: Deze site gebruikt %{consul}; een %{open_source} toepassing. faq: hier @@ -217,7 +217,7 @@ nl: other: U heeft %{count} nieuwe meldingen no_notifications: "U heeft geen nieuwe meldingen" open: open - open_city_slogan_html: Er zijn steden die rechtstreeks door hun bewoners worden bestuurd, welke discussiëren over de onderwerpen waarover ze zich zorgen maken, welke voorstellen doen om hun leven te verbeteren en zelf beslissen welke daarvan zullen worden uitgevoerd. + open_city_slogan_html: Er zijn steden die rechtstreeks door hun bewoners worden bestuurd, welke discussiëren over de onderwerpen waarover ze zich zorgen maken, welke voorstellen doen om hun leven te verbeteren en zelf beslissen welke daarvan zullen worden uitgevoerd. open_city_title: De gemeente waar u van houdt is de gemeente waarin u meedenkt. open_gov: Open bestuur proposals: Voorstellen @@ -297,10 +297,10 @@ nl: done: Is gebeurt other: Anders form: - geozone: Regio + geozone: Regio proposal_external_url: Link naar meet informatie proposal_question: Vraag - proposal_question_example_html: Moet samengevat worden in een vraag met een ja/nee antwoord. E.g. 'Ben je het eens met autovrije Geldersekade?' + proposal_question_example_html: Moet samengevat worden in een vraag met een ja/nee antwoord.
E.g. 'Ben je het eens met autovrije Geldersekade?' proposal_responsible_name: Volledige naam van persoon die het voorstel doet proposal_responsible_name_note: "(individueel of als vertegenwoordiger van een collectief; niet publiek zichtbaar)" proposal_summary: Samenvatting voorstel @@ -506,7 +506,7 @@ nl: suggest: debate: found: - + one: "Er is een debat met de term '%{query}'; u kunt daar deelnemen in plaats van een nieuwe discussie te openen." other: "Er zijn discussies met de term '%{query}'; u kunt daar deelnemen in plaats van een nieuwe discussie te openen." message: "Er worden %{limit} uit %{count} discussies met de term '%{query}' getoond" @@ -636,7 +636,7 @@ nl: other: "%{count} Begrotingsvoorstellen" no_activity: Deze deelnemer heeft geen publieke activiteit no_private_messages: "Deze deelnemer ontvangt geen privé berichten." - private_activity: Deze deelnemer heeft besloten activiteiten niet te delen + private_activity: Deze deelnemer heeft besloten activiteiten niet te delen send_private_message: "Stuur privé bericht" proposals: send_notification: "Stuur melding" diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 90e4f35d8..69ca72c02 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -1267,8 +1267,8 @@ pt-BR: proposal_external_url: Link para documentação adicional proposal_question: Questão proposta proposal_question_example_html: 'Precisa ser sumarizado em uma questão com resposta - Sim ou Não. Ex.: ''Você concorda com a mudança da Calle Mayor como via - exclusiva de pedestres?''' + Sim ou Não.
Ex.: ''Você concorda com a mudança da Calle Mayor como via + exclusiva de pedestres?' proposal_responsible_name: Nome completo da pessoa que está submetendo a proposta proposal_responsible_name_note: "(indivudualmente ou como representante de um coletivo; não será mostrado publicamente)" From 10d418efd8335489217bd8243e3aa04836727856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baza=CC=81n?= Date: Tue, 27 Jun 2017 11:37:37 +0200 Subject: [PATCH 63/75] rails up to 4.2.9 --- Gemfile | 2 +- Gemfile.lock | 76 ++++++++++++++++++++++++++-------------------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/Gemfile b/Gemfile index 86ac55fd3..245ca2a88 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' -gem 'rails', '4.2.8' +gem 'rails', '4.2.9' # Use PostgreSQL gem 'pg', '~> 0.20.0' # Use SCSS for stylesheets diff --git a/Gemfile.lock b/Gemfile.lock index 6a9d8a1ce..de9002e3a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,36 +2,36 @@ GEM remote: https://rubygems.org/ remote: https://rails-assets.org/ specs: - actionmailer (4.2.8) - actionpack (= 4.2.8) - actionview (= 4.2.8) - activejob (= 4.2.8) + actionmailer (4.2.9) + actionpack (= 4.2.9) + actionview (= 4.2.9) + activejob (= 4.2.9) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.8) - actionview (= 4.2.8) - activesupport (= 4.2.8) + actionpack (4.2.9) + actionview (= 4.2.9) + activesupport (= 4.2.9) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.8) - activesupport (= 4.2.8) + actionview (4.2.9) + activesupport (= 4.2.9) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.3) - activejob (4.2.8) - activesupport (= 4.2.8) + activejob (4.2.9) + activesupport (= 4.2.9) globalid (>= 0.3.0) - activemodel (4.2.8) - activesupport (= 4.2.8) + activemodel (4.2.9) + activesupport (= 4.2.9) builder (~> 3.1) - activerecord (4.2.8) - activemodel (= 4.2.8) - activesupport (= 4.2.8) + activerecord (4.2.9) + activemodel (= 4.2.9) + activesupport (= 4.2.9) arel (~> 6.0) - activesupport (4.2.8) + activesupport (4.2.9) i18n (~> 0.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) @@ -174,8 +174,8 @@ GEM rspec-core (~> 3.0) ruby-progressbar (~> 1.4) geocoder (1.4.3) - globalid (0.3.7) - activesupport (>= 4.1.0) + globalid (0.4.0) + activesupport (>= 4.2.0) graphiql-rails (1.4.1) rails graphql (1.6.3) @@ -188,7 +188,7 @@ GEM htmlentities (4.3.4) httpi (2.4.1) rack - i18n (0.8.1) + i18n (0.8.4) i18n-tasks (0.9.15) activesupport (>= 4.0.2) ast (>= 2.1.0) @@ -248,8 +248,8 @@ GEM mime-types-data (~> 3.2015) mime-types-data (3.2016.0521) mimemagic (0.3.2) - mini_portile2 (2.1.0) - minitest (5.10.1) + mini_portile2 (2.2.0) + minitest (5.10.2) mixlib-cli (1.7.0) mixlib-config (2.2.4) multi_json (1.12.1) @@ -259,8 +259,8 @@ GEM net-ssh (>= 2.6.5) net-ssh (4.1.0) newrelic_rpm (4.1.0.333) - nokogiri (1.7.2) - mini_portile2 (~> 2.1.0) + nokogiri (1.8.0) + mini_portile2 (~> 2.2.0) nori (2.6.0) oauth (0.5.1) oauth2 (1.3.1) @@ -313,23 +313,23 @@ GEM public_suffix (2.0.5) quiet_assets (1.1.0) railties (>= 3.1, < 5.0) - rack (1.6.5) + rack (1.6.8) rack-accept (0.4.5) rack (>= 0.4) rack-attack (5.0.1) rack rack-test (0.6.3) rack (>= 1.0) - rails (4.2.8) - actionmailer (= 4.2.8) - actionpack (= 4.2.8) - actionview (= 4.2.8) - activejob (= 4.2.8) - activemodel (= 4.2.8) - activerecord (= 4.2.8) - activesupport (= 4.2.8) + rails (4.2.9) + actionmailer (= 4.2.9) + actionpack (= 4.2.9) + actionview (= 4.2.9) + activejob (= 4.2.9) + activemodel (= 4.2.9) + activerecord (= 4.2.9) + activesupport (= 4.2.9) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.8) + railties (= 4.2.9) sprockets-rails rails-assets-markdown-it (8.2.1) rails-deprecated_sanitizer (1.0.3) @@ -340,9 +340,9 @@ GEM rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.3) loofah (~> 2.0) - railties (4.2.8) - actionpack (= 4.2.8) - activesupport (= 4.2.8) + railties (4.2.9) + actionpack (= 4.2.9) + activesupport (= 4.2.9) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.2.2) @@ -541,7 +541,7 @@ DEPENDENCIES pg_search poltergeist (~> 1.15.0) quiet_assets - rails (= 4.2.8) + rails (= 4.2.9) rails-assets-markdown-it! redcarpet (~> 3.4.0) responders (~> 2.4.0) From 97a7cb71d0e69e4102b8873ac32d75b8c3c81749 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 27 Jun 2017 23:25:28 +0200 Subject: [PATCH 64/75] Add population value to Budget Heading factory --- spec/factories.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/factories.rb b/spec/factories.rb index a93d911ed..7397669bd 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -254,6 +254,7 @@ FactoryGirl.define do association :group, factory: :budget_group sequence(:name) { |n| "Heading #{n}" } price 1000000 + population 1234 end factory :budget_investment, class: 'Budget::Investment' do From c96d58df757fcc61eba2358329dea200f29103d1 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 27 Jun 2017 23:28:22 +0200 Subject: [PATCH 65/75] Add population value to dev seed budget headings --- db/dev_seeds.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 99605b392..42018d41d 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -390,7 +390,8 @@ Budget::PHASES.each_with_index do |phase, i| geozones = Geozone.reorder("RANDOM()").limit([2, 5, 6, 7].sample) geozones.each do |geozone| group.headings << group.headings.create!(name: geozone.name, - price: rand(1..100) * 100000) + price: rand(1..100) * 100000, + population: rand(1..50) * 10000) end end end From a97130934a79ccb4d81a71f8132f4cdaec89eb5d Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 28 Jun 2017 13:40:37 +0200 Subject: [PATCH 66/75] fixes text on publish comment button --- app/views/legislation/annotations/_form.html.erb | 4 +--- spec/features/legislation/draft_versions_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/app/views/legislation/annotations/_form.html.erb b/app/views/legislation/annotations/_form.html.erb index 2c6cee9cd..369d0d691 100644 --- a/app/views/legislation/annotations/_form.html.erb +++ b/app/views/legislation/annotations/_form.html.erb @@ -16,9 +16,7 @@
<%= t('legislation.annotations.comments.cancel') %> - <%= f.submit class: 'button publish-comment' do %> - <%= t('legislation.annotations.comments.publish_comment') %> - <% end %> + <%= f.submit value: t('legislation.annotations.comments.publish_comment'), class: 'button publish-comment' %>
<%= f.hidden_field :quote %> diff --git a/spec/features/legislation/draft_versions_spec.rb b/spec/features/legislation/draft_versions_spec.rb index c70a8f1a3..f0a798b85 100644 --- a/spec/features/legislation/draft_versions_spec.rb +++ b/spec/features/legislation/draft_versions_spec.rb @@ -154,11 +154,11 @@ feature 'Legislation Draft Versions' do page.find(:css, ".legislation-annotatable").double_click page.find(:css, ".annotator-adder button").click - page.click_button "Create Annotation" + page.click_button "Publish Comment" expect(page).to have_content "Comment can't be blank" fill_in 'legislation_annotation_text', with: 'this is my annotation' - page.click_button "Create Annotation" + page.click_button "Publish Comment" expect(page).to have_css ".annotator-hl" first(:css, ".annotator-hl").click From ef1a416b50a02feb64ef2264058502bea916ffe1 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 28 Jun 2017 13:40:44 +0200 Subject: [PATCH 67/75] improves color palette for annotation weights --- .../stylesheets/annotator_overrides.scss | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/app/assets/stylesheets/annotator_overrides.scss b/app/assets/stylesheets/annotator_overrides.scss index 9bf27f22c..eb01c0691 100644 --- a/app/assets/stylesheets/annotator_overrides.scss +++ b/app/assets/stylesheets/annotator_overrides.scss @@ -102,27 +102,27 @@ .annotator-hl { cursor: pointer; - background: rgba(255, 255, 10, 0.2); -} + background: rgba(255, 249, 218, 0.75); -.annotator-hl.weight-1 { - background: #fff9da; -} + &.weight-1 { + background: #fff9da; + } -.annotator-hl.weight-2 { - background: #fff5bc; -} + &.weight-2 { + background: #f4f7be; + } -.annotator-hl.weight-3 { - background: #fff1a2; -} + &.weight-3 { + background: #fff5b2; + } -.annotator-hl.weight-4 { - background: #ffef8c; -} + &.weight-4 { + background: #f9e784; + } -.annotator-hl.weight-5 { - background: #ffe95f; + &.weight-5 { + background: #eec643; + } } .current-annotation { From 2fa92937d2558410f3d2c4949faa74889f2fe7e5 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sun, 25 Jun 2017 15:57:05 +0200 Subject: [PATCH 68/75] Fix all Style/BracesAroundHashParameters rubocop issues and remove them from rubocop_todo list --- .rubocop_todo.yml | 16 ---------------- .../admin/poll/polls_controller.rb | 2 +- .../spending_proposals_controller.rb | 2 +- app/models/concerns/searchable.rb | 19 +++++++++---------- app/models/officing/residence.rb | 11 +++++------ app/models/verification/residence.rb | 10 +++++----- lib/manager_authenticator.rb | 2 +- ...grate_spending_proposals_to_investments.rb | 2 +- spec/controllers/graphql_controller_spec.rb | 6 +++--- .../management/users_controller_spec.rb | 2 +- .../features/admin/budget_investments_spec.rb | 2 +- .../features/admin/spending_proposals_spec.rb | 2 +- spec/lib/manager_authenticator_spec.rb | 10 +++++----- spec/models/officing/residence_spec.rb | 8 ++++---- spec/models/residence_spec.rb | 14 +++++++------- spec/models/user_spec.rb | 4 ++-- 16 files changed, 47 insertions(+), 65 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 54a3f650f..076069d66 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -165,22 +165,6 @@ Layout/AlignParameters: - 'spec/models/user_spec.rb' - 'spec/rails_helper.rb' -# Offense count: 19 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -# SupportedStyles: braces, no_braces, context_dependent -Style/BracesAroundHashParameters: - Exclude: - - 'app/controllers/valuation/spending_proposals_controller.rb' - - 'app/models/concerns/searchable.rb' - - 'app/models/verification/residence.rb' - - 'lib/manager_authenticator.rb' - - 'spec/controllers/management/users_controller_spec.rb' - - 'spec/features/admin/spending_proposals_spec.rb' - - 'spec/lib/manager_authenticator_spec.rb' - - 'spec/models/residence_spec.rb' - - 'spec/models/user_spec.rb' - # Offense count: 57 # Configuration parameters: EnforcedStyle, SupportedStyles. # SupportedStyles: nested, compact diff --git a/app/controllers/admin/poll/polls_controller.rb b/app/controllers/admin/poll/polls_controller.rb index 6046ffb48..cad91f218 100644 --- a/app/controllers/admin/poll/polls_controller.rb +++ b/app/controllers/admin/poll/polls_controller.rb @@ -60,7 +60,7 @@ class Admin::Poll::PollsController < Admin::BaseController end def search_questions - @questions = ::Poll::Question.where("poll_id IS ? OR poll_id != ?", nil, @poll.id).search({search: @search}).order(title: :asc) + @questions = ::Poll::Question.where("poll_id IS ? OR poll_id != ?", nil, @poll.id).search(search: @search).order(title: :asc) respond_to do |format| format.js end diff --git a/app/controllers/valuation/spending_proposals_controller.rb b/app/controllers/valuation/spending_proposals_controller.rb index 623c9ac46..1273b80b6 100644 --- a/app/controllers/valuation/spending_proposals_controller.rb +++ b/app/controllers/valuation/spending_proposals_controller.rb @@ -58,7 +58,7 @@ class Valuation::SpendingProposalsController < Valuation::BaseController end def params_for_current_valuator - params.merge({valuator_id: current_user.valuator.id}) + params.merge(valuator_id: current_user.valuator.id) end def restrict_access_to_assigned_items diff --git a/app/models/concerns/searchable.rb b/app/models/concerns/searchable.rb index 147a37fbc..7de037ca1 100644 --- a/app/models/concerns/searchable.rb +++ b/app/models/concerns/searchable.rb @@ -5,15 +5,14 @@ module Searchable include PgSearch include SearchCache - pg_search_scope :pg_search, { - against: :ignored, # not used since using a tsvector_column - using: { - tsearch: { tsvector_column: 'tsv', dictionary: "spanish", prefix: true } - }, - ignoring: :accents, - ranked_by: '(:tsearch)', - order_within_rank: (self.column_names.include?('cached_votes_up') ? "#{self.table_name}.cached_votes_up DESC" : nil) - } + pg_search_scope :pg_search, + against: :ignored, # not used since using a tsvector_column + using: { + tsearch: { tsvector_column: 'tsv', dictionary: "spanish", prefix: true } + }, + ignoring: :accents, + ranked_by: '(:tsearch)', + order_within_rank: (self.column_names.include?('cached_votes_up') ? "#{self.table_name}.cached_votes_up DESC" : nil) end -end \ No newline at end of file +end diff --git a/app/models/officing/residence.rb b/app/models/officing/residence.rb index 63250d041..b0fc56078 100644 --- a/app/models/officing/residence.rb +++ b/app/models/officing/residence.rb @@ -43,14 +43,13 @@ class Officing::Residence end def store_failed_census_call - FailedCensusCall.create({ + FailedCensusCall.create( user: user, document_number: document_number, - document_type: document_type, - year_of_birth: year_of_birth, - poll_officer: officer - }) - + document_type: document_type, + year_of_birth: year_of_birth, + poll_officer: officer + ) end def user_exists? diff --git a/app/models/verification/residence.rb b/app/models/verification/residence.rb index 00f729d2c..7fa7f74b4 100644 --- a/app/models/verification/residence.rb +++ b/app/models/verification/residence.rb @@ -47,13 +47,13 @@ class Verification::Residence end def store_failed_attempt - FailedCensusCall.create({ + FailedCensusCall.create( user: user, document_number: document_number, - document_type: document_type, - date_of_birth: date_of_birth, - postal_code: postal_code - }) + document_type: document_type, + date_of_birth: date_of_birth, + postal_code: postal_code + ) end def geozone diff --git a/lib/manager_authenticator.rb b/lib/manager_authenticator.rb index 11928e737..8f9a1f55a 100644 --- a/lib/manager_authenticator.rb +++ b/lib/manager_authenticator.rb @@ -25,7 +25,7 @@ class ManagerAuthenticator parsed_response = parser.parse((response[:get_applications_user_list_response][:get_applications_user_list_return])) aplication_value = parsed_response["APLICACIONES"]["APLICACION"] # aplication_value from UWEB can be an array of hashes or a hash - aplication_value.include?({"CLAVE_APLICACION" => application_key}) || aplication_value["CLAVE_APLICACION"] == application_key + aplication_value.include?("CLAVE_APLICACION" => application_key) || aplication_value["CLAVE_APLICACION"] == application_key rescue false end diff --git a/lib/migrate_spending_proposals_to_investments.rb b/lib/migrate_spending_proposals_to_investments.rb index 9ef2f096d..6df75d3f7 100644 --- a/lib/migrate_spending_proposals_to_investments.rb +++ b/lib/migrate_spending_proposals_to_investments.rb @@ -50,7 +50,7 @@ class MigrateSpendingProposalsToInvestments votes = ActsAsVotable::Vote.where(votable_type: 'SpendingProposal', votable_id: sp.id) - votes.each {|v| investment.vote_by({voter: v.voter, vote: 'yes'}) } + votes.each {|v| investment.vote_by(voter: v.voter, vote: 'yes') } # Spending proposals are not commentable in Consul so we can not test this # diff --git a/spec/controllers/graphql_controller_spec.rb b/spec/controllers/graphql_controller_spec.rb index 1b8c64793..0f15da038 100644 --- a/spec/controllers/graphql_controller_spec.rb +++ b/spec/controllers/graphql_controller_spec.rb @@ -71,19 +71,19 @@ describe GraphqlController, type: :request do let(:query_string) { "{ proposal(id: #{proposal.id}) { title } }" } specify "when absent" do - get '/graphql', { query: query_string } + get '/graphql', query: query_string expect(response).to have_http_status(:ok) end specify "when specified as the 'null' string" do - get '/graphql', { query: query_string, variables: 'null' } + get '/graphql', query: query_string, variables: 'null' expect(response).to have_http_status(:ok) end specify "when specified as an empty string" do - get '/graphql', { query: query_string, variables: '' } + get '/graphql', query: query_string, variables: '' expect(response).to have_http_status(:ok) end diff --git a/spec/controllers/management/users_controller_spec.rb b/spec/controllers/management/users_controller_spec.rb index e57ff7b15..8fb41128a 100644 --- a/spec/controllers/management/users_controller_spec.rb +++ b/spec/controllers/management/users_controller_spec.rb @@ -10,7 +10,7 @@ describe Management::UsersController do get :logout - expect(session[:manager]).to eq({user_key: "31415926", date: "20151031135905", login: "JJB033"}) + expect(session[:manager]).to eq(user_key: "31415926", date: "20151031135905", login: "JJB033") expect(session[:document_type]).to be_nil expect(session[:document_number]).to be_nil expect(response).to be_redirect diff --git a/spec/features/admin/budget_investments_spec.rb b/spec/features/admin/budget_investments_spec.rb index c50a05f32..727cc3d6c 100644 --- a/spec/features/admin/budget_investments_spec.rb +++ b/spec/features/admin/budget_investments_spec.rb @@ -47,7 +47,7 @@ feature 'Admin budget investments' do budget_investment1.valuators << valuator1 budget_investment2.valuator_ids = [valuator1.id, valuator2.id] - budget_investment3.update({administrator_id: admin.id}) + budget_investment3.update(administrator_id: admin.id) visit admin_budget_budget_investments_path(budget_id: @budget.id) diff --git a/spec/features/admin/spending_proposals_spec.rb b/spec/features/admin/spending_proposals_spec.rb index 239454902..91eb6716b 100644 --- a/spec/features/admin/spending_proposals_spec.rb +++ b/spec/features/admin/spending_proposals_spec.rb @@ -43,7 +43,7 @@ feature 'Admin spending proposals' do spending_proposal1.valuators << valuator1 spending_proposal2.valuator_ids = [valuator1.id, valuator2.id] - spending_proposal3.update({administrator_id: admin.id}) + spending_proposal3.update(administrator_id: admin.id) visit admin_spending_proposals_path diff --git a/spec/lib/manager_authenticator_spec.rb b/spec/lib/manager_authenticator_spec.rb index 256303fdd..c53a26f5e 100644 --- a/spec/lib/manager_authenticator_spec.rb +++ b/spec/lib/manager_authenticator_spec.rb @@ -3,24 +3,24 @@ require 'rails_helper' describe ManagerAuthenticator do describe 'initialization params' do it 'should cause auth to return false if blank login' do - authenticator = ManagerAuthenticator.new({login: "", clave_usuario: "31415926", fecha_conexion: "20151031135905"}) + authenticator = ManagerAuthenticator.new(login: "", clave_usuario: "31415926", fecha_conexion: "20151031135905") expect(authenticator.auth).to be false end it 'should cause auth to return false if blank user_key' do - authenticator = ManagerAuthenticator.new({login: "JJB033", clave_usuario: "", fecha_conexion: "20151031135905"}) + authenticator = ManagerAuthenticator.new(login: "JJB033", clave_usuario: "", fecha_conexion: "20151031135905") expect(authenticator.auth).to be false end it 'should cause auth to return false if blank date' do - authenticator = ManagerAuthenticator.new({login: "JJB033", clave_usuario: "31415926", fecha_conexion: ""}) + authenticator = ManagerAuthenticator.new(login: "JJB033", clave_usuario: "31415926", fecha_conexion: "") expect(authenticator.auth).to be false end end describe '#auth' do before(:all) do - @authenticator = ManagerAuthenticator.new({login: "JJB033", clave_usuario: "31415926", fecha_conexion: "20151031135905"}) + @authenticator = ManagerAuthenticator.new(login: "JJB033", clave_usuario: "31415926", fecha_conexion: "20151031135905") end it 'should return false if not manager_exists' do @@ -47,7 +47,7 @@ describe ManagerAuthenticator do describe 'SOAP' do before(:all) do - @authenticator = ManagerAuthenticator.new({login: "JJB033", clave_usuario: "31415926", fecha_conexion: "20151031135905"}) + @authenticator = ManagerAuthenticator.new(login: "JJB033", clave_usuario: "31415926", fecha_conexion: "20151031135905") end it 'should call the verification user method' do diff --git a/spec/models/officing/residence_spec.rb b/spec/models/officing/residence_spec.rb index dee63b85a..c39711e30 100644 --- a/spec/models/officing/residence_spec.rb +++ b/spec/models/officing/residence_spec.rb @@ -44,12 +44,12 @@ describe Officing::Residence do describe "new" do it "should upcase document number" do - residence = Officing::Residence.new({document_number: "x1234567z"}) + residence = Officing::Residence.new(document_number: "x1234567z") expect(residence.document_number).to eq("X1234567Z") end it "should remove all characters except numbers and letters" do - residence = Officing::Residence.new({document_number: " 12.345.678 - B"}) + residence = Officing::Residence.new(document_number: " 12.345.678 - B") expect(residence.document_number).to eq("12345678B") end end @@ -108,13 +108,13 @@ describe Officing::Residence do residence.save expect(FailedCensusCall.count).to eq(1) - expect(FailedCensusCall.first).to have_attributes({ + expect(FailedCensusCall.first).to have_attributes( user_id: residence.user.id, poll_officer_id: residence.officer.id, document_number: "12345678Z", document_type: "1", year_of_birth: Time.current.year - }) + ) end end diff --git a/spec/models/residence_spec.rb b/spec/models/residence_spec.rb index d518c41af..072782508 100644 --- a/spec/models/residence_spec.rb +++ b/spec/models/residence_spec.rb @@ -13,19 +13,19 @@ describe Verification::Residence do describe "dates" do it "should be valid with a valid date of birth" do - residence = Verification::Residence.new({"date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "1980"}) + residence = Verification::Residence.new("date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "1980") expect(residence.errors[:date_of_birth].size).to eq(0) end it "should not be valid without a date of birth" do - residence = Verification::Residence.new({"date_of_birth(3i)" => "", "date_of_birth(2i)" => "", "date_of_birth(1i)" => ""}) + residence = Verification::Residence.new("date_of_birth(3i)" => "", "date_of_birth(2i)" => "", "date_of_birth(1i)" => "") expect(residence).to_not be_valid expect(residence.errors[:date_of_birth]).to include("can't be blank") end end it "should validate user has allowed age" do - residence = Verification::Residence.new({"date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "#{5.years.ago.year}"}) + residence = Verification::Residence.new("date_of_birth(3i)" => "1", "date_of_birth(2i)" => "1", "date_of_birth(1i)" => "#{5.years.ago.year}") expect(residence).to_not be_valid expect(residence.errors[:date_of_birth]).to include("You don't have the required age to participate") end @@ -50,12 +50,12 @@ describe Verification::Residence do describe "new" do it "should upcase document number" do - residence = Verification::Residence.new({document_number: "x1234567z"}) + residence = Verification::Residence.new(document_number: "x1234567z") expect(residence.document_number).to eq("X1234567Z") end it "should remove all characters except numbers and letters" do - residence = Verification::Residence.new({document_number: " 12.345.678 - B"}) + residence = Verification::Residence.new(document_number: " 12.345.678 - B") expect(residence.document_number).to eq("12345678B") end end @@ -99,13 +99,13 @@ describe Verification::Residence do residence.save expect(FailedCensusCall.count).to eq(1) - expect(FailedCensusCall.first).to have_attributes({ + expect(FailedCensusCall.first).to have_attributes( user_id: residence.user.id, document_number: "12345678Z", document_type: "1", date_of_birth: Date.new(1980, 12, 31), postal_code: "28001" - }) + ) end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 0ea321423..2e92e5c96 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -434,13 +434,13 @@ describe User do describe "document_number" do it "should upcase document number" do - user = User.new({document_number: "x1234567z"}) + user = User.new(document_number: "x1234567z") user.valid? expect(user.document_number).to eq("X1234567Z") end it "should remove all characters except numbers and letters" do - user = User.new({document_number: " 12.345.678 - B"}) + user = User.new(document_number: " 12.345.678 - B") user.valid? expect(user.document_number).to eq("12345678B") end From 775da2d5813d823b6335677aeb2339ceed1178be Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sun, 25 Jun 2017 16:01:31 +0200 Subject: [PATCH 69/75] Remove all Layout/EmptyLines issues on code and file list from rubocop_todo --- .rubocop_todo.yml | 14 -------------- app/models/concerns/search_cache.rb | 1 - app/models/notification.rb | 1 - spec/features/admin/feature_flags_spec.rb | 1 - spec/features/admin/spending_proposals_spec.rb | 1 - spec/features/admin/verifications_spec.rb | 1 - spec/features/debates_spec.rb | 3 --- spec/features/registration_form_spec.rb | 1 - spec/features/users_auth_spec.rb | 1 - spec/features/valuation/budget_investments_spec.rb | 1 - spec/features/verification/verified_user_spec.rb | 1 - spec/models/budget/investment_spec.rb | 1 - spec/support/verifiable.rb | 1 - 13 files changed, 28 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 076069d66..067ddfce9 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -216,20 +216,6 @@ Style/EmptyCaseCondition: Exclude: - 'app/models/concerns/verification.rb' -# Offense count: 9 -# Cop supports --auto-correct. -Layout/EmptyLines: - Exclude: - - 'app/models/concerns/search_cache.rb' - - 'app/models/notification.rb' - - 'spec/features/admin/spending_proposals_spec.rb' - - 'spec/features/admin/verifications_spec.rb' - - 'spec/features/debates_spec.rb' - - 'spec/features/registration_form_spec.rb' - - 'spec/features/users_auth_spec.rb' - - 'spec/features/verification/verified_user_spec.rb' - - 'spec/support/verifiable.rb' - # Offense count: 29 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. diff --git a/app/models/concerns/search_cache.rb b/app/models/concerns/search_cache.rb index cf4d04f16..9b9e62024 100644 --- a/app/models/concerns/search_cache.rb +++ b/app/models/concerns/search_cache.rb @@ -31,5 +31,4 @@ module SearchCache ActionController::Base.helpers.sanitize(value, tags: []) end - end diff --git a/app/models/notification.rb b/app/models/notification.rb index bbbb18942..d08baecf2 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -7,7 +7,6 @@ class Notification < ActiveRecord::Base scope :not_emailed, -> { where(emailed_at: nil) } scope :for_render, -> { includes(:notifiable) } - def timestamp notifiable.created_at end diff --git a/spec/features/admin/feature_flags_spec.rb b/spec/features/admin/feature_flags_spec.rb index 956d80e6c..99c460477 100644 --- a/spec/features/admin/feature_flags_spec.rb +++ b/spec/features/admin/feature_flags_spec.rb @@ -13,7 +13,6 @@ feature 'Admin feature flags' do Setting['feature.spending_proposal_features.voting_allowed'] = nil end - scenario 'Enabled features are listed on menu' do visit admin_root_path diff --git a/spec/features/admin/spending_proposals_spec.rb b/spec/features/admin/spending_proposals_spec.rb index 91eb6716b..c27e102ee 100644 --- a/spec/features/admin/spending_proposals_spec.rb +++ b/spec/features/admin/spending_proposals_spec.rb @@ -634,7 +634,6 @@ feature 'Admin spending proposals' do proposal5 = create(:spending_proposal, geozone: new_york, valuation_finished: true) proposal6 = create(:spending_proposal, geozone: new_york, valuation_finished: false) - create(:vote, votable: proposal1) create(:vote, votable: proposal2) create(:vote, votable: proposal3) diff --git a/spec/features/admin/verifications_spec.rb b/spec/features/admin/verifications_spec.rb index 50ff457a1..ce455fe87 100644 --- a/spec/features/admin/verifications_spec.rb +++ b/spec/features/admin/verifications_spec.rb @@ -36,7 +36,6 @@ feature 'Incomplete verifications' do expect(page).to_not have_content("Isabel_anonymous") end - scenario "Residence unverified" do incompletely_verified_user = create(:user, :incomplete_verification) diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index 4d48508f2..3c90171e9 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -211,8 +211,6 @@ feature 'Debates' do expect(page.html).to_not include "" end - - scenario 'Update should not be posible if logged user is not the author' do debate = create(:debate) expect(debate).to be_editable @@ -947,7 +945,6 @@ feature 'Debates' do end end - scenario 'Index do not show featured debates if none is marked as featured' do admin = create(:administrator) login_as(admin.user) diff --git a/spec/features/registration_form_spec.rb b/spec/features/registration_form_spec.rb index 81b9d9bec..2d3d16a25 100644 --- a/spec/features/registration_form_spec.rb +++ b/spec/features/registration_form_spec.rb @@ -78,5 +78,4 @@ feature 'Registration form' do expect(current_path).to eq(new_user_registration_path) end - end diff --git a/spec/features/users_auth_spec.rb b/spec/features/users_auth_spec.rb index 617b1b1d4..566c1c233 100644 --- a/spec/features/users_auth_spec.rb +++ b/spec/features/users_auth_spec.rb @@ -200,7 +200,6 @@ feature 'Users' do expect(current_path).to eq(finish_signup_path) click_link 'Cancel login' - visit '/' expect_to_not_be_signed_in end diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb index 7b1d48b8b..3f91d8925 100644 --- a/spec/features/valuation/budget_investments_spec.rb +++ b/spec/features/valuation/budget_investments_spec.rb @@ -76,7 +76,6 @@ feature 'Valuation budget investments' do expect(page).to have_link("Realocate visitors") expect(page).to have_link("Destroy the city") - expect(page).to have_content "All headings (2)" expect(page).to have_content "District 9 (1)" expect(page).to have_content "Down to the river (1)" diff --git a/spec/features/verification/verified_user_spec.rb b/spec/features/verification/verified_user_spec.rb index 451ea03e5..3b020fcb0 100644 --- a/spec/features/verification/verified_user_spec.rb +++ b/spec/features/verification/verified_user_spec.rb @@ -69,7 +69,6 @@ feature 'Verified users' do expect(current_path).to eq new_sms_path end - scenario "Select a verified email" do user = create(:user, residence_verified_at: Time.current, diff --git a/spec/models/budget/investment_spec.rb b/spec/models/budget/investment_spec.rb index 3b16bb033..827ca9d21 100644 --- a/spec/models/budget/investment_spec.rb +++ b/spec/models/budget/investment_spec.rb @@ -590,7 +590,6 @@ describe Budget::Investment do most_voted2 = create(:budget_investment, cached_votes_up: 10) least_voted2 = create(:budget_investment, cached_votes_up: 1) - expect(Budget::Investment.sort_by_confidence_score.first).to eq most_voted2 expect(Budget::Investment.sort_by_confidence_score.second).to eq most_voted expect(Budget::Investment.sort_by_confidence_score.third).to eq least_voted2 diff --git a/spec/support/verifiable.rb b/spec/support/verifiable.rb index 53c5931cc..9112c67cf 100644 --- a/spec/support/verifiable.rb +++ b/spec/support/verifiable.rb @@ -67,7 +67,6 @@ shared_examples_for "verifiable" do user3 = create(:user, verified_at: nil, confirmed_phone: nil) user4 = create(:user, verified_at: Time.current, residence_verified_at: Time.current, unconfirmed_phone: "123456789", confirmed_phone: "123456789") - expect(model.incomplete_verification).to include(user1) expect(model.incomplete_verification).to include(user2) expect(model.incomplete_verification).to_not include(user3) From c9bc028524e638a9ac8cd778c87e3443635671d4 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sun, 25 Jun 2017 16:02:32 +0200 Subject: [PATCH 70/75] Remove all unnecesary extra spacing and Layout/ExtraSpacing list from rubocop file --- .rubocop_todo.yml | 6 ------ Gemfile | 8 ++++---- app/controllers/admin/settings_controller.rb | 2 +- app/controllers/graphql_controller.rb | 2 +- app/controllers/users_controller.rb | 2 +- app/models/abilities/common.rb | 2 +- app/models/activity.rb | 2 +- app/models/banner.rb | 2 +- app/models/budget/investment.rb | 2 +- app/models/concerns/verification.rb | 2 +- app/models/poll.rb | 2 +- app/models/poll/null_result.rb | 2 +- app/models/poll/question.rb | 2 +- app/models/poll/white_result.rb | 2 +- app/models/proposal.rb | 4 ++-- app/models/setting.rb | 4 ++-- app/models/spending_proposal.rb | 2 +- bin/setup | 2 +- .../management/sessions_controller_spec.rb | 2 +- .../management/users_controller_spec.rb | 2 +- spec/factories.rb | 4 ++-- spec/features/budgets/investments_spec.rb | 12 ++++++------ spec/features/comments/budget_investments_spec.rb | 2 +- .../comments/legislation_annotations_spec.rb | 2 +- .../comments/legislation_questions_spec.rb | 2 +- spec/features/comments/proposals_spec.rb | 2 +- spec/features/debates_spec.rb | 10 +++++----- spec/features/organizations_spec.rb | 4 ++-- spec/features/proposals_spec.rb | 4 ++-- spec/lib/age_spec.rb | 14 +++++++------- spec/lib/graph_ql/query_type_creator_spec.rb | 2 +- spec/models/abilities/common_spec.rb | 6 +++--- spec/models/letter_spec.rb | 2 +- spec/models/poll/poll_spec.rb | 2 +- spec/models/tag_cloud_spec.rb | 2 +- 35 files changed, 59 insertions(+), 65 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 067ddfce9..0449d48f3 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -216,12 +216,6 @@ Style/EmptyCaseCondition: Exclude: - 'app/models/concerns/verification.rb' -# Offense count: 29 -# Cop supports --auto-correct. -# Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. -Layout/ExtraSpacing: - Enabled: false - # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. diff --git a/Gemfile b/Gemfile index 245ca2a88..0f00da1ba 100644 --- a/Gemfile +++ b/Gemfile @@ -88,10 +88,10 @@ group :development, :test do gem 'quiet_assets' gem 'letter_opener_web', '~> 1.3.1' gem 'i18n-tasks', '~> 0.9.15' - gem 'capistrano', '~> 3.8.1', require: false - gem 'capistrano-bundler', '~> 1.2', require: false - gem "capistrano-rails", '~> 1.2.3', require: false - gem 'rvm1-capistrano3', require: false + gem 'capistrano', '~> 3.8.1', require: false + gem 'capistrano-bundler', '~> 1.2', require: false + gem "capistrano-rails", '~> 1.2.3', require: false + gem 'rvm1-capistrano3', require: false gem 'capistrano3-delayed-job', '~> 1.7.3' gem "bullet", '~> 5.5.1' gem "faker", '~> 1.7.3' diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb index f17afff4c..63ec8cf52 100644 --- a/app/controllers/admin/settings_controller.rb +++ b/app/controllers/admin/settings_controller.rb @@ -1,7 +1,7 @@ class Admin::SettingsController < Admin::BaseController def index - all_settings = (Setting.all).group_by { |s| s.type } + all_settings = (Setting.all).group_by { |s| s.type } @settings = all_settings['common'] @feature_flags = all_settings['feature'] @banner_styles = all_settings['banner-style'] diff --git a/app/controllers/graphql_controller.rb b/app/controllers/graphql_controller.rb index 762239dc8..5f3fd0a9f 100644 --- a/app/controllers/graphql_controller.rb +++ b/app/controllers/graphql_controller.rb @@ -36,7 +36,7 @@ class GraphqlController < ApplicationController def query_string if request.headers["CONTENT_TYPE"] == 'application/graphql' - request.body.string # request.body.class => StringIO + request.body.string # request.body.class => StringIO else params[:query] end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 07ff645e6..e99102396 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -25,7 +25,7 @@ class UsersController < ApplicationController when "proposals" then load_proposals when "debates" then load_debates when "budget_investments" then load_budget_investments - when "comments" then load_comments + when "comments" then load_comments else load_available_activity end end diff --git a/app/models/abilities/common.rb b/app/models/abilities/common.rb index 16747c8a7..71e839d3d 100644 --- a/app/models/abilities/common.rb +++ b/app/models/abilities/common.rb @@ -48,7 +48,7 @@ module Abilities can :create, Budget::Investment, budget: { phase: "accepting" } can :suggest, Budget::Investment, budget: { phase: "accepting" } can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id - can :vote, Budget::Investment, budget: { phase: "selecting" } + can :vote, Budget::Investment, budget: { phase: "selecting" } can [:show, :create], Budget::Ballot, budget: { phase: "balloting" } can [:create, :destroy], Budget::Ballot::Line, budget: { phase: "balloting" } diff --git a/app/models/activity.rb b/app/models/activity.rb index 58a91cd18..6c357d891 100644 --- a/app/models/activity.rb +++ b/app/models/activity.rb @@ -1,5 +1,5 @@ class Activity < ActiveRecord::Base - belongs_to :actionable, -> { with_hidden }, polymorphic: true + belongs_to :actionable, -> { with_hidden }, polymorphic: true belongs_to :user, -> { with_hidden } VALID_ACTIONS = %w(hide block restore valuate) diff --git a/app/models/banner.rb b/app/models/banner.rb index 2764785d1..8e816d446 100644 --- a/app/models/banner.rb +++ b/app/models/banner.rb @@ -5,7 +5,7 @@ class Banner < ActiveRecord::Base validates :title, presence: true, length: { minimum: 2 } - validates :description, presence: true + validates :description, presence: true validates :target_url, presence: true validates :style, presence: true validates :image, presence: true diff --git a/app/models/budget/investment.rb b/app/models/budget/investment.rb index 7ba0548e2..0d9c738b9 100644 --- a/app/models/budget/investment.rb +++ b/app/models/budget/investment.rb @@ -60,7 +60,7 @@ class Budget 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 :for_render, -> { includes(:heading) } + scope :for_render, -> { includes(:heading) } before_save :calculate_confidence_score before_validation :set_responsible_name diff --git a/app/models/concerns/verification.rb b/app/models/concerns/verification.rb index 88458a03d..a4770117e 100644 --- a/app/models/concerns/verification.rb +++ b/app/models/concerns/verification.rb @@ -7,7 +7,7 @@ module Verification scope :level_two_verified, -> { where("users.level_two_verified_at IS NOT NULL OR (users.confirmed_phone IS NOT NULL AND users.residence_verified_at IS NOT NULL) AND verified_at IS NULL") } scope :level_two_or_three_verified, -> { where("users.verified_at IS NOT NULL OR users.level_two_verified_at IS NOT NULL OR (users.confirmed_phone IS NOT NULL AND users.residence_verified_at IS NOT NULL)") } scope :unverified, -> { where("users.verified_at IS NULL AND (users.level_two_verified_at IS NULL AND (users.residence_verified_at IS NULL OR users.confirmed_phone IS NULL))") } - scope :incomplete_verification, -> { where("(users.residence_verified_at IS NULL AND users.failed_census_calls_count > ?) OR (users.residence_verified_at IS NOT NULL AND (users.unconfirmed_phone IS NULL OR users.confirmed_phone IS NULL))", 0) } + scope :incomplete_verification, -> { where("(users.residence_verified_at IS NULL AND users.failed_census_calls_count > ?) OR (users.residence_verified_at IS NOT NULL AND (users.unconfirmed_phone IS NULL OR users.confirmed_phone IS NULL))", 0) } end def verification_email_sent? diff --git a/app/models/poll.rb b/app/models/poll.rb index c6be3073a..6d033f514 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -18,7 +18,7 @@ class Poll < ActiveRecord::Base scope :current, -> { where('starts_at <= ? and ? <= ends_at', Time.current, Time.current) } scope :incoming, -> { where('? < starts_at', Time.current) } scope :expired, -> { where('ends_at < ?', Time.current) } - scope :published, -> { where('published = ?', true) } + scope :published, -> { where('published = ?', true) } scope :by_geozone_id, ->(geozone_id) { where(geozones: {id: geozone_id}.joins(:geozones)) } scope :sort_for_list, -> { order(:geozone_restricted, :starts_at, :name) } diff --git a/app/models/poll/null_result.rb b/app/models/poll/null_result.rb index d1724037b..bdd708504 100644 --- a/app/models/poll/null_result.rb +++ b/app/models/poll/null_result.rb @@ -2,7 +2,7 @@ class Poll::NullResult < ActiveRecord::Base VALID_ORIGINS = %w{web booth} - belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' + belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' belongs_to :booth_assignment belongs_to :officer_assignment diff --git a/app/models/poll/question.rb b/app/models/poll/question.rb index dd4eae3bc..a1d949d42 100644 --- a/app/models/poll/question.rb +++ b/app/models/poll/question.rb @@ -19,7 +19,7 @@ class Poll::Question < ActiveRecord::Base validates :title, length: { minimum: 4 } validates :description, length: { maximum: Poll::Question.description_max_length } - scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) } + scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) } scope :sort_for_list, -> { order('poll_questions.proposal_id IS NULL', :created_at)} scope :for_render, -> { includes(:author, :proposal) } diff --git a/app/models/poll/white_result.rb b/app/models/poll/white_result.rb index 6ca613d05..3f41795b3 100644 --- a/app/models/poll/white_result.rb +++ b/app/models/poll/white_result.rb @@ -2,7 +2,7 @@ class Poll::WhiteResult < ActiveRecord::Base VALID_ORIGINS = %w{web booth} - belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' + belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id' belongs_to :booth_assignment belongs_to :officer_assignment diff --git a/app/models/proposal.rb b/app/models/proposal.rb index 926cbe1ee..8c7e2065a 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -38,8 +38,8 @@ class Proposal < ActiveRecord::Base before_save :calculate_hot_score, :calculate_confidence_score - scope :for_render, -> { includes(:tags) } - scope :sort_by_hot_score, -> { reorder(hot_score: :desc) } + scope :for_render, -> { includes(:tags) } + scope :sort_by_hot_score, -> { reorder(hot_score: :desc) } scope :sort_by_confidence_score, -> { reorder(confidence_score: :desc) } scope :sort_by_created_at, -> { reorder(created_at: :desc) } scope :sort_by_most_commented, -> { reorder(comments_count: :desc) } diff --git a/app/models/setting.rb b/app/models/setting.rb index 9010abba5..34c45aeed 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -2,8 +2,8 @@ class Setting < ActiveRecord::Base validates :key, presence: true, uniqueness: true default_scope { order(id: :asc) } - scope :banner_style, -> { where("key ilike ?", "banner-style.%")} - scope :banner_img, -> { where("key ilike ?", "banner-img.%")} + scope :banner_style, -> { where("key ilike ?", "banner-style.%")} + scope :banner_img, -> { where("key ilike ?", "banner-img.%")} def type if feature_flag? diff --git a/app/models/spending_proposal.rb b/app/models/spending_proposal.rb index b08d7533a..8026a3b9f 100644 --- a/app/models/spending_proposal.rb +++ b/app/models/spending_proposal.rb @@ -35,7 +35,7 @@ class SpendingProposal < ActiveRecord::Base scope :by_tag, ->(tag_name) { tagged_with(tag_name) } scope :by_valuator, ->(valuator) { where("valuation_assignments.valuator_id = ?", valuator.presence).joins(:valuation_assignments) } - scope :for_render, -> { includes(:geozone) } + scope :for_render, -> { includes(:geozone) } before_validation :set_responsible_name diff --git a/bin/setup b/bin/setup index acdb2c138..d3bb99760 100755 --- a/bin/setup +++ b/bin/setup @@ -2,7 +2,7 @@ require 'pathname' # path to your application root. -APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) Dir.chdir APP_ROOT do # This script is a starting point to setup your application. diff --git a/spec/controllers/management/sessions_controller_spec.rb b/spec/controllers/management/sessions_controller_spec.rb index ec8f762d9..0e2a18544 100644 --- a/spec/controllers/management/sessions_controller_spec.rb +++ b/spec/controllers/management/sessions_controller_spec.rb @@ -44,7 +44,7 @@ describe Management::SessionsController do describe 'Sign out' do it "should destroy the session data and redirect" do session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"} - session[:document_type] = "1" + session[:document_type] = "1" session[:document_number] = "12345678Z" delete :destroy diff --git a/spec/controllers/management/users_controller_spec.rb b/spec/controllers/management/users_controller_spec.rb index 8fb41128a..221d302b6 100644 --- a/spec/controllers/management/users_controller_spec.rb +++ b/spec/controllers/management/users_controller_spec.rb @@ -5,7 +5,7 @@ describe Management::UsersController do describe 'logout' do it "should remove user data from the session" do session[:manager] = {user_key: "31415926", date: "20151031135905", login: "JJB033"} - session[:document_type] = "1" + session[:document_type] = "1" session[:document_number] = "12345678Z" get :logout diff --git a/spec/factories.rb b/spec/factories.rb index 7397669bd..18df18120 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -258,7 +258,7 @@ FactoryGirl.define do end factory :budget_investment, class: 'Budget::Investment' do - sequence(:title) { |n| "Budget Investment #{n} title" } + sequence(:title) { |n| "Budget Investment #{n} title" } association :heading, factory: :budget_heading association :author, factory: :user description 'Spend money on this' @@ -585,7 +585,7 @@ FactoryGirl.define do factory :banner do sequence(:title) { |n| "Banner title #{n}" } - sequence(:description) { |n| "This is the text of Banner #{n}" } + sequence(:description) { |n| "This is the text of Banner #{n}" } style {["banner-style-one", "banner-style-two", "banner-style-three"].sample} image {["banner.banner-img-one", "banner.banner-img-two", "banner.banner-img-three"].sample} target_url {["/proposals", "/debates" ].sample} diff --git a/spec/features/budgets/investments_spec.rb b/spec/features/budgets/investments_spec.rb index f8110b614..dfb64a755 100644 --- a/spec/features/budgets/investments_spec.rb +++ b/spec/features/budgets/investments_spec.rb @@ -5,7 +5,7 @@ feature 'Budget Investments' do let(:author) { create(:user, :level_two, username: 'Isabel') } let(:budget) { create(:budget, name: "Big Budget") } let(:other_budget) { create(:budget, name: "What a Budget!") } - let(:group) { create(:budget_group, name: "Health", budget: budget) } + let(:group) { create(:budget_group, name: "Health", budget: budget) } let!(:heading) { create(:budget_heading, name: "More hospitals", group: group) } scenario 'Index' do @@ -641,11 +641,11 @@ feature 'Budget Investments' do carabanchel_heading = create(:budget_heading, group: group, name: "Carabanchel") new_york_heading = create(:budget_heading, group: group, name: "New York") - sp1 = create(:budget_investment, :selected, price: 1, heading: global_heading) - sp2 = create(:budget_investment, :selected, price: 10, heading: global_heading) - sp3 = create(:budget_investment, :selected, price: 100, heading: global_heading) - sp4 = create(:budget_investment, :selected, price: 1000, heading: carabanchel_heading) - sp5 = create(:budget_investment, :selected, price: 10000, heading: carabanchel_heading) + sp1 = create(:budget_investment, :selected, price: 1, heading: global_heading) + sp2 = create(:budget_investment, :selected, price: 10, heading: global_heading) + sp3 = create(:budget_investment, :selected, price: 100, heading: global_heading) + sp4 = create(:budget_investment, :selected, price: 1000, heading: carabanchel_heading) + sp5 = create(:budget_investment, :selected, price: 10000, heading: carabanchel_heading) sp6 = create(:budget_investment, :selected, price: 100000, heading: new_york_heading) login_as(user) diff --git a/spec/features/comments/budget_investments_spec.rb b/spec/features/comments/budget_investments_spec.rb index 73e1b0869..7e96b1f80 100644 --- a/spec/features/comments/budget_investments_spec.rb +++ b/spec/features/comments/budget_investments_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' include ActionView::Helpers::DateHelper feature 'Commenting Budget::Investments' do - let(:user) { create :user } + let(:user) { create :user } let(:investment) { create :budget_investment } scenario 'Index' do diff --git a/spec/features/comments/legislation_annotations_spec.rb b/spec/features/comments/legislation_annotations_spec.rb index d8c539201..7727d8204 100644 --- a/spec/features/comments/legislation_annotations_spec.rb +++ b/spec/features/comments/legislation_annotations_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' include ActionView::Helpers::DateHelper feature 'Commenting legislation questions' do - let(:user) { create :user } + let(:user) { create :user } let(:legislation_annotation) { create :legislation_annotation, author: user } scenario 'Index' do diff --git a/spec/features/comments/legislation_questions_spec.rb b/spec/features/comments/legislation_questions_spec.rb index 4bdaed1ee..064a72ae0 100644 --- a/spec/features/comments/legislation_questions_spec.rb +++ b/spec/features/comments/legislation_questions_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' include ActionView::Helpers::DateHelper feature 'Commenting legislation questions' do - let(:user) { create :user, :level_two } + let(:user) { create :user, :level_two } let(:process) { create :legislation_process, :in_debate_phase } let(:legislation_question) { create :legislation_question, process: process } diff --git a/spec/features/comments/proposals_spec.rb b/spec/features/comments/proposals_spec.rb index ad088b79a..d10a11de7 100644 --- a/spec/features/comments/proposals_spec.rb +++ b/spec/features/comments/proposals_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' include ActionView::Helpers::DateHelper feature 'Commenting proposals' do - let(:user) { create :user } + let(:user) { create :user } let(:proposal) { create :proposal } scenario 'Index' do diff --git a/spec/features/debates_spec.rb b/spec/features/debates_spec.rb index 3c90171e9..b1357bb1c 100644 --- a/spec/features/debates_spec.rb +++ b/spec/features/debates_spec.rb @@ -674,7 +674,7 @@ feature 'Debates' do click_link "Advanced search" fill_in "Write the text", with: "Schwifty" select Setting['official_level_1_name'], from: "advanced_search_official_level" - select "Last 24 hours", from: "js-advanced-search-date-min" + select "Last 24 hours", from: "js-advanced-search-date-min" click_button "Filter" @@ -866,10 +866,10 @@ feature 'Debates' do login_as(author) debate1 = create(:debate, title: "First debate has 1 vote", cached_votes_up: 1) - debate2 = create(:debate, title: "Second debate has 2 votes", cached_votes_up: 2) - debate3 = create(:debate, title: "Third debate has 3 votes", cached_votes_up: 3) - debate4 = create(:debate, title: "This one has 4 votes", description: "This is the fourth debate", cached_votes_up: 4) - debate5 = create(:debate, title: "Fifth debate has 5 votes", cached_votes_up: 5) + debate2 = create(:debate, title: "Second debate has 2 votes", cached_votes_up: 2) + debate3 = create(:debate, title: "Third debate has 3 votes", cached_votes_up: 3) + debate4 = create(:debate, title: "This one has 4 votes", description: "This is the fourth debate", cached_votes_up: 4) + debate5 = create(:debate, title: "Fifth debate has 5 votes", cached_votes_up: 5) debate6 = create(:debate, title: "Sixth debate has 6 votes", description: 'This is the sixth debate', cached_votes_up: 6) debate7 = create(:debate, title: "This has seven votes, and is not suggest", description: 'This is the seven', cached_votes_up: 7) diff --git a/spec/features/organizations_spec.rb b/spec/features/organizations_spec.rb index 0a7a2bcc7..f968d6cac 100644 --- a/spec/features/organizations_spec.rb +++ b/spec/features/organizations_spec.rb @@ -8,7 +8,7 @@ feature 'Organizations' do visit new_organization_registration_path - fill_in 'user_organization_attributes_name', with: 'Greenpeace' + fill_in 'user_organization_attributes_name', with: 'Greenpeace' fill_in 'user_organization_attributes_responsible_name', with: 'Dorothy Stowe' fill_in 'user_email', with: 'green@peace.com' fill_in 'user_password', with: 'greenpeace' @@ -45,7 +45,7 @@ feature 'Organizations' do scenario 'Create organization too fast' do allow(InvisibleCaptcha).to receive(:timestamp_threshold).and_return(Float::INFINITY) visit new_organization_registration_path - fill_in 'user_organization_attributes_name', with: 'robot' + fill_in 'user_organization_attributes_name', with: 'robot' fill_in 'user_organization_attributes_responsible_name', with: 'Robots are more responsible than humans' fill_in 'user_email', with: 'robot@robot.com' fill_in 'user_password', with: 'destroyallhumans' diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index cfe9cc918..99f7cbfed 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -89,7 +89,7 @@ feature 'Proposals' do end end - context "Embedded video" do + context "Embedded video" do scenario "Show YouTube video" do proposal = create(:proposal, video_url: "http://www.youtube.com/watch?v=a7UFm6ErMPU") @@ -1072,7 +1072,7 @@ feature 'Proposals' do click_link "Advanced search" fill_in "Write the text", with: "Schwifty" select Setting['official_level_1_name'], from: "advanced_search_official_level" - select "Last 24 hours", from: "js-advanced-search-date-min" + select "Last 24 hours", from: "js-advanced-search-date-min" click_button "Filter" diff --git a/spec/lib/age_spec.rb b/spec/lib/age_spec.rb index 6e1012fd4..02637966e 100644 --- a/spec/lib/age_spec.rb +++ b/spec/lib/age_spec.rb @@ -17,7 +17,7 @@ describe Age do d = Date.new(1980, 12, 31) expect(Age.in_years(d, Date.new(2000, 12, 30))).to eq(19) expect(Age.in_years(d, Date.new(2000, 12, 31))).to eq(20) - expect(Age.in_years(d, Date.new(2001, 1, 1))).to eq(20) + expect(Age.in_years(d, Date.new(2001, 1, 1))).to eq(20) d = Date.new(1980, 1, 1) expect(Age.in_years(d, Date.new(2000, 12, 31))).to eq(20) @@ -31,28 +31,28 @@ describe Age do expect(Age.in_years(d, Date.new(2000, 2, 27))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 28))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 29))).to eq(20) - expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20) + expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 27))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 28))).to eq(20) - expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21) + expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21) d = Date.new(1980, 2, 28) expect(Age.in_years(d, Date.new(2000, 2, 27))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 28))).to eq(20) expect(Age.in_years(d, Date.new(2000, 2, 29))).to eq(20) - expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20) + expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 27))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 28))).to eq(21) - expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21) + expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21) d = Date.new(1980, 3, 1) expect(Age.in_years(d, Date.new(2000, 2, 27))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 28))).to eq(19) expect(Age.in_years(d, Date.new(2000, 2, 29))).to eq(19) - expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20) + expect(Age.in_years(d, Date.new(2000, 3, 1))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 27))).to eq(20) expect(Age.in_years(d, Date.new(2001, 2, 28))).to eq(20) - expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21) + expect(Age.in_years(d, Date.new(2001, 3, 1))).to eq(21) end end end diff --git a/spec/lib/graph_ql/query_type_creator_spec.rb b/spec/lib/graph_ql/query_type_creator_spec.rb index 6d3fe7a2a..be223c109 100644 --- a/spec/lib/graph_ql/query_type_creator_spec.rb +++ b/spec/lib/graph_ql/query_type_creator_spec.rb @@ -7,7 +7,7 @@ describe GraphQL::QueryTypeCreator do Proposal => { fields: { id: :integer, title: :string } } } end - let(:api_types) { GraphQL::ApiTypesCreator.create(api_type_definitions) } + let(:api_types) { GraphQL::ApiTypesCreator.create(api_type_definitions) } describe "::create" do let(:query_type) { GraphQL::QueryTypeCreator.create(api_types) } diff --git a/spec/models/abilities/common_spec.rb b/spec/models/abilities/common_spec.rb index f5e3a6599..da398e610 100644 --- a/spec/models/abilities/common_spec.rb +++ b/spec/models/abilities/common_spec.rb @@ -35,14 +35,14 @@ describe "Abilities::Common" do let(:incoming_poll) { create(:poll, :incoming) } let(:incoming_poll_from_own_geozone) { create(:poll, :incoming, geozone_restricted: true, geozones: [geozone]) } let(:incoming_poll_from_other_geozone) { create(:poll, :incoming, geozone_restricted: true, geozones: [create(:geozone)]) } - let(:expired_poll) { create(:poll, :expired) } + let(:expired_poll) { create(:poll, :expired) } let(:expired_poll_from_own_geozone) { create(:poll, :expired, geozone_restricted: true, geozones: [geozone]) } let(:expired_poll_from_other_geozone) { create(:poll, :expired, geozone_restricted: true, geozones: [create(:geozone)]) } let(:poll) { create(:poll, geozone_restricted: false) } let(:poll_from_own_geozone) { create(:poll, geozone_restricted: true, geozones: [geozone]) } let(:poll_from_other_geozone) { create(:poll, geozone_restricted: true, geozones: [create(:geozone)]) } - let(:poll_question_from_own_geozone) { create(:poll_question, poll: poll_from_own_geozone) } + let(:poll_question_from_own_geozone) { create(:poll_question, poll: poll_from_own_geozone) } let(:poll_question_from_other_geozone) { create(:poll_question, poll: poll_from_other_geozone) } let(:poll_question_from_all_geozones) { create(:poll_question, poll: poll) } @@ -222,7 +222,7 @@ describe "Abilities::Common" do it { should be_able_to(:vote, Proposal) } it { should be_able_to(:vote_featured, Proposal) } - it { should be_able_to(:create, SpendingProposal) } + it { should be_able_to(:create, SpendingProposal) } it { should_not be_able_to(:destroy, create(:spending_proposal)) } it { should_not be_able_to(:destroy, own_spending_proposal) } diff --git a/spec/models/letter_spec.rb b/spec/models/letter_spec.rb index fdec7f390..eca9f815e 100644 --- a/spec/models/letter_spec.rb +++ b/spec/models/letter_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' describe 'Verification::Letter' do - let(:user) { create(:user) } + let(:user) { create(:user) } describe "validations" do diff --git a/spec/models/poll/poll_spec.rb b/spec/models/poll/poll_spec.rb index 80a57e916..61f9fce52 100644 --- a/spec/models/poll/poll_spec.rb +++ b/spec/models/poll/poll_spec.rb @@ -93,7 +93,7 @@ describe :poll do let(:non_user) { nil } let(:level1) { create(:user) } let(:level2) { create(:user, :level_two) } - let(:level2_from_geozone) { create(:user, :level_two, geozone: geozone) } + let(:level2_from_geozone) { create(:user, :level_two, geozone: geozone) } let(:all_users) { [non_user, level1, level2, level2_from_geozone] } describe 'instance method' do diff --git a/spec/models/tag_cloud_spec.rb b/spec/models/tag_cloud_spec.rb index 5de136ae1..7b84154dc 100644 --- a/spec/models/tag_cloud_spec.rb +++ b/spec/models/tag_cloud_spec.rb @@ -24,7 +24,7 @@ describe TagCloud do it "returns budget investment tags" do create(:budget_investment, tag_list: 'participation') - create(:debate, tag_list: 'world hunger') + create(:debate, tag_list: 'world hunger') tag_cloud = TagCloud.new(Budget::Investment) From 904e3fdcfa8154071185f39c2f319d235fcfccf4 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Sun, 25 Jun 2017 16:03:16 +0200 Subject: [PATCH 71/75] Fix all Style/HashSyntax rubocop issues and remove from rubocop_todo list --- .rubocop_todo.yml | 9 --------- app/controllers/sandbox_controller.rb | 6 +++--- app/models/legislation/question.rb | 2 +- lib/sms_api.rb | 15 ++++++++++++++- spec/factories.rb | 2 +- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0449d48f3..fac09b643 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -229,15 +229,6 @@ Layout/FirstParameterIndentation: Style/GuardClause: Enabled: false -# Offense count: 10 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles, UseHashRocketsWithSymbolValues, PreferHashRocketsForNonAlnumEndingSymbols. -# SupportedStyles: ruby19, hash_rockets, no_mixed_keys, ruby19_no_mixed_keys -Style/HashSyntax: - Exclude: - - 'lib/sms_api.rb' - - 'spec/factories.rb' - # Offense count: 6 # Cop supports --auto-correct. # Configuration parameters: MaxLineLength. diff --git a/app/controllers/sandbox_controller.rb b/app/controllers/sandbox_controller.rb index 12b5dd91e..b1a143f54 100644 --- a/app/controllers/sandbox_controller.rb +++ b/app/controllers/sandbox_controller.rb @@ -14,10 +14,10 @@ class SandboxController < ApplicationController def show if params[:template].index('.') # CVE-2014-0130 - render :action => "index" + render action: "index" elsif lookup_context.exists?("sandbox/#{params[:template]}") if params[:template] == "index" - render :action => "index" + render action: "index" else render "sandbox/#{params[:template]}" end @@ -25,7 +25,7 @@ class SandboxController < ApplicationController elsif lookup_context.exists?("sandbox/#{params[:template]}/index") render "sandbox/#{params[:template]}/index" else - render :action => "index" + render action: "index" end end diff --git a/app/models/legislation/question.rb b/app/models/legislation/question.rb index 4381b752a..09449b449 100644 --- a/app/models/legislation/question.rb +++ b/app/models/legislation/question.rb @@ -9,7 +9,7 @@ class Legislation::Question < ActiveRecord::Base has_many :answers, class_name: 'Legislation::Answer', foreign_key: 'legislation_question_id', dependent: :destroy, inverse_of: :question has_many :comments, as: :commentable, dependent: :destroy - accepts_nested_attributes_for :question_options, :reject_if => proc { |attributes| attributes[:value].blank? }, allow_destroy: true + accepts_nested_attributes_for :question_options, reject_if: proc { |attributes| attributes[:value].blank? }, allow_destroy: true validates :process, presence: true validates :title, presence: true diff --git a/lib/sms_api.rb b/lib/sms_api.rb index 9b866fc87..252d0749e 100644 --- a/lib/sms_api.rb +++ b/lib/sms_api.rb @@ -38,7 +38,20 @@ class SMSApi end def stubbed_response - {:respuesta_sms => {:identificador_mensaje => "1234567", :fecha_respuesta => "Thu, 20 Aug 2015 16:28:05 +0200", :respuesta_pasarela => {:codigo_pasarela => "0000", :descripcion_pasarela => "Operación ejecutada correctamente."}, :respuesta_servicio_externo => {:codigo_respuesta => "1000", :texto_respuesta => "Success"}}} + { + respuesta_sms: { + identificador_mensaje: "1234567", + fecha_respuesta: "Thu, 20 Aug 2015 16:28:05 +0200", + respuesta_pasarela: { + codigo_pasarela: "0000", + descripcion_pasarela: "Operación ejecutada correctamente." + }, + respuesta_servicio_externo: { + codigo_respuesta: "1000", + texto_respuesta: "Success" + } + } + } end end diff --git a/spec/factories.rb b/spec/factories.rb index 18df18120..5dc19a708 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -552,7 +552,7 @@ FactoryGirl.define do sequence(:value) { |n| "Setting #{n} Value" } end - factory :ahoy_event, :class => Ahoy::Event do + factory :ahoy_event, class: Ahoy::Event do id { SecureRandom.uuid } time DateTime.current sequence(:name) {|n| "Event #{n} type"} From c16b0cba4d6b02c5a6095d0204f0c55ab4df87ed Mon Sep 17 00:00:00 2001 From: Bertocq Date: Tue, 27 Jun 2017 17:19:05 +0200 Subject: [PATCH 72/75] Disable Style/EmptyMethod rubocop rule after debate agreement --- .rubocop.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.rubocop.yml b/.rubocop.yml index cbb1bd0fb..c23172921 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -22,6 +22,9 @@ Metrics/LineLength: Layout/IndentationConsistency: EnforcedStyle: rails +Style/EmptyMethod: + Enabled: false + Style/StringLiterals: Enabled: false From c4ba35bf639132c7fa16ab40de4a8f208b9acde0 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Wed, 28 Jun 2017 14:27:49 +0200 Subject: [PATCH 73/75] Revert rubocop autocorrections and add it to exclusion list on rubocop_todo file --- .rubocop_todo.yml | 8 ++++++++ app/models/concerns/searchable.rb | 17 +++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index fac09b643..a29c06239 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -550,3 +550,11 @@ Style/VariableNumber: Style/WordArray: EnforcedStyle: percent MinSize: 3 + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, SupportedStyles. +# SupportedStyles: braces, no_braces, context_dependent +Style/BracesAroundHashParameters: + Exclude: + - 'app/models/concerns/searchable.rb' diff --git a/app/models/concerns/searchable.rb b/app/models/concerns/searchable.rb index 7de037ca1..6694df114 100644 --- a/app/models/concerns/searchable.rb +++ b/app/models/concerns/searchable.rb @@ -5,14 +5,15 @@ module Searchable include PgSearch include SearchCache - pg_search_scope :pg_search, - against: :ignored, # not used since using a tsvector_column - using: { - tsearch: { tsvector_column: 'tsv', dictionary: "spanish", prefix: true } - }, - ignoring: :accents, - ranked_by: '(:tsearch)', - order_within_rank: (self.column_names.include?('cached_votes_up') ? "#{self.table_name}.cached_votes_up DESC" : nil) + pg_search_scope :pg_search, { + against: :ignored, # not used since using a tsvector_column + using: { + tsearch: { tsvector_column: 'tsv', dictionary: "spanish", prefix: true } + }, + ignoring: :accents, + ranked_by: '(:tsearch)', + order_within_rank: (self.column_names.include?('cached_votes_up') ? "#{self.table_name}.cached_votes_up DESC" : nil) + } end end From fe069b6be952a51e08fec23832658cbe2640e066 Mon Sep 17 00:00:00 2001 From: decabeza Date: Wed, 28 Jun 2017 16:33:02 +0200 Subject: [PATCH 74/75] changes hex to hsla colors --- .../stylesheets/annotator_overrides.scss | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/app/assets/stylesheets/annotator_overrides.scss b/app/assets/stylesheets/annotator_overrides.scss index eb01c0691..c2cbe68ff 100644 --- a/app/assets/stylesheets/annotator_overrides.scss +++ b/app/assets/stylesheets/annotator_overrides.scss @@ -105,23 +105,43 @@ background: rgba(255, 249, 218, 0.75); &.weight-1 { - background: #fff9da; + background: hsla(50, 100, 93, 0.5); + + .weight-1 { + background: hsla(50, 100, 93, 0.75); + } } &.weight-2 { - background: #f4f7be; + background: hsla(63, 78, 86, 0.5); + + .weight-2 { + background: hsla(63, 78, 86, 0.75); + } } &.weight-3 { - background: #fff5b2; + background: hsla(52, 100, 85, 0.5); + + .weight-3 { + background: hsla(52, 100, 85, 0.75); + } } &.weight-4 { - background: #f9e784; + background: hsla(51, 91, 75, 0.5); + + .weight-4 { + background: hsla(51, 91, 75, 0.75); + } } &.weight-5 { - background: #eec643; + background: hsla(46, 83, 60, 0.5); + + .weight-5 { + background: hsla(46, 83, 60, 0.5); + } } } From 76ac788823433f2a26848145a5c68ba87252aa89 Mon Sep 17 00:00:00 2001 From: Bertocq Date: Thu, 29 Jun 2017 18:32:26 +0200 Subject: [PATCH 75/75] Improve Readme with PRs-welcome badge, plus PR guide link Why: * Try to make the repo more friendly for first time contributors and any contributor on general How: * Adding a PRs-welcom badget that links to the issues list filtered by PRs-welcome label * Adding a Link to on the Contributing guide to a free course about Pull Request and Contributions on Github. --- CONTRIBUTING.md | 4 +++- CONTRIBUTING_ES.md | 5 ++++- README.md | 1 + README_ES.md | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3147d1e4a..fabf10a0a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -35,7 +35,9 @@ If you want to contribute code to solve an issue: * Commit there your code to solve the issue. * Make sure all test are passing (and add specs to test any new feature if needed). * Follow these [best practices](https://github.com/styleguide/ruby) -* Open a *pull request* to the main repository describing what issue you are addressing. +* Open a *pull request* to the main repository describing what issue you are addressing. + +**Working on your first Pull Request?** You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github) ## Cleaning up diff --git a/CONTRIBUTING_ES.md b/CONTRIBUTING_ES.md index b981bc408..6b77c0f42 100644 --- a/CONTRIBUTING_ES.md +++ b/CONTRIBUTING_ES.md @@ -35,7 +35,10 @@ Cuando quieras resolver una incidencia mediante código: * Añade el código necesario para resolver la incidencia en tantos commits como sea preciso * Asegúrate de que los tests pasan (y escribe más tests para probar la nueva funcionalidad si fuera preciso) * Sigue estas [buenas prácticas](https://github.com/styleguide/ruby) -* Envía una *pull request* al repositorio principal indicando la incidencia que se está arreglando +* Envía una *pull request* al repositorio principal indicando la incidencia que se está arreglando. + +**¿Es tu primer Pull Request?** Puedes aprender en este curso gratuito (en inglés) sobre [cómo contribuir a un proyecto OpenSource en GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github) + ## Limpiar diff --git a/README.md b/README.md index 380d03031..8dbfcd281 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Citizen Participation and Open Government Application [![A11y issues checked with Rocket Validator](https://rocketvalidator.com/badges/checked_with_rocket_validator.svg?url=https://rocketvalidator.com)](https://rocketvalidator.com/opensource) [![Join the chat at https://gitter.im/consul/consul](https://badges.gitter.im/consul/consul.svg)](https://gitter.im/consul/consul?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/consul/consul/issues?q=is%3Aissue+is%3Aopen+label%3APRs-welcome) This is the opensource code repository of the eParticipation website originally developed for the Madrid City government eParticipation website diff --git a/README_ES.md b/README_ES.md index 9a57b1f18..7b9267351 100644 --- a/README_ES.md +++ b/README_ES.md @@ -15,6 +15,7 @@ Aplicación de Participación Ciudadana y Gobierno Abierto [![A11y issues checked with Rocket Validator](https://rocketvalidator.com/badges/checked_with_rocket_validator.svg?url=https://rocketvalidator.com)](https://rocketvalidator.com/opensource) [![Join the chat at https://gitter.im/consul/consul](https://badges.gitter.im/consul/consul.svg)](https://gitter.im/consul/consul?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/consul/consul/issues?q=is%3Aissue+is%3Aopen+label%3APRs-welcome) Este es el repositorio de código abierto de la Aplicación de Participación Ciudadana Consul, creada originariamente por el Ayuntamiento de Madrid.