Merge pull request #4629 from consul/dependabot/bundler/master/rubocop-rails-and-rubocop-performance-and-rubocop-rspec-and-rubocop-2.11.3
Bump rubocop-rails, rubocop-performance, rubocop-rspec and rubocop
This commit is contained in:
89
.rubocop.yml
89
.rubocop.yml
@@ -17,21 +17,6 @@ Bundler/OrderedGems:
|
||||
Enabled: true
|
||||
ConsiderPunctuation: true
|
||||
|
||||
Capybara/CurrentPathExpectation:
|
||||
Enabled: true
|
||||
|
||||
Capybara/FeatureMethods:
|
||||
Enabled: true
|
||||
EnabledMethods:
|
||||
- scenario
|
||||
- xscenario
|
||||
|
||||
Capybara/VisibilityMatcher:
|
||||
Enabled: true
|
||||
|
||||
FactoryBot/FactoryClassName:
|
||||
Enabled: true
|
||||
|
||||
Layout/AssignmentIndentation:
|
||||
Enabled: true
|
||||
|
||||
@@ -175,9 +160,15 @@ Lint/BooleanSymbol:
|
||||
Lint/ConstantDefinitionInBlock:
|
||||
Enabled: true
|
||||
|
||||
Lint/DuplicateBranch:
|
||||
Enabled: true
|
||||
|
||||
Lint/DuplicateMethods:
|
||||
Enabled: true
|
||||
|
||||
Lint/EmptyBlock:
|
||||
Enabled: true
|
||||
|
||||
Lint/EmptyFile:
|
||||
Enabled: true
|
||||
|
||||
@@ -196,12 +187,21 @@ Lint/SafeNavigationChain:
|
||||
Lint/ShadowingOuterLocalVariable:
|
||||
Enabled: true
|
||||
|
||||
Lint/SymbolConversion:
|
||||
Enabled: true
|
||||
Exclude:
|
||||
- "app/models/setting.rb"
|
||||
- "db/dev_seeds/settings.rb"
|
||||
|
||||
Lint/UselessAssignment:
|
||||
Enabled: true
|
||||
|
||||
Lint/Void:
|
||||
Enabled: true
|
||||
|
||||
Naming/VariableName:
|
||||
Enabled: true
|
||||
|
||||
Performance/BlockGivenWithExplicitBlock:
|
||||
Enabled: true
|
||||
|
||||
@@ -223,6 +223,9 @@ Performance/Sum:
|
||||
Rails/ActiveRecordCallbacksOrder:
|
||||
Enabled: true
|
||||
|
||||
Rails/AddColumnIndex:
|
||||
Enabled: true
|
||||
|
||||
Rails/CreateTableWithTimestamps:
|
||||
Enabled: true
|
||||
Exclude:
|
||||
@@ -260,6 +263,14 @@ Rails/HasManyOrHasOneDependent:
|
||||
Enabled: true
|
||||
Severity: refactor
|
||||
|
||||
Rails/HttpStatus:
|
||||
Enabled: true
|
||||
|
||||
Rails/I18nLocaleAssignment:
|
||||
Enabled: true
|
||||
Exclude:
|
||||
- "spec/spec_helper.rb"
|
||||
|
||||
Rails/InverseOf:
|
||||
Enabled: true
|
||||
Exclude:
|
||||
@@ -343,6 +354,18 @@ RSpec/AroundBlock:
|
||||
RSpec/BeforeAfterAll:
|
||||
Enabled: true
|
||||
|
||||
RSpec/Capybara/CurrentPathExpectation:
|
||||
Enabled: true
|
||||
|
||||
RSpec/Capybara/FeatureMethods:
|
||||
Enabled: true
|
||||
EnabledMethods:
|
||||
- scenario
|
||||
- xscenario
|
||||
|
||||
RSpec/Capybara/VisibilityMatcher:
|
||||
Enabled: true
|
||||
|
||||
RSpec/ContextMethod:
|
||||
Enabled: true
|
||||
|
||||
@@ -369,6 +392,9 @@ RSpec/EmptyLineAfterExampleGroup:
|
||||
RSpec/ExampleWording:
|
||||
Enabled: true
|
||||
|
||||
RSpec/FactoryBot/FactoryClassName:
|
||||
Enabled: true
|
||||
|
||||
RSpec/FilePath:
|
||||
Enabled: true
|
||||
|
||||
@@ -443,18 +469,33 @@ Style/ClassVars:
|
||||
Style/CollectionMethods:
|
||||
Enabled: true
|
||||
|
||||
Style/HashConversion:
|
||||
Enabled: true
|
||||
|
||||
Style/HashSyntax:
|
||||
Enabled: true
|
||||
|
||||
Style/HashTransformKeys:
|
||||
Enabled: true
|
||||
|
||||
Style/HashTransformValues:
|
||||
Enabled: true
|
||||
|
||||
Style/IdenticalConditionalBranches:
|
||||
Enabled: true
|
||||
|
||||
Style/IfWithBooleanLiteralBranches:
|
||||
Enabled: true
|
||||
|
||||
Style/MethodDefParentheses:
|
||||
Enabled: true
|
||||
|
||||
Style/MutableConstant:
|
||||
Enabled: true
|
||||
|
||||
Style/NegatedIfElseCondition:
|
||||
Enabled: true
|
||||
|
||||
Style/Not:
|
||||
Enabled: true
|
||||
|
||||
@@ -470,6 +511,9 @@ Style/Proc:
|
||||
Style/RaiseArgs:
|
||||
Enabled: true
|
||||
|
||||
Style/RedundantArgument:
|
||||
Enabled: true
|
||||
|
||||
Style/RedundantCondition:
|
||||
Enabled: true
|
||||
|
||||
@@ -482,12 +526,27 @@ Style/RedundantFreeze:
|
||||
Style/RedundantInterpolation:
|
||||
Enabled: true
|
||||
|
||||
Style/RedundantParentheses:
|
||||
Enabled: true
|
||||
|
||||
Style/RedundantReturn:
|
||||
Enabled: true
|
||||
|
||||
Style/RedundantSelf:
|
||||
Enabled: true
|
||||
|
||||
Style/SafeNavigation:
|
||||
Enabled: true
|
||||
|
||||
Style/SingleLineMethods:
|
||||
Enabled: true
|
||||
|
||||
Style/SoleNestedConditional:
|
||||
Enabled: true
|
||||
|
||||
Style/StringChars:
|
||||
Enabled: true
|
||||
|
||||
Style/StringLiterals:
|
||||
EnforcedStyle: double_quotes
|
||||
|
||||
|
||||
8
Gemfile
8
Gemfile
@@ -108,10 +108,10 @@ group :development do
|
||||
gem "pronto-eslint", "~> 0.11.0", require: false
|
||||
gem "pronto-rubocop", "~> 0.11.1", require: false
|
||||
gem "pronto-scss", "~> 0.11.0", require: false
|
||||
gem "rubocop", "~> 0.93.1", require: false
|
||||
gem "rubocop-performance", "~> 1.10.1", require: false
|
||||
gem "rubocop-rails", "~> 2.9.1", require: false
|
||||
gem "rubocop-rspec", "~> 1.44.1", require: false
|
||||
gem "rubocop", "~> 1.18.4", require: false
|
||||
gem "rubocop-performance", "~> 1.11.4", require: false
|
||||
gem "rubocop-rails", "~> 2.11.3", require: false
|
||||
gem "rubocop-rspec", "~> 2.4.0", require: false
|
||||
gem "rvm1-capistrano3", "~> 1.4.0", require: false
|
||||
gem "scss_lint", "~> 0.59.0", require: false
|
||||
gem "web-console", "~> 3.7.0"
|
||||
|
||||
32
Gemfile.lock
32
Gemfile.lock
@@ -538,27 +538,27 @@ GEM
|
||||
rspec-mocks (~> 3.10)
|
||||
rspec-support (~> 3.10)
|
||||
rspec-support (3.10.2)
|
||||
rubocop (0.93.1)
|
||||
rubocop (1.18.4)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 2.7.1.5)
|
||||
parser (>= 3.0.0.0)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml
|
||||
rubocop-ast (>= 0.6.0)
|
||||
rubocop-ast (>= 1.8.0, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 2.0)
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.9.1)
|
||||
parser (>= 3.0.1.1)
|
||||
rubocop-performance (1.10.2)
|
||||
rubocop (>= 0.90.0, < 2.0)
|
||||
rubocop-performance (1.11.4)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-ast (>= 0.4.0)
|
||||
rubocop-rails (2.9.1)
|
||||
rubocop-rails (2.11.3)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 0.90.0, < 2.0)
|
||||
rubocop-rspec (1.44.1)
|
||||
rubocop (~> 0.87)
|
||||
rubocop-ast (>= 0.7.1)
|
||||
rubocop (>= 1.7.0, < 2.0)
|
||||
rubocop-rspec (2.4.0)
|
||||
rubocop (~> 1.0)
|
||||
rubocop-ast (>= 1.1.0)
|
||||
ruby-progressbar (1.11.0)
|
||||
ruby2_keywords (0.0.5)
|
||||
rubyzip (2.3.2)
|
||||
@@ -768,10 +768,10 @@ DEPENDENCIES
|
||||
rinku (~> 2.0.6)
|
||||
rollbar (~> 3.2.0)
|
||||
rspec-rails (~> 5.0)
|
||||
rubocop (~> 0.93.1)
|
||||
rubocop-performance (~> 1.10.1)
|
||||
rubocop-rails (~> 2.9.1)
|
||||
rubocop-rspec (~> 1.44.1)
|
||||
rubocop (~> 1.18.4)
|
||||
rubocop-performance (~> 1.11.4)
|
||||
rubocop-rails (~> 2.11.3)
|
||||
rubocop-rspec (~> 2.4.0)
|
||||
rvm1-capistrano3 (~> 1.4.0)
|
||||
sassc-rails (~> 2.1.2)
|
||||
savon (~> 2.12.1)
|
||||
|
||||
@@ -6,9 +6,7 @@ class Admin::AdministratorsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def search
|
||||
@users = User.search(params[:search])
|
||||
.includes(:administrator)
|
||||
.page(params[:page])
|
||||
@users = User.search(params[:search]).includes(:administrator).page(params[:page])
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -6,9 +6,7 @@ class Admin::ManagersController < Admin::BaseController
|
||||
end
|
||||
|
||||
def search
|
||||
@users = User.search(params[:search])
|
||||
.includes(:manager)
|
||||
.page(params[:page])
|
||||
@users = User.search(params[:search]).includes(:manager).page(params[:page])
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -13,8 +13,7 @@ class Admin::MilestoneStatusesController < Admin::BaseController
|
||||
@status = Milestone::Status.new(status_params)
|
||||
|
||||
if @status.save
|
||||
redirect_to admin_milestone_statuses_path,
|
||||
notice: t("admin.statuses.create.notice")
|
||||
redirect_to admin_milestone_statuses_path, notice: t("admin.statuses.create.notice")
|
||||
else
|
||||
render :new
|
||||
end
|
||||
@@ -25,8 +24,7 @@ class Admin::MilestoneStatusesController < Admin::BaseController
|
||||
|
||||
def update
|
||||
if @status.update(status_params)
|
||||
redirect_to admin_milestone_statuses_path,
|
||||
notice: t("admin.statuses.update.notice")
|
||||
redirect_to admin_milestone_statuses_path, notice: t("admin.statuses.update.notice")
|
||||
else
|
||||
render :edit
|
||||
end
|
||||
@@ -34,8 +32,7 @@ class Admin::MilestoneStatusesController < Admin::BaseController
|
||||
|
||||
def destroy
|
||||
@status.destroy!
|
||||
redirect_to admin_milestone_statuses_path,
|
||||
notice: t("admin.statuses.delete.notice")
|
||||
redirect_to admin_milestone_statuses_path, notice: t("admin.statuses.delete.notice")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -6,9 +6,7 @@ class Admin::ModeratorsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def search
|
||||
@users = User.search(params[:search])
|
||||
.includes(:moderator)
|
||||
.page(params[:page])
|
||||
@users = User.search(params[:search]).includes(:moderator).page(params[:page])
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -25,8 +25,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
|
||||
def create
|
||||
@poll = Poll.find(booth_assignment_params[:poll_id])
|
||||
@booth = Poll::Booth.find(booth_assignment_params[:booth_id])
|
||||
@booth_assignment = ::Poll::BoothAssignment.new(poll: @poll,
|
||||
booth: @booth)
|
||||
@booth_assignment = ::Poll::BoothAssignment.new(poll: @poll, booth: @booth)
|
||||
|
||||
@booth_assignment.save!
|
||||
|
||||
|
||||
@@ -114,11 +114,7 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
|
||||
private
|
||||
|
||||
def content_block_params
|
||||
params.require(:site_customization_content_block).permit(
|
||||
:name,
|
||||
:locale,
|
||||
:body
|
||||
)
|
||||
params.require(:site_customization_content_block).permit(:name, :locale, :body)
|
||||
end
|
||||
|
||||
def is_heading_content_block?(name)
|
||||
|
||||
@@ -39,8 +39,6 @@ class Admin::SiteCustomization::ImagesController < Admin::SiteCustomization::Bas
|
||||
private
|
||||
|
||||
def image_params
|
||||
params.require(:site_customization_image).permit(
|
||||
:image
|
||||
)
|
||||
params.require(:site_customization_image).permit(:image)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -41,8 +41,7 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
|
||||
end
|
||||
|
||||
def delete_translations
|
||||
languages_to_delete = params[:enabled_translations].select { |_, v| v == "0" }
|
||||
.keys
|
||||
languages_to_delete = params[:enabled_translations].select { |_, v| v == "0" }.keys
|
||||
|
||||
languages_to_delete.each do |locale|
|
||||
I18nContentTranslation.where(locale: locale).destroy_all
|
||||
@@ -56,8 +55,6 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
|
||||
end
|
||||
|
||||
def enabled_translations
|
||||
params.fetch(:enabled_translations, {})
|
||||
.select { |_, v| v == "1" }
|
||||
.keys
|
||||
params.fetch(:enabled_translations, {}).select { |_, v| v == "1" }.keys
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,9 +10,7 @@ class Admin::ValuatorsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def search
|
||||
@users = User.search(params[:search])
|
||||
.includes(:valuator)
|
||||
.page(params[:page])
|
||||
@users = User.search(params[:search]).includes(:valuator).page(params[:page])
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
@@ -21,7 +21,7 @@ class DirectUploadsController < ApplicationController
|
||||
attachment_url: @direct_upload.relation.attachment.url }
|
||||
else
|
||||
render json: { errors: @direct_upload.errors[:attachment].join(", ") },
|
||||
status: 422
|
||||
status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -10,9 +10,7 @@ class InstallationController < ApplicationController
|
||||
private
|
||||
|
||||
def consul_installation_details
|
||||
{
|
||||
release: "1.3.1"
|
||||
}.merge(features: settings_feature_flags)
|
||||
{ release: "1.3.1" }.merge(features: settings_feature_flags)
|
||||
end
|
||||
|
||||
def settings_feature_flags
|
||||
|
||||
@@ -99,9 +99,9 @@ class Legislation::AnnotationsController < Legislation::BaseController
|
||||
end
|
||||
|
||||
def track_event
|
||||
ahoy.track "legislation_annotation_created".to_sym,
|
||||
"legislation_annotation_id": @annotation.id,
|
||||
"legislation_draft_version_id": @draft_version.id
|
||||
ahoy.track :legislation_annotation_created,
|
||||
legislation_annotation_id: @annotation.id,
|
||||
legislation_draft_version_id: @draft_version.id
|
||||
end
|
||||
|
||||
def convert_ranges_parameters
|
||||
|
||||
@@ -29,15 +29,13 @@ class Legislation::AnswersController < Legislation::BaseController
|
||||
private
|
||||
|
||||
def answer_params
|
||||
params.require(:legislation_answer).permit(
|
||||
:legislation_question_option_id
|
||||
)
|
||||
params.require(:legislation_answer).permit(:legislation_question_option_id)
|
||||
end
|
||||
|
||||
def track_event
|
||||
ahoy.track "legislation_answer_created".to_sym,
|
||||
"legislation_answer_id": @answer.id,
|
||||
"legislation_question_option_id": @answer.legislation_question_option_id,
|
||||
"legislation_question_id": @answer.legislation_question_id
|
||||
ahoy.track :legislation_answer_created,
|
||||
legislation_answer_id: @answer.id,
|
||||
legislation_question_option_id: @answer.legislation_question_option_id,
|
||||
legislation_question_id: @answer.legislation_question_id
|
||||
end
|
||||
end
|
||||
|
||||
@@ -35,7 +35,7 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
set_process
|
||||
@phase = :debate_phase
|
||||
|
||||
if @process.debate_phase.started? || (current_user&.administrator?)
|
||||
if @process.debate_phase.started? || current_user&.administrator?
|
||||
render :debate
|
||||
else
|
||||
render :phase_not_open
|
||||
@@ -123,7 +123,7 @@ class Legislation::ProcessesController < Legislation::BaseController
|
||||
@proposals = @proposals.send(@current_filter).page(params[:page])
|
||||
end
|
||||
|
||||
if @process.proposals_phase.started? || (current_user&.administrator?)
|
||||
if @process.proposals_phase.started? || current_user&.administrator?
|
||||
legislation_proposal_votes(@proposals)
|
||||
render :proposals
|
||||
else
|
||||
|
||||
@@ -47,7 +47,7 @@ class Management::UsersController < Management::BaseController
|
||||
end
|
||||
|
||||
def user_without_email
|
||||
new_password = "aAbcdeEfghiJkmnpqrstuUvwxyz23456789$!".split("").sample(10).join("")
|
||||
new_password = "aAbcdeEfghiJkmnpqrstuUvwxyz23456789$!".chars.sample(10).join
|
||||
@user.password = new_password
|
||||
@user.password_confirmation = new_password
|
||||
|
||||
|
||||
@@ -14,6 +14,6 @@ class PagesController < ApplicationController
|
||||
render action: params[:id]
|
||||
end
|
||||
rescue ActionView::MissingTemplate
|
||||
head 404, content_type: "text/html"
|
||||
head :not_found, content_type: "text/html"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -7,9 +7,7 @@ class Valuation::BudgetsController < Valuation::BaseController
|
||||
def index
|
||||
@budget = current_budget
|
||||
if @budget.present?
|
||||
@investments = @budget.investments
|
||||
.by_valuator(current_user.valuator)
|
||||
.valuation_open
|
||||
@investments = @budget.investments.by_valuator(current_user.valuator).valuation_open
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
module BudgetsHelper
|
||||
def csv_params
|
||||
csv_params = params.clone.merge(format: :csv)
|
||||
csv_params = csv_params.to_unsafe_h.map { |k, v| [k.to_sym, v] }.to_h
|
||||
csv_params = csv_params.to_unsafe_h.transform_keys(&:to_sym)
|
||||
csv_params.delete(:page)
|
||||
csv_params
|
||||
end
|
||||
|
||||
@@ -4,10 +4,7 @@ module FollowablesHelper
|
||||
end
|
||||
|
||||
def followable_icon(followable)
|
||||
{
|
||||
proposals: "Proposal",
|
||||
budget: "Budget::Investment"
|
||||
}.invert[followable]
|
||||
{ proposals: "Proposal", budget: "Budget::Investment" }.invert[followable]
|
||||
end
|
||||
|
||||
def render_follow(follow)
|
||||
|
||||
@@ -15,8 +15,6 @@ module ImagesHelper
|
||||
|
||||
def render_image(image, version, show_caption = true)
|
||||
version = image.persisted? ? version : :original
|
||||
render "images/image", image: image,
|
||||
version: version,
|
||||
show_caption: show_caption
|
||||
render "images/image", image: image, version: version, show_caption: show_caption
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@ module SettingsHelper
|
||||
end
|
||||
|
||||
def setting
|
||||
@all_settings ||= Hash[Setting.all.map { |s| [s.key, s.value.presence] }]
|
||||
@all_settings ||= Setting.all.map { |s| [s.key, s.value.presence] }.to_h
|
||||
end
|
||||
|
||||
def display_setting_name(setting_name)
|
||||
|
||||
@@ -9,10 +9,7 @@ module SiteCustomizationHelper
|
||||
|
||||
def translation_for_locale(content, locale)
|
||||
if content.present?
|
||||
I18nContentTranslation.find_by(
|
||||
i18n_content_id: content.id,
|
||||
locale: locale
|
||||
)&.value
|
||||
I18nContentTranslation.find_by(i18n_content_id: content.id, locale: locale)&.value
|
||||
else
|
||||
false
|
||||
end
|
||||
|
||||
@@ -62,7 +62,7 @@ module UsersHelper
|
||||
def show_admin_menu?(user = nil)
|
||||
unless namespace == "officing"
|
||||
current_administrator? || current_moderator? || current_valuator? || current_manager? ||
|
||||
(user&.administrator?) || current_poll_officer? || current_sdg_manager?
|
||||
user&.administrator? || current_poll_officer? || current_sdg_manager?
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class AdminNotification < ApplicationRecord
|
||||
return unless link.present?
|
||||
|
||||
unless link =~ /\A(http:\/\/|https:\/\/|\/)/
|
||||
self.link = "http://#{self.link}"
|
||||
self.link = "http://#{link}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -187,12 +187,10 @@ class Budget < ApplicationRecord
|
||||
|
||||
def investments_orders
|
||||
case phase
|
||||
when "accepting", "reviewing"
|
||||
when "accepting", "reviewing", "finished"
|
||||
%w[random]
|
||||
when "publishing_prices", "balloting", "reviewing_ballots"
|
||||
%w[random price]
|
||||
when "finished"
|
||||
%w[random]
|
||||
else
|
||||
%w[random confidence_score]
|
||||
end
|
||||
|
||||
@@ -292,8 +292,7 @@ class Budget
|
||||
end
|
||||
|
||||
def valid_heading?(user)
|
||||
voted_in?(heading, user) ||
|
||||
can_vote_in_another_heading?(user)
|
||||
voted_in?(heading, user) || can_vote_in_another_heading?(user)
|
||||
end
|
||||
|
||||
def can_vote_in_another_heading?(user)
|
||||
@@ -364,11 +363,11 @@ class Budget
|
||||
end
|
||||
|
||||
def assigned_valuators
|
||||
self.valuators.map(&:description_or_name).compact.join(", ").presence
|
||||
valuators.map(&:description_or_name).compact.join(", ").presence
|
||||
end
|
||||
|
||||
def assigned_valuation_groups
|
||||
self.valuator_groups.map(&:name).compact.join(", ").presence
|
||||
valuator_groups.map(&:name).compact.join(", ").presence
|
||||
end
|
||||
|
||||
def self.with_milestone_status_id(status_id)
|
||||
|
||||
@@ -14,8 +14,8 @@ class Budget
|
||||
include Imageable
|
||||
|
||||
belongs_to :budget, touch: true
|
||||
belongs_to :next_phase, class_name: self.name, inverse_of: :prev_phase
|
||||
has_one :prev_phase, class_name: self.name, foreign_key: :next_phase_id, inverse_of: :next_phase
|
||||
belongs_to :next_phase, class_name: name, inverse_of: :prev_phase
|
||||
has_one :prev_phase, class_name: name, foreign_key: :next_phase_id, inverse_of: :next_phase
|
||||
|
||||
validates_translation :name, presence: true
|
||||
validates_translation :description, length: { maximum: DESCRIPTION_MAX_LENGTH }
|
||||
|
||||
@@ -31,9 +31,7 @@ class Budget
|
||||
|
||||
def store_reclassified_votes(reason)
|
||||
ballot_lines_for_investment.order(:id).each do |line|
|
||||
attrs = { user: line.ballot.user,
|
||||
investment: self,
|
||||
reason: reason }
|
||||
attrs = { user: line.ballot.user, investment: self, reason: reason }
|
||||
Budget::ReclassifiedVote.create!(attrs)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,8 +12,8 @@ class CommentNotifier
|
||||
private
|
||||
|
||||
def send_comment_email
|
||||
unless @comment.commentable.is_a?(Legislation::Annotation)
|
||||
Mailer.comment(@comment).deliver_later if email_on_comment?
|
||||
if !@comment.commentable.is_a?(Legislation::Annotation) && email_on_comment?
|
||||
Mailer.comment(@comment).deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ module Globalizable
|
||||
translated_attribute_names.any? { |attr| required_attribute?(attr) }
|
||||
end
|
||||
|
||||
if self.paranoid? && translation_class.attribute_names.include?("hidden_at")
|
||||
if paranoid? && translation_class.attribute_names.include?("hidden_at")
|
||||
translation_class.send :acts_as_paranoid, column: :hidden_at
|
||||
end
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ module Measurable
|
||||
|
||||
class_methods do
|
||||
def title_max_length
|
||||
@title_max_length ||= (columns.find { |c| c.name == "title" }&.limit) || 80
|
||||
@title_max_length ||= columns.find { |c| c.name == "title" }&.limit || 80
|
||||
end
|
||||
|
||||
def responsible_name_max_length
|
||||
@responsible_name_max_length ||= (columns.find { |c| c.name == "responsible_name" }&.limit) || 60
|
||||
@responsible_name_max_length ||= columns.find { |c| c.name == "responsible_name" }&.limit || 60
|
||||
end
|
||||
|
||||
def question_max_length
|
||||
|
||||
@@ -11,10 +11,7 @@ class Dashboard::Action < ApplicationRecord
|
||||
|
||||
enum action_type: [:proposed_action, :resource]
|
||||
|
||||
validates :title,
|
||||
presence: true,
|
||||
allow_blank: false,
|
||||
length: { in: 4..80 }
|
||||
validates :title, presence: true, allow_blank: false, length: { in: 4..80 }
|
||||
|
||||
validates :action_type, presence: true
|
||||
|
||||
|
||||
@@ -165,7 +165,7 @@ class Debate < ApplicationRecord
|
||||
end
|
||||
|
||||
def description_sanitized
|
||||
real_description_length = ActionView::Base.full_sanitizer.sanitize("#{description}").squish.length
|
||||
real_description_length = ActionView::Base.full_sanitizer.sanitize(description.to_s).squish.length
|
||||
if real_description_length < Debate.description_min_length
|
||||
errors.add(:description, :too_short, count: Debate.description_min_length)
|
||||
end
|
||||
|
||||
@@ -50,18 +50,18 @@ class Document < ApplicationRecord
|
||||
end
|
||||
|
||||
def prefix(attachment, _style)
|
||||
if !attachment.instance.persisted?
|
||||
"cached_attachments/user/#{attachment.instance.user_id}"
|
||||
else
|
||||
if attachment.instance.persisted?
|
||||
":attachment/:id_partition"
|
||||
else
|
||||
"cached_attachments/user/#{attachment.instance.user_id}"
|
||||
end
|
||||
end
|
||||
|
||||
def custom_hash_data(attachment)
|
||||
original_filename = if !attachment.instance.persisted?
|
||||
attachment.instance.attachment_file_name
|
||||
else
|
||||
original_filename = if attachment.instance.persisted?
|
||||
attachment.instance.title
|
||||
else
|
||||
attachment.instance.attachment_file_name
|
||||
end
|
||||
"#{attachment.instance.user_id}/#{original_filename}"
|
||||
end
|
||||
|
||||
@@ -52,10 +52,10 @@ class Image < ApplicationRecord
|
||||
end
|
||||
|
||||
def prefix(attachment, _style)
|
||||
if !attachment.instance.persisted?
|
||||
"cached_attachments/user/#{attachment.instance.user_id}"
|
||||
else
|
||||
if attachment.instance.persisted?
|
||||
":attachment/:id_partition"
|
||||
else
|
||||
"cached_attachments/user/#{attachment.instance.user_id}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ class LocalCensusRecord < ApplicationRecord
|
||||
private
|
||||
|
||||
def sanitize
|
||||
self.document_type = self.document_type&.strip
|
||||
self.document_number = self.document_number&.strip
|
||||
self.postal_code = self.postal_code&.strip
|
||||
self.document_type = document_type&.strip
|
||||
self.document_number = document_number&.strip
|
||||
self.postal_code = postal_code&.strip
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,13 +24,11 @@ class Organization < ApplicationRecord
|
||||
end
|
||||
|
||||
def verified?
|
||||
verified_at.present? &&
|
||||
(rejected_at.blank? || rejected_at < verified_at)
|
||||
verified_at.present? && (rejected_at.blank? || rejected_at < verified_at)
|
||||
end
|
||||
|
||||
def rejected?
|
||||
rejected_at.present? &&
|
||||
(verified_at.blank? || verified_at < rejected_at)
|
||||
rejected_at.present? && (verified_at.blank? || verified_at < rejected_at)
|
||||
end
|
||||
|
||||
def self.search(text)
|
||||
|
||||
@@ -106,15 +106,13 @@ class Poll < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.votable_by(user)
|
||||
answerable_by(user).
|
||||
not_voted_by(user)
|
||||
answerable_by(user).not_voted_by(user)
|
||||
end
|
||||
|
||||
def votable_by?(user)
|
||||
return false if user_has_an_online_ballot?(user)
|
||||
|
||||
answerable_by?(user) &&
|
||||
not_voted_by?(user)
|
||||
answerable_by?(user) && not_voted_by?(user)
|
||||
end
|
||||
|
||||
def user_has_an_online_ballot?(user)
|
||||
|
||||
@@ -12,7 +12,7 @@ class Poll
|
||||
has_many :recounts
|
||||
|
||||
def shifts?
|
||||
shifts.empty? ? false : true
|
||||
!shifts.empty?
|
||||
end
|
||||
|
||||
def unable_to_destroy?
|
||||
|
||||
@@ -58,6 +58,6 @@ class ProposalNotification < ApplicationRecord
|
||||
private
|
||||
|
||||
def set_author
|
||||
self.update(author_id: self.proposal.author_id) if self.proposal
|
||||
update(author_id: proposal.author_id) if proposal
|
||||
end
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class RelatedContent < ApplicationRecord
|
||||
belongs_to :author, class_name: "User"
|
||||
belongs_to :parent_relationable, polymorphic: true, optional: false, touch: true
|
||||
belongs_to :child_relationable, polymorphic: true, optional: false, touch: true
|
||||
has_one :opposite_related_content, class_name: self.name, foreign_key: :related_content_id
|
||||
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] }
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
class RelatedContentScore < ApplicationRecord
|
||||
SCORES = {
|
||||
POSITIVE: 1,
|
||||
NEGATIVE: -1
|
||||
}.freeze
|
||||
SCORES = { POSITIVE: 1, NEGATIVE: -1 }.freeze
|
||||
|
||||
belongs_to :related_content, touch: true, counter_cache: :related_content_scores_count
|
||||
belongs_to :user
|
||||
|
||||
@@ -12,8 +12,7 @@ class Verification::Letter
|
||||
validate :validate_correct_code, if: :verify?
|
||||
|
||||
def save
|
||||
valid? &&
|
||||
letter_requested!
|
||||
valid? && letter_requested!
|
||||
end
|
||||
|
||||
def save!
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<%= render Admin::TableActionsComponent.new(booth_assignment,
|
||||
actions: [:destroy],
|
||||
destroy_text: t("admin.booth_assignments.manage.actions.unassign"),
|
||||
destroy_confirmation: (booth_assignment.shifts? ? "#{t("admin.poll_booth_assignments.alert.shifts")}" : ""),
|
||||
destroy_confirmation: (booth_assignment.shifts? ? t("admin.poll_booth_assignments.alert.shifts") : ""),
|
||||
destroy_options: { remote: true }
|
||||
) %>
|
||||
<% end %>
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
<% @answer.videos.each do |video| %>
|
||||
<tr id="<%= dom_id(video) %>" class="poll_question_answer_video">
|
||||
<td><%= video.title %></td>
|
||||
<td><%= link_to "#{video.url}", video.url %></td>
|
||||
<td><%= link_to video.url, video.url %></td>
|
||||
<td>
|
||||
<%= render Admin::TableActionsComponent.new(video) %>
|
||||
</td>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<% Setting.mime_types[group].each do |content_type, mime_type_value| %>
|
||||
<span class="content-type">
|
||||
<%= check_box_tag content_type,
|
||||
setting.value.split(" ").include?(mime_type_value),
|
||||
setting.value.split(" ").include?(mime_type_value) %>
|
||||
setting.value.split.include?(mime_type_value),
|
||||
setting.value.split.include?(mime_type_value) %>
|
||||
<%= label_tag content_type, content_type.upcase %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<div class="<%= results_type == :compatible ? "success" : "js-discarded" %>"
|
||||
style="<%= results_type != :compatible ? "display: none" : "" %>"
|
||||
style="<%= results_type == :compatible ? "" : "display: none" %>"
|
||||
id="<%= results_type %>-container">
|
||||
|
||||
<h4><%= title %></h4>
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
<% if user_signed_in? && !comments_closed_for_commentable?(comment.commentable) && !require_verified_resident_for_commentable?(comment.commentable, current_user) %>
|
||||
<span class="divider"> | </span>
|
||||
<%= link_to(comment_link_text(comment), "",
|
||||
class: "js-add-comment-link", data: { "id": dom_id(comment) }) %>
|
||||
class: "js-add-comment-link", data: { id: dom_id(comment) }) %>
|
||||
|
||||
<% unless valuation %>
|
||||
<%= render "comments/actions", { comment: comment } %>
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
|
||||
<p class="topic-info">
|
||||
<%= t("communities.poll.take_part",
|
||||
from: l(poll.starts_at.to_date), to: (poll.ends_at.to_date)) %>
|
||||
from: l(poll.starts_at.to_date), to: l(poll.ends_at.to_date)) %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<% if can?(:manage_polls, proposal) %>
|
||||
<li>
|
||||
<%= link_to proposal_dashboard_polls_path(proposal),
|
||||
class: "#{"submenu-active" if polls_menu_active?}" do %>
|
||||
class: ("submenu-active" if polls_menu_active?) do %>
|
||||
<span data-tooltip title="<%= Setting["proposals.poll_short_title"] ||
|
||||
t("dashboard.menu.polls") %>">
|
||||
<%= t("dashboard.menu.polls") %>
|
||||
@@ -48,7 +48,7 @@
|
||||
<% if can?(:manage_mailing, proposal) %>
|
||||
<li>
|
||||
<%= link_to new_proposal_dashboard_mailing_path(proposal),
|
||||
class: "#{"submenu-active" if mailing_menu_active?}" do %>
|
||||
class: ("submenu-active" if mailing_menu_active?) do %>
|
||||
<span data-tooltip title="<%= Setting["proposals.email_short_title"] ||
|
||||
t("dashboard.menu.mailing") %>">
|
||||
<%= t("dashboard.menu.mailing") %>
|
||||
@@ -60,7 +60,7 @@
|
||||
<% if can?(:manage_poster, proposal) %>
|
||||
<li>
|
||||
<%= link_to new_proposal_dashboard_poster_path(proposal),
|
||||
class: "#{"submenu-active" if poster_menu_active?}" do %>
|
||||
class: ("submenu-active" if poster_menu_active?) do %>
|
||||
<span data-tooltip title="<%= Setting["proposals.poster_short_title"] ||
|
||||
t("dashboard.menu.poster") %>">
|
||||
<%= t("dashboard.menu.poster") %>
|
||||
@@ -72,7 +72,7 @@
|
||||
<% resources.each do |resource| %>
|
||||
<li>
|
||||
<%= link_to new_request_proposal_dashboard_action_path(proposal, resource),
|
||||
class: "#{"submenu-active" if is_request_active(resource.id)}" do %>
|
||||
class: ("submenu-active" if is_request_active(resource.id)) do %>
|
||||
<span data-tooltip title="<%= resource.short_description %>">
|
||||
<%= resource.title %>
|
||||
</span>
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
|
||||
<%= raw setting["html.per_page_code_head"] %>
|
||||
</head>
|
||||
<body class="<%= yield (:body_class) %> public">
|
||||
<body class="<%= yield(:body_class) %> public">
|
||||
<%= 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 %>
|
||||
|
||||
<% if request.headers["User-Agent"] =~ /MSIE/ && cookies["ie_alert_closed"] != "true" %>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<%= image_tag ("annotator_help.gif"), alt: t("annotator.help.alt") %>
|
||||
<%= image_tag "annotator_help.gif", alt: t("annotator.help.alt") %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -29,13 +29,11 @@
|
||||
class: "button hollow expanded"
|
||||
] if feature?(:polls)
|
||||
),
|
||||
(
|
||||
[
|
||||
t("pages.help.menu.processes"),
|
||||
"#processes",
|
||||
class: "button hollow expanded"
|
||||
]
|
||||
),
|
||||
[
|
||||
t("pages.help.menu.processes"),
|
||||
"#processes",
|
||||
class: "button hollow expanded"
|
||||
],
|
||||
[
|
||||
t("pages.help.menu.other"),
|
||||
"#other",
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<% if can? :destroy, budget_investment %>
|
||||
<%= link_to t("shared.delete"), budget_investment_path(budget_investment.budget, budget_investment),
|
||||
method: :delete, class: "button hollow alert",
|
||||
data: { confirm: "#{t("users.show.delete_alert")}" } %>
|
||||
data: { confirm: t("users.show.delete_alert") } %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<div class="small-12 medium-4 column select-heading">
|
||||
<% slice.each do |filter| %>
|
||||
<%= link_to valuation_budget_budget_investments_path(budget_id: @budget.id, heading_id: filter[:id]),
|
||||
class: "#{"is-active" if params[:heading_id].to_s == filter[:id].to_s}" do %>
|
||||
class: ("is-active" if params[:heading_id].to_s == filter[:id].to_s) do %>
|
||||
<%= filter[:name] %> (<%= filter[:count] %>)
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
@@ -38,9 +38,7 @@ Rails.application.configure do
|
||||
# The :test delivery method accumulates sent emails in the
|
||||
# ActionMailer::Base.deliveries array.
|
||||
config.action_mailer.delivery_method = :test
|
||||
config.action_mailer.default_url_options = {
|
||||
host: "test"
|
||||
}
|
||||
config.action_mailer.default_url_options = { host: "test" }
|
||||
config.action_mailer.asset_host = "http://consul.test"
|
||||
|
||||
# Print deprecation notices to the stderr.
|
||||
|
||||
@@ -42,11 +42,11 @@ module Devise
|
||||
module Models
|
||||
module PasswordExpirable
|
||||
def need_change_password?
|
||||
self.administrator? && password_expired?
|
||||
administrator? && password_expired?
|
||||
end
|
||||
|
||||
def password_expired?
|
||||
self.password_changed_at < self.expire_password_after.ago
|
||||
password_changed_at < expire_password_after.ago
|
||||
end
|
||||
end
|
||||
|
||||
@@ -60,11 +60,11 @@ module Devise
|
||||
end
|
||||
|
||||
def current_equal_password_validation
|
||||
if !self.new_record? && !self.encrypted_password_change.nil? && !self.erased?
|
||||
if !new_record? && !encrypted_password_change.nil? && !erased?
|
||||
dummy = self.class.new
|
||||
dummy.encrypted_password = self.encrypted_password_change.first
|
||||
dummy.password_salt = self.password_salt_change.first if self.respond_to?(:password_salt_change) && !self.password_salt_change.nil?
|
||||
self.errors.add(:password, :equal_to_current_password) if dummy.valid_password?(self.password)
|
||||
dummy.encrypted_password = encrypted_password_change.first
|
||||
dummy.password_salt = password_salt_change.first if respond_to?(:password_salt_change) && !password_salt_change.nil?
|
||||
errors.add(:password, :equal_to_current_password) if dummy.valid_password?(password)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# not use compression
|
||||
class SitemapGenerator::FileAdapter
|
||||
def gzip(stream, data); stream.write(data); stream.close end
|
||||
def gzip(stream, data)
|
||||
stream.write(data)
|
||||
stream.close
|
||||
end
|
||||
end
|
||||
SitemapGenerator::Sitemap.namer = SitemapGenerator::SimpleNamer.new(:sitemap, extension: ".xml")
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AddConfidenceScoreToComments < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :comments, :confidence_score, :integer, index: true
|
||||
add_column :comments, :confidence_score, :integer
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class AddGenreAndDobToUsers < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :users, :genre, :string, index: true, limit: 10
|
||||
add_column :users, :date_of_birth, :datetime, index: true
|
||||
add_column :users, :genre, :string, limit: 10
|
||||
add_column :users, :date_of_birth, :datetime
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class DesnormalizeBallotLine < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :budget_ballot_lines, :budget_id, :integer, index: true
|
||||
add_column :budget_ballot_lines, :group_id, :integer, index: true
|
||||
add_column :budget_ballot_lines, :heading_id, :integer, index: true
|
||||
add_column :budget_ballot_lines, :budget_id, :integer
|
||||
add_column :budget_ballot_lines, :group_id, :integer
|
||||
add_column :budget_ballot_lines, :heading_id, :integer
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class DenormalizeInvestments < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :budget_investments, :budget_id, :integer, index: true
|
||||
add_column :budget_investments, :group_id, :integer, index: true
|
||||
add_column :budget_investments, :budget_id, :integer
|
||||
add_column :budget_investments, :group_id, :integer
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AddSelectedToBudgetInvestment < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :budget_investments, :selected, :bool, default: false, index: true
|
||||
add_column :budget_investments, :selected, :bool, default: false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AddGeozoneRestrictedToPolls < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :polls, :geozone_restricted, :boolean, default: false, index: true
|
||||
add_column :polls, :geozone_restricted, :boolean, default: false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class AddOfficerIdToFailedCensusCalls < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :failed_census_calls, :poll_officer_id, :integer, index: true
|
||||
add_column :failed_census_calls, :poll_officer_id, :integer
|
||||
add_foreign_key :failed_census_calls, :poll_officers
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AddIncompatibleToBudgetInvestments < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :budget_investments, :incompatible, :bool, default: false, index: true
|
||||
add_column :budget_investments, :incompatible, :bool, default: false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class AddSelectedToProposal < ActiveRecord::Migration[4.2]
|
||||
def change
|
||||
add_column :proposals, :selected, :bool, default: false, index: true
|
||||
add_column :proposals, :selected, :bool, default: false
|
||||
end
|
||||
end
|
||||
|
||||
17
db/migrate/20210811195800_add_missing_indexes.rb
Normal file
17
db/migrate/20210811195800_add_missing_indexes.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
class AddMissingIndexes < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_index :comments, :confidence_score
|
||||
add_index :users, :gender
|
||||
add_index :users, :date_of_birth
|
||||
add_index :budget_ballot_lines, :budget_id
|
||||
add_index :budget_ballot_lines, :group_id
|
||||
add_index :budget_ballot_lines, :heading_id
|
||||
add_index :budget_investments, :budget_id
|
||||
add_index :budget_investments, :group_id
|
||||
add_index :budget_investments, :selected
|
||||
add_index :polls, :geozone_restricted
|
||||
add_index :failed_census_calls, :poll_officer_id
|
||||
add_index :budget_investments, :incompatible
|
||||
add_index :proposals, :selected
|
||||
end
|
||||
end
|
||||
15
db/schema.rb
15
db/schema.rb
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_05_19_115700) do
|
||||
ActiveRecord::Schema.define(version: 2021_08_11_195800) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_trgm"
|
||||
@@ -155,6 +155,9 @@ ActiveRecord::Schema.define(version: 2021_05_19_115700) do
|
||||
t.integer "heading_id"
|
||||
t.index ["ballot_id", "investment_id"], name: "index_budget_ballot_lines_on_ballot_id_and_investment_id", unique: true
|
||||
t.index ["ballot_id"], name: "index_budget_ballot_lines_on_ballot_id"
|
||||
t.index ["budget_id"], name: "index_budget_ballot_lines_on_budget_id"
|
||||
t.index ["group_id"], name: "index_budget_ballot_lines_on_group_id"
|
||||
t.index ["heading_id"], name: "index_budget_ballot_lines_on_heading_id"
|
||||
t.index ["investment_id"], name: "index_budget_ballot_lines_on_investment_id"
|
||||
end
|
||||
|
||||
@@ -274,8 +277,12 @@ ActiveRecord::Schema.define(version: 2021_05_19_115700) do
|
||||
t.integer "original_heading_id"
|
||||
t.index ["administrator_id"], name: "index_budget_investments_on_administrator_id"
|
||||
t.index ["author_id"], name: "index_budget_investments_on_author_id"
|
||||
t.index ["budget_id"], name: "index_budget_investments_on_budget_id"
|
||||
t.index ["community_id"], name: "index_budget_investments_on_community_id"
|
||||
t.index ["group_id"], name: "index_budget_investments_on_group_id"
|
||||
t.index ["heading_id"], name: "index_budget_investments_on_heading_id"
|
||||
t.index ["incompatible"], name: "index_budget_investments_on_incompatible"
|
||||
t.index ["selected"], name: "index_budget_investments_on_selected"
|
||||
t.index ["tsv"], name: "index_budget_investments_on_tsv", using: :gin
|
||||
end
|
||||
|
||||
@@ -424,6 +431,7 @@ ActiveRecord::Schema.define(version: 2021_05_19_115700) do
|
||||
t.index ["cached_votes_total"], name: "index_comments_on_cached_votes_total"
|
||||
t.index ["cached_votes_up"], name: "index_comments_on_cached_votes_up"
|
||||
t.index ["commentable_id", "commentable_type"], name: "index_comments_on_commentable_id_and_commentable_type"
|
||||
t.index ["confidence_score"], name: "index_comments_on_confidence_score"
|
||||
t.index ["hidden_at"], name: "index_comments_on_hidden_at"
|
||||
t.index ["user_id"], name: "index_comments_on_user_id"
|
||||
t.index ["valuation"], name: "index_comments_on_valuation"
|
||||
@@ -570,6 +578,7 @@ ActiveRecord::Schema.define(version: 2021_05_19_115700) do
|
||||
t.string "district_code"
|
||||
t.integer "poll_officer_id"
|
||||
t.integer "year_of_birth"
|
||||
t.index ["poll_officer_id"], name: "index_failed_census_calls_on_poll_officer_id"
|
||||
t.index ["user_id"], name: "index_failed_census_calls_on_user_id"
|
||||
end
|
||||
|
||||
@@ -1203,6 +1212,7 @@ ActiveRecord::Schema.define(version: 2021_05_19_115700) do
|
||||
t.integer "related_id"
|
||||
t.tsvector "tsv"
|
||||
t.index ["budget_id"], name: "index_polls_on_budget_id", unique: true
|
||||
t.index ["geozone_restricted"], name: "index_polls_on_geozone_restricted"
|
||||
t.index ["related_type", "related_id"], name: "index_polls_on_related_type_and_related_id"
|
||||
t.index ["starts_at", "ends_at"], name: "index_polls_on_starts_at_and_ends_at"
|
||||
end
|
||||
@@ -1283,6 +1293,7 @@ ActiveRecord::Schema.define(version: 2021_05_19_115700) do
|
||||
t.index ["geozone_id"], name: "index_proposals_on_geozone_id"
|
||||
t.index ["hidden_at"], name: "index_proposals_on_hidden_at"
|
||||
t.index ["hot_score"], name: "index_proposals_on_hot_score"
|
||||
t.index ["selected"], name: "index_proposals_on_selected"
|
||||
t.index ["tsv"], name: "index_proposals_on_tsv", using: :gin
|
||||
end
|
||||
|
||||
@@ -1595,7 +1606,9 @@ ActiveRecord::Schema.define(version: 2021_05_19_115700) do
|
||||
t.boolean "recommended_debates", default: true
|
||||
t.boolean "recommended_proposals", default: true
|
||||
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
|
||||
t.index ["date_of_birth"], name: "index_users_on_date_of_birth"
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
t.index ["gender"], name: "index_users_on_gender"
|
||||
t.index ["geozone_id"], name: "index_users_on_geozone_id"
|
||||
t.index ["hidden_at"], name: "index_users_on_hidden_at"
|
||||
t.index ["password_changed_at"], name: "index_users_on_password_changed_at"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
module ActiveModel::Dates
|
||||
def parse_date(field, attrs)
|
||||
year, month, day = attrs["#{field}(1i)"],
|
||||
attrs["#{field}(2i)"],
|
||||
attrs["#{field}(3i)"]
|
||||
year, month, day = attrs["#{field}(1i)"], attrs["#{field}(2i)"], attrs["#{field}(3i)"]
|
||||
|
||||
return nil unless day.present? && month.present? && year.present?
|
||||
|
||||
|
||||
@@ -20,12 +20,12 @@ class ConsulFormBuilder < FoundationRailsHelper::FormBuilder
|
||||
end
|
||||
|
||||
def check_box(attribute, options = {})
|
||||
if options[:label] != false
|
||||
if options[:label] == false
|
||||
super
|
||||
else
|
||||
label = tag.span sanitize(label_text(attribute, options[:label])), class: "checkbox"
|
||||
|
||||
super(attribute, options.merge(label: label, label_options: label_options_for(options)))
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -4,11 +4,7 @@ namespace :proposal_actions do
|
||||
ProposalDashboardAction.where.not(link: nil).each do |action|
|
||||
next if action.link.blank?
|
||||
|
||||
Link.create!(
|
||||
label: action.title,
|
||||
url: action.link,
|
||||
linkable: action
|
||||
)
|
||||
Link.create!(label: action.title, url: action.link, linkable: action)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -3,10 +3,7 @@ require "rails_helper"
|
||||
describe Admin::Budgets::FormComponent, type: :component do
|
||||
describe "#voting_styles_select_options" do
|
||||
it "provides vote kinds" do
|
||||
types = [
|
||||
["Knapsack", "knapsack"],
|
||||
["Approval", "approval"]
|
||||
]
|
||||
types = [["Knapsack", "knapsack"], ["Approval", "approval"]]
|
||||
|
||||
component = Admin::Budgets::FormComponent.new(double)
|
||||
|
||||
|
||||
@@ -91,8 +91,7 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :widget_feed, class: "Widget::Feed" do
|
||||
end
|
||||
factory :widget_feed, class: "Widget::Feed"
|
||||
|
||||
factory :i18n_content, class: "I18nContent" do
|
||||
key { "debates.index.section_footer.description" }
|
||||
|
||||
@@ -214,6 +214,5 @@ FactoryBot.define do
|
||||
end
|
||||
end
|
||||
|
||||
factory :active_poll do
|
||||
end
|
||||
factory :active_poll
|
||||
end
|
||||
|
||||
@@ -15,8 +15,7 @@ describe LocalesHelper do
|
||||
end
|
||||
|
||||
it "returns the language name in i18n.language.name translation" do
|
||||
keys = { language: {
|
||||
name: "World Language" }}
|
||||
keys = { language: { name: "World Language" }}
|
||||
|
||||
I18n.backend.store_translations(:wl, { i18n: keys })
|
||||
|
||||
|
||||
@@ -22,9 +22,7 @@ describe "I18n" do
|
||||
end
|
||||
|
||||
it "returns plural rule if translation present" do
|
||||
keys = { zero: "No comments",
|
||||
one: "1 comment",
|
||||
other: "%{count} comments" }
|
||||
keys = { zero: "No comments", one: "1 comment", other: "%{count} comments" }
|
||||
|
||||
I18n.backend.store_translations(:en, { test_plural: keys })
|
||||
|
||||
@@ -34,20 +32,25 @@ describe "I18n" do
|
||||
end
|
||||
|
||||
it "returns default locale's plural rule if whole translation not present" do
|
||||
keys = { zero: "No comments",
|
||||
one: "1 comment",
|
||||
other: "%{count} comments" }
|
||||
keys = { zero: "No comments", one: "1 comment", other: "%{count} comments" }
|
||||
|
||||
I18n.backend.store_translations(I18n.default_locale, { test_plural: keys })
|
||||
I18n.backend.store_translations(:zz, {})
|
||||
|
||||
I18n.enforce_available_locales = false
|
||||
I18n.locale = :zz
|
||||
I18n.fallbacks[:zz] << I18n.default_locale
|
||||
default_enforce = I18n.enforce_available_locales
|
||||
|
||||
expect(I18n.t("test_plural", count: 0)).to eq("No comments")
|
||||
expect(I18n.t("test_plural", count: 1)).to eq("1 comment")
|
||||
expect(I18n.t("test_plural", count: 2)).to eq("2 comments")
|
||||
begin
|
||||
I18n.enforce_available_locales = false
|
||||
I18n.with_locale(:zz) do
|
||||
I18n.fallbacks[:zz] << I18n.default_locale
|
||||
|
||||
expect(I18n.t("test_plural", count: 0)).to eq("No comments")
|
||||
expect(I18n.t("test_plural", count: 1)).to eq("1 comment")
|
||||
expect(I18n.t("test_plural", count: 2)).to eq("2 comments")
|
||||
end
|
||||
ensure
|
||||
I18n.enforce_available_locales = default_enforce
|
||||
end
|
||||
end
|
||||
|
||||
it "returns count if specific plural rule not present" do
|
||||
|
||||
@@ -27,9 +27,7 @@ describe Administrator do
|
||||
let!(:user) { create(:user, username: "Billy Wilder", email: "test@test.com") }
|
||||
|
||||
it "returns description and email if decription present" do
|
||||
administrator = create(:administrator,
|
||||
description: "John Doe",
|
||||
user: user)
|
||||
administrator = create(:administrator, description: "John Doe", user: user)
|
||||
|
||||
expect(administrator.description_or_name_and_email).to eq("John Doe (test@test.com)")
|
||||
end
|
||||
|
||||
@@ -430,9 +430,7 @@ describe Budget::Investment do
|
||||
describe "with without_admin filter" do
|
||||
let(:params) { { advanced_filters: ["without_admin"], budget_id: budget.id } }
|
||||
it "returns only investment without admin" do
|
||||
create(:budget_investment,
|
||||
:with_administrator,
|
||||
budget: budget)
|
||||
create(:budget_investment, :with_administrator, budget: budget)
|
||||
investment2 = create(:budget_investment, budget: budget)
|
||||
|
||||
expect(Budget::Investment.scoped_filter(params, "all")).to eq([investment2])
|
||||
@@ -442,14 +440,9 @@ describe Budget::Investment do
|
||||
describe "with without_valuator filter" do
|
||||
let(:params) { { advanced_filters: ["without_valuator"], budget_id: budget.id } }
|
||||
it "returns only investment without valuator" do
|
||||
create(:budget_investment,
|
||||
:with_valuator,
|
||||
budget: budget)
|
||||
investment2 = create(:budget_investment,
|
||||
:with_administrator,
|
||||
budget: budget)
|
||||
investment3 = create(:budget_investment,
|
||||
budget: budget)
|
||||
create(:budget_investment, :with_valuator, budget: budget)
|
||||
investment2 = create(:budget_investment, :with_administrator, budget: budget)
|
||||
investment3 = create(:budget_investment, budget: budget)
|
||||
|
||||
expect(Budget::Investment.scoped_filter(params, "all"))
|
||||
.to contain_exactly(investment2, investment3)
|
||||
@@ -471,14 +464,9 @@ describe Budget::Investment do
|
||||
describe "with valuation_finished filter" do
|
||||
let(:params) { { advanced_filters: ["valuation_finished"], budget_id: budget.id } }
|
||||
it "returns only investment with valuation finished" do
|
||||
investment1 = create(:budget_investment,
|
||||
:selected,
|
||||
budget: budget)
|
||||
create(:budget_investment,
|
||||
:with_administrator,
|
||||
budget: budget)
|
||||
create(:budget_investment,
|
||||
budget: budget)
|
||||
investment1 = create(:budget_investment, :selected, budget: budget)
|
||||
create(:budget_investment, :with_administrator, budget: budget)
|
||||
create(:budget_investment, budget: budget)
|
||||
|
||||
expect(Budget::Investment.scoped_filter(params, "all")).to eq([investment1])
|
||||
end
|
||||
|
||||
@@ -336,30 +336,34 @@ describe Budget do
|
||||
describe "#formatted_amount" do
|
||||
it "correctly formats Euros with Spanish" do
|
||||
budget.update!(currency_symbol: "€")
|
||||
I18n.locale = :es
|
||||
|
||||
expect(budget.formatted_amount(1000.00)).to eq "1.000 €"
|
||||
I18n.with_locale(:es) do
|
||||
expect(budget.formatted_amount(1000.00)).to eq "1.000 €"
|
||||
end
|
||||
end
|
||||
|
||||
it "correctly formats Dollars with Spanish" do
|
||||
budget.update!(currency_symbol: "$")
|
||||
I18n.locale = :es
|
||||
|
||||
expect(budget.formatted_amount(1000.00)).to eq "1.000 $"
|
||||
I18n.with_locale(:es) do
|
||||
expect(budget.formatted_amount(1000.00)).to eq "1.000 $"
|
||||
end
|
||||
end
|
||||
|
||||
it "correctly formats Dollars with English" do
|
||||
budget.update!(currency_symbol: "$")
|
||||
I18n.locale = :en
|
||||
|
||||
expect(budget.formatted_amount(1000.00)).to eq "$1,000"
|
||||
I18n.with_locale(:en) do
|
||||
expect(budget.formatted_amount(1000.00)).to eq "$1,000"
|
||||
end
|
||||
end
|
||||
|
||||
it "correctly formats Euros with English" do
|
||||
budget.update!(currency_symbol: "€")
|
||||
I18n.locale = :en
|
||||
|
||||
expect(budget.formatted_amount(1000.00)).to eq "€1,000"
|
||||
I18n.with_locale(:en) do
|
||||
expect(budget.formatted_amount(1000.00)).to eq "€1,000"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -85,13 +85,11 @@ describe Comment do
|
||||
let(:comment) { create(:comment) }
|
||||
|
||||
it "expires cache when it has a new vote" do
|
||||
expect { create(:vote, votable: comment) }
|
||||
.to change { comment.cache_version }
|
||||
expect { create(:vote, votable: comment) }.to change { comment.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when hidden" do
|
||||
expect { comment.hide }
|
||||
.to change { comment.cache_version }
|
||||
expect { comment.hide }.to change { comment.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when the author is hidden" do
|
||||
|
||||
@@ -21,8 +21,7 @@ shared_examples_for "sluggable" do |updatable_slug_trait:|
|
||||
|
||||
context "slug updating condition is false" do
|
||||
it "slug isn't updated" do
|
||||
expect { sluggable.update(name: "New Name") }
|
||||
.not_to change { sluggable.slug }
|
||||
expect { sluggable.update(name: "New Name") }.not_to change { sluggable.slug }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -355,28 +355,23 @@ describe Debate do
|
||||
let(:debate) { create(:debate) }
|
||||
|
||||
it "expires cache when it has a new comment" do
|
||||
expect { create(:comment, commentable: debate) }
|
||||
.to change { debate.cache_version }
|
||||
expect { create(:comment, commentable: debate) }.to change { debate.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when it has a new vote" do
|
||||
expect { create(:vote, votable: debate) }
|
||||
.to change { debate.cache_version }
|
||||
expect { create(:vote, votable: debate) }.to change { debate.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when it has a new flag" do
|
||||
expect { create(:flag, flaggable: debate) }
|
||||
.to change { debate.reload.cache_version }
|
||||
expect { create(:flag, flaggable: debate) }.to change { debate.reload.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when it has a new tag" do
|
||||
expect { debate.update(tag_list: "new tag") }
|
||||
.to change { debate.cache_version }
|
||||
expect { debate.update(tag_list: "new tag") }.to change { debate.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when hidden" do
|
||||
expect { debate.hide }
|
||||
.to change { debate.cache_version }
|
||||
expect { debate.hide }.to change { debate.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when the author is hidden" do
|
||||
|
||||
@@ -45,39 +45,17 @@ RSpec.describe I18nContent, type: :model do
|
||||
|
||||
describe "#flat_hash" do
|
||||
it "uses one parameter" do
|
||||
expect(I18nContent.flat_hash(nil)).to eq({
|
||||
nil => nil
|
||||
})
|
||||
|
||||
expect(I18nContent.flat_hash("string")).to eq({
|
||||
nil => "string"
|
||||
})
|
||||
|
||||
expect(I18nContent.flat_hash({ w: "string" })).to eq({
|
||||
"w" => "string"
|
||||
})
|
||||
|
||||
expect(I18nContent.flat_hash({ w: { p: "string" }})).to eq({
|
||||
"w.p" => "string"
|
||||
})
|
||||
expect(I18nContent.flat_hash(nil)).to eq({ nil => nil })
|
||||
expect(I18nContent.flat_hash("string")).to eq({ nil => "string" })
|
||||
expect(I18nContent.flat_hash({ w: "string" })).to eq({ "w" => "string" })
|
||||
expect(I18nContent.flat_hash({ w: { p: "string" }})).to eq({ "w.p" => "string" })
|
||||
end
|
||||
|
||||
it "uses the first two parameters" do
|
||||
expect(I18nContent.flat_hash("string", "f")).to eq({
|
||||
"f" => "string"
|
||||
})
|
||||
|
||||
expect(I18nContent.flat_hash(nil, "f")).to eq({
|
||||
"f" => nil
|
||||
})
|
||||
|
||||
expect(I18nContent.flat_hash({ w: "string" }, "f")).to eq({
|
||||
"f.w" => "string"
|
||||
})
|
||||
|
||||
expect(I18nContent.flat_hash({ w: { p: "string" }}, "f")).to eq({
|
||||
"f.w.p" => "string"
|
||||
})
|
||||
expect(I18nContent.flat_hash("string", "f")).to eq({ "f" => "string" })
|
||||
expect(I18nContent.flat_hash(nil, "f")).to eq({ "f" => nil })
|
||||
expect(I18nContent.flat_hash({ w: "string" }, "f")).to eq({ "f.w" => "string" })
|
||||
expect(I18nContent.flat_hash({ w: { p: "string" }}, "f")).to eq({ "f.w.p" => "string" })
|
||||
end
|
||||
|
||||
it "uses the first and last parameters" do
|
||||
|
||||
@@ -36,8 +36,7 @@ describe Poll do
|
||||
expect(poll).not_to be_valid
|
||||
end
|
||||
|
||||
it "no overlapping polls for proposal polls are allowed" do
|
||||
end
|
||||
pending "no overlapping polls for proposal polls are allowed"
|
||||
end
|
||||
|
||||
describe "proposal polls specific validations" do
|
||||
@@ -195,8 +194,7 @@ describe Poll do
|
||||
end
|
||||
|
||||
it "returns restricted & unrestricted polls for level 2 users of the correct geozone" do
|
||||
list = Poll.answerable_by(level2_from_geozone)
|
||||
.order(:geozone_restricted)
|
||||
list = Poll.answerable_by(level2_from_geozone).order(:geozone_restricted)
|
||||
expect(list.to_a).to eq([current_poll, current_restricted_poll])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,10 +33,11 @@ RSpec.describe Poll::Question, type: :model do
|
||||
end
|
||||
|
||||
context "locale with non-underscored name" do
|
||||
before { I18n.locale = :"pt-BR" }
|
||||
|
||||
it "correctly creates a translation" do
|
||||
poll_question.copy_attributes_from_proposal(proposal)
|
||||
I18n.with_locale(:"pt-BR") do
|
||||
poll_question.copy_attributes_from_proposal(proposal)
|
||||
end
|
||||
|
||||
translation = poll_question.translations.first
|
||||
|
||||
expect(poll_question.title).to eq(proposal.title)
|
||||
|
||||
@@ -385,28 +385,23 @@ describe Proposal do
|
||||
let(:proposal) { create(:proposal) }
|
||||
|
||||
it "expires cache when it has a new comment" do
|
||||
expect { create(:comment, commentable: proposal) }
|
||||
.to change { proposal.cache_version }
|
||||
expect { create(:comment, commentable: proposal) }.to change { proposal.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when it has a new vote" do
|
||||
expect { create(:vote, votable: proposal) }
|
||||
.to change { proposal.cache_version }
|
||||
expect { create(:vote, votable: proposal) }.to change { proposal.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when it has a new flag" do
|
||||
expect { create(:flag, flaggable: proposal) }
|
||||
.to change { proposal.reload.cache_version }
|
||||
expect { create(:flag, flaggable: proposal) }.to change { proposal.reload.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when it has a new tag" do
|
||||
expect { proposal.update(tag_list: "new tag") }
|
||||
.to change { proposal.cache_version }
|
||||
expect { proposal.update(tag_list: "new tag") }.to change { proposal.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when hidden" do
|
||||
expect { proposal.hide }
|
||||
.to change { proposal.cache_version }
|
||||
expect { proposal.hide }.to change { proposal.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache when the author is hidden" do
|
||||
|
||||
@@ -483,19 +483,16 @@ describe User do
|
||||
let(:user) { create(:user) }
|
||||
|
||||
it "expires cache with becoming a moderator" do
|
||||
expect { create(:moderator, user: user) }
|
||||
.to change { user.cache_version }
|
||||
expect { create(:moderator, user: user) }.to change { user.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache with becoming an admin" do
|
||||
expect { create(:administrator, user: user) }
|
||||
.to change { user.cache_version }
|
||||
expect { create(:administrator, user: user) }.to change { user.cache_version }
|
||||
end
|
||||
|
||||
it "expires cache with becoming a veridied organization" do
|
||||
create(:organization, user: user)
|
||||
expect { user.organization.verify }
|
||||
.to change { user.reload.cache_version }
|
||||
expect { user.organization.verify }.to change { user.reload.cache_version }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -546,9 +543,7 @@ describe User do
|
||||
end
|
||||
|
||||
it "maintains associated identification document" do
|
||||
user = create(:user,
|
||||
document_number: "1234",
|
||||
document_type: "1")
|
||||
user = create(:user, document_number: "1234", document_type: "1")
|
||||
user.erase
|
||||
user.reload
|
||||
|
||||
@@ -711,10 +706,7 @@ describe User do
|
||||
end
|
||||
|
||||
it "is false for verified users with no email" do
|
||||
user = create(:user,
|
||||
username: "Lois",
|
||||
email: "",
|
||||
verified_at: Time.current)
|
||||
user = create(:user, username: "Lois", email: "", verified_at: Time.current)
|
||||
|
||||
expect(user).to be_valid
|
||||
expect(user.email_required?).to eq(false)
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
shared_examples "remotely_translatable" do |factory_name, path_name, path_arguments|
|
||||
let(:arguments) do
|
||||
path_arguments.map do |argument_name, path_to_value|
|
||||
[argument_name, resource.send(path_to_value)]
|
||||
end.to_h
|
||||
path_arguments.transform_values { |path_to_value| resource.send(path_to_value) }
|
||||
end
|
||||
let(:path) { send(path_name, arguments) }
|
||||
let!(:resource) { create(factory_name) }
|
||||
|
||||
@@ -6,9 +6,7 @@ describe "Admin budget investments", :admin do
|
||||
create(:administrator, user: create(:user, username: "Ana", email: "ana@admins.org"))
|
||||
end
|
||||
|
||||
it_behaves_like "admin_milestoneable",
|
||||
:budget_investment,
|
||||
"admin_polymorphic_path"
|
||||
it_behaves_like "admin_milestoneable", :budget_investment, "admin_polymorphic_path"
|
||||
|
||||
context "Load" do
|
||||
let!(:investment) { create(:budget_investment, budget: budget) }
|
||||
@@ -240,13 +238,8 @@ describe "Admin budget investments", :admin do
|
||||
end
|
||||
|
||||
scenario "Filtering by without assigned admin" do
|
||||
create(:budget_investment,
|
||||
title: "Investment without admin",
|
||||
budget: budget)
|
||||
create(:budget_investment,
|
||||
:with_administrator,
|
||||
title: "Investment with admin",
|
||||
budget: budget)
|
||||
create(:budget_investment, title: "Investment without admin", budget: budget)
|
||||
create(:budget_investment, :with_administrator, title: "Investment with admin", budget: budget)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_id: budget)
|
||||
expect(page).to have_link("Investment without admin")
|
||||
@@ -269,15 +262,8 @@ describe "Admin budget investments", :admin do
|
||||
end
|
||||
|
||||
scenario "Filtering by without assigned valuator" do
|
||||
user = create(:user)
|
||||
valuator = create(:valuator, user: user)
|
||||
create(:budget_investment,
|
||||
title: "Investment without valuator",
|
||||
budget: budget)
|
||||
create(:budget_investment,
|
||||
title: "Investment with valuator",
|
||||
budget: budget,
|
||||
valuators: [valuator])
|
||||
create(:budget_investment, title: "Investment without valuator", budget: budget)
|
||||
create(:budget_investment, :with_valuator, title: "Investment with valuator", budget: budget)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_id: budget)
|
||||
expect(page).to have_link("Investment without valuator")
|
||||
@@ -300,14 +286,12 @@ describe "Admin budget investments", :admin do
|
||||
end
|
||||
|
||||
scenario "Filtering by under valuation" do
|
||||
user = create(:user)
|
||||
valuator = create(:valuator, user: user)
|
||||
create(:budget_investment,
|
||||
:with_administrator,
|
||||
:with_valuator,
|
||||
:open,
|
||||
title: "Investment without valuation",
|
||||
budget: budget,
|
||||
valuators: [valuator])
|
||||
budget: budget)
|
||||
create(:budget_investment,
|
||||
:with_administrator,
|
||||
title: "Investment with valuation",
|
||||
@@ -334,13 +318,8 @@ describe "Admin budget investments", :admin do
|
||||
end
|
||||
|
||||
scenario "Filtering by valuation finished" do
|
||||
create(:budget_investment,
|
||||
title: "Investment valuation open",
|
||||
budget: budget)
|
||||
create(:budget_investment,
|
||||
:finished,
|
||||
title: "Investment valuation finished",
|
||||
budget: budget)
|
||||
create(:budget_investment, title: "Investment valuation open", budget: budget)
|
||||
create(:budget_investment, :finished, title: "Investment valuation finished", budget: budget)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_id: budget)
|
||||
expect(page).to have_link("Investment valuation open")
|
||||
@@ -363,14 +342,8 @@ describe "Admin budget investments", :admin do
|
||||
end
|
||||
|
||||
scenario "Filtering by winners" do
|
||||
create(:budget_investment,
|
||||
:winner,
|
||||
:finished,
|
||||
title: "Investment winner",
|
||||
budget: budget)
|
||||
create(:budget_investment,
|
||||
title: "Investment without winner",
|
||||
budget: budget)
|
||||
create(:budget_investment, :winner, :finished, title: "Investment winner", budget: budget)
|
||||
create(:budget_investment, title: "Investment without winner", budget: budget)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_id: budget)
|
||||
expect(page).to have_link("Investment winner")
|
||||
|
||||
@@ -4,7 +4,7 @@ describe "Images", :admin do
|
||||
it_behaves_like "nested imageable",
|
||||
"poll_question_answer",
|
||||
"new_admin_answer_image_path",
|
||||
{ "answer_id": "id" },
|
||||
{ answer_id: "id" },
|
||||
nil,
|
||||
"Save image",
|
||||
"Image uploaded successfully",
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Admin proposals", :admin do
|
||||
it_behaves_like "admin_milestoneable",
|
||||
:proposal,
|
||||
"admin_polymorphic_path"
|
||||
it_behaves_like "admin_milestoneable", :proposal, "admin_polymorphic_path"
|
||||
|
||||
context "Index" do
|
||||
scenario "Search" do
|
||||
|
||||
@@ -16,12 +16,12 @@ describe "Budget Investments" do
|
||||
it_behaves_like "remotely_translatable",
|
||||
:budget_investment,
|
||||
"budget_investments_path",
|
||||
{ "budget_id": "budget_id" }
|
||||
{ budget_id: "budget_id" }
|
||||
|
||||
it_behaves_like "remotely_translatable",
|
||||
:budget_investment,
|
||||
"budget_investment_path",
|
||||
{ "budget_id": "budget_id", "id": "id" }
|
||||
{ budget_id: "budget_id", id: "id" }
|
||||
it_behaves_like "flaggable", :budget_investment
|
||||
end
|
||||
|
||||
@@ -1039,25 +1039,25 @@ describe "Budget Investments" do
|
||||
expect(page).not_to have_content("Local government is not competent in this matter")
|
||||
end
|
||||
|
||||
it_behaves_like "followable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }
|
||||
it_behaves_like "followable", "budget_investment", "budget_investment_path", { budget_id: "budget_id", id: "id" }
|
||||
|
||||
it_behaves_like "imageable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }
|
||||
it_behaves_like "imageable", "budget_investment", "budget_investment_path", { budget_id: "budget_id", id: "id" }
|
||||
|
||||
it_behaves_like "nested imageable",
|
||||
"budget_investment",
|
||||
"new_budget_investment_path",
|
||||
{ "budget_id": "budget_id" },
|
||||
{ budget_id: "budget_id" },
|
||||
"imageable_fill_new_valid_budget_investment",
|
||||
"Create Investment",
|
||||
"Budget Investment created successfully."
|
||||
|
||||
it_behaves_like "documentable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }
|
||||
it_behaves_like "documentable", "budget_investment", "budget_investment_path", { budget_id: "budget_id", id: "id" }
|
||||
|
||||
it_behaves_like "nested documentable",
|
||||
"user",
|
||||
"budget_investment",
|
||||
"new_budget_investment_path",
|
||||
{ "budget_id": "budget_id" },
|
||||
{ budget_id: "budget_id" },
|
||||
"documentable_fill_new_valid_budget_investment",
|
||||
"Create Investment",
|
||||
"Budget Investment created successfully."
|
||||
@@ -1068,7 +1068,7 @@ describe "Budget Investments" do
|
||||
"new_budget_investment_path",
|
||||
"",
|
||||
"budget_investment_path",
|
||||
{ "budget_id": "budget_id" }
|
||||
{ budget_id: "budget_id" }
|
||||
|
||||
context "Destroy" do
|
||||
scenario "Admin cannot destroy budget investments", :admin do
|
||||
|
||||
@@ -4,14 +4,8 @@ describe "Debates" do
|
||||
context "Concerns" do
|
||||
it_behaves_like "notifiable in-app", :debate
|
||||
it_behaves_like "relationable", Debate
|
||||
it_behaves_like "remotely_translatable",
|
||||
:debate,
|
||||
"debates_path",
|
||||
{}
|
||||
it_behaves_like "remotely_translatable",
|
||||
:debate,
|
||||
"debate_path",
|
||||
{ "id": "id" }
|
||||
it_behaves_like "remotely_translatable", :debate, "debates_path", {}
|
||||
it_behaves_like "remotely_translatable", :debate, "debate_path", { id: "id" }
|
||||
it_behaves_like "flaggable", :debate
|
||||
end
|
||||
|
||||
|
||||
@@ -316,8 +316,7 @@ describe "Emails" do
|
||||
expect { open_last_email }.to raise_error "No email has been sent!"
|
||||
end
|
||||
|
||||
xscenario "Delete all Notifications included in the digest after email sent" do
|
||||
end
|
||||
xscenario "Delete all Notifications included in the digest after email sent"
|
||||
end
|
||||
|
||||
context "User invites" do
|
||||
|
||||
@@ -11,7 +11,7 @@ describe "Budget Investments" do
|
||||
"user",
|
||||
"budget_investment",
|
||||
"new_management_budget_investment_path",
|
||||
{ "budget_id": "budget_id" },
|
||||
{ budget_id: "budget_id" },
|
||||
"documentable_fill_new_valid_budget_investment",
|
||||
"Create Investment",
|
||||
"Investment created successfully.",
|
||||
@@ -20,7 +20,7 @@ describe "Budget Investments" do
|
||||
it_behaves_like "nested imageable",
|
||||
"budget_investment",
|
||||
"new_management_budget_investment_path",
|
||||
{ "budget_id": "budget_id" },
|
||||
{ budget_id: "budget_id" },
|
||||
"imageable_fill_new_valid_budget_investment",
|
||||
"Create Investment",
|
||||
"Investment created successfully.",
|
||||
@@ -32,7 +32,7 @@ describe "Budget Investments" do
|
||||
"new_management_budget_investment_path",
|
||||
"",
|
||||
"management_budget_investment_path",
|
||||
{ "budget_id": "budget_id" },
|
||||
{ budget_id: "budget_id" },
|
||||
management: true
|
||||
|
||||
context "Load" do
|
||||
|
||||
@@ -129,8 +129,7 @@ describe "Polls" do
|
||||
Setting["feature.sdg"] = true
|
||||
Setting["sdg.process.polls"] = true
|
||||
|
||||
create(:poll, sdg_goals: [SDG::Goal[1]],
|
||||
sdg_targets: [SDG::Target["1.1"]])
|
||||
create(:poll, sdg_goals: [SDG::Goal[1]], sdg_targets: [SDG::Target["1.1"]])
|
||||
|
||||
visit polls_path
|
||||
|
||||
@@ -414,8 +413,7 @@ describe "Polls" do
|
||||
Setting["feature.sdg"] = true
|
||||
Setting["sdg.process.polls"] = true
|
||||
|
||||
poll = create(:poll, sdg_goals: [SDG::Goal[1]],
|
||||
sdg_targets: [SDG::Target["1.1"]])
|
||||
poll = create(:poll, sdg_goals: [SDG::Goal[1]], sdg_targets: [SDG::Target["1.1"]])
|
||||
|
||||
visit poll_path(poll)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user