Merge pull request #5161 from consuldemocracy/line_length
Apply Layout/LineLength rubocop rule
This commit is contained in:
@@ -120,7 +120,14 @@ Layout/LineEndStringConcatenationIndentation:
|
||||
|
||||
Layout/LineLength:
|
||||
Max: 110
|
||||
Severity: refactor
|
||||
Exclude:
|
||||
- "Gemfile"
|
||||
- "config/environments/production.rb"
|
||||
- "config/environments/staging.rb"
|
||||
- "config/initializers/devise.rb"
|
||||
- "config/initializers/backtrace_silencers.rb"
|
||||
- "db/migrate/*create_delayed_jobs.rb"
|
||||
- "app/models/budget/stats.rb"
|
||||
|
||||
Layout/MultilineArrayBraceLayout:
|
||||
Enabled: true
|
||||
|
||||
@@ -183,7 +183,8 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
[
|
||||
t("admin.menu.poll_booth_assignments"),
|
||||
booth_assignments_admin_polls_path,
|
||||
controller_name == "polls" && action_name == "booth_assignments" || controller_name == "booth_assignments" && action_name == "manage"
|
||||
controller_name == "polls" && action_name == "booth_assignments" ||
|
||||
controller_name == "booth_assignments" && action_name == "manage"
|
||||
]
|
||||
end
|
||||
|
||||
@@ -255,7 +256,8 @@ class Admin::MenuComponent < ApplicationComponent
|
||||
banners_link,
|
||||
information_texts_link,
|
||||
documents_link,
|
||||
class: ("is-active" if customization? && controller.class.module_parent != Admin::Poll::Questions::Answers)
|
||||
class: ("is-active" if customization? &&
|
||||
controller.class.module_parent != Admin::Poll::Questions::Answers)
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
@@ -64,7 +64,10 @@ class Budgets::Investments::VotesComponent < ApplicationComponent
|
||||
t("votes.budget_investments.#{reason}",
|
||||
count: investment.group.max_votable_headings,
|
||||
verify_account: link_to_verify_account,
|
||||
supported_headings: (current_user && current_user.headings_voted_within_group(investment.group).map(&:name).sort.to_sentence))
|
||||
supported_headings: (current_user && current_user.headings_voted_within_group(investment.group)
|
||||
.map(&:name)
|
||||
.sort
|
||||
.to_sentence))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,6 +13,8 @@ class Relationable::RelatedListComponent < ApplicationComponent
|
||||
private
|
||||
|
||||
def related_contents
|
||||
@related_contents ||= Kaminari.paginate_array(relationable.relationed_contents).page(params[:page]).per(5)
|
||||
@related_contents ||= Kaminari.paginate_array(relationable.relationed_contents)
|
||||
.page(params[:page])
|
||||
.per(5)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,7 +33,8 @@ class SDG::FilterLinksComponent < ApplicationComponent
|
||||
|
||||
def index_by(advanced_search)
|
||||
if related_model.name == "Legislation::Proposal"
|
||||
legislation_process_proposals_path(params[:id], advanced_search: advanced_search, filter: params[:filter])
|
||||
legislation_process_proposals_path(params[:id], advanced_search: advanced_search,
|
||||
filter: params[:filter])
|
||||
else
|
||||
polymorphic_path(related_model, advanced_search: advanced_search)
|
||||
end
|
||||
|
||||
@@ -22,7 +22,8 @@ class Admin::Api::StatsController < Admin::Api::BaseController
|
||||
end
|
||||
|
||||
if params[:user_supported_budgets].present?
|
||||
ds.add "User supported budgets", Vote.where(votable_type: "Budget::Investment").group_by_day(:updated_at).count
|
||||
ds.add "User supported budgets",
|
||||
Vote.where(votable_type: "Budget::Investment").group_by_day(:updated_at).count
|
||||
end
|
||||
render json: ds.build
|
||||
end
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseController
|
||||
include Translatable
|
||||
|
||||
load_and_authorize_resource :draft_version, class: "Legislation::DraftVersion", through: :process, prepend: true
|
||||
load_and_authorize_resource :process, class: "Legislation::Process", prepend: true
|
||||
load_and_authorize_resource :process, class: "Legislation::Process"
|
||||
load_and_authorize_resource :draft_version, class: "Legislation::DraftVersion", through: :process
|
||||
|
||||
def index
|
||||
@draft_versions = @process.draft_versions
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -7,9 +7,9 @@ class Admin::StatsController < Admin::BaseController
|
||||
@proposals = Proposal.with_hidden.count
|
||||
@comments = Comment.not_valuations.with_hidden.count
|
||||
|
||||
@debate_votes = Vote.where(votable_type: "Debate").count
|
||||
@proposal_votes = Vote.where(votable_type: "Proposal").count
|
||||
@comment_votes = Vote.where(votable_type: "Comment").count
|
||||
@debate_votes = Vote.count_for("Debate")
|
||||
@proposal_votes = Vote.count_for("Proposal")
|
||||
@comment_votes = Vote.count_for("Comment")
|
||||
|
||||
@votes = Vote.count
|
||||
|
||||
|
||||
@@ -10,7 +10,9 @@ module Budgets
|
||||
|
||||
authorize_resource :budget
|
||||
authorize_resource :ballot
|
||||
load_and_authorize_resource :line, through: :ballot, find_by: :investment_id, class: "Budget::Ballot::Line"
|
||||
load_and_authorize_resource :line, through: :ballot,
|
||||
find_by: :investment_id,
|
||||
class: "Budget::Ballot::Line"
|
||||
|
||||
def create
|
||||
load_investment
|
||||
|
||||
@@ -28,7 +28,8 @@ module Budgets
|
||||
|
||||
has_orders %w[most_voted newest oldest], only: :show
|
||||
has_orders ->(c) { c.instance_variable_get(:@budget).investments_orders }, only: :index
|
||||
has_filters ->(c) { c.instance_variable_get(:@budget).investments_filters }, only: [:index, :show, :suggest]
|
||||
has_filters ->(c) { c.instance_variable_get(:@budget).investments_filters },
|
||||
only: [:index, :show, :suggest]
|
||||
|
||||
invisible_captcha only: [:create, :update], honeypot: :subtitle, scope: :budget_investment
|
||||
|
||||
@@ -79,12 +80,14 @@ module Budgets
|
||||
|
||||
def destroy
|
||||
@investment.destroy!
|
||||
redirect_to user_path(current_user, filter: "budget_investments"), notice: t("flash.actions.destroy.budget_investment")
|
||||
redirect_to user_path(current_user, filter: "budget_investments"),
|
||||
notice: t("flash.actions.destroy.budget_investment")
|
||||
end
|
||||
|
||||
def suggest
|
||||
@resource_path_method = :namespaced_budget_investment_path
|
||||
@resource_relation = resource_model.where(budget: @budget).apply_filters_and_search(@budget, params, @current_filter)
|
||||
@resource_relation = resource_model.where(budget: @budget)
|
||||
.apply_filters_and_search(@budget, params, @current_filter)
|
||||
super
|
||||
end
|
||||
|
||||
|
||||
@@ -59,7 +59,8 @@ module Admin::BudgetHeadingsActions
|
||||
end
|
||||
|
||||
def allowed_params
|
||||
valid_attributes = [:price, :population, :allow_custom_content, :latitude, :longitude, :max_ballot_lines, :geozone_id]
|
||||
valid_attributes = [:price, :population, :allow_custom_content, :latitude, :longitude,
|
||||
:max_ballot_lines, :geozone_id]
|
||||
|
||||
[*valid_attributes, translation_params(Budget::Heading)]
|
||||
end
|
||||
|
||||
@@ -7,7 +7,11 @@ module CommentableActions
|
||||
def index
|
||||
@resources = resource_model.all
|
||||
|
||||
@resources = @current_order == "recommendations" && current_user.present? ? @resources.recommendations(current_user) : @resources.for_render
|
||||
@resources = if @current_order == "recommendations" && current_user.present?
|
||||
@resources.recommendations(current_user)
|
||||
else
|
||||
@resources.for_render
|
||||
end
|
||||
@resources = @resources.search(@search_terms) if @search_terms.present?
|
||||
@resources = @resources.filter_by(@advanced_search_terms)
|
||||
|
||||
|
||||
@@ -8,7 +8,9 @@ class DirectUploadsController < ApplicationController
|
||||
helper_method :render_destroy_upload_link
|
||||
|
||||
def create
|
||||
@direct_upload = DirectUpload.new(direct_upload_params.merge(user: current_user, attachment: params[:attachment]))
|
||||
@direct_upload = DirectUpload.new(
|
||||
direct_upload_params.merge(user: current_user, attachment: params[:attachment])
|
||||
)
|
||||
|
||||
if @direct_upload.valid?
|
||||
@direct_upload.save_attachment
|
||||
|
||||
@@ -4,13 +4,13 @@ class FollowsController < ApplicationController
|
||||
|
||||
def create
|
||||
@follow.save!
|
||||
flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow.followable)}.create.notice")
|
||||
flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow)}.create.notice")
|
||||
render :refresh_follow_button
|
||||
end
|
||||
|
||||
def destroy
|
||||
@follow.destroy!
|
||||
flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow.followable)}.destroy.notice")
|
||||
flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow)}.destroy.notice")
|
||||
render :refresh_follow_button
|
||||
end
|
||||
|
||||
@@ -24,7 +24,7 @@ class FollowsController < ApplicationController
|
||||
[:followable_type, :followable_id]
|
||||
end
|
||||
|
||||
def followable_translation_key(followable)
|
||||
followable.class.name.parameterize(separator: "_")
|
||||
def followable_translation_key(follow)
|
||||
follow.followable.class.name.parameterize(separator: "_")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,6 +14,9 @@ class InstallationController < ApplicationController
|
||||
end
|
||||
|
||||
def settings_feature_flags
|
||||
Setting.where("key LIKE 'process.%'").each_with_object({}) { |x, n| n[x.key.remove("process.")] = x.value }
|
||||
Setting.where("key LIKE 'process.%'")
|
||||
.pluck(:key, :value)
|
||||
.to_h
|
||||
.transform_keys { |key| key.remove("process.") }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,7 +30,8 @@ class Legislation::ProposalsController < Legislation::BaseController
|
||||
@proposal = Legislation::Proposal.new(proposal_params.merge(author: current_user))
|
||||
|
||||
if @proposal.save
|
||||
redirect_to legislation_process_proposal_path(params[:process_id], @proposal), notice: I18n.t("flash.actions.create.proposal")
|
||||
redirect_to legislation_process_proposal_path(params[:process_id], @proposal),
|
||||
notice: I18n.t("flash.actions.create.proposal")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
||||
@@ -37,7 +37,10 @@ class Management::Budgets::InvestmentsController < Management::BaseController
|
||||
end
|
||||
|
||||
def print
|
||||
@investments = @investments.apply_filters_and_search(@budget, params).order(cached_votes_up: :desc).for_render.limit(15)
|
||||
@investments = @investments.apply_filters_and_search(@budget, params)
|
||||
.order(cached_votes_up: :desc)
|
||||
.for_render
|
||||
.limit(15)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -15,7 +15,9 @@ class Management::DocumentVerificationsController < Management::BaseController
|
||||
elsif @document_verification.user?
|
||||
render :new
|
||||
elsif @document_verification.in_census?
|
||||
redirect_to new_management_email_verification_path(email_verification: document_verification_params.to_h)
|
||||
redirect_to new_management_email_verification_path(
|
||||
email_verification: document_verification_params.to_h
|
||||
)
|
||||
else
|
||||
render :invalid_document
|
||||
end
|
||||
@@ -49,6 +51,8 @@ class Management::DocumentVerificationsController < Management::BaseController
|
||||
def clean_document_number
|
||||
return if params[:document_verification][:document_number].blank?
|
||||
|
||||
params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase
|
||||
params[:document_verification][:document_number] = params[:document_verification][:document_number]
|
||||
.gsub(/[^a-z0-9]+/i, "")
|
||||
.upcase
|
||||
end
|
||||
end
|
||||
|
||||
@@ -31,7 +31,9 @@ class Management::ProposalsController < Management::BaseController
|
||||
super
|
||||
@notifications = @proposal.notifications
|
||||
|
||||
redirect_to management_proposal_path(@proposal), status: :moved_permanently if request.path != management_proposal_path(@proposal)
|
||||
if request.path != management_proposal_path(@proposal)
|
||||
redirect_to management_proposal_path(@proposal), status: :moved_permanently
|
||||
end
|
||||
end
|
||||
|
||||
def vote
|
||||
|
||||
@@ -24,7 +24,10 @@ class Management::UsersController < Management::BaseController
|
||||
end
|
||||
|
||||
def erase
|
||||
managed_user.erase(t("management.users.erased_by_manager", manager: current_manager["login"])) if current_manager.present?
|
||||
if current_manager.present?
|
||||
managed_user.erase(t("management.users.erased_by_manager", manager: current_manager["login"]))
|
||||
end
|
||||
|
||||
destroy_session
|
||||
redirect_to management_document_verifications_path, notice: t("management.users.erased_notice")
|
||||
end
|
||||
|
||||
@@ -10,7 +10,8 @@ class Officing::ResidenceController < Officing::BaseController
|
||||
def create
|
||||
@residence = Officing::Residence.new(residence_params.merge(officer: current_user.poll_officer))
|
||||
if @residence.save
|
||||
redirect_to new_officing_voter_path(id: @residence.user.id), notice: t("officing.residence.flash.create")
|
||||
redirect_to new_officing_voter_path(id: @residence.user.id),
|
||||
notice: t("officing.residence.flash.create")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
|
||||
@@ -46,10 +46,12 @@ class Officing::ResultsController < Officing::BaseController
|
||||
answer = question.question_answers.find_by(given_order: answer_index.to_i + 1).title
|
||||
go_back_to_new if question.blank?
|
||||
|
||||
partial_result = ::Poll::PartialResult.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: Date.current,
|
||||
question_id: question_id,
|
||||
answer: answer)
|
||||
partial_result = ::Poll::PartialResult.find_or_initialize_by(
|
||||
booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: Date.current,
|
||||
question_id: question_id,
|
||||
answer: answer
|
||||
)
|
||||
partial_result.officer_assignment_id = @officer_assignment.id
|
||||
partial_result.amount = count.to_i
|
||||
partial_result.author = current_user
|
||||
@@ -62,8 +64,10 @@ class Officing::ResultsController < Officing::BaseController
|
||||
end
|
||||
|
||||
def build_recounts
|
||||
recount = ::Poll::Recount.find_or_initialize_by(booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: Date.current)
|
||||
recount = ::Poll::Recount.find_or_initialize_by(
|
||||
booth_assignment_id: @officer_assignment.booth_assignment_id,
|
||||
date: Date.current
|
||||
)
|
||||
recount.officer_assignment_id = @officer_assignment.id
|
||||
recount.author = current_user
|
||||
recount.origin = "booth"
|
||||
@@ -90,7 +94,9 @@ class Officing::ResultsController < Officing::BaseController
|
||||
|
||||
def load_officer_assignment
|
||||
@officer_assignment = current_user.poll_officer
|
||||
.officer_assignments.final.find_by(id: results_params[:officer_assignment_id])
|
||||
.officer_assignments
|
||||
.final
|
||||
.find_by(id: results_params[:officer_assignment_id])
|
||||
end
|
||||
|
||||
def load_officer_assignments
|
||||
|
||||
@@ -19,7 +19,7 @@ class Officing::VotersController < Officing::BaseController
|
||||
poll: @poll,
|
||||
origin: "booth",
|
||||
officer: current_user.poll_officer,
|
||||
booth_assignment: Poll::BoothAssignment.find_by(poll: @poll, booth: current_booth),
|
||||
booth_assignment: current_booth.booth_assignments.find_by(poll: @poll),
|
||||
officer_assignment: officer_assignment(@poll))
|
||||
@voter.save!
|
||||
end
|
||||
|
||||
@@ -137,7 +137,10 @@ class ProposalsController < ApplicationController
|
||||
def load_retired
|
||||
if params[:retired].present?
|
||||
@resources = @resources.retired
|
||||
@resources = @resources.where(retired_reason: params[:retired]) if Proposal::RETIRE_OPTIONS.include?(params[:retired])
|
||||
|
||||
if Proposal::RETIRE_OPTIONS.include?(params[:retired])
|
||||
@resources = @resources.where(retired_reason: params[:retired])
|
||||
end
|
||||
else
|
||||
@resources = @resources.not_retired
|
||||
end
|
||||
@@ -152,7 +155,8 @@ class ProposalsController < ApplicationController
|
||||
end
|
||||
|
||||
def load_featured
|
||||
return unless !@advanced_search_terms && @search_terms.blank? && params[:retired].blank? && @current_order != "recommendations"
|
||||
return unless !@advanced_search_terms && @search_terms.blank? &&
|
||||
params[:retired].blank? && @current_order != "recommendations"
|
||||
|
||||
if Setting["feature.featured_proposals"]
|
||||
@featured_proposals = Proposal.not_archived
|
||||
|
||||
@@ -11,10 +11,10 @@ class StatsController < ApplicationController
|
||||
@proposals = daily_cache("proposals") { Proposal.with_hidden.count }
|
||||
@comments = daily_cache("comments") { Comment.not_valuations.with_hidden.count }
|
||||
|
||||
@debate_votes = daily_cache("debate_votes") { Vote.where(votable_type: "Debate").count }
|
||||
@proposal_votes = daily_cache("proposal_votes") { Vote.where(votable_type: "Proposal").count }
|
||||
@comment_votes = daily_cache("comment_votes") { Vote.where(votable_type: "Comment").count }
|
||||
@investment_votes = daily_cache("budget_investment_votes") { Vote.where(votable_type: "Budget::Investment").count }
|
||||
@debate_votes = daily_cache("debate_votes") { Vote.count_for("Debate") }
|
||||
@proposal_votes = daily_cache("proposal_votes") { Vote.count_for("Proposal") }
|
||||
@comment_votes = daily_cache("comment_votes") { Vote.count_for("Comment") }
|
||||
@investment_votes = daily_cache("budget_investment_votes") { Vote.count_for("Budget::Investment") }
|
||||
@votes = daily_cache("votes") { Vote.count }
|
||||
|
||||
@verified_users = daily_cache("verified_users") { User.with_hidden.level_two_or_three_verified.count }
|
||||
|
||||
@@ -43,7 +43,8 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||
|
||||
yield resource if block_given?
|
||||
|
||||
# New condition added to if: when no password was given, display the "show" view (which uses "update" above)
|
||||
# New condition added to if: when no password was given, display the "show" view
|
||||
# (which uses "update" above)
|
||||
if resource.encrypted_password.blank?
|
||||
respond_with_navigational(resource) { render :show }
|
||||
elsif resource.errors.empty?
|
||||
@@ -51,9 +52,14 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||
|
||||
if resource.confirm
|
||||
set_flash_message(:notice, :confirmed) if is_flashing_format?
|
||||
respond_with_navigational(resource) { redirect_to after_confirmation_path_for(resource_name, resource) }
|
||||
|
||||
respond_with_navigational(resource) do
|
||||
redirect_to after_confirmation_path_for(resource_name, resource)
|
||||
end
|
||||
else
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new, status: :unprocessable_entity }
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity) do
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
else
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity) { render :new }
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class Users::RegistrationsController < Devise::RegistrationsController
|
||||
prepend_before_action :authenticate_scope!, only: [:edit, :update, :destroy, :finish_signup, :do_finish_signup]
|
||||
prepend_before_action :authenticate_scope!,
|
||||
only: [:edit, :update, :destroy, :finish_signup, :do_finish_signup]
|
||||
before_action :configure_permitted_parameters
|
||||
|
||||
invisible_captcha only: [:create], honeypot: :address, scope: :user
|
||||
@@ -52,16 +53,21 @@ class Users::RegistrationsController < Devise::RegistrationsController
|
||||
|
||||
def check_username
|
||||
if User.find_by username: params[:username]
|
||||
render json: { available: false, message: t("devise_views.users.registrations.new.username_is_not_available") }
|
||||
render json: { available: false,
|
||||
message: t("devise_views.users.registrations.new.username_is_not_available") }
|
||||
else
|
||||
render json: { available: true, message: t("devise_views.users.registrations.new.username_is_available") }
|
||||
render json: { available: true,
|
||||
message: t("devise_views.users.registrations.new.username_is_available") }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sign_up_params
|
||||
params[:user].delete(:redeemable_code) if params[:user].present? && params[:user][:redeemable_code].blank?
|
||||
if params[:user].present? && params[:user][:redeemable_code].blank?
|
||||
params[:user].delete(:redeemable_code)
|
||||
end
|
||||
|
||||
params.require(:user).permit(allowed_params)
|
||||
end
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ class Verification::EmailController < ApplicationController
|
||||
@email.encrypted_token,
|
||||
@verified_user.document_type,
|
||||
@verified_user.document_number).deliver_later
|
||||
redirect_to account_path, notice: t("verification.email.create.flash.success", email: @verified_user.email)
|
||||
redirect_to account_path,
|
||||
notice: t("verification.email.create.flash.success", email: @verified_user.email)
|
||||
else
|
||||
redirect_to verified_user_path, alert: t("verification.email.create.alert.failure")
|
||||
end
|
||||
|
||||
@@ -20,8 +20,15 @@ module Types
|
||||
argument :id, ID, required: true, default_value: false
|
||||
end
|
||||
|
||||
field :proposal_notifications, Types::ProposalNotificationType.connection_type, "Returns all proposal notifications", null: false
|
||||
field :proposal_notification, Types::ProposalNotificationType, "Returns proposal notification for ID", null: false do
|
||||
field :proposal_notifications,
|
||||
Types::ProposalNotificationType.connection_type,
|
||||
"Returns all proposal notifications",
|
||||
null: false
|
||||
|
||||
field :proposal_notification,
|
||||
Types::ProposalNotificationType,
|
||||
"Returns proposal notification for ID",
|
||||
null: false do
|
||||
argument :id, ID, required: true, default_value: false
|
||||
end
|
||||
|
||||
|
||||
@@ -6,7 +6,10 @@ module AdminHelper
|
||||
def official_level_options
|
||||
options = [["", 0]]
|
||||
(1..5).each do |i|
|
||||
options << [[t("admin.officials.level_#{i}"), setting["official_level_#{i}_name"]].compact.join(": "), i]
|
||||
options << [
|
||||
[t("admin.officials.level_#{i}"), setting["official_level_#{i}_name"]].compact.join(": "),
|
||||
i
|
||||
]
|
||||
end
|
||||
options
|
||||
end
|
||||
|
||||
@@ -21,9 +21,17 @@ module CommentsHelper
|
||||
|
||||
def comment_button_text(parent_id, commentable)
|
||||
if commentable.class == Legislation::Question
|
||||
parent_id.present? ? t("comments_helper.reply_button") : t("legislation.questions.comments.comment_button")
|
||||
if parent_id.present?
|
||||
t("comments_helper.reply_button")
|
||||
else
|
||||
t("legislation.questions.comments.comment_button")
|
||||
end
|
||||
else
|
||||
parent_id.present? ? t("comments_helper.reply_button") : t("comments_helper.comment_button")
|
||||
if parent_id.present?
|
||||
t("comments_helper.reply_button")
|
||||
else
|
||||
t("comments_helper.comment_button")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -8,7 +8,11 @@ module CommunitiesHelper
|
||||
end
|
||||
|
||||
def community_description(community)
|
||||
community.from_proposal? ? t("community.show.description.proposal") : t("community.show.description.investment")
|
||||
if community.from_proposal?
|
||||
t("community.show.description.proposal")
|
||||
else
|
||||
t("community.show.description.investment")
|
||||
end
|
||||
end
|
||||
|
||||
def author?(community, participant)
|
||||
@@ -28,7 +32,11 @@ module CommunitiesHelper
|
||||
end
|
||||
|
||||
def community_access_text(community)
|
||||
community.from_proposal? ? t("community.sidebar.description.proposal") : t("community.sidebar.description.investment")
|
||||
if community.from_proposal?
|
||||
t("community.sidebar.description.proposal")
|
||||
else
|
||||
t("community.sidebar.description.investment")
|
||||
end
|
||||
end
|
||||
|
||||
def create_topic_link(community)
|
||||
|
||||
@@ -49,7 +49,10 @@ module MailerHelper
|
||||
end
|
||||
|
||||
def css_for_mailer_button
|
||||
mailer_font_family + "background: #004a83;border-radius: 6px;color: #fff!important;display: inline-block;font-weight: bold;margin: 0;min-width: 200px;padding: 10px 15px;text-align: center;text-decoration: none;"
|
||||
mailer_font_family + "background: #004a83;border-radius: 6px;color: #fff!important;" \
|
||||
"display: inline-block;font-weight: bold;margin: 0;" \
|
||||
"min-width: 200px;padding: 10px 15px;text-align: center;" \
|
||||
"text-decoration: none;"
|
||||
end
|
||||
|
||||
def css_for_mailer_link
|
||||
|
||||
@@ -2,7 +2,8 @@ module ProposalsHelper
|
||||
def progress_bar_percentage(proposal)
|
||||
case proposal.cached_votes_up
|
||||
when 0 then 0
|
||||
when 1..Proposal.votes_needed_for_success then (proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success).floor
|
||||
when 1..Proposal.votes_needed_for_success
|
||||
(proposal.total_votes.to_f * 100 / Proposal.votes_needed_for_success).floor
|
||||
else 100
|
||||
end
|
||||
end
|
||||
|
||||
@@ -11,7 +11,10 @@ class Mailer < ApplicationMailer
|
||||
manage_subscriptions_token(@commentable.author)
|
||||
|
||||
with_user(@commentable.author) do
|
||||
subject = t("mailers.comment.subject", commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase)
|
||||
subject = t(
|
||||
"mailers.comment.subject",
|
||||
commentable: t("activerecord.models.#{@commentable.class.name.underscore}", count: 1).downcase
|
||||
)
|
||||
mail(to: @email_to, subject: subject) if @commentable.present? && @commentable.author.present?
|
||||
end
|
||||
end
|
||||
@@ -65,7 +68,8 @@ class Mailer < ApplicationMailer
|
||||
manage_subscriptions_token(user)
|
||||
|
||||
with_user(user) do
|
||||
mail(to: @email_to, subject: t("mailers.proposal_notification_digest.title", org_name: Setting["org_name"]))
|
||||
mail(to: @email_to,
|
||||
subject: t("mailers.proposal_notification_digest.title", org_name: Setting["org_name"]))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -49,8 +49,9 @@ module Abilities
|
||||
can :mark_featured, Debate
|
||||
can :unmark_featured, Debate
|
||||
|
||||
can :comment_as_administrator, [Debate, Comment, Proposal, Poll, Poll::Question, Budget::Investment,
|
||||
Legislation::Question, Legislation::Proposal, Legislation::Annotation, Topic]
|
||||
can :comment_as_administrator, [Debate, Comment, Proposal, Poll, Poll::Question,
|
||||
Budget::Investment, Legislation::Question,
|
||||
Legislation::Proposal, Legislation::Annotation, Topic]
|
||||
|
||||
can [:search, :create, :index, :destroy, :update], ::Administrator
|
||||
can [:search, :create, :index, :destroy], ::Moderator
|
||||
@@ -121,7 +122,8 @@ module Abilities
|
||||
can [:manage], ::Legislation::DraftVersion
|
||||
can [:manage], ::Legislation::Question
|
||||
can [:manage], ::Legislation::Proposal
|
||||
cannot :comment_as_moderator, [::Legislation::Question, Legislation::Annotation, ::Legislation::Proposal]
|
||||
cannot :comment_as_moderator,
|
||||
[::Legislation::Question, Legislation::Annotation, ::Legislation::Proposal]
|
||||
|
||||
can [:create], Document
|
||||
can [:destroy], Document do |document|
|
||||
|
||||
@@ -91,10 +91,10 @@ module Abilities
|
||||
can :vote, Legislation::Proposal
|
||||
can :create, Legislation::Answer
|
||||
|
||||
can :create, Budget::Investment, budget: { phase: "accepting" }
|
||||
can :update, Budget::Investment, budget: { phase: "accepting" }, author_id: user.id
|
||||
can :suggest, Budget::Investment, budget: { phase: "accepting" }
|
||||
can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id
|
||||
can :create, Budget::Investment, budget: { phase: "accepting" }
|
||||
can :update, Budget::Investment, budget: { phase: "accepting" }, author_id: user.id
|
||||
can :suggest, Budget::Investment, budget: { phase: "accepting" }
|
||||
can :destroy, Budget::Investment, budget: { phase: ["accepting", "reviewing"] }, author_id: user.id
|
||||
can [:create, :destroy], ActsAsVotable::Vote,
|
||||
voter_id: user.id,
|
||||
votable_type: "Budget::Investment",
|
||||
|
||||
@@ -5,8 +5,9 @@ module Abilities
|
||||
def initialize(user)
|
||||
merge Abilities::Moderation.new(user)
|
||||
|
||||
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll, Poll::Question,
|
||||
Legislation::Question, Legislation::Annotation, Legislation::Proposal, Topic]
|
||||
can :comment_as_moderator, [Debate, Comment, Proposal, Budget::Investment, Poll,
|
||||
Poll::Question, Legislation::Question,
|
||||
Legislation::Annotation, Legislation::Proposal, Topic]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,5 +21,7 @@ class Banner < ApplicationRecord
|
||||
|
||||
scope :with_active, -> { where("post_started_at <= :date and post_ended_at >= :date", date: Date.current) }
|
||||
scope :with_inactive, -> { where.not(id: with_active) }
|
||||
scope :in_section, ->(section_name) { joins(:web_sections, :sections).where("web_sections.name ilike ?", section_name) }
|
||||
scope :in_section, ->(section_name) do
|
||||
joins(:web_sections, :sections).where("web_sections.name ilike ?", section_name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,8 @@ class Budget
|
||||
def check_valid_heading
|
||||
return if ballot.valid_heading?(heading)
|
||||
|
||||
errors.add(:heading, "This heading's budget is invalid, or a heading on the same group was already selected")
|
||||
errors.add(:heading,
|
||||
"This heading's budget is invalid, or a heading on the same group was already selected")
|
||||
end
|
||||
|
||||
def check_selected
|
||||
|
||||
@@ -56,7 +56,8 @@ class Budget
|
||||
class_name: "Comment"
|
||||
|
||||
validates_translation :title, presence: true, length: { in: 4..Budget::Investment.title_max_length }
|
||||
validates_translation :description, presence: true, length: { maximum: Budget::Investment.description_max_length }
|
||||
validates_translation :description, presence: true,
|
||||
length: { maximum: Budget::Investment.description_max_length }
|
||||
|
||||
validates :author, presence: true
|
||||
validates :heading_id, presence: true
|
||||
@@ -67,17 +68,20 @@ class Budget
|
||||
scope :sort_by_confidence_score, -> { reorder(confidence_score: :desc, id: :desc) }
|
||||
scope :sort_by_ballots, -> { reorder(ballot_lines_count: :desc, id: :desc) }
|
||||
scope :sort_by_price, -> { reorder(price: :desc, confidence_score: :desc, id: :desc) }
|
||||
|
||||
scope :sort_by_id, -> { order("id DESC") }
|
||||
scope :sort_by_supports, -> { order("cached_votes_up DESC") }
|
||||
scope :sort_by_id, -> { order("id DESC") }
|
||||
scope :sort_by_supports, -> { order("cached_votes_up DESC") }
|
||||
|
||||
scope :valuation_open, -> { where(valuation_finished: false) }
|
||||
scope :with_admin, -> { where.not(administrator_id: nil) }
|
||||
scope :without_admin, -> { where(administrator_id: nil) }
|
||||
scope :without_valuator_group, -> { where(valuator_group_assignments_count: 0) }
|
||||
scope :without_valuator, -> { without_valuator_group.where(valuator_assignments_count: 0) }
|
||||
scope :under_valuation, -> { valuation_open.valuating.where("administrator_id IS NOT ?", nil) }
|
||||
scope :managed, -> { valuation_open.where(valuator_assignments_count: 0).where("administrator_id IS NOT ?", nil) }
|
||||
scope :valuating, -> { valuation_open.where("valuator_assignments_count > 0 OR valuator_group_assignments_count > 0") }
|
||||
scope :under_valuation, -> { valuation_open.valuating.with_admin }
|
||||
scope :managed, -> { valuation_open.where(valuator_assignments_count: 0).with_admin }
|
||||
scope :with_valuator_assignments, -> { where("valuator_assignments_count > 0") }
|
||||
scope :with_group_assignments, -> { where("valuator_group_assignments_count > 0") }
|
||||
scope :with_valuation_assignments, -> { with_valuator_assignments.or(with_group_assignments) }
|
||||
scope :valuating, -> { valuation_open.with_valuation_assignments }
|
||||
scope :visible_to_valuators, -> { where(visible_to_valuators: true) }
|
||||
scope :valuation_finished, -> { where(valuation_finished: true) }
|
||||
scope :valuation_finished_feasible, -> { where(valuation_finished: true, feasibility: "feasible") }
|
||||
@@ -85,22 +89,25 @@ class Budget
|
||||
scope :unfeasible, -> { where(feasibility: "unfeasible") }
|
||||
scope :not_unfeasible, -> { where.not(feasibility: "unfeasible") }
|
||||
scope :undecided, -> { where(feasibility: "undecided") }
|
||||
scope :with_supports, -> { where("cached_votes_up > 0") }
|
||||
scope :selected, -> { feasible.where(selected: true) }
|
||||
scope :compatible, -> { where(incompatible: false) }
|
||||
scope :incompatible, -> { where(incompatible: true) }
|
||||
scope :winners, -> { selected.compatible.where(winner: true) }
|
||||
scope :unselected, -> { not_unfeasible.where(selected: false) }
|
||||
scope :last_week, -> { where("created_at >= ?", 7.days.ago) }
|
||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :sort_by_created_at, -> { reorder(created_at: :desc) }
|
||||
|
||||
scope :by_budget, ->(budget) { where(budget: budget) }
|
||||
scope :by_group, ->(group_id) { where(group_id: group_id) }
|
||||
scope :by_heading, ->(heading_id) { where(heading_id: heading_id) }
|
||||
scope :by_admin, ->(admin_id) { where(administrator_id: admin_id) }
|
||||
scope :by_tag, ->(tag_name) { tagged_with(tag_name).distinct }
|
||||
scope :visible_to_valuator, ->(valuator) { visible_to_valuators.where(id: valuator&.assigned_investment_ids) }
|
||||
scope :with_supports, -> { where("cached_votes_up > 0") }
|
||||
scope :selected, -> { feasible.where(selected: true) }
|
||||
scope :compatible, -> { where(incompatible: false) }
|
||||
scope :incompatible, -> { where(incompatible: true) }
|
||||
scope :winners, -> { selected.compatible.where(winner: true) }
|
||||
scope :unselected, -> { not_unfeasible.where(selected: false) }
|
||||
scope :last_week, -> { where("created_at >= ?", 7.days.ago) }
|
||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :sort_by_created_at, -> { reorder(created_at: :desc) }
|
||||
|
||||
scope :by_budget, ->(budget) { where(budget: budget) }
|
||||
scope :by_group, ->(group_id) { where(group_id: group_id) }
|
||||
scope :by_heading, ->(heading_id) { where(heading_id: heading_id) }
|
||||
scope :by_admin, ->(admin_id) { where(administrator_id: admin_id) }
|
||||
scope :by_tag, ->(tag_name) { tagged_with(tag_name).distinct }
|
||||
scope :visible_to_valuator, ->(valuator) do
|
||||
visible_to_valuators.where(id: valuator&.assigned_investment_ids)
|
||||
end
|
||||
|
||||
scope :for_render, -> { includes(:heading) }
|
||||
|
||||
@@ -135,21 +142,25 @@ class Budget
|
||||
budget = Budget.find_by_slug_or_id params[:budget_id]
|
||||
results = Investment.by_budget(budget)
|
||||
|
||||
results = results.where("cached_votes_up + physical_votes >= ?",
|
||||
params[:min_total_supports]) if params[:min_total_supports].present?
|
||||
results = results.where("cached_votes_up + physical_votes <= ?",
|
||||
params[:max_total_supports]) if params[:max_total_supports].present?
|
||||
results = results.where(group_id: params[:group_id]) if params[:group_id].present?
|
||||
results = results.by_tag(params[:tag_name]) if params[:tag_name].present?
|
||||
results = results.by_tag(params[:milestone_tag_name]) if params[:milestone_tag_name].present?
|
||||
results = results.by_heading(params[:heading_id]) if params[:heading_id].present?
|
||||
results = results.by_valuator(params[:valuator_id]) if params[:valuator_id].present?
|
||||
results = results.by_valuator_group(params[:valuator_group_id]) if params[:valuator_group_id].present?
|
||||
results = results.by_admin(params[:administrator_id]) if params[:administrator_id].present?
|
||||
results = results.search_by_title_or_id(params[:title_or_id].strip) if params[:title_or_id]
|
||||
results = advanced_filters(params, results) if params[:advanced_filters].present?
|
||||
if params[:min_total_supports].present?
|
||||
results = results.where("cached_votes_up + physical_votes >= ?", params[:min_total_supports])
|
||||
end
|
||||
if params[:max_total_supports].present?
|
||||
results = results.where("cached_votes_up + physical_votes <= ?", params[:max_total_supports])
|
||||
end
|
||||
|
||||
results = results.where(group_id: params[:group_id]) if params[:group_id].present?
|
||||
results = results.by_heading(params[:heading_id]) if params[:heading_id].present?
|
||||
results = results.by_tag(params[:tag_name]) if params[:tag_name].present?
|
||||
results = results.by_tag(params[:milestone_tag_name]) if params[:milestone_tag_name].present?
|
||||
results = results.by_valuator(params[:valuator_id]) if params[:valuator_id].present?
|
||||
results = results.by_valuator_group(params[:valuator_group_id]) if params[:valuator_group_id].present?
|
||||
results = results.by_admin(params[:administrator_id]) if params[:administrator_id].present?
|
||||
|
||||
results = results.search_by_title_or_id(params[:title_or_id].strip) if params[:title_or_id]
|
||||
results = advanced_filters(params, results) if params[:advanced_filters].present?
|
||||
results = results.send(current_filter) if current_filter.present?
|
||||
|
||||
results.includes(:heading, :group, :budget, administrator: :user, valuators: :user)
|
||||
end
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@ 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_date_range, ->(date_range) { where(created_at: date_range) }
|
||||
scope :by_official_level, ->(official_level) do
|
||||
where(users: { official_level: official_level }).joins(:author)
|
||||
end
|
||||
end
|
||||
|
||||
class_methods do
|
||||
|
||||
@@ -83,9 +83,10 @@ module Globalizable
|
||||
def validates_translation(method, options = {})
|
||||
validates(method, options.merge(if: lambda { |resource| resource.translations.blank? }))
|
||||
if options.include?(:length)
|
||||
lenght_validate = { length: options[:length] }
|
||||
translation_class.instance_eval do
|
||||
validates method, lenght_validate.merge(if: lambda { |translation| translation.locale == I18n.default_locale })
|
||||
validates method,
|
||||
length: options[:length],
|
||||
if: lambda { |translation| translation.locale == I18n.default_locale }
|
||||
end
|
||||
if options.count > 1
|
||||
translation_class.instance_eval do
|
||||
@@ -112,7 +113,9 @@ module Globalizable
|
||||
translations_ids = translation_class
|
||||
.select("DISTINCT ON (#{translations_foreign_key}) id")
|
||||
.where(locale: fallbacks)
|
||||
.joins("LEFT JOIN (VALUES #{fallbacks_with_order}) AS locales(name, ordering) ON locale = locales.name")
|
||||
.joins("LEFT JOIN (VALUES #{fallbacks_with_order}) " \
|
||||
"AS locales(name, ordering) " \
|
||||
"ON locale = locales.name")
|
||||
.order(translations_foreign_key, "locales.ordering")
|
||||
|
||||
with_translations(fallbacks).where("#{translations_table_name}.id": translations_ids)
|
||||
|
||||
@@ -3,11 +3,23 @@ module Verification
|
||||
|
||||
included do
|
||||
scope :residence_verified, -> { where.not(residence_verified_at: nil) }
|
||||
scope :residence_unverified, -> { where(residence_verified_at: nil) }
|
||||
scope :residence_and_phone_verified, -> { residence_verified.where.not(confirmed_phone: nil) }
|
||||
scope :residence_or_phone_unverified, -> { residence_unverified.or(where(confirmed_phone: nil)) }
|
||||
scope :phone_not_fully_confirmed, -> { where(unconfirmed_phone: nil).or(where(confirmed_phone: nil)) }
|
||||
|
||||
scope :level_three_verified, -> { where.not(verified_at: nil) }
|
||||
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 :level_two_verified, -> do
|
||||
where.not(level_two_verified_at: nil).or(residence_and_phone_verified.where(verified_at: nil))
|
||||
end
|
||||
scope :level_two_or_three_verified, -> { level_two_verified.or(level_three_verified) }
|
||||
scope :unverified, -> do
|
||||
residence_or_phone_unverified.where(verified_at: nil, level_two_verified_at: nil)
|
||||
end
|
||||
scope :incomplete_verification, -> do
|
||||
residence_unverified.where("failed_census_calls_count > ?", 0)
|
||||
.or(residence_verified.phone_not_fully_confirmed)
|
||||
end
|
||||
end
|
||||
|
||||
def skip_verification?
|
||||
|
||||
@@ -107,8 +107,13 @@ class Debate < ApplicationRecord
|
||||
|
||||
def register_vote(user, vote_value)
|
||||
if votable_by?(user)
|
||||
Debate.increment_counter(:cached_anonymous_votes_total, id) if user.unverified? && !user.voted_for?(self)
|
||||
vote_by(voter: user, vote: vote_value)
|
||||
transaction do
|
||||
if user.unverified? && !user.voted_for?(self)
|
||||
Debate.increment_counter(:cached_anonymous_votes_total, id)
|
||||
end
|
||||
|
||||
vote_by(voter: user, vote: vote_value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -155,7 +160,11 @@ class Debate < ApplicationRecord
|
||||
|
||||
def self.debates_orders(user)
|
||||
orders = %w[hot_score confidence_score created_at relevance]
|
||||
orders << "recommendations" if Setting["feature.user.recommendations_on_debates"] && user&.recommended_debates
|
||||
|
||||
if Setting["feature.user.recommendations_on_debates"] && user&.recommended_debates
|
||||
orders << "recommendations"
|
||||
end
|
||||
|
||||
orders
|
||||
end
|
||||
|
||||
|
||||
@@ -9,19 +9,22 @@ class DirectUpload
|
||||
|
||||
validates :attachment, :resource_type, :resource_relation, :user, presence: true
|
||||
validate :parent_resource_attachment_validations,
|
||||
if: -> { attachment.present? && resource_type.present? && resource_relation.present? && user.present? }
|
||||
if: -> { [attachment, resource_type, resource_relation, user].all?(&:present?) }
|
||||
|
||||
def initialize(attributes = {})
|
||||
attributes.each do |name, value|
|
||||
send("#{name}=", value)
|
||||
end
|
||||
|
||||
if @resource_type.present? && @resource_relation.present? && (@attachment.present? || @cached_attachment.present?)
|
||||
if @resource_type.present? &&
|
||||
@resource_relation.present? &&
|
||||
(@attachment.present? || @cached_attachment.present?)
|
||||
@resource = @resource_type.constantize.find_or_initialize_by(id: @resource_id)
|
||||
|
||||
# Refactor
|
||||
@relation = if @resource.respond_to?(:images) &&
|
||||
((@attachment.present? && !@attachment.content_type.match(/pdf/)) || @cached_attachment.present?)
|
||||
(@attachment.present? && !@attachment.content_type.match(/pdf/) ||
|
||||
@cached_attachment.present?)
|
||||
@resource.images.send(:build, relation_attributtes)
|
||||
elsif @resource.class.reflections[@resource_relation].macro == :has_one
|
||||
@resource.send("build_#{resource_relation}", relation_attributtes)
|
||||
|
||||
@@ -10,12 +10,19 @@ class Legislation::Question < ApplicationRecord
|
||||
belongs_to :author, -> { with_hidden }, class_name: "User", inverse_of: :legislation_questions
|
||||
belongs_to :process, foreign_key: "legislation_process_id", inverse_of: :questions
|
||||
|
||||
has_many :question_options, -> { order(:id) }, class_name: "Legislation::QuestionOption", foreign_key: "legislation_question_id",
|
||||
dependent: :destroy, inverse_of: :question
|
||||
has_many :answers, class_name: "Legislation::Answer", foreign_key: "legislation_question_id", dependent: :destroy, inverse_of: :question
|
||||
has_many :question_options, -> { order(:id) }, class_name: "Legislation::QuestionOption",
|
||||
foreign_key: "legislation_question_id",
|
||||
dependent: :destroy,
|
||||
inverse_of: :question
|
||||
has_many :answers, class_name: "Legislation::Answer",
|
||||
foreign_key: "legislation_question_id",
|
||||
dependent: :destroy,
|
||||
inverse_of: :question
|
||||
has_many :comments, as: :commentable, inverse_of: :commentable, dependent: :destroy
|
||||
|
||||
accepts_nested_attributes_for :question_options, reject_if: proc { |attributes| attributes.all? { |k, v| v.blank? } }, allow_destroy: true
|
||||
accepts_nested_attributes_for :question_options,
|
||||
reject_if: proc { |attributes| attributes.all? { |k, v| v.blank? } },
|
||||
allow_destroy: true
|
||||
|
||||
validates :process, presence: true
|
||||
validates_translation :title, presence: true
|
||||
|
||||
@@ -22,13 +22,15 @@ class MachineLearning
|
||||
|
||||
return unless run_machine_learning_scripts
|
||||
|
||||
if updated_file?(MachineLearning.proposals_taggings_filename) && updated_file?(MachineLearning.proposals_tags_filename)
|
||||
if updated_file?(MachineLearning.proposals_taggings_filename) &&
|
||||
updated_file?(MachineLearning.proposals_tags_filename)
|
||||
cleanup_proposals_tags!
|
||||
import_ml_proposals_tags
|
||||
update_machine_learning_info_for("tags")
|
||||
end
|
||||
|
||||
if updated_file?(MachineLearning.investments_taggings_filename) && updated_file?(MachineLearning.investments_tags_filename)
|
||||
if updated_file?(MachineLearning.investments_taggings_filename) &&
|
||||
updated_file?(MachineLearning.investments_tags_filename)
|
||||
cleanup_investments_tags!
|
||||
import_ml_investments_tags
|
||||
update_machine_learning_info_for("tags")
|
||||
@@ -95,14 +97,32 @@ class MachineLearning
|
||||
def data_output_files
|
||||
files = { tags: [], related_content: [], comments_summary: [] }
|
||||
|
||||
files[:tags] << proposals_tags_filename if File.exist?(data_folder.join(proposals_tags_filename))
|
||||
files[:tags] << proposals_taggings_filename if File.exist?(data_folder.join(proposals_taggings_filename))
|
||||
files[:tags] << investments_tags_filename if File.exist?(data_folder.join(investments_tags_filename))
|
||||
files[:tags] << investments_taggings_filename if File.exist?(data_folder.join(investments_taggings_filename))
|
||||
files[:related_content] << proposals_related_filename if File.exist?(data_folder.join(proposals_related_filename))
|
||||
files[:related_content] << investments_related_filename if File.exist?(data_folder.join(investments_related_filename))
|
||||
files[:comments_summary] << proposals_comments_summary_filename if File.exist?(data_folder.join(proposals_comments_summary_filename))
|
||||
files[:comments_summary] << investments_comments_summary_filename if File.exist?(data_folder.join(investments_comments_summary_filename))
|
||||
if File.exist?(data_folder.join(proposals_tags_filename))
|
||||
files[:tags] << proposals_tags_filename
|
||||
end
|
||||
if File.exist?(data_folder.join(proposals_taggings_filename))
|
||||
files[:tags] << proposals_taggings_filename
|
||||
end
|
||||
if File.exist?(data_folder.join(investments_tags_filename))
|
||||
files[:tags] << investments_tags_filename
|
||||
end
|
||||
if File.exist?(data_folder.join(investments_taggings_filename))
|
||||
files[:tags] << investments_taggings_filename
|
||||
end
|
||||
|
||||
if File.exist?(data_folder.join(proposals_related_filename))
|
||||
files[:related_content] << proposals_related_filename
|
||||
end
|
||||
if File.exist?(data_folder.join(investments_related_filename))
|
||||
files[:related_content] << investments_related_filename
|
||||
end
|
||||
|
||||
if File.exist?(data_folder.join(proposals_comments_summary_filename))
|
||||
files[:comments_summary] << proposals_comments_summary_filename
|
||||
end
|
||||
if File.exist?(data_folder.join(investments_comments_summary_filename))
|
||||
files[:comments_summary] << investments_comments_summary_filename
|
||||
end
|
||||
|
||||
files
|
||||
end
|
||||
|
||||
@@ -12,8 +12,13 @@ class Organization < ApplicationRecord
|
||||
delegate :email, :phone_number, to: :user
|
||||
|
||||
scope :pending, -> { where(verified_at: nil, rejected_at: nil) }
|
||||
scope :verified, -> { where.not(verified_at: nil).where("(rejected_at IS NULL or rejected_at < organizations.verified_at)") }
|
||||
scope :rejected, -> { where.not(rejected_at: nil).where("(organizations.verified_at IS NULL or organizations.verified_at < rejected_at)") }
|
||||
scope :verified, -> do
|
||||
where.not(verified_at: nil).where("(rejected_at IS NULL or rejected_at < organizations.verified_at)")
|
||||
end
|
||||
scope :rejected, -> do
|
||||
where.not(rejected_at: nil)
|
||||
.where("(organizations.verified_at IS NULL or organizations.verified_at < rejected_at)")
|
||||
end
|
||||
|
||||
def verify
|
||||
update(verified_at: Time.current)
|
||||
@@ -33,7 +38,8 @@ class Organization < ApplicationRecord
|
||||
|
||||
def self.search(text)
|
||||
if text.present?
|
||||
joins(:user).where("users.email = ? OR users.phone_number = ? OR organizations.name ILIKE ?", text, text, "%#{text}%")
|
||||
joins(:user).where("users.email = ? OR users.phone_number = ? OR organizations.name ILIKE ?",
|
||||
text, text, "%#{text}%")
|
||||
else
|
||||
none
|
||||
end
|
||||
|
||||
@@ -57,7 +57,8 @@ class Poll < ApplicationRecord
|
||||
|
||||
def self.sort_for_list(user = nil)
|
||||
all.sort do |poll, another_poll|
|
||||
[poll.weight(user), poll.starts_at, poll.name] <=> [another_poll.weight(user), another_poll.starts_at, another_poll.name]
|
||||
[poll.weight(user), poll.starts_at, poll.name] <=>
|
||||
[another_poll.weight(user), another_poll.starts_at, another_poll.name]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -181,6 +182,11 @@ class Poll < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def geozone_restricted_to=(geozones)
|
||||
self.geozone_restricted = true
|
||||
self.geozones = geozones
|
||||
end
|
||||
|
||||
def generate_slug?
|
||||
slug.nil?
|
||||
end
|
||||
|
||||
@@ -24,7 +24,9 @@ class Poll
|
||||
private
|
||||
|
||||
def shifts
|
||||
Poll::Shift.where(booth_id: booth_id, officer_id: officer_assignments.pluck(:officer_id), date: officer_assignments.pluck(:date))
|
||||
Poll::Shift.where(booth_id: booth_id,
|
||||
officer_id: officer_assignments.pluck(:officer_id),
|
||||
date: officer_assignments.pluck(:date))
|
||||
end
|
||||
|
||||
def destroy_poll_shifts
|
||||
|
||||
@@ -19,8 +19,8 @@ class Poll
|
||||
where("officer_id = ? AND poll_booth_assignments.poll_id = ?", officer_id, poll_id)
|
||||
end
|
||||
scope :by_officer, ->(officer) { where(officer_id: officer.id) }
|
||||
scope :by_poll, ->(poll) { joins(:booth_assignment).where("poll_booth_assignments.poll_id" => poll.id) }
|
||||
scope :by_booth, ->(booth) { joins(:booth_assignment).where("poll_booth_assignments.booth_id" => booth.id) }
|
||||
scope :by_poll, ->(poll) { joins(:booth_assignment).where("poll_booth_assignments.poll_id": poll.id) }
|
||||
scope :by_booth, ->(booth) { joins(:booth_assignment).where("poll_booth_assignments.booth_id": booth.id) }
|
||||
scope :by_date, ->(date) { where(date: date) }
|
||||
|
||||
before_create :log_user_data
|
||||
|
||||
@@ -20,7 +20,9 @@ class Poll::Recount < ApplicationRecord
|
||||
amounts_changed = false
|
||||
|
||||
[:white, :null, :total].each do |amount|
|
||||
next unless send("will_save_change_to_#{amount}_amount?") && send("#{amount}_amount_in_database").present?
|
||||
unless send("will_save_change_to_#{amount}_amount?") && send("#{amount}_amount_in_database").present?
|
||||
next
|
||||
end
|
||||
|
||||
self["#{amount}_amount_log"] += ":#{send("#{amount}_amount_in_database")}"
|
||||
amounts_changed = true
|
||||
|
||||
@@ -16,7 +16,10 @@ class ProgressBar < ApplicationRecord
|
||||
scope: [:progressable_type, :progressable_id],
|
||||
conditions: -> { primary }
|
||||
}
|
||||
validates :percentage, presence: true, inclusion: { in: ->(*) { RANGE }}, numericality: { only_integer: true }
|
||||
validates :percentage,
|
||||
presence: true,
|
||||
inclusion: { in: ->(*) { RANGE }},
|
||||
numericality: { only_integer: true }
|
||||
|
||||
validates_translation :title, presence: true, unless: :primary?
|
||||
end
|
||||
|
||||
@@ -50,8 +50,12 @@ class Proposal < ApplicationRecord
|
||||
validates :author, presence: true
|
||||
validates :responsible_name, presence: true, unless: :skip_user_verification?
|
||||
|
||||
validates :responsible_name, length: { in: 6..Proposal.responsible_name_max_length }, unless: :skip_user_verification?
|
||||
validates :retired_reason, presence: true, inclusion: { in: ->(*) { RETIRE_OPTIONS }}, unless: -> { retired_at.blank? }
|
||||
validates :responsible_name,
|
||||
length: { in: 6..Proposal.responsible_name_max_length },
|
||||
unless: :skip_user_verification?
|
||||
validates :retired_reason,
|
||||
presence: true,
|
||||
inclusion: { in: ->(*) { RETIRE_OPTIONS }}, unless: -> { retired_at.blank? }
|
||||
|
||||
validates :terms_of_service, acceptance: { allow_nil: false }, on: :create
|
||||
|
||||
@@ -72,20 +76,22 @@ class Proposal < ApplicationRecord
|
||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :sort_by_archival_date, -> { archived.sort_by_confidence_score }
|
||||
scope :sort_by_recommendations, -> { order(cached_votes_up: :desc) }
|
||||
scope :archived, -> { where("proposals.created_at <= ?", Setting["months_to_archive_proposals"].to_i.months.ago) }
|
||||
scope :not_archived, -> { where("proposals.created_at > ?", Setting["months_to_archive_proposals"].to_i.months.ago) }
|
||||
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago) }
|
||||
scope :retired, -> { where.not(retired_at: nil) }
|
||||
scope :not_retired, -> { where(retired_at: nil) }
|
||||
scope :successful, -> { where("cached_votes_up >= ?", Proposal.votes_needed_for_success) }
|
||||
scope :unsuccessful, -> { where("cached_votes_up < ?", Proposal.votes_needed_for_success) }
|
||||
scope :public_for_api, -> { all }
|
||||
scope :selected, -> { where(selected: true) }
|
||||
scope :not_selected, -> { where(selected: false) }
|
||||
scope :not_supported_by_user, ->(user) { where.not(id: user.find_voted_items(votable_type: "Proposal").compact.map(&:id)) }
|
||||
scope :published, -> { where.not(published_at: nil) }
|
||||
scope :draft, -> { where(published_at: nil) }
|
||||
scope :created_by, ->(author) { where(author: author) }
|
||||
|
||||
scope :archived, -> { where("proposals.created_at <= ?", Setting.archived_proposals_date_limit) }
|
||||
scope :not_archived, -> { where("proposals.created_at > ?", Setting.archived_proposals_date_limit) }
|
||||
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago) }
|
||||
scope :retired, -> { where.not(retired_at: nil) }
|
||||
scope :not_retired, -> { where(retired_at: nil) }
|
||||
scope :successful, -> { where("cached_votes_up >= ?", Proposal.votes_needed_for_success) }
|
||||
scope :unsuccessful, -> { where("cached_votes_up < ?", Proposal.votes_needed_for_success) }
|
||||
scope :public_for_api, -> { all }
|
||||
scope :selected, -> { where(selected: true) }
|
||||
scope :not_selected, -> { where(selected: false) }
|
||||
scope :published, -> { where.not(published_at: nil) }
|
||||
scope :draft, -> { where(published_at: nil) }
|
||||
|
||||
scope :not_supported_by_user, ->(user) { where.not(id: user.find_voted_items(votable_type: "Proposal")) }
|
||||
scope :created_by, ->(author) { where(author: author) }
|
||||
|
||||
def publish
|
||||
update!(published_at: Time.current)
|
||||
@@ -221,7 +227,7 @@ class Proposal < ApplicationRecord
|
||||
end
|
||||
|
||||
def archived?
|
||||
created_at <= Setting["months_to_archive_proposals"].to_i.months.ago
|
||||
created_at <= Setting.archived_proposals_date_limit
|
||||
end
|
||||
|
||||
def notifications
|
||||
@@ -234,7 +240,11 @@ class Proposal < ApplicationRecord
|
||||
|
||||
def self.proposals_orders(user)
|
||||
orders = %w[hot_score confidence_score created_at relevance archival_date]
|
||||
orders << "recommendations" if Setting["feature.user.recommendations_on_proposals"] && user&.recommended_proposals
|
||||
|
||||
if Setting["feature.user.recommendations_on_proposals"] && user&.recommended_proposals
|
||||
orders << "recommendations"
|
||||
end
|
||||
|
||||
orders
|
||||
end
|
||||
|
||||
|
||||
@@ -31,7 +31,11 @@ class ProposalNotification < ApplicationRecord
|
||||
interval = Setting[:proposal_notification_minimum_interval_in_days]
|
||||
minimum_interval = (Time.current - interval.to_i.days).to_datetime
|
||||
if proposal.notifications.last.created_at > minimum_interval
|
||||
errors.add(:title, I18n.t("activerecord.errors.models.proposal_notification.attributes.minimum_interval.invalid", interval: interval))
|
||||
errors.add(
|
||||
:title,
|
||||
I18n.t("activerecord.errors.models.proposal_notification.attributes.minimum_interval.invalid",
|
||||
interval: interval)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -11,7 +11,10 @@ class RelatedContent < ApplicationRecord
|
||||
has_one :opposite_related_content, class_name: name, foreign_key: :related_content_id
|
||||
has_many :related_content_scores, dependent: :destroy
|
||||
|
||||
validates :parent_relationable_id, uniqueness: { scope: [:parent_relationable_type, :child_relationable_id, :child_relationable_type] }
|
||||
validates :parent_relationable_id,
|
||||
uniqueness: {
|
||||
scope: [:parent_relationable_type, :child_relationable_id, :child_relationable_type]
|
||||
}
|
||||
validate :different_parent_and_child
|
||||
|
||||
after_create :create_opposite_related_content, unless: proc { opposite_related_content.present? }
|
||||
@@ -66,7 +69,10 @@ class RelatedContent < ApplicationRecord
|
||||
|
||||
def score(value, user)
|
||||
score_with_opposite(value, user)
|
||||
hide_with_opposite if (related_content_scores.sum(:value) / related_content_scores_count) < RELATED_CONTENT_SCORE_THRESHOLD
|
||||
|
||||
if (related_content_scores.sum(:value) / related_content_scores_count) < RELATED_CONTENT_SCORE_THRESHOLD
|
||||
hide_with_opposite
|
||||
end
|
||||
end
|
||||
|
||||
def hide_with_opposite
|
||||
|
||||
@@ -4,7 +4,7 @@ class RemoteTranslation < ApplicationRecord
|
||||
validates :remote_translatable_id, presence: true
|
||||
validates :remote_translatable_type, presence: true
|
||||
validates :locale, presence: true
|
||||
validates :locale, inclusion: { in: ->(_) { RemoteTranslations::Microsoft::AvailableLocales.available_locales }}
|
||||
validates :locale, inclusion: { in: ->(_) { RemoteTranslations::Microsoft::AvailableLocales.locales }}
|
||||
validate :already_translated_resource
|
||||
after_create :enqueue_remote_translation
|
||||
|
||||
|
||||
@@ -229,5 +229,9 @@ class Setting < ApplicationRecord
|
||||
Setting["feature.remote_census"].present? &&
|
||||
Setting["remote_census.request.postal_code"].present?
|
||||
end
|
||||
|
||||
def archived_proposals_date_limit
|
||||
Setting["months_to_archive_proposals"].to_i.months.ago
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -28,7 +28,9 @@ class Signature < ApplicationRecord
|
||||
def assign_vote_to_user
|
||||
set_user
|
||||
if signable.is_a? Budget::Investment
|
||||
signable.vote_by(voter: user, vote: "yes") if [nil, :no_selecting_allowed].include?(signable.reason_for_not_being_selectable_by(user))
|
||||
if [nil, :no_selecting_allowed].include?(signable.reason_for_not_being_selectable_by(user))
|
||||
signable.vote_by(voter: user, vote: "yes")
|
||||
end
|
||||
else
|
||||
signable.register_vote(user, "yes")
|
||||
end
|
||||
|
||||
@@ -53,10 +53,12 @@ class Verification::Management::Email
|
||||
return if errors.count > 0
|
||||
|
||||
if document_number_mismatch?
|
||||
errors.add(:email,
|
||||
I18n.t("management.email_verifications.document_mismatch",
|
||||
document_type: ApplicationController.helpers.humanize_document_type(user.document_type),
|
||||
document_number: user.document_number))
|
||||
errors.add(
|
||||
:email,
|
||||
I18n.t("management.email_verifications.document_mismatch",
|
||||
document_type: ApplicationController.helpers.humanize_document_type(user.document_type),
|
||||
document_number: user.document_number)
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -48,7 +48,9 @@ class Verification::Residence
|
||||
end
|
||||
|
||||
def document_number_uniqueness
|
||||
errors.add(:document_number, I18n.t("errors.messages.taken")) if User.active.where(document_number: document_number).any?
|
||||
if User.active.where(document_number: document_number).any?
|
||||
errors.add(:document_number, I18n.t("errors.messages.taken"))
|
||||
end
|
||||
end
|
||||
|
||||
def store_failed_attempt
|
||||
@@ -74,7 +76,8 @@ class Verification::Residence
|
||||
end
|
||||
|
||||
def local_postal_code
|
||||
errors.add(:postal_code, I18n.t("verification.residence.new.error_not_allowed_postal_code")) unless valid_postal_code?
|
||||
errors.add(:postal_code,
|
||||
I18n.t("verification.residence.new.error_not_allowed_postal_code")) unless valid_postal_code?
|
||||
end
|
||||
|
||||
def local_residence
|
||||
|
||||
@@ -4,11 +4,19 @@ xlsx_package.workbook.add_worksheet(name: "Summary") do |sheet|
|
||||
link = styles.add_style(fg_color: "0000FF", u: true)
|
||||
|
||||
if @process.debate_phase.enabled? && @process.questions.any?
|
||||
sheet.add_row [t("legislation.summary.debate_phase"), t("legislation.summary.debates", count: @process.questions.count)], style: title
|
||||
sheet.add_row(
|
||||
[
|
||||
t("legislation.summary.debate_phase"),
|
||||
t("legislation.summary.debates", count: @process.questions.count)
|
||||
],
|
||||
style: title
|
||||
)
|
||||
@process.questions.each do |question|
|
||||
sheet.add_row [question.title, t("shared.comments", count: question.comments.count)], style: link
|
||||
sheet.add_hyperlink location: legislation_process_question_url(question.process, question), ref: sheet.rows.last.cells.first
|
||||
sheet.add_hyperlink location: polymorphic_url(question, anchor: "comments"), ref: sheet.rows.last.cells.last
|
||||
sheet.add_hyperlink location: legislation_process_question_url(question.process, question),
|
||||
ref: sheet.rows.last.cells.first
|
||||
sheet.add_hyperlink location: polymorphic_url(question, anchor: "comments"),
|
||||
ref: sheet.rows.last.cells.last
|
||||
sheet.add_row [t("legislation.summary.most_voted_comments")] if question.best_comments.any?
|
||||
question.best_comments.each do |comment|
|
||||
sheet.add_row [comment.body, t("legislation.summary.votes", count: comment.votes_score)]
|
||||
@@ -20,22 +28,37 @@ xlsx_package.workbook.add_worksheet(name: "Summary") do |sheet|
|
||||
end
|
||||
|
||||
if @process.proposals_phase.enabled? && @proposals.any?
|
||||
sheet.add_row [t("legislation.summary.proposals_phase"), t("legislation.summary.proposals", count: @proposals.count)], style: title
|
||||
sheet.add_row(
|
||||
[
|
||||
t("legislation.summary.proposals_phase"),
|
||||
t("legislation.summary.proposals", count: @proposals.count)
|
||||
],
|
||||
style: title
|
||||
)
|
||||
@proposals.sort_by_supports.each do |proposal|
|
||||
sheet.add_row [proposal.title, t("legislation.summary.votes", count: proposal.votes_score)]
|
||||
sheet.add_hyperlink location: legislation_process_proposal_url(proposal.legislation_process_id, proposal), ref: sheet.rows.last.cells.first
|
||||
sheet.add_hyperlink(
|
||||
location: legislation_process_proposal_url(proposal.legislation_process_id, proposal),
|
||||
ref: sheet.rows.last.cells.first
|
||||
)
|
||||
sheet.rows.last.cells.first.style = link
|
||||
end
|
||||
sheet.add_row ["", ""]
|
||||
end
|
||||
|
||||
if @process.allegations_phase.enabled? && @comments.any?
|
||||
sheet.add_row [t("legislation.summary.allegations_phase"),
|
||||
t("legislation.summary.top_comments", count: @comments.count)], style: title
|
||||
sheet.add_row(
|
||||
[
|
||||
t("legislation.summary.allegations_phase"),
|
||||
t("legislation.summary.top_comments", count: @comments.count)
|
||||
],
|
||||
style: title
|
||||
)
|
||||
@comments.group_by(&:commentable).each do |annotation, annotation_comments|
|
||||
sheet.add_row [t("legislation.annotations.index.comments_about")]
|
||||
sheet.add_row [annotation.quote, t("shared.comments", count: annotation.comments.count)]
|
||||
sheet.add_hyperlink location: polymorphic_url(annotation, anchor: "comments"), ref: sheet.rows.last.cells.last
|
||||
sheet.add_hyperlink location: polymorphic_url(annotation, anchor: "comments"),
|
||||
ref: sheet.rows.last.cells.last
|
||||
sheet.rows.last.cells.last.style = link
|
||||
|
||||
annotation_comments.each do |comment|
|
||||
|
||||
@@ -30,7 +30,8 @@ set :pty, true
|
||||
set :use_sudo, false
|
||||
|
||||
set :linked_files, %w[config/database.yml config/secrets.yml]
|
||||
set :linked_dirs, %w[.bundle log tmp public/system public/assets public/ckeditor_assets public/machine_learning/data storage]
|
||||
set :linked_dirs, %w[.bundle log tmp public/system public/assets
|
||||
public/ckeditor_assets public/machine_learning/data storage]
|
||||
|
||||
set :keep_releases, 5
|
||||
|
||||
|
||||
@@ -99,7 +99,8 @@ Apartment.configure do |config|
|
||||
#
|
||||
# config.pg_excluded_names = ["uuid_generate_v4"]
|
||||
|
||||
# Specifies whether the database and schema (when using PostgreSQL schemas) will prepend in ActiveRecord log.
|
||||
# Specifies whether the database and schema (when using PostgreSQL schemas)
|
||||
# will prepend in ActiveRecord log.
|
||||
# Uncomment the line below if you want to enable this behavior.
|
||||
#
|
||||
# config.active_record_log = true
|
||||
@@ -107,9 +108,9 @@ end
|
||||
|
||||
# Setup a custom Tenant switching middleware. The Proc should return the name of the Tenant that
|
||||
# you want to switch to.
|
||||
Rails.application.config.middleware.insert_before Warden::Manager, Apartment::Elevators::Generic, ->(request) do
|
||||
Tenant.resolve_host(request.host)
|
||||
end
|
||||
Rails.application.config.middleware.insert_before Warden::Manager,
|
||||
Apartment::Elevators::Generic,
|
||||
->(request) { Tenant.resolve_host(request.host) }
|
||||
|
||||
# Rails.application.config.middleware.use Apartment::Elevators::Domain
|
||||
# Rails.application.config.middleware.use Apartment::Elevators::Subdomain
|
||||
|
||||
@@ -63,7 +63,11 @@ module Devise
|
||||
if !new_record? && !encrypted_password_change.nil? && !erased?
|
||||
dummy = self.class.new
|
||||
dummy.encrypted_password = encrypted_password_change.first
|
||||
dummy.password_salt = password_salt_change.first if respond_to?(:password_salt_change) && !password_salt_change.nil?
|
||||
|
||||
if respond_to?(:password_salt_change) && !password_salt_change.nil?
|
||||
dummy.password_salt = password_salt_change.first
|
||||
end
|
||||
|
||||
errors.add(:password, :equal_to_current_password) if dummy.valid_password?(password)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,6 +8,10 @@ ActsAsVotable::Vote.class_eval do
|
||||
where(votable: [Debate.public_for_api, Proposal.public_for_api, Comment.public_for_api])
|
||||
end
|
||||
|
||||
def self.count_for(votable_type)
|
||||
where(votable_type: votable_type).count
|
||||
end
|
||||
|
||||
def value
|
||||
vote_flag
|
||||
end
|
||||
|
||||
@@ -253,9 +253,12 @@ namespace :admin do
|
||||
end
|
||||
resources :images, only: [:index, :update, :destroy]
|
||||
resources :content_blocks, except: [:show]
|
||||
delete "/heading_content_blocks/:id", to: "content_blocks#delete_heading_content_block", as: "delete_heading_content_block"
|
||||
get "/edit_heading_content_blocks/:id", to: "content_blocks#edit_heading_content_block", as: "edit_heading_content_block"
|
||||
put "/update_heading_content_blocks/:id", to: "content_blocks#update_heading_content_block", as: "update_heading_content_block"
|
||||
delete "/heading_content_blocks/:id", to: "content_blocks#delete_heading_content_block",
|
||||
as: "delete_heading_content_block"
|
||||
get "/edit_heading_content_blocks/:id", to: "content_blocks#edit_heading_content_block",
|
||||
as: "edit_heading_content_block"
|
||||
put "/update_heading_content_blocks/:id", to: "content_blocks#update_heading_content_block",
|
||||
as: "update_heading_content_block"
|
||||
resources :information_texts, only: [:index] do
|
||||
post :update, on: :collection
|
||||
end
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace :management do
|
||||
get :print_investments
|
||||
end
|
||||
|
||||
resources :investments, only: [:index, :new, :create, :show, :destroy], controller: "budgets/investments" do
|
||||
resources :investments, only: [:index, :new, :create, :show], controller: "budgets/investments" do
|
||||
get :print, on: :collection
|
||||
|
||||
resources :votes, controller: "budgets/investments/votes", only: [:create, :destroy]
|
||||
|
||||
@@ -2,23 +2,28 @@ section "Creating Geozones" do
|
||||
Geozone.create!(name: I18n.t("seeds.geozones.north_district"),
|
||||
external_code: "001", census_code: "01",
|
||||
html_map_coordinates: "30,139,45,153,77,148,107,165,138,201,146,218,186,198,216," \
|
||||
"196,233,203,240,215,283,194,329,185,377,184,388,165,369,126,333,113,334,84,320," \
|
||||
"66,286,73,258,65,265,57,249,47,207,58,159,84,108,85,72,101,51,114")
|
||||
"196,233,203,240,215,283,194,329,185,377,184,388,165,369," \
|
||||
"126,333,113,334,84,320,66,286,73,258,65,265,57,249,47," \
|
||||
"207,58,159,84,108,85,72,101,51,114")
|
||||
Geozone.create!(name: I18n.t("seeds.geozones.west_district"),
|
||||
external_code: "002", census_code: "02",
|
||||
html_map_coordinates: "42,153,31,176,24,202,20,221,44,235,59,249,55,320,30,354," \
|
||||
"31,372,52,396,64,432,89,453,116,432,149,419,162,412,165,377,172,357,189,352,228," \
|
||||
"327,246,313,262,297,234,291,210,284,193,284,176,294,158,303,154,310,146,289,140," \
|
||||
"268,138,246,135,236,139,222,151,214,136,197,120,179,99,159,85,149,65,149,56,149")
|
||||
"31,372,52,396,64,432,89,453,116,432,149,419,162,412,165," \
|
||||
"377,172,357,189,352,228,327,246,313,262,297,234,291,210," \
|
||||
"284,193,284,176,294,158,303,154,310,146,289,140,268,138," \
|
||||
"246,135,236,139,222,151,214,136,197,120,179,99,159,85," \
|
||||
"149,65,149,56,149")
|
||||
Geozone.create!(name: I18n.t("seeds.geozones.east_district"),
|
||||
external_code: "003", census_code: "03",
|
||||
html_map_coordinates: "175,353,162,378,161,407,153,416,167,432,184,447,225,426," \
|
||||
"250,409,283,390,298,369,344,363,351,334,356,296,361,267,376,245,378,185,327,188," \
|
||||
"281,195,239,216,245,221,245,232,261,244,281,238,300,242,304,251,285,262,278,277," \
|
||||
"267,294,249,312,219,333,198,346,184,353")
|
||||
"250,409,283,390,298,369,344,363,351,334,356,296,361,267," \
|
||||
"376,245,378,185,327,188,281,195,239,216,245,221,245,232," \
|
||||
"261,244,281,238,300,242,304,251,285,262,278,277,267,294," \
|
||||
"249,312,219,333,198,346,184,353")
|
||||
Geozone.create!(name: I18n.t("seeds.geozones.central_district"),
|
||||
external_code: "004", census_code: "04",
|
||||
html_map_coordinates: "152,308,137,258,133,235,147,216,152,214,186,194,210,196," \
|
||||
"228,202,240,216,241,232,263,243,293,241,301,245,302,254,286,265,274,278,267,296," \
|
||||
"243,293,226,289,209,285,195,283,177,297")
|
||||
"228,202,240,216,241,232,263,243,293,241,301,245,302,254," \
|
||||
"286,265,274,278,267,296,243,293,226,289,209,285,195,283," \
|
||||
"177,297")
|
||||
end
|
||||
|
||||
@@ -20,8 +20,7 @@ section "Creating polls" do
|
||||
slug: I18n.t("seeds.polls.current_poll_geozone_restricted").parameterize,
|
||||
starts_at: 5.days.ago,
|
||||
ends_at: 5.days.from_now,
|
||||
geozone_restricted: true,
|
||||
geozones: Geozone.sample(3))
|
||||
geozone_restricted_to: Geozone.sample(3))
|
||||
|
||||
create_poll!(name: I18n.t("seeds.polls.recounting_poll"),
|
||||
slug: I18n.t("seeds.polls.recounting_poll").parameterize,
|
||||
|
||||
@@ -49,7 +49,6 @@ section "Creating Archived Proposals" do
|
||||
5.times do
|
||||
author = User.all.sample
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
|
||||
months_to_archive_proposals = Setting["months_to_archive_proposals"]
|
||||
proposal = Proposal.create!(author: author,
|
||||
title: Faker::Lorem.sentence(word_count: 3).truncate(60),
|
||||
summary: Faker::Lorem.sentence(word_count: 3),
|
||||
@@ -58,8 +57,8 @@ section "Creating Archived Proposals" do
|
||||
tag_list: tags.sample(3).join(","),
|
||||
geozone: Geozone.all.sample,
|
||||
terms_of_service: "1",
|
||||
created_at: months_to_archive_proposals.to_i.months.ago,
|
||||
published_at: months_to_archive_proposals.to_i.months.ago)
|
||||
created_at: Setting.archived_proposals_date_limit,
|
||||
published_at: Setting.archived_proposals_date_limit)
|
||||
random_locales.map do |locale|
|
||||
Globalize.with_locale(locale) do
|
||||
proposal.title = "Archived proposal title for locale #{locale}"
|
||||
|
||||
@@ -10,6 +10,7 @@ class CreateInappropiateFlags < ActiveRecord::Migration[4.2]
|
||||
end
|
||||
|
||||
add_index :inappropiate_flags, [:flaggable_type, :flaggable_id]
|
||||
add_index :inappropiate_flags, [:user_id, :flaggable_type, :flaggable_id], name: "access_inappropiate_flags"
|
||||
add_index :inappropiate_flags, [:user_id, :flaggable_type, :flaggable_id],
|
||||
name: "access_inappropiate_flags"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
class CreateRelatedContent < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
create_table :related_contents do |t|
|
||||
t.references :parent_relationable, polymorphic: true, index: { name: "index_related_contents_on_parent_relationable" }
|
||||
t.references :child_relationable, polymorphic: true, index: { name: "index_related_contents_on_child_relationable" }
|
||||
t.references :parent_relationable, polymorphic: true,
|
||||
index: { name: "index_related_contents_on_parent_relationable" }
|
||||
t.references :child_relationable, polymorphic: true,
|
||||
index: { name: "index_related_contents_on_child_relationable" }
|
||||
t.references :related_content, index: { name: "opposite_related_content" }
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :related_contents, [:parent_relationable_id, :parent_relationable_type, :child_relationable_id, :child_relationable_type], name: "unique_parent_child_related_content", unique: true, using: :btree
|
||||
add_index :related_contents,
|
||||
[:parent_relationable_id, :parent_relationable_type,
|
||||
:child_relationable_id, :child_relationable_type],
|
||||
name: "unique_parent_child_related_content",
|
||||
unique: true,
|
||||
using: :btree
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,6 +6,10 @@ class CreateRelatedContentScores < ActiveRecord::Migration[4.2]
|
||||
t.integer :value
|
||||
end
|
||||
|
||||
add_index :related_content_scores, [:user_id, :related_content_id], name: "unique_user_related_content_scoring", unique: true, using: :btree
|
||||
add_index :related_content_scores,
|
||||
[:user_id, :related_content_id],
|
||||
name: "unique_user_related_content_scoring",
|
||||
unique: true,
|
||||
using: :btree
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
class RenameAdministratorTaskToDashboardAdministratorTask < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
rename_index :administrator_tasks, "index_administrator_tasks_on_source_type_and_source_id", "index_dashboard_administrator_tasks_on_source"
|
||||
rename_index :administrator_tasks,
|
||||
"index_administrator_tasks_on_source_type_and_source_id",
|
||||
"index_dashboard_administrator_tasks_on_source"
|
||||
rename_table :administrator_tasks, :dashboard_administrator_tasks
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,6 +29,9 @@ class CreateLegislationPeopleProposalsTable < ActiveRecord::Migration[4.2]
|
||||
t.boolean "validated"
|
||||
t.integer "cached_votes_score", default: 0
|
||||
end
|
||||
add_index "legislation_people_proposals", ["cached_votes_score"], name: "index_legislation_people_proposals_on_cached_votes_score", using: :btree
|
||||
add_index "legislation_people_proposals",
|
||||
["cached_votes_score"],
|
||||
name: "index_legislation_people_proposals_on_cached_votes_score",
|
||||
using: :btree
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,7 +4,9 @@ class CreateSDGRelations < ActiveRecord::Migration[5.2]
|
||||
t.references :related_sdg, polymorphic: true
|
||||
t.references :relatable, polymorphic: true
|
||||
|
||||
t.index [:related_sdg_id, :related_sdg_type, :relatable_id, :relatable_type], name: "sdg_relations_unique", unique: true
|
||||
t.index [:related_sdg_id, :related_sdg_type, :relatable_id, :relatable_type],
|
||||
name: "sdg_relations_unique",
|
||||
unique: true
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
@@ -20,7 +20,9 @@ class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
|
||||
|
||||
t.datetime :created_at, null: false
|
||||
|
||||
t.index [:record_type, :record_id, :name, :blob_id], name: "index_active_storage_attachments_uniqueness", unique: true
|
||||
t.index [:record_type, :record_id, :name, :blob_id],
|
||||
name: "index_active_storage_attachments_uniqueness",
|
||||
unique: true
|
||||
t.foreign_key :active_storage_blobs, column: :blob_id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
class ManagerAuthenticator
|
||||
def initialize(data = {})
|
||||
@manager = { login: data[:login], user_key: data[:clave_usuario], date: data[:fecha_conexion] }.with_indifferent_access
|
||||
@manager = {
|
||||
login: data[:login],
|
||||
user_key: data[:clave_usuario],
|
||||
date: data[:fecha_conexion]
|
||||
}.with_indifferent_access
|
||||
end
|
||||
|
||||
def auth
|
||||
@@ -13,7 +17,11 @@ class ManagerAuthenticator
|
||||
private
|
||||
|
||||
def manager_exists?
|
||||
response = client.call(:get_status_user_data, message: { ub: { user_key: @manager[:user_key], date: @manager[:date] }}).body
|
||||
response = client.call(
|
||||
:get_status_user_data,
|
||||
message: { ub: { user_key: @manager[:user_key], date: @manager[:date] }}
|
||||
).body
|
||||
|
||||
parsed_response = parser.parse((response[:get_status_user_data_response][:get_status_user_data_return]))
|
||||
@manager[:login] == parsed_response["USUARIO"]["LOGIN"]
|
||||
rescue
|
||||
@@ -21,11 +29,17 @@ class ManagerAuthenticator
|
||||
end
|
||||
|
||||
def application_authorized?
|
||||
response = client.call(:get_applications_user_list, message: { ub: { user_key: @manager[:user_key] }}).body
|
||||
parsed_response = parser.parse((response[:get_applications_user_list_response][:get_applications_user_list_return]))
|
||||
response = client.call(
|
||||
:get_applications_user_list,
|
||||
message: { ub: { user_key: @manager[:user_key] }}
|
||||
).body
|
||||
|
||||
user_list_return = response[:get_applications_user_list_response][:get_applications_user_list_return]
|
||||
parsed_response = parser.parse(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
|
||||
|
||||
@@ -4,7 +4,7 @@ require "cgi"
|
||||
require "json"
|
||||
|
||||
class RemoteTranslations::Microsoft::AvailableLocales
|
||||
def self.available_locales
|
||||
def self.locales
|
||||
daily_cache("locales") do
|
||||
remote_available_locales.map { |locale| remote_locale_to_app_locale(locale) }
|
||||
end
|
||||
@@ -15,7 +15,7 @@ class RemoteTranslations::Microsoft::AvailableLocales
|
||||
end
|
||||
|
||||
def self.include_locale?(locale)
|
||||
available_locales.include?(locale.to_s)
|
||||
locales.include?(locale.to_s)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -11,7 +11,8 @@ describe Account::PermissionsListComponent do
|
||||
it "adds a hint when an action cannot be performed" do
|
||||
render_inline Account::PermissionsListComponent.new(User.new)
|
||||
|
||||
expect(page).to have_css "li", exact_text: "Additional verification needed Support proposals", normalize_ws: true
|
||||
expect(page).to have_css "li", exact_text: "Additional verification needed Support proposals",
|
||||
normalize_ws: true
|
||||
expect(page).to have_css "li", exact_text: "Participate in debates", normalize_ws: true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::AllowedTableActionsComponent, controller: Admin::BaseController do
|
||||
describe Admin::AllowedTableActionsComponent, :admin do
|
||||
before do
|
||||
sign_in(create(:administrator).user)
|
||||
allow_any_instance_of(Admin::AllowedTableActionsComponent).to receive(:can?).and_return true
|
||||
end
|
||||
let(:record) { create(:banner, title: "Important!") }
|
||||
|
||||
@@ -26,7 +26,8 @@ describe Admin::BudgetHeadings::FormComponent do
|
||||
|
||||
render_inline component
|
||||
|
||||
expect(page).to have_select "Scope of operation", options: ["All city", "Under the sea", "Above the skies"]
|
||||
expect(page).to have_select "Scope of operation",
|
||||
options: ["All city", "Under the sea", "Above the skies"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::BudgetHeadings::HeadingsComponent, controller: Admin::BaseController do
|
||||
describe Admin::BudgetHeadings::HeadingsComponent, :admin do
|
||||
it "includes group name in the message when there are no headings" do
|
||||
group = create(:budget_group, name: "Whole planet")
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::BudgetPhases::ToggleEnabledComponent, controller: Admin::BaseController do
|
||||
describe Admin::BudgetPhases::ToggleEnabledComponent, :admin do
|
||||
let(:phase) { create(:budget).phases.informing }
|
||||
let(:component) { Admin::BudgetPhases::ToggleEnabledComponent.new(phase) }
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Budgets::ActionsComponent, controller: Admin::BaseController do
|
||||
describe Admin::Budgets::ActionsComponent, :admin do
|
||||
include Rails.application.routes.url_helpers
|
||||
before { sign_in(create(:administrator).user) }
|
||||
|
||||
let(:budget) { create(:budget) }
|
||||
let(:component) { Admin::Budgets::ActionsComponent.new(budget) }
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Budgets::CalculateWinnersButtonComponent, controller: Admin::BaseController do
|
||||
describe Admin::Budgets::CalculateWinnersButtonComponent, :admin do
|
||||
let(:budget) { create(:budget) }
|
||||
let(:component) { Admin::Budgets::CalculateWinnersButtonComponent.new(budget) }
|
||||
before { sign_in(create(:administrator).user) }
|
||||
|
||||
it "renders when reviewing ballots" do
|
||||
budget.update!(phase: "reviewing_ballots")
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Budgets::LinksComponent, controller: Admin::BaseController do
|
||||
before { sign_in(create(:administrator).user) }
|
||||
|
||||
describe Admin::Budgets::LinksComponent, :admin do
|
||||
describe "see results link" do
|
||||
let(:budget) { create(:budget, :finished) }
|
||||
let(:component) { Admin::Budgets::LinksComponent.new(budget) }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Budgets::TableActionsComponent, controller: Admin::BaseController do
|
||||
describe Admin::Budgets::TableActionsComponent, :admin do
|
||||
let(:budget) { create(:budget) }
|
||||
let(:component) { Admin::Budgets::TableActionsComponent.new(budget) }
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Geozones::IndexComponent, controller: Admin::BaseController do
|
||||
describe Admin::Geozones::IndexComponent, :admin do
|
||||
describe "Coordinates description" do
|
||||
it "includes whether coordinates are defined or not" do
|
||||
geozones = [
|
||||
create(:geozone, :with_geojson, name: "GeoJSON", external_code: "1", census_code: "2"),
|
||||
create(:geozone, :with_html_coordinates, name: "HTML", external_code: "3", census_code: "4"),
|
||||
create(:geozone, :with_geojson, :with_html_coordinates, name: "With both", external_code: "6", census_code: "7"),
|
||||
create(:geozone, :with_geojson, :with_html_coordinates, name: "With both",
|
||||
external_code: "6",
|
||||
census_code: "7"),
|
||||
create(:geozone, name: "With none", external_code: "8", census_code: "9")
|
||||
]
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Poll::Officers::OfficersComponent, controller: Admin::BaseController do
|
||||
describe Admin::Poll::Officers::OfficersComponent, :admin do
|
||||
let(:existing_officer) { create(:poll_officer, name: "Old officer") }
|
||||
let(:new_officer) { build(:poll_officer, name: "New officer") }
|
||||
let(:officers) { [existing_officer, new_officer] }
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Poll::Questions::Answers::Documents::TableActionsComponent, controller: Admin::BaseController do
|
||||
before { sign_in(create(:administrator).user) }
|
||||
describe Admin::Poll::Questions::Answers::Documents::TableActionsComponent, :admin do
|
||||
let(:future_answer) { create(:poll_question_answer, poll: create(:poll, :future)) }
|
||||
let(:current_answer) { create(:poll_question_answer, poll: create(:poll)) }
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Poll::Questions::Answers::TableActionsComponent, controller: Admin::BaseController do
|
||||
before { sign_in(create(:administrator).user) }
|
||||
|
||||
describe Admin::Poll::Questions::Answers::TableActionsComponent, :admin do
|
||||
it "displays the edit and destroy actions when the poll has not started" do
|
||||
answer = create(:poll_question_answer, poll: create(:poll, :future))
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Poll::Questions::Answers::Videos::TableActionsComponent, controller: Admin::BaseController do
|
||||
before { sign_in(create(:administrator).user) }
|
||||
|
||||
describe Admin::Poll::Questions::Answers::Videos::TableActionsComponent, :admin do
|
||||
it "displays the edit and destroy actions when the poll has not started" do
|
||||
video = create(:poll_answer_video, poll: create(:poll, :future))
|
||||
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Poll::Questions::TableActionsComponent, controller: Admin::BaseController do
|
||||
before { sign_in(create(:administrator).user) }
|
||||
|
||||
describe Admin::Poll::Questions::TableActionsComponent, :admin do
|
||||
it "displays the edit and destroy actions when the poll has not started" do
|
||||
question = create(:poll_question, poll: create(:poll, :future))
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::Roles::TableActionsComponent, controller: Admin::BaseController do
|
||||
describe Admin::Roles::TableActionsComponent, :admin do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it "renders button to add the role for new records" do
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::SiteCustomization::Pages::IndexComponent, controller: Admin::SiteCustomization::PagesController do
|
||||
describe Admin::SiteCustomization::Pages::IndexComponent,
|
||||
controller: Admin::SiteCustomization::PagesController do
|
||||
before { SiteCustomization::Page.delete_all }
|
||||
|
||||
it "shows date in created_at and updated_at fields" do
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe Admin::TableActionsComponent, controller: Admin::BaseController do
|
||||
describe Admin::TableActionsComponent, :admin do
|
||||
let(:record) { create(:banner, title: "Important!") }
|
||||
|
||||
it "renders edit and destroy actions by default" do
|
||||
|
||||
@@ -32,7 +32,8 @@ describe Budgets::BudgetComponent do
|
||||
render_inline Budgets::BudgetComponent.new(budget)
|
||||
|
||||
page.find(".budget-header") do |header|
|
||||
expect(header).to have_link "Participate now!", href: "https://consuldemocracy.org", class: "main-link"
|
||||
expect(header).to have_link "Participate now!", href: "https://consuldemocracy.org",
|
||||
class: "main-link"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user