Merge pull request #5893 from consuldemocracy/obsolete_code

Remove some obsolete code
This commit is contained in:
Javi Martín
2025-03-26 17:25:27 +01:00
committed by GitHub
50 changed files with 166 additions and 331 deletions

View File

@@ -1,11 +0,0 @@
.admin .poll-questions-filter {
$gap: 0.5em;
@include flex-with-gap($gap);
align-items: flex-end;
flex-wrap: wrap;
[type="submit"] {
@include regular-button;
margin-left: $gap;
}
}

View File

@@ -512,28 +512,6 @@
} }
} }
.icon-debates,
.icon-proposals,
.icon-budget {
font-size: rem-calc(18);
line-height: $line-height;
margin-left: rem-calc(6);
top: 0;
}
.icon-debates {
color: $debates;
}
.icon-proposals {
color: $proposals-dark;
}
.icon-budget {
color: $budget;
font-size: $small-font-size;
}
.debate-info, .debate-info,
.proposal-info, .proposal-info,
.investment-project-info, .investment-project-info,

View File

@@ -1,7 +0,0 @@
<%= form_tag "", method: :get, class: "poll-questions-filter" do %>
<div class="filter">
<%= label_tag :poll_id, t("admin.questions.index.filter_poll") %>
<%= select_tag "poll_id", poll_select_options, prompt: t("polls.all") %>
</div>
<%= submit_tag t("shared.filter") %>
<% end %>

View File

@@ -1,14 +0,0 @@
class Admin::Poll::Questions::FilterComponent < ApplicationComponent
attr_reader :polls
use_helpers :current_path_with_query_params
def initialize(polls)
@polls = polls
end
private
def poll_select_options
options_from_collection_for_select(polls, :id, :name, params[:poll_id])
end
end

View File

@@ -0,0 +1,41 @@
<% provide :main_class, "admin-proposals-index" %>
<%= header do %>
<%= successful_proposals_link %>
<% end %>
<% if proposals.any? %>
<%= render Admin::SearchComponent.new(label: t("admin.shared.search.label.proposals")) %>
<h3><%= page_entries_info proposals %></h3>
<table>
<thead>
<tr>
<th class="text-center"><%= t("admin.proposals.index.id") %></th>
<th><%= Proposal.human_attribute_name(:title) %></th>
<th><%= t("admin.proposals.index.author") %></th>
<th><%= t("admin.proposals.index.milestones") %></th>
<th><%= t("admin.proposals.index.selected") %></th>
</tr>
</thead>
<tbody>
<% proposals.each do |proposal| %>
<tr id="<%= dom_id(proposal) %>" class="proposal">
<td class="text-center"><%= proposal.id %></td>
<td><%= link_to proposal.title, admin_proposal_path(proposal) %></td>
<td><%= proposal.author.username %></td>
<td><%= proposal.milestones.count %></td>
<td><%= render Admin::Proposals::ToggleSelectionComponent.new(proposal) %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate proposals %>
<% else %>
<div class="callout primary">
<%= t("admin.proposals.index.no_proposals") %>
</div>
<% end %>

View File

@@ -0,0 +1,20 @@
class Admin::Proposals::IndexComponent < ApplicationComponent
include Header
attr_reader :proposals
def initialize(proposals)
@proposals = proposals
end
def title
t("admin.proposals.index.title")
end
private
def successful_proposals_link
if Proposal.successful.any?
link_to t("admin.questions.index.successful_proposals_tab"), successful_admin_proposals_path
end
end
end

View File

@@ -1,3 +1,9 @@
<% provide :main_class, "admin-proposals-successful" %>
<%= back_link_to admin_proposals_path %>
<%= header %>
<table> <table>
<thead> <thead>
<tr> <tr>
@@ -6,7 +12,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @proposals.each do |proposal| %> <% proposals.each do |proposal| %>
<tr id="<%= dom_id(proposal) %>"> <tr id="<%= dom_id(proposal) %>">
<td> <td>
<%= proposal.title %> <%= proposal.title %>

View File

@@ -0,0 +1,12 @@
class Admin::Proposals::SuccessfulComponent < ApplicationComponent
include Header
attr_reader :proposals
def initialize(proposals)
@proposals = proposals
end
def title
t("admin.questions.index.successful_proposals_tab")
end
end

View File

@@ -1,3 +0,0 @@
class Admin::Api::BaseController < Admin::BaseController
protect_from_forgery with: :null_session
end

View File

@@ -4,14 +4,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
load_and_authorize_resource :poll load_and_authorize_resource :poll
load_resource class: "Poll::Question" load_resource class: "Poll::Question"
authorize_resource except: [:new, :index] authorize_resource except: :new
def index
@polls = Poll.not_budget
@questions = @questions.search(search_params).page(params[:page]).order("created_at DESC")
@proposals = Proposal.successful.sort_by_confidence_score
end
def new def new
proposal = Proposal.find(params[:proposal_id]) if params[:proposal_id].present? proposal = Proposal.find(params[:proposal_id]) if params[:proposal_id].present?
@@ -61,8 +54,4 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
attributes = [:poll_id, :question, :proposal_id, votation_type_attributes: [:vote_type, :max_votes]] attributes = [:poll_id, :question, :proposal_id, votation_type_attributes: [:vote_type, :max_votes]]
[*attributes, translation_params(Poll::Question)] [*attributes, translation_params(Poll::Question)]
end end
def search_params
params.permit(:poll_id, :search)
end
end end

View File

@@ -6,7 +6,11 @@ class Admin::ProposalsController < Admin::BaseController
has_orders %w[created_at] has_orders %w[created_at]
before_action :load_proposal, except: :index before_action :load_proposal, except: [:index, :successful]
def successful
@proposals = Proposal.successful.sort_by_confidence_score
end
def show def show
end end

View File

@@ -6,9 +6,7 @@ class Users::RegistrationsController < Devise::RegistrationsController
invisible_captcha only: [:create], honeypot: :address, scope: :user invisible_captcha only: [:create], honeypot: :address, scope: :user
def new def new
super do |user| super
user.use_redeemable_code = true if params[:use_redeemable_code].present?
end
end end
def create def create
@@ -64,18 +62,13 @@ class Users::RegistrationsController < Devise::RegistrationsController
private private
def sign_up_params def sign_up_params
if params[:user].present? && params[:user][:redeemable_code].blank?
params[:user].delete(:redeemable_code)
end
params.require(:user).permit(allowed_params) params.require(:user).permit(allowed_params)
end end
def allowed_params def allowed_params
[ [
:username, :email, :password, :username, :email, :password,
:password_confirmation, :terms_of_service, :locale, :password_confirmation, :terms_of_service, :locale
:redeemable_code
] ]
end end

View File

@@ -18,17 +18,15 @@ module WelcomeHelper
end end
end end
def render_recommendation_image(recommended, image_default) def render_recommendation_image(recommended)
image_path = calculate_image_path(recommended, image_default) image_path = calculate_image_path(recommended)
image_tag(image_path) if image_path.present? image_tag(image_path) if image_path.present?
end end
def calculate_image_path(recommended, image_default) def calculate_image_path(recommended)
if recommended.respond_to?(:image) && recommended.image.present? && if recommended.respond_to?(:image) && recommended.image.present? &&
recommended.image.attachment.attached? recommended.image.attachment.attached?
recommended.image.variant(:medium) recommended.image.variant(:medium)
elsif image_default.present?
image_default
end end
end end

View File

@@ -1,6 +1,5 @@
class Poll::Question < ApplicationRecord class Poll::Question < ApplicationRecord
include Measurable include Measurable
include Searchable
acts_as_paranoid column: :hidden_at acts_as_paranoid column: :hidden_at
include ActsAsParanoidAliases include ActsAsParanoidAliases
@@ -30,25 +29,9 @@ class Poll::Question < ApplicationRecord
delegate :multiple?, :vote_type, to: :votation_type, allow_nil: true delegate :multiple?, :vote_type, to: :votation_type, allow_nil: true
scope :by_poll_id, ->(poll_id) { where(poll_id: poll_id) }
scope :sort_for_list, -> { order(Arel.sql("poll_questions.proposal_id IS NULL"), :created_at) } scope :sort_for_list, -> { order(Arel.sql("poll_questions.proposal_id IS NULL"), :created_at) }
scope :for_render, -> { includes(:author, :proposal) } scope :for_render, -> { includes(:author, :proposal) }
def self.search(params)
results = all
results = results.by_poll_id(params[:poll_id]) if params[:poll_id].present?
results = results.pg_search(params[:search]) if params[:search].present?
results
end
def searchable_values
{ title => "A",
proposal&.title => "A",
author.username => "C",
author_visible_name => "C" }
end
def copy_attributes_from_proposal(proposal) def copy_attributes_from_proposal(proposal)
if proposal.present? if proposal.present?
self.author = proposal.author self.author = proposal.author

View File

@@ -89,7 +89,7 @@ class User < ApplicationRecord
accepts_nested_attributes_for :organization, update_only: true accepts_nested_attributes_for :organization, update_only: true
attr_accessor :skip_password_validation, :use_redeemable_code, :login attr_accessor :skip_password_validation, :login
scope :administrators, -> { joins(:administrator) } scope :administrators, -> { joins(:administrator) }
scope :moderators, -> { joins(:moderator) } scope :moderators, -> { joins(:moderator) }

View File

@@ -1,12 +0,0 @@
<ul class="tabs" data-tabs id="questions-tabs">
<li class="tabs-title is-active">
<%= link_to "#tab-questions" do %>
<%= t("admin.questions.index.questions_tab") %>
<% end %>
</li>
<li class="tabs-title">
<%= link_to "#tab-successful-proposals" do %>
<%= t("admin.questions.index.successful_proposals_tab") %>
<% end %>
</li>
</ul>

View File

@@ -1,38 +0,0 @@
<%= render Admin::Poll::Questions::FilterComponent.new(@polls) %>
<% if @questions.count == 0 %>
<div class="callout primary margin-top">
<%= t("admin.questions.index.no_questions") %>
</div>
<% else %>
<table>
<thead>
<tr>
<th><%= t("admin.questions.index.table_question") %></th>
<th><%= t("admin.questions.index.table_poll") %></th>
<th><%= t("admin.actions.actions") %></th>
</tr>
</thead>
<tbody>
<% @questions.each do |question| %>
<tr id="<%= dom_id(question) %>">
<td><%= question.title %></td>
<td>
<% if question.poll.present? %>
<%= question.poll.name %>
<% else %>
<em><%= t("admin.questions.index.poll_not_assigned") %></em>
<% end %>
</td>
<td>
<%= render Admin::TableActionsComponent.new(question) do |actions| %>
<%= actions.action(:options, text: t("admin.polls.show.edit_answers")) %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @questions %>
<% end %>

View File

@@ -1,18 +0,0 @@
<h2 class="inline-block"><%= t("admin.questions.index.title") %></h2>
<%= link_to t("admin.questions.index.create"), new_admin_question_path,
class: "button float-right" %>
<%= render "search" %>
<div class="tabs-content" data-tabs-content="questions-tabs">
<%= render "filter_subnav" %>
<div class="tabs-panel is-active" id="tab-questions">
<%= render "questions" %>
</div>
<div class="tabs-panel" id="tab-successful-proposals">
<%= render "successful_proposals" %>
</div>
</div>

View File

@@ -100,11 +100,3 @@
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<% if @question.video_url.present? %>
<p>
<strong><%= t("admin.questions.show.video_url") %></strong>
<br>
<a href="<%= @question.video_url %>"><%= @question.video_url %></a>
</p>
<% end %>

View File

@@ -1,41 +1 @@
<% provide(:title) do %> <%= render Admin::Proposals::IndexComponent.new(@proposals) %>
<%= t("admin.header.title") %> - <%= t("admin.proposals.index.title") %>
<% end %>
<h2><%= t("admin.proposals.index.title") %></h2>
<% if @proposals.any? %>
<%= render Admin::SearchComponent.new(label: t("admin.shared.search.label.proposals")) %>
<h3><%= page_entries_info @proposals %></h3>
<table>
<thead>
<tr>
<th class="text-center"><%= t("admin.proposals.index.id") %></th>
<th><%= Proposal.human_attribute_name(:title) %></th>
<th><%= t("admin.proposals.index.author") %></th>
<th><%= t("admin.proposals.index.milestones") %></th>
<th><%= t("admin.proposals.index.selected") %></th>
</tr>
</thead>
<tbody>
<% @proposals.each do |proposal| %>
<tr id="<%= dom_id(proposal) %>" class="proposal">
<td class="text-center"><%= proposal.id %></td>
<td><%= link_to proposal.title, admin_proposal_path(proposal) %></td>
<td><%= proposal.author.username %></td>
<td><%= proposal.milestones.count %></td>
<td><%= render Admin::Proposals::ToggleSelectionComponent.new(proposal) %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @proposals %>
<% else %>
<div class="callout primary">
<%= t("admin.proposals.index.no_proposals") %>
</div>
<% end %>

View File

@@ -0,0 +1 @@
<%= render Admin::Proposals::SuccessfulComponent.new(@proposals) %>

View File

@@ -18,7 +18,7 @@
<%= raw setting["html.per_page_code_body"] %> <%= raw setting["html.per_page_code_body"] %>
<div class="wrapper <%= yield(:wrapper_class) %>"> <div class="wrapper <%= yield(:wrapper_class) %>">
<%= render "layouts/header", with_subnavigation: true %> <%= render "layouts/header" %>
<main id="main" class="public-content <%= yield(:main_class) %>"> <main id="main" class="public-content <%= yield(:main_class) %>">
<%= render "layouts/flash" %> <%= render "layouts/flash" %>

View File

@@ -18,7 +18,7 @@
<h1 class="show-for-sr"><%= setting["org_name"] %></h1> <h1 class="show-for-sr"><%= setting["org_name"] %></h1>
<%= render "layouts/header", with_subnavigation: false %> <%= render "layouts/header" %>
<div class="menu-and-content"> <div class="menu-and-content">
<%= check_box_tag :show_menu, nil, false, role: "switch" %> <%= check_box_tag :show_menu, nil, false, role: "switch" %>

View File

@@ -15,7 +15,6 @@
<div class="row"> <div class="row">
<div class="small-12 column"> <div class="small-12 column">
<%= f.hidden_field :use_redeemable_code %>
<%= f.hidden_field :locale, value: I18n.locale %> <%= f.hidden_field :locale, value: I18n.locale %>
<%= f.text_field :username, autofocus: true, maxlength: User.username_max_length, <%= f.text_field :username, autofocus: true, maxlength: User.username_max_length,
@@ -30,10 +29,6 @@
<%= f.password_field :password_confirmation, autocomplete: "off", <%= f.password_field :password_confirmation, autocomplete: "off",
label: t("devise_views.users.registrations.new.password_confirmation_label") %> label: t("devise_views.users.registrations.new.password_confirmation_label") %>
<% if resource.use_redeemable_code %>
<%= f.text_field :redeemable_code %>
<% end %>
<%= f.check_box :terms_of_service, <%= f.check_box :terms_of_service,
label: t("devise_views.users.registrations.new.terms", label: t("devise_views.users.registrations.new.terms",
terms: new_window_link_to(t("devise_views.users.registrations.new.terms_link"), terms: new_window_link_to(t("devise_views.users.registrations.new.terms_link"),

View File

@@ -13,7 +13,6 @@
key: "debates", key: "debates",
image_field: nil, image_field: nil,
image_version: nil, image_version: nil,
image_default: nil,
carousel_size: carousel_size, carousel_size: carousel_size,
btn_text_link: t("welcome.recommended.debates.btn_text_link"), btn_text_link: t("welcome.recommended.debates.btn_text_link"),
btn_path_link: debates_path(order: "recommendations") %> btn_path_link: debates_path(order: "recommendations") %>
@@ -25,7 +24,6 @@
key: "proposals", key: "proposals",
image_field: :attachment, image_field: :attachment,
image_version: :thumb, image_version: :thumb,
image_default: nil,
carousel_size: carousel_size, carousel_size: carousel_size,
btn_text_link: t("welcome.recommended.proposals.btn_text_link"), btn_text_link: t("welcome.recommended.proposals.btn_text_link"),
btn_path_link: proposals_path(order: "recommendations") %> btn_path_link: proposals_path(order: "recommendations") %>

View File

@@ -11,7 +11,7 @@
<li class="orbit-slide <%= is_active_class(index) %>" data-slide="<%= index %>" style="position: relative; <%= slide_display(index) %>" aria-live="polite"> <li class="orbit-slide <%= is_active_class(index) %>" data-slide="<%= index %>" style="position: relative; <%= slide_display(index) %>" aria-live="polite">
<div class="card"> <div class="card">
<%= render_recommendation_image(recommended, image_default) %> <%= render_recommendation_image(recommended) %>
<div class="card-section"> <div class="card-section">
<%= link_to recommended_path(recommended) do %> <%= link_to recommended_path(recommended) do %>
<h4 class="truncate-horizontal-text"><%= recommended.title %></h4> <h4 class="truncate-horizontal-text"><%= recommended.title %></h4>

View File

@@ -296,7 +296,6 @@ en:
public_interests: "Keep the elements I follow public" public_interests: "Keep the elements I follow public"
recommended_debates: "Recommend debates to me" recommended_debates: "Recommend debates to me"
recommended_proposals: "Recommend proposals to me" recommended_proposals: "Recommend proposals to me"
redeemable_code: "Verification code received via email"
direct_message: direct_message:
title: "Title" title: "Title"
body: "Message" body: "Message"

View File

@@ -1134,18 +1134,11 @@ en:
multiple_description: "Allows to choose multiple answers. It's possible to set the maximum number of answers." multiple_description: "Allows to choose multiple answers. It's possible to set the maximum number of answers."
questions: questions:
index: index:
title: "Questions"
create: "Create question" create: "Create question"
no_questions: "There are no questions."
filter_poll: Filter by Poll
select_poll: Select Poll select_poll: Select Poll
questions_tab: "Questions"
successful_proposals_tab: "Successful proposals" successful_proposals_tab: "Successful proposals"
create_question: "Create question" create_question: "Create question"
table_proposal: "Proposal" table_proposal: "Proposal"
table_question: "Question"
table_poll: "Poll"
poll_not_assigned: "Poll not assigned"
edit: edit:
title: "Edit Question" title: "Edit Question"
form: form:
@@ -1166,7 +1159,6 @@ en:
edit_question: Edit question edit_question: Edit question
valid_answers: Valid answers valid_answers: Valid answers
add_answer: Add answer add_answer: Add answer
video_url: External video
answers: answers:
title: Answer title: Answer
description: Description description: Description

View File

@@ -569,7 +569,6 @@ en:
support: "You just have to click on the button that you will see below 'Support this proposal' and you can inform yourself about before promoting it. Only the proposals that achieve the maximum support will be carried out by the City Council, and I thought that you, I'm sure you help me achieve it!" support: "You just have to click on the button that you will see below 'Support this proposal' and you can inform yourself about before promoting it. Only the proposals that achieve the maximum support will be carried out by the City Council, and I thought that you, I'm sure you help me achieve it!"
share: "And if you also do me the great favor of sharing my proposal with your friends, family and contacts, it would be perfect!" share: "And if you also do me the great favor of sharing my proposal with your friends, family and contacts, it would be perfect!"
polls: polls:
all: "All"
dates: "From %{open_at} to %{closed_at}" dates: "From %{open_at} to %{closed_at}"
final_date: "Final recounts/Results" final_date: "Final recounts/Results"
index: index:

View File

@@ -296,7 +296,6 @@ es:
public_interests: "Mostrar públicamente los elementos que sigo" public_interests: "Mostrar públicamente los elementos que sigo"
recommended_debates: "Mostrar recomendaciones en el listado de debates" recommended_debates: "Mostrar recomendaciones en el listado de debates"
recommended_proposals: "Mostrar recomendaciones en el listado de propuestas" recommended_proposals: "Mostrar recomendaciones en el listado de propuestas"
redeemable_code: "Código de verificación por carta (opcional)"
direct_message: direct_message:
title: "Título" title: "Título"
body: "Mensaje" body: "Mensaje"

View File

@@ -1134,18 +1134,11 @@ es:
multiple_description: "Permite elegir más de una respuesta. Se puede elegir el número máximo de respuestas." multiple_description: "Permite elegir más de una respuesta. Se puede elegir el número máximo de respuestas."
questions: questions:
index: index:
title: "Preguntas de votaciones"
create: "Crear pregunta ciudadana" create: "Crear pregunta ciudadana"
no_questions: "No hay ninguna pregunta ciudadana."
filter_poll: Filtrar por votación
select_poll: Seleccionar votación select_poll: Seleccionar votación
questions_tab: "Preguntas"
successful_proposals_tab: "Propuestas que han superado el umbral" successful_proposals_tab: "Propuestas que han superado el umbral"
create_question: "Crear pregunta para votación" create_question: "Crear pregunta para votación"
table_proposal: "Propuesta" table_proposal: "Propuesta"
table_question: "Pregunta"
table_poll: "Votación"
poll_not_assigned: "Votación no asignada"
edit: edit:
title: "Editar pregunta ciudadana" title: "Editar pregunta ciudadana"
form: form:
@@ -1166,7 +1159,6 @@ es:
edit_question: Editar pregunta edit_question: Editar pregunta
valid_answers: Respuestas válidas valid_answers: Respuestas válidas
add_answer: Añadir respuesta add_answer: Añadir respuesta
video_url: Vídeo externo
answers: answers:
title: Respuesta title: Respuesta
description: Descripción description: Descripción

View File

@@ -569,7 +569,6 @@ es:
support: "Tan sólo tienes que hacer clic en el botón que verás a continuación 'Apoyar esta propuesta' y directamente podrás informarte acerca de ella antes de impulsarla. Sólo las propuestas que consigan el máximo apoyo se llevarán a cabo por parte del Ayuntamiento, y he pensado que tú ¡seguro que me ayudas a lograrlo!" support: "Tan sólo tienes que hacer clic en el botón que verás a continuación 'Apoyar esta propuesta' y directamente podrás informarte acerca de ella antes de impulsarla. Sólo las propuestas que consigan el máximo apoyo se llevarán a cabo por parte del Ayuntamiento, y he pensado que tú ¡seguro que me ayudas a lograrlo!"
share: "Y si además, me haces el gran favor de compartir mi propuesta con tus amigos, familiares y contactos ¡sería perfecto!" share: "Y si además, me haces el gran favor de compartir mi propuesta con tus amigos, familiares y contactos ¡sería perfecto!"
polls: polls:
all: "Todas"
dates: "Desde el %{open_at} hasta el %{closed_at}" dates: "Desde el %{open_at} hasta el %{closed_at}"
final_date: "Recuento final/Resultados" final_date: "Recuento final/Resultados"
index: index:

View File

@@ -45,6 +45,10 @@ namespace :admin do
resources :debates, only: [:index, :show] resources :debates, only: [:index, :show]
resources :proposals, only: [:index, :show, :update] do resources :proposals, only: [:index, :show, :update] do
collection do
get :successful
end
member do member do
patch :select patch :select
patch :deselect patch :deselect
@@ -192,7 +196,7 @@ namespace :admin do
end end
end end
resources :questions, shallow: true do resources :questions, except: :index, shallow: true do
resources :options, except: [:index, :show], controller: "questions/options", shallow: false resources :options, except: [:index, :show], controller: "questions/options", shallow: false
resources :options, only: [], controller: "questions/options" do resources :options, only: [], controller: "questions/options" do
resources :images, controller: "questions/options/images" resources :images, controller: "questions/options/images"

View File

@@ -0,0 +1,5 @@
class RemovePollQuestionsVideoUrl < ActiveRecord::Migration[7.0]
def change
remove_column :poll_questions, :video_url, :string
end
end

View File

@@ -0,0 +1,5 @@
class RemoveUsersRedeemableCode < ActiveRecord::Migration[7.0]
def change
remove_column :users, :redeemable_code, :string
end
end

View File

@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2024_10_26_112901) do ActiveRecord::Schema[7.0].define(version: 2025_03_13_014205) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm" enable_extension "pg_trgm"
enable_extension "plpgsql" enable_extension "plpgsql"
@@ -1138,7 +1138,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_26_112901) do
t.datetime "created_at", precision: nil t.datetime "created_at", precision: nil
t.datetime "updated_at", precision: nil t.datetime "updated_at", precision: nil
t.tsvector "tsv" t.tsvector "tsv"
t.string "video_url"
t.index ["author_id"], name: "index_poll_questions_on_author_id" t.index ["author_id"], name: "index_poll_questions_on_author_id"
t.index ["poll_id"], name: "index_poll_questions_on_poll_id" t.index ["poll_id"], name: "index_poll_questions_on_poll_id"
t.index ["proposal_id"], name: "index_poll_questions_on_proposal_id" t.index ["proposal_id"], name: "index_poll_questions_on_proposal_id"
@@ -1612,7 +1611,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_26_112901) do
t.string "locale" t.string "locale"
t.string "oauth_email" t.string "oauth_email"
t.integer "geozone_id" t.integer "geozone_id"
t.string "redeemable_code"
t.string "gender", limit: 10 t.string "gender", limit: 10
t.datetime "date_of_birth", precision: nil t.datetime "date_of_birth", precision: nil
t.boolean "email_digest", default: true t.boolean "email_digest", default: true

View File

@@ -1,9 +0,0 @@
require "rails_helper"
describe Admin::Poll::Questions::FilterComponent do
it "renders a button to submit the form" do
render_inline Admin::Poll::Questions::FilterComponent.new([])
expect(page).to have_button "Filter"
end
end

View File

@@ -0,0 +1,35 @@
require "rails_helper"
describe Admin::Proposals::IndexComponent, controller: Admin::ProposalsController do
around do |example|
with_request_url(Rails.application.routes.url_helpers.admin_proposals_path) { example.run }
end
describe "#successful_proposals_link" do
it "is shown when there are successful proposals" do
create(:proposal, :successful)
render_inline Admin::Proposals::IndexComponent.new(Proposal.page(1))
expect(page).to have_link "Successful proposals"
end
it "is not shown when there aren't any successful proposals" do
create(:proposal)
render_inline Admin::Proposals::IndexComponent.new(Proposal.page(1))
expect(page).not_to have_link "Successful proposals"
end
it "is shown when there are successful proposals on a previous page" do
allow(Proposal).to receive(:default_per_page).and_return(1)
create(:proposal, :successful)
create(:proposal)
render_inline Admin::Proposals::IndexComponent.new(Proposal.order(:id).page(2))
expect(page).to have_link "Successful proposals"
end
end
end

View File

@@ -118,10 +118,9 @@ describe "Admin poll questions", :admin do
create(:poll, :future, name: "Proposals") create(:poll, :future, name: "Proposals")
proposal = create(:proposal, :successful) proposal = create(:proposal, :successful)
visit admin_proposal_path(proposal) visit admin_proposals_path
click_link "Successful proposals"
expect(page).to have_content("This proposal has reached the required supports") click_link "Create question"
click_link "Add this proposal to a poll to be voted"
expect(page).to have_current_path(new_admin_question_path, ignore_query: true) expect(page).to have_current_path(new_admin_question_path, ignore_query: true)
expect(page).to have_field("Question", with: proposal.title) expect(page).to have_field("Question", with: proposal.title)
@@ -130,11 +129,7 @@ describe "Admin poll questions", :admin do
click_button "Save" click_button "Save"
expect(page).to have_content(proposal.title) expect(page).to have_content proposal.title
visit admin_questions_path
expect(page).to have_content(proposal.title)
end end
scenario "Update" do scenario "Update" do

View File

@@ -130,8 +130,6 @@ describe "Admin edit translatable records", :admin do
end end
context "Add an invalid translation" do context "Add an invalid translation" do
let(:translatable) { create(:budget_investment) }
context "Input field" do context "Input field" do
let(:translatable) { create(:budget, main_link_url: "https://consuldemocracy.org") } let(:translatable) { create(:budget, main_link_url: "https://consuldemocracy.org") }

View File

@@ -1,13 +0,0 @@
require "rails_helper"
describe "Poll Questions", :admin do
scenario "Do not display polls associated to a budget" do
create(:poll, name: "Citizen Proposal Poll")
create(:poll, :for_budget, name: "Participatory Budget Poll")
visit admin_questions_path
expect(page).to have_select("poll_id", text: "Citizen Proposal Poll")
expect(page).not_to have_select("poll_id", text: "Participatory Budget Poll")
end
end

View File

@@ -1,9 +1,7 @@
require "rails_helper" require "rails_helper"
describe "Budgets" do describe "Budgets" do
let(:budget) { create(:budget) } let(:budget) { create(:budget) }
let(:level_two_user) { create(:user, :level_two) }
let(:allowed_phase_list) { ["balloting", "reviewing_ballots", "finished"] }
context "Load" do context "Load" do
before { budget.update(slug: "budget_slug") } before { budget.update(slug: "budget_slug") }

View File

@@ -1,8 +1,7 @@
require "rails_helper" require "rails_helper"
describe "Stats" do describe "Stats" do
let(:budget) { create(:budget, :finished) } let(:budget) { create(:budget, :finished) }
let(:heading) { create(:budget_heading, budget: budget, price: 1000) }
context "Load" do context "Load" do
before { budget.update(slug: "budget_slug") } before { budget.update(slug: "budget_slug") }

View File

@@ -2,7 +2,6 @@ require "rails_helper"
describe "Commenting legislation annotations" do describe "Commenting legislation annotations" do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:annotation) { create(:legislation_annotation, author: user) }
describe "Merged comment threads" do describe "Merged comment threads" do
let!(:draft_version) { create(:legislation_draft_version, :published) } let!(:draft_version) { create(:legislation_draft_version, :published) }

View File

@@ -72,6 +72,7 @@ describe "Users" do
scenario "Delete a level 2 user account from document verification page" do scenario "Delete a level 2 user account from document verification page" do
level_2_user = create(:user, :level_two, document_number: "12345678Z") level_2_user = create(:user, :level_two, document_number: "12345678Z")
manager = create(:manager) manager = create(:manager)
administrator = create(:administrator)
login_as_manager(manager) login_as_manager(manager)
visit management_document_verifications_path visit management_document_verifications_path
@@ -92,7 +93,7 @@ describe "Users" do
expect(page).to have_content "no user account associated to it" expect(page).to have_content "no user account associated to it"
logout logout
login_as(create(:administrator).user) login_as(administrator.user)
visit admin_users_path(filter: "erased") visit admin_users_path(filter: "erased")

View File

@@ -38,26 +38,6 @@ describe "Registration form" do
expect(page).to have_content "can't be blank" expect(page).to have_content "can't be blank"
end end
scenario "do not save blank redeemable codes" do
visit new_user_registration_path(use_redeemable_code: "true")
fill_in "user_username", with: "NewUserWithCode77"
fill_in "user_email", with: "new@consul.dev"
fill_in "user_password", with: "password"
fill_in "user_password_confirmation", with: "password"
fill_in "user_redeemable_code", with: " "
check "user_terms_of_service"
click_button "Register"
expect(page).to have_title "Confirm your email address"
expect(page).to have_content "Thank you for registering"
new_user = User.last
expect(new_user.username).to eq("NewUserWithCode77")
expect(new_user.redeemable_code).to be nil
end
scenario "Create with invisible_captcha honeypot field", :no_js do scenario "Create with invisible_captcha honeypot field", :no_js do
visit new_user_registration_path visit new_user_registration_path

View File

@@ -10,7 +10,6 @@ describe "Tags" do
end end
let!(:tag_medio_ambiente) { create(:tag, :category, name: "Medio Ambiente") } let!(:tag_medio_ambiente) { create(:tag, :category, name: "Medio Ambiente") }
let!(:tag_economia) { create(:tag, :category, name: "Economía") } let!(:tag_economia) { create(:tag, :category, name: "Economía") }
let(:admin) { create(:administrator).user }
scenario "Index" do scenario "Index" do
earth = create(:budget_investment, heading: heading, tag_list: tag_medio_ambiente.name) earth = create(:budget_investment, heading: heading, tag_list: tag_medio_ambiente.name)

View File

@@ -213,8 +213,6 @@ describe "Users" do
end end
describe "User email" do describe "User email" do
let(:user) { create(:user) }
scenario "is not shown if no user logged in" do scenario "is not shown if no user logged in" do
visit user_path(user) visit user_path(user)
expect(page).not_to have_content(user.email) expect(page).not_to have_content(user.email)

View File

@@ -1,8 +1,6 @@
require "rails_helper" require "rails_helper"
describe "Welcome screen" do describe "Welcome screen" do
let(:budget) { create(:budget) }
it_behaves_like "remotely_translatable", :proposal, "root_path", {} it_behaves_like "remotely_translatable", :proposal, "root_path", {}
it_behaves_like "remotely_translatable", :debate, "root_path", {} it_behaves_like "remotely_translatable", :debate, "root_path", {}
it_behaves_like "remotely_translatable", :legislation_process, "root_path", {} it_behaves_like "remotely_translatable", :legislation_process, "root_path", {}

View File

@@ -1,36 +1,34 @@
require "rails_helper" require "rails_helper"
RSpec.describe "welcome#index" do RSpec.describe "welcome#index" do
it "Display images on orbit carrousel when we have defined image_default" do it "displays images on the orbit carrousel when recommendations have an image" do
debate = create(:debate) proposal = create(:proposal, :with_image)
render template: "welcome/_recommended_carousel", render template: "welcome/_recommended_carousel",
locals: { key: "debates", locals: { key: "debates",
recommendeds: [debate], recommendeds: [proposal],
image_field: nil, image_field: nil,
image_version: nil, image_version: nil,
image_default: "https://dummyimage.com/600x400/000/fff",
carousel_size: "medium-6 large-6 medium-centered large-centered", carousel_size: "medium-6 large-6 medium-centered large-centered",
btn_text_link: t("welcome.recommended.debates.btn_text_link"), btn_text_link: t("welcome.recommended.proposals.btn_text_link"),
btn_path_link: debates_path(order: "recommendations") } btn_path_link: proposals_path(order: "recommendations") }
within 'li[data-slide="0"] .card' do within 'li[data-slide="0"] .card' do
expect(page).to have_css "img" expect(page).to have_css "img"
end end
end end
it "Not display images on orbit carrousel when we have not defined image_default" do it "does not display images on the orbit carrousel when recommendations don't have an image" do
debate = create(:debate) proposal = create(:proposal)
render template: "welcome/_recommended_carousel", render template: "welcome/_recommended_carousel",
locals: { key: "debates", locals: { key: "debates",
recommendeds: [debate], recommendeds: [proposal],
image_field: nil, image_field: nil,
image_version: nil, image_version: nil,
image_default: nil,
carousel_size: "medium-6 large-6 medium-centered large-centered", carousel_size: "medium-6 large-6 medium-centered large-centered",
btn_text_link: t("welcome.recommended.debates.btn_text_link"), btn_text_link: t("welcome.recommended.proposals.btn_text_link"),
btn_path_link: debates_path(order: "recommendations") } btn_path_link: proposals_path(order: "recommendations") }
within 'li[data-slide="0"] .card' do within 'li[data-slide="0"] .card' do
expect(page).not_to have_css "img" expect(page).not_to have_css "img"