Merge pull request #3636 from consul/change_basic_rubocop_rules
Change basic rubocop rules
This commit is contained in:
69
.rubocop.yml
69
.rubocop.yml
@@ -1,14 +1,8 @@
|
||||
inherit_from: .rubocop_basic.yml
|
||||
|
||||
Bundler/DuplicatedGem:
|
||||
Enabled: true
|
||||
|
||||
Bundler/InsecureProtocolSource:
|
||||
Enabled: true
|
||||
|
||||
Bundler/OrderedGems:
|
||||
Enabled: true
|
||||
|
||||
Gemspec/DuplicatedAssignment:
|
||||
Enabled: true
|
||||
|
||||
@@ -141,12 +135,6 @@ Rails/Output:
|
||||
Rails/OutputSafety:
|
||||
Enabled: true
|
||||
|
||||
Rails/PluralizationGrammar:
|
||||
Enabled: true
|
||||
|
||||
Rails/Presence:
|
||||
Enabled: true
|
||||
|
||||
Rails/Present:
|
||||
Enabled: true
|
||||
|
||||
@@ -156,15 +144,9 @@ Rails/ReadWriteAttribute:
|
||||
Rails/RedundantReceiverInWithOptions:
|
||||
Enabled: true
|
||||
|
||||
Rails/RequestReferer:
|
||||
Enabled: true
|
||||
|
||||
Rails/ReversibleMigration:
|
||||
Enabled: true
|
||||
|
||||
Rails/SafeNavigation:
|
||||
Enabled: true
|
||||
|
||||
Rails/SaveBang:
|
||||
Enabled: true
|
||||
|
||||
@@ -177,12 +159,6 @@ Rails/SkipsModelValidations:
|
||||
Rails/UniqBeforePluck:
|
||||
Enabled: true
|
||||
|
||||
Rails/UnknownEnv:
|
||||
Enabled: true
|
||||
|
||||
Rails/Validation:
|
||||
Enabled: true
|
||||
|
||||
RSpec/AlignLeftLetBrace:
|
||||
Enabled: false
|
||||
|
||||
@@ -192,18 +168,9 @@ RSpec/AlignRightLetBrace:
|
||||
RSpec/AnyInstance:
|
||||
Enabled: false
|
||||
|
||||
RSpec/AroundBlock:
|
||||
Enabled: true
|
||||
|
||||
RSpec/BeEql:
|
||||
Enabled: true
|
||||
|
||||
RSpec/BeforeAfterAll:
|
||||
Enabled: true
|
||||
|
||||
Capybara/CurrentPathExpectation:
|
||||
Enabled: true
|
||||
|
||||
Capybara/FeatureMethods:
|
||||
Enabled: false
|
||||
|
||||
@@ -219,18 +186,9 @@ RSpec/DescribeMethod:
|
||||
RSpec/DescribeSymbol:
|
||||
Enabled: true
|
||||
|
||||
RSpec/EmptyExampleGroup:
|
||||
Enabled: true
|
||||
|
||||
RSpec/EmptyLineAfterSubject:
|
||||
Enabled: true
|
||||
|
||||
RSpec/ExampleLength:
|
||||
Enabled: false
|
||||
|
||||
RSpec/ExampleWording:
|
||||
Enabled: true
|
||||
|
||||
RSpec/ExpectActual:
|
||||
Enabled: true
|
||||
|
||||
@@ -243,12 +201,6 @@ RSpec/ExpectOutput:
|
||||
RSpec/FilePath:
|
||||
Enabled: true
|
||||
|
||||
RSpec/Focus:
|
||||
Enabled: true
|
||||
|
||||
RSpec/HookArgument:
|
||||
Enabled: true
|
||||
|
||||
RSpec/ImplicitExpect:
|
||||
Enabled: true
|
||||
EnforcedStyle: should
|
||||
@@ -271,12 +223,6 @@ RSpec/IteratedExpectation:
|
||||
RSpec/LeadingSubject:
|
||||
Enabled: true
|
||||
|
||||
RSpec/LetBeforeExamples:
|
||||
Enabled: true
|
||||
|
||||
RSpec/LetSetup:
|
||||
Enabled: true
|
||||
|
||||
RSpec/MessageChain:
|
||||
Enabled: true
|
||||
|
||||
@@ -303,9 +249,6 @@ RSpec/NestedGroups:
|
||||
Enabled: true
|
||||
Max: 4
|
||||
|
||||
RSpec/OverwritingSetup:
|
||||
Enabled: true
|
||||
|
||||
RSpec/PredicateMatcher:
|
||||
Enabled: true
|
||||
|
||||
@@ -315,18 +258,9 @@ Rails/HttpStatus:
|
||||
RSpec/RepeatedDescription:
|
||||
Enabled: true
|
||||
|
||||
RSpec/RepeatedExample:
|
||||
Enabled: true
|
||||
|
||||
RSpec/ReturnFromStub:
|
||||
Enabled: true
|
||||
|
||||
RSpec/ScatteredLet:
|
||||
Enabled: true
|
||||
|
||||
RSpec/ScatteredSetup:
|
||||
Enabled: true
|
||||
|
||||
RSpec/SharedContext:
|
||||
Enabled: true
|
||||
|
||||
@@ -339,9 +273,6 @@ RSpec/SubjectStub:
|
||||
RSpec/VerifiedDoubles:
|
||||
Enabled: true
|
||||
|
||||
RSpec/VoidExpect:
|
||||
Enabled: true
|
||||
|
||||
Security/Eval:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -11,6 +11,15 @@ AllCops:
|
||||
# to ignore them, so only the ones explicitly set in this file are enabled.
|
||||
DisabledByDefault: true
|
||||
|
||||
Bundler/DuplicatedGem:
|
||||
Enabled: true
|
||||
|
||||
Bundler/OrderedGems:
|
||||
Enabled: true
|
||||
|
||||
Capybara/CurrentPathExpectation:
|
||||
Enabled: true
|
||||
|
||||
Capybara/FeatureMethods:
|
||||
Enabled: true
|
||||
EnabledMethods:
|
||||
@@ -129,15 +138,86 @@ Rails/Date:
|
||||
Rails/HttpPositionalArguments:
|
||||
Enabled: true
|
||||
|
||||
Rails/PluralizationGrammar:
|
||||
Enabled: true
|
||||
|
||||
Rails/Presence:
|
||||
Enabled: true
|
||||
|
||||
Rails/RelativeDateConstant:
|
||||
Enabled: true
|
||||
|
||||
Rails/RequestReferer:
|
||||
Enabled: true
|
||||
|
||||
Rails/SafeNavigation:
|
||||
Enabled: true
|
||||
ConvertTry: true
|
||||
|
||||
Rails/TimeZone:
|
||||
Enabled: true
|
||||
|
||||
Rails/UnknownEnv:
|
||||
Enabled: true
|
||||
Environments:
|
||||
- development
|
||||
- test
|
||||
- production
|
||||
- preproduction
|
||||
- staging
|
||||
|
||||
Rails/Validation:
|
||||
Enabled: true
|
||||
|
||||
RSpec/AroundBlock:
|
||||
Enabled: true
|
||||
|
||||
RSpec/BeforeAfterAll:
|
||||
Enabled: true
|
||||
|
||||
RSpec/EmptyExampleGroup:
|
||||
Enabled: true
|
||||
Exclude:
|
||||
- spec/factories/**/*
|
||||
|
||||
RSpec/EmptyLineAfterExampleGroup:
|
||||
Enabled: true
|
||||
Exclude:
|
||||
- spec/factories/**/*
|
||||
|
||||
RSpec/ExampleWording:
|
||||
Enabled: true
|
||||
|
||||
RSpec/Focus:
|
||||
Enabled: true
|
||||
|
||||
RSpec/HookArgument:
|
||||
Enabled: true
|
||||
|
||||
RSpec/LetBeforeExamples:
|
||||
Enabled: true
|
||||
|
||||
RSpec/LetSetup:
|
||||
Enabled: true
|
||||
|
||||
RSpec/NotToNot:
|
||||
Enabled: true
|
||||
|
||||
RSpec/OverwritingSetup:
|
||||
Enabled: true
|
||||
|
||||
RSpec/RepeatedExample:
|
||||
Enabled: true
|
||||
|
||||
RSpec/ScatteredLet:
|
||||
Enabled: true
|
||||
|
||||
RSpec/ScatteredSetup:
|
||||
Enabled: true
|
||||
|
||||
RSpec/VoidExpect:
|
||||
Enabled: true
|
||||
|
||||
Style/PercentLiteralDelimiters:
|
||||
Enabled: true
|
||||
|
||||
|
||||
8
Gemfile
8
Gemfile
@@ -7,6 +7,8 @@ gem "acts_as_votable", "~> 0.11.1"
|
||||
gem "ahoy_matey", "~> 1.6.0"
|
||||
gem "ancestry", "~> 3.0.2"
|
||||
gem "autoprefixer-rails", "~> 8.2.0"
|
||||
gem "axlsx", "~> 3.0.0.pre"
|
||||
gem "axlsx_rails", "~> 0.5.2"
|
||||
gem "browser", "~> 2.5.3"
|
||||
gem "cancancan", "~> 2.3.0"
|
||||
gem "ckeditor", "~> 4.2.3"
|
||||
@@ -40,6 +42,7 @@ gem "paperclip", "~> 5.2.1"
|
||||
gem "paranoia", "~> 2.4.1"
|
||||
gem "pg", "~> 0.21.0"
|
||||
gem "pg_search", "~> 2.0.1"
|
||||
gem "recipient_interceptor", "~> 0.2.0"
|
||||
gem "redcarpet", "~> 3.4.0"
|
||||
gem "responders", "~> 2.4.0"
|
||||
gem "rinku", "~> 2.0.2", require: "rails_rinku"
|
||||
@@ -55,11 +58,8 @@ gem "turnout", "~> 2.4.0"
|
||||
gem "uglifier", "~> 4.1.2"
|
||||
gem "unicorn", "~> 5.4.1"
|
||||
gem "whenever", "~> 0.10.0", require: false
|
||||
gem "recipient_interceptor", "~> 0.2.0"
|
||||
gem "wkhtmltopdf-binary", "~> 0.12.4"
|
||||
gem "wicked_pdf", "~> 1.1.0"
|
||||
gem "axlsx", "~> 3.0.0.pre"
|
||||
gem "axlsx_rails", "~> 0.5.2"
|
||||
gem "wkhtmltopdf-binary", "~> 0.12.4"
|
||||
|
||||
source "https://rails-assets.org" do
|
||||
gem "rails-assets-leaflet"
|
||||
|
||||
@@ -8,7 +8,7 @@ class Admin::BaseController < ApplicationController
|
||||
private
|
||||
|
||||
def verify_administrator
|
||||
raise CanCan::AccessDenied unless current_user.try(:administrator?)
|
||||
raise CanCan::AccessDenied unless current_user&.administrator?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class Admin::Legislation::HomepagesController < Admin::Legislation::BaseControll
|
||||
def update
|
||||
if @process.update(process_params)
|
||||
link = legislation_process_path(@process).html_safe
|
||||
redirect_back(fallback_location: (request.referrer || root_path),
|
||||
redirect_back(fallback_location: (request.referer || root_path),
|
||||
notice: t("admin.legislation.processes.update.notice", link: link))
|
||||
else
|
||||
flash.now[:error] = t("admin.legislation.processes.update.error")
|
||||
|
||||
@@ -35,7 +35,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
set_tag_list
|
||||
|
||||
link = legislation_process_path(@process).html_safe
|
||||
redirect_back(fallback_location: (request.referrer || root_path),
|
||||
redirect_back(fallback_location: (request.referer || root_path),
|
||||
notice: t("admin.legislation.processes.update.notice", link: link))
|
||||
else
|
||||
flash.now[:error] = t("admin.legislation.processes.update.error")
|
||||
|
||||
@@ -38,7 +38,7 @@ class Admin::Poll::Questions::Answers::VideosController < Admin::Poll::BaseContr
|
||||
else
|
||||
t("flash.actions.destroy.error")
|
||||
end
|
||||
redirect_back(fallback_location: (request.referrer || root_path), notice: notice)
|
||||
redirect_back(fallback_location: (request.referer || root_path), notice: notice)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -21,7 +21,7 @@ class Admin::Poll::QuestionsController < Admin::Poll::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
@question.author = @question.proposal.try(:author) || current_user
|
||||
@question.author = @question.proposal&.author || current_user
|
||||
@question.votation_type = VotationType.build_by_type(@question, params[:votation_type])
|
||||
|
||||
if @question.save
|
||||
|
||||
@@ -110,9 +110,9 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def set_default_budget_filter
|
||||
if @budget.try(:balloting?) || @budget.try(:publishing_prices?)
|
||||
if @budget&.balloting? || @budget&.publishing_prices?
|
||||
params[:filter] ||= "selected"
|
||||
elsif @budget.try(:finished?)
|
||||
elsif @budget&.finished?
|
||||
params[:filter] ||= "winners"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -141,7 +141,7 @@ module Budgets
|
||||
def load_heading
|
||||
if params[:heading_id].present?
|
||||
@heading = @budget.headings.find_by_slug_or_id! params[:heading_id]
|
||||
@assigned_heading = @ballot.try(:heading_for_group, @heading.try(:group))
|
||||
@assigned_heading = @ballot&.heading_for_group(@heading&.group)
|
||||
load_map
|
||||
end
|
||||
end
|
||||
|
||||
@@ -85,7 +85,7 @@ class CommentsController < ApplicationController
|
||||
|
||||
def add_notification(comment)
|
||||
notifiable = comment.reply? ? comment.parent : comment.commentable
|
||||
notifiable_author_id = notifiable.try(:author_id)
|
||||
notifiable_author_id = notifiable&.author_id
|
||||
if notifiable_author_id.present? && notifiable_author_id != comment.author_id
|
||||
Notification.add(notifiable.author, notifiable)
|
||||
end
|
||||
|
||||
@@ -27,13 +27,13 @@ class Management::SessionsController < ActionController::Base
|
||||
end
|
||||
|
||||
def admin?
|
||||
if current_user.try(:administrator?)
|
||||
if current_user&.administrator?
|
||||
session[:manager] = { login: "admin_user_#{current_user.id}" }
|
||||
end
|
||||
end
|
||||
|
||||
def manager?
|
||||
if current_user.try(:manager?)
|
||||
if current_user&.manager?
|
||||
session[:manager] = { login: "manager_user_#{current_user.id}" }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ class Moderation::BaseController < ApplicationController
|
||||
private
|
||||
|
||||
def verify_moderator
|
||||
raise CanCan::AccessDenied unless current_user.try(:moderator?) || current_user.try(:administrator?)
|
||||
raise CanCan::AccessDenied unless current_user&.moderator? || current_user&.administrator?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ class Officing::BaseController < ApplicationController
|
||||
private
|
||||
|
||||
def verify_officer
|
||||
raise CanCan::AccessDenied unless current_user.try(:poll_officer?)
|
||||
raise CanCan::AccessDenied unless current_user&.poll_officer?
|
||||
end
|
||||
|
||||
def check_officer_assignment
|
||||
|
||||
@@ -51,7 +51,7 @@ class Polls::AnswersController < ApplicationController
|
||||
end
|
||||
|
||||
def load_for_answers
|
||||
@page = params[:page].present? ? params[:page] : 1
|
||||
@page = params[:page].presence || 1
|
||||
question_answers
|
||||
@answers_by_question_id = { @question.id => @question.answers
|
||||
.by_author(current_user)
|
||||
|
||||
@@ -37,7 +37,7 @@ class Polls::QuestionsController < ApplicationController
|
||||
private
|
||||
|
||||
def load_for_answers
|
||||
@page = params[:page].present? ? params[:page] : 1
|
||||
@page = params[:page].presence || 1
|
||||
question_answers
|
||||
@answers_by_question_id = { @question.id => @question.answers
|
||||
.by_author(current_user)
|
||||
|
||||
@@ -25,7 +25,7 @@ class PollsController < ApplicationController
|
||||
.where.not(description: "").order(:given_order)
|
||||
|
||||
@answers_by_question_id = {}
|
||||
poll_answers = ::Poll::Answer.by_question(@poll.question_ids).by_author(current_user.try(:id))
|
||||
poll_answers = ::Poll::Answer.by_question(@poll.question_ids).by_author(current_user&.id)
|
||||
|
||||
@last_pair_question_answers = {}
|
||||
@questions.each do |question|
|
||||
|
||||
@@ -9,7 +9,7 @@ class Tracking::BaseController < ApplicationController
|
||||
private
|
||||
|
||||
def verify_tracker
|
||||
raise CanCan::AccessDenied unless current_user.try(:tracker?) || current_user.try(:administrator?)
|
||||
raise CanCan::AccessDenied unless current_user&.tracker? || current_user&.administrator?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -47,8 +47,7 @@ class Tracking::BudgetInvestmentsController < Tracking::BaseController
|
||||
end
|
||||
|
||||
def heading_filters
|
||||
investments = @budget.investments.by_tracker(current_user.tracker.try(:id))
|
||||
.distinct
|
||||
investments = @budget.investments.by_tracker(current_user.tracker&.id).distinct
|
||||
investment_headings = Budget::Heading.where(id: investments.pluck(:heading_id).uniq)
|
||||
.order(name: :asc)
|
||||
all_headings_filter = [
|
||||
|
||||
@@ -9,7 +9,7 @@ class Valuation::BaseController < ApplicationController
|
||||
private
|
||||
|
||||
def verify_valuator
|
||||
raise CanCan::AccessDenied unless current_user.try(:valuator?) || current_user.try(:administrator?)
|
||||
raise CanCan::AccessDenied unless current_user&.valuator? || current_user&.administrator?
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -73,8 +73,7 @@ class Valuation::BudgetInvestmentsController < Valuation::BaseController
|
||||
end
|
||||
|
||||
def heading_filters
|
||||
investments = @budget.investments.by_valuator(current_user.valuator.try(:id))
|
||||
.visible_to_valuators.distinct
|
||||
investments = @budget.investments.by_valuator(current_user.valuator&.id).visible_to_valuators.distinct
|
||||
investment_headings = Budget::Heading.where(id: investments.pluck(:heading_id)).sort_by(&:name)
|
||||
|
||||
all_headings_filter = [
|
||||
|
||||
@@ -13,11 +13,11 @@ module BannersHelper
|
||||
end
|
||||
|
||||
def banner_bg_color_or_default
|
||||
@banner.background_color.present? ? @banner.background_color : banner_default_bg_color
|
||||
@banner.background_color.presence || banner_default_bg_color
|
||||
end
|
||||
|
||||
def banner_font_color_or_default
|
||||
@banner.font_color.present? ? @banner.font_color : banner_default_font_color
|
||||
@banner.font_color.presence || banner_default_font_color
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ module BudgetHeadingsHelper
|
||||
|
||||
def heading_link(assigned_heading = nil, budget = nil)
|
||||
return nil unless assigned_heading && budget
|
||||
heading_path = budget_investments_path(budget, heading_id: assigned_heading.try(:id))
|
||||
heading_path = budget_investments_path(budget, heading_id: assigned_heading&.id)
|
||||
link_to(assigned_heading.name, heading_path)
|
||||
end
|
||||
|
||||
|
||||
@@ -35,11 +35,11 @@ module LegislationHelper
|
||||
end
|
||||
|
||||
def bg_color_or_default
|
||||
@process.background_color.present? ? @process.background_color : default_bg_color
|
||||
@process.background_color.presence || default_bg_color
|
||||
end
|
||||
|
||||
def font_color_or_default
|
||||
@process.font_color.present? ? @process.font_color : default_font_color
|
||||
@process.font_color.presence || default_font_color
|
||||
end
|
||||
|
||||
def css_for_process_header
|
||||
|
||||
@@ -12,7 +12,7 @@ module SiteCustomizationHelper
|
||||
I18nContentTranslation.where(
|
||||
i18n_content_id: content.id,
|
||||
locale: locale
|
||||
).first.try(:value)
|
||||
).first&.value
|
||||
else
|
||||
false
|
||||
end
|
||||
|
||||
@@ -72,7 +72,7 @@ module Abilities
|
||||
can [:create, :destroy], Follow
|
||||
|
||||
can [:destroy], Document do |document|
|
||||
document.documentable.try(:author_id) == user.id
|
||||
document.documentable&.author_id == user.id
|
||||
end
|
||||
|
||||
can [:destroy], Image, imageable: { author_id: user.id }
|
||||
|
||||
@@ -25,7 +25,7 @@ class AdminNotification < ApplicationRecord
|
||||
end
|
||||
|
||||
def list_of_recipients_count
|
||||
list_of_recipients.try(:count) || 0
|
||||
list_of_recipients&.count || 0
|
||||
end
|
||||
|
||||
def deliver
|
||||
|
||||
@@ -79,7 +79,7 @@ class Budget < ApplicationRecord
|
||||
if phases.exists? && phases.send(phase).description.present?
|
||||
phases.send(phase).description
|
||||
else
|
||||
send("description_#{phase}").try(:html_safe)
|
||||
send("description_#{phase}")&.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ class Budget
|
||||
private
|
||||
|
||||
def set_denormalized_ids
|
||||
self.heading_id ||= investment.try(:heading_id)
|
||||
self.group_id ||= investment.try(:group_id)
|
||||
self.budget_id ||= investment.try(:budget_id)
|
||||
self.heading_id ||= investment&.heading_id
|
||||
self.group_id ||= investment&.group_id
|
||||
self.budget_id ||= investment&.budget_id
|
||||
end
|
||||
|
||||
def store_user_heading
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
class Budget
|
||||
class ContentBlock < ApplicationRecord
|
||||
validates :locale, presence: true, inclusion: { in: I18n.available_locales.map(&:to_s) }
|
||||
validates :heading, presence: true
|
||||
validates_uniqueness_of :heading, scope: :locale
|
||||
validates :heading, presence: true, uniqueness: { scope: :locale }
|
||||
|
||||
belongs_to :heading
|
||||
end
|
||||
|
||||
@@ -319,7 +319,7 @@ class Budget
|
||||
end
|
||||
|
||||
def set_responsible_name
|
||||
self.responsible_name = author.try(:document_number) if author.try(:document_number).present?
|
||||
self.responsible_name = author&.document_number if author&.document_number.present?
|
||||
end
|
||||
|
||||
def should_show_aside?
|
||||
@@ -400,8 +400,8 @@ class Budget
|
||||
private
|
||||
|
||||
def set_denormalized_ids
|
||||
self.group_id = heading.try(:group_id) if heading_id_changed?
|
||||
self.budget_id ||= heading.try(:group).try(:budget_id)
|
||||
self.group_id = heading&.group_id if heading_id_changed?
|
||||
self.budget_id ||= heading&.group&.budget_id
|
||||
end
|
||||
|
||||
def change_log
|
||||
|
||||
@@ -10,7 +10,7 @@ module Globalizable
|
||||
after_validation :copy_error_to_current_translation, on: :update
|
||||
|
||||
def description
|
||||
self.read_attribute(:description).try :html_safe
|
||||
self.read_attribute(:description)&.html_safe
|
||||
end
|
||||
|
||||
def locales_not_marked_for_destruction
|
||||
|
||||
@@ -12,7 +12,7 @@ module Mappable
|
||||
def map_must_be_valid
|
||||
return true if skip_map?
|
||||
|
||||
unless map_location.try(:available?)
|
||||
unless map_location&.available?
|
||||
skip_map_error = I18n.t("activerecord.errors.models.map_location.attributes.map.invalid")
|
||||
errors.add(:skip_map, skip_map_error)
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ module Sanitizable
|
||||
|
||||
unless included_modules.include? Globalizable
|
||||
def description
|
||||
super.try :html_safe
|
||||
super&.html_safe
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -74,7 +74,7 @@ class Debate < ApplicationRecord
|
||||
{
|
||||
author.username => "B",
|
||||
tag_list.join(" ") => "B",
|
||||
geozone.try(:name) => "B",
|
||||
geozone&.name => "B",
|
||||
}.merge!(searchable_globalized_values)
|
||||
end
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class Flag < ApplicationRecord
|
||||
|
||||
def self.flagged?(user, flaggable)
|
||||
return false unless user
|
||||
!!by_user_and_flaggable(user, flaggable).try(:first)
|
||||
!!by_user_and_flaggable(user, flaggable)&.first
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ class Legislation::PeopleProposal < ApplicationRecord
|
||||
|
||||
def self.search(terms)
|
||||
by_code = search_by_code(terms.strip)
|
||||
by_code.present? ? by_code : pg_search(terms)
|
||||
by_code.presence || pg_search(terms)
|
||||
end
|
||||
|
||||
def self.search_by_code(terms)
|
||||
|
||||
@@ -59,14 +59,14 @@ class Legislation::Proposal < ApplicationRecord
|
||||
{ title => "A",
|
||||
author.username => "B",
|
||||
tag_list.join(" ") => "B",
|
||||
geozone.try(:name) => "B",
|
||||
geozone&.name => "B",
|
||||
summary => "C",
|
||||
description => "D" }
|
||||
end
|
||||
|
||||
def self.search(terms)
|
||||
by_code = search_by_code(terms.strip)
|
||||
by_code.present? ? by_code : pg_search(terms)
|
||||
by_code.presence || pg_search(terms)
|
||||
end
|
||||
|
||||
def self.search_by_code(terms)
|
||||
|
||||
@@ -3,12 +3,10 @@ class Newsletter < ApplicationRecord
|
||||
|
||||
validates :subject, presence: true
|
||||
validates :segment_recipient, presence: true
|
||||
validates :from, presence: true
|
||||
validates :from, presence: true, format: { with: /@/ }
|
||||
validates :body, presence: true
|
||||
validate :validate_segment_recipient
|
||||
|
||||
validates_format_of :from, :with => /@/
|
||||
|
||||
acts_as_paranoid column: :hidden_at
|
||||
include ActsAsParanoidAliases
|
||||
|
||||
|
||||
@@ -44,10 +44,10 @@ class Poll::Question < ApplicationRecord
|
||||
end
|
||||
|
||||
def searchable_values
|
||||
{ title => "A",
|
||||
proposal.try(:title) => "A",
|
||||
author.username => "C",
|
||||
author_visible_name => "C" }
|
||||
{ title => "A",
|
||||
proposal&.title => "A",
|
||||
author.username => "C",
|
||||
author_visible_name => "C" }
|
||||
end
|
||||
|
||||
def copy_attributes_from_proposal(proposal)
|
||||
|
||||
@@ -20,7 +20,7 @@ class Poll::Question::Answer < ApplicationRecord
|
||||
scope :visibles, -> { where(hidden: false) }
|
||||
|
||||
def description
|
||||
self[:description].try :html_safe
|
||||
self[:description]&.html_safe
|
||||
end
|
||||
|
||||
def self.order_answers(ordered_array)
|
||||
|
||||
@@ -42,7 +42,7 @@ class Poll
|
||||
private
|
||||
|
||||
def set_denormalized_booth_assignment_id
|
||||
self.booth_assignment_id ||= officer_assignment.try(:booth_assignment_id)
|
||||
self.booth_assignment_id ||= officer_assignment&.booth_assignment_id
|
||||
end
|
||||
|
||||
def in_census?
|
||||
@@ -56,7 +56,7 @@ class Poll
|
||||
def fill_stats_fields
|
||||
if in_census?
|
||||
self.gender = census_api_response.gender
|
||||
self.geozone_id = Geozone.select(:id).where(census_code: census_api_response.district_code).first.try(:id)
|
||||
self.geozone_id = Geozone.select(:id).where(census_code: census_api_response.district_code).first&.id
|
||||
self.age = voter_age(census_api_response.date_of_birth)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -135,13 +135,13 @@ class Proposal < ApplicationRecord
|
||||
{
|
||||
author.username => "B",
|
||||
tag_list.join(" ") => "B",
|
||||
geozone.try(:name) => "B"
|
||||
geozone&.name => "B"
|
||||
}.merge!(searchable_globalized_values)
|
||||
end
|
||||
|
||||
def self.search(terms)
|
||||
by_code = search_by_code(terms.strip)
|
||||
by_code.present? ? by_code : pg_search(terms)
|
||||
by_code.presence || pg_search(terms)
|
||||
end
|
||||
|
||||
def self.search_by_code(terms)
|
||||
|
||||
@@ -25,7 +25,7 @@ class ProposalNotification < ApplicationRecord
|
||||
after_create :set_author
|
||||
|
||||
def minimum_interval
|
||||
return true if proposal.try(:notifications).blank?
|
||||
return true if proposal&.notifications.blank?
|
||||
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
|
||||
|
||||
@@ -6,6 +6,6 @@ class SiteCustomization::ContentBlock < ApplicationRecord
|
||||
|
||||
def self.block_for(name, locale)
|
||||
locale ||= I18n.default_locale
|
||||
find_by(name: name, locale: locale).try(:body)
|
||||
find_by(name: name, locale: locale)&.body
|
||||
end
|
||||
end
|
||||
|
||||
@@ -29,11 +29,11 @@ class SiteCustomization::Image < ApplicationRecord
|
||||
end
|
||||
|
||||
def required_width
|
||||
VALID_IMAGES[name].try(:first)
|
||||
VALID_IMAGES[name]&.first
|
||||
end
|
||||
|
||||
def required_height
|
||||
VALID_IMAGES[name].try(:second)
|
||||
VALID_IMAGES[name]&.second
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -9,11 +9,11 @@ class Tracker < ApplicationRecord
|
||||
validates :user_id, presence: true, uniqueness: true
|
||||
|
||||
def description_or_email
|
||||
description.present? ? description : email
|
||||
description.presence || email
|
||||
end
|
||||
|
||||
def description_or_name
|
||||
description.present? ? description : name
|
||||
description.presence || name
|
||||
end
|
||||
|
||||
def assigned_investment_ids
|
||||
|
||||
@@ -10,15 +10,15 @@ class Valuator < ApplicationRecord
|
||||
validates :user_id, presence: true, uniqueness: true
|
||||
|
||||
def description_or_email
|
||||
description.present? ? description : email
|
||||
description.presence || email
|
||||
end
|
||||
|
||||
def description_or_name
|
||||
description.present? ? description : name
|
||||
description.presence || name
|
||||
end
|
||||
|
||||
def assigned_investment_ids
|
||||
investment_ids + [valuator_group.try(:investment_ids)].flatten
|
||||
investment_ids + [valuator_group&.investment_ids].flatten
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class Verification::Email
|
||||
|
||||
def initialize(verified_user)
|
||||
@verified_user = verified_user
|
||||
@recipient = @verified_user.try(:email)
|
||||
@recipient = @verified_user&.email
|
||||
end
|
||||
|
||||
def save
|
||||
|
||||
@@ -28,7 +28,7 @@ class Verification::Letter
|
||||
|
||||
def validate_correct_code
|
||||
return if errors.include?(:verification_code)
|
||||
if user.try(:letter_verification_code).to_i != verification_code.to_i
|
||||
if user&.letter_verification_code.to_i != verification_code.to_i
|
||||
errors.add(:verification_code, I18n.t("verification.letter.errors.incorrect_code"))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -30,12 +30,9 @@ class VotationType < ApplicationRecord
|
||||
|
||||
validates :questionable, presence: true
|
||||
validates :questionable_type, inclusion: { in: QUESTIONABLE_TYPES }
|
||||
validates_presence_of :max_votes, allow_blank: false,
|
||||
if: :max_votes_required?
|
||||
validates_presence_of :max_groups_answers, allow_blank: false,
|
||||
if: :max_groups_answers_required?
|
||||
validates_presence_of :prioritization_type, allow_blank: false,
|
||||
if: :prioritization_type_required?
|
||||
validates :max_votes, presence: { allow_blank: false, if: :max_votes_required? }
|
||||
validates :max_groups_answers, presence: { allow_blank: false, if: :max_groups_answers_required? }
|
||||
validates :prioritization_type, presence: { allow_blank: false, if: :prioritization_type_required? }
|
||||
|
||||
after_create :add_skip_question_answer, if: :display_skip_question?
|
||||
|
||||
|
||||
@@ -7,16 +7,12 @@ module ActionView
|
||||
include TagHelper
|
||||
|
||||
def t(key, options = {})
|
||||
current_locale = options[:locale].present? ? options[:locale] : I18n.locale
|
||||
current_locale = options[:locale].presence || I18n.locale
|
||||
|
||||
i18_content = I18nContent.by_key(key).first
|
||||
translation = I18nContentTranslation.where(i18n_content_id: i18_content&.id,
|
||||
locale: current_locale).first&.value
|
||||
if translation.present?
|
||||
translation
|
||||
else
|
||||
translate(key, options)
|
||||
end
|
||||
translation.presence || translate(key, options)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ module RemoteTranslations::Microsoft::SentencesParser
|
||||
def get_split_position(valid_point, valid_whitespace, minimum_valid_index)
|
||||
split_position = minimum_valid_index
|
||||
if valid_point.present? || valid_whitespace.present?
|
||||
valid_position = valid_point.present? ? valid_point : valid_whitespace
|
||||
valid_position = valid_point.presence || valid_whitespace
|
||||
split_position = split_position + valid_position
|
||||
end
|
||||
split_position
|
||||
|
||||
@@ -205,7 +205,8 @@ describe "Admin activity" do
|
||||
|
||||
within("#proposal_#{proposal.id}") do
|
||||
click_link "Hide author"
|
||||
expect(current_path).to eq(debates_path)
|
||||
|
||||
expect(page).to have_current_path(debates_path)
|
||||
end
|
||||
|
||||
visit admin_activity_path
|
||||
|
||||
@@ -19,7 +19,7 @@ describe "Admin budget phases" do
|
||||
scenario "Update phase", :js do
|
||||
visit edit_admin_budget_budget_phase_path(budget, budget.current_phase)
|
||||
|
||||
fill_in "start_date", with: Date.current + 1.days
|
||||
fill_in "start_date", with: Date.current + 1.day
|
||||
fill_in "end_date", with: Date.current + 12.days
|
||||
fill_in_translatable_ckeditor "summary", :en, with: "New summary of the phase."
|
||||
fill_in_translatable_ckeditor "description", :en, with: "New description of the phase."
|
||||
@@ -29,7 +29,7 @@ describe "Admin budget phases" do
|
||||
expect(page).to have_current_path(edit_admin_budget_path(budget))
|
||||
expect(page).to have_content "Changes saved"
|
||||
|
||||
expect(budget.current_phase.starts_at.to_date).to eq((Date.current + 1.days).to_date)
|
||||
expect(budget.current_phase.starts_at.to_date).to eq((Date.current + 1.day).to_date)
|
||||
expect(budget.current_phase.ends_at.to_date).to eq((Date.current + 12.days).to_date)
|
||||
expect(budget.current_phase.summary).to include("New summary of the phase.")
|
||||
expect(budget.current_phase.description).to include("New description of the phase.")
|
||||
|
||||
@@ -97,7 +97,7 @@ describe "Admin collaborative legislation" do
|
||||
fill_in "legislation_process[draft_start_date]",
|
||||
with: (base_date - 3.days).strftime("%d/%m/%Y")
|
||||
fill_in "legislation_process[draft_end_date]",
|
||||
with: (base_date - 1.days).strftime("%d/%m/%Y")
|
||||
with: (base_date - 1.day).strftime("%d/%m/%Y")
|
||||
fill_in "legislation_process[draft_publication_date]",
|
||||
with: (base_date + 3.days).strftime("%d/%m/%Y")
|
||||
fill_in "legislation_process[allegations_start_date]",
|
||||
|
||||
@@ -18,7 +18,7 @@ describe "Admin users" do
|
||||
scenario "The username links to their public profile" do
|
||||
click_link @user.name
|
||||
|
||||
expect(current_path).to eq(user_path(@user))
|
||||
expect(page).to have_current_path(user_path(@user))
|
||||
end
|
||||
|
||||
scenario "Search" do
|
||||
|
||||
@@ -18,7 +18,7 @@ describe "Admin Budgets" do
|
||||
|
||||
balloting_phase = budget.phases.where(kind: "balloting").first
|
||||
|
||||
expect(current_path).to match(/admin\/polls\/\d+/)
|
||||
expect(page).to have_current_path(/admin\/polls\/\d+/)
|
||||
expect(page).to have_content(budget.name)
|
||||
expect(page).to have_content(balloting_phase.starts_at.to_date)
|
||||
expect(page).to have_content(balloting_phase.ends_at.to_date)
|
||||
@@ -37,7 +37,7 @@ describe "Admin Budgets" do
|
||||
|
||||
click_link "Bulletins de l’admin"
|
||||
|
||||
expect(current_path).to match(/admin\/polls\/\d+/)
|
||||
expect(page).to have_current_path(/admin\/polls\/\d+/)
|
||||
expect(page).to have_content("Budget pour le changement climatique")
|
||||
|
||||
expect(Poll.count).to eq(1)
|
||||
|
||||
@@ -1292,24 +1292,6 @@ describe "Budget Investments" do
|
||||
expect(page).not_to have_content("Local government is not competent in this matter")
|
||||
end
|
||||
|
||||
scenario "Show (unfeasible budget investment with valuation not finished)" do
|
||||
user = create(:user)
|
||||
login_as(user)
|
||||
|
||||
investment = create(:budget_investment,
|
||||
:unfeasible,
|
||||
valuation_finished: false,
|
||||
budget: budget,
|
||||
group: group,
|
||||
heading: heading,
|
||||
unfeasibility_explanation: "Local government is not competent in this matter")
|
||||
|
||||
visit budget_investment_path(budget, id: investment.id)
|
||||
|
||||
expect(page).not_to have_content("Unfeasibility explanation")
|
||||
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 "imageable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }
|
||||
|
||||
@@ -18,7 +18,7 @@ describe "Legislation" do
|
||||
|
||||
context "process empty" do
|
||||
before do
|
||||
@process = create(:legislation_process, :empty, end_date: Date.current - 1.days)
|
||||
@process = create(:legislation_process, :empty, end_date: Date.current - 1.day)
|
||||
end
|
||||
|
||||
scenario "warning empty" do
|
||||
@@ -29,7 +29,7 @@ describe "Legislation" do
|
||||
|
||||
context "phases empty" do
|
||||
before do
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.days)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.day)
|
||||
end
|
||||
|
||||
scenario "debates empty" do
|
||||
@@ -56,7 +56,7 @@ describe "Legislation" do
|
||||
|
||||
context "process empty" do
|
||||
before do
|
||||
@process = create(:legislation_process, :empty, end_date: Date.current - 1.days)
|
||||
@process = create(:legislation_process, :empty, end_date: Date.current - 1.day)
|
||||
end
|
||||
|
||||
scenario "warning empty" do
|
||||
@@ -68,7 +68,7 @@ describe "Legislation" do
|
||||
context "only debates exist" do
|
||||
before do
|
||||
user = create(:user, :level_two)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.days)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.day)
|
||||
@debate = create(:legislation_question, process: @process, title: "Question 1")
|
||||
create(:debate_comment, user: user, commentable_id: @debate.id, body: "Answer 1")
|
||||
create(:debate_comment, user: user, commentable_id: @debate.id, body: "Answer 2")
|
||||
@@ -123,7 +123,7 @@ describe "Legislation" do
|
||||
|
||||
context "only proposals exist" do
|
||||
before do
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.days)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.day)
|
||||
create(:legislation_proposal, legislation_process_id: @process.id,
|
||||
title: "Legislation proposal 1", selected: true)
|
||||
create(:legislation_proposal, legislation_process_id: @process.id,
|
||||
@@ -171,7 +171,7 @@ describe "Legislation" do
|
||||
context "only text comments exist" do
|
||||
before do
|
||||
user = create(:user, :level_two)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.days)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.day)
|
||||
draft_version_1 = create(:legislation_draft_version, process: @process,
|
||||
title: "Version 1", body: "Body of the first version",
|
||||
status: "published")
|
||||
@@ -231,7 +231,7 @@ describe "Legislation" do
|
||||
describe Legislation::ProcessesController, type: :controller do
|
||||
before do
|
||||
user = create(:user, :level_two)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.days)
|
||||
@process = create(:legislation_process, end_date: Date.current - 1.day)
|
||||
@debate = create(:legislation_question, process: @process, title: "Question 1")
|
||||
create(:debate_comment, user: user, commentable_id: @debate.id, body: "Answer 1")
|
||||
create(:debate_comment, user: user, commentable_id: @debate.id, body: "Answer 2")
|
||||
|
||||
@@ -186,11 +186,11 @@ describe "Notifications" do
|
||||
let!(:user2) { create(:user) }
|
||||
let!(:user3) { create(:user) }
|
||||
let!(:proposal_notification) { create(:proposal_notification) }
|
||||
let!(:notification1) { create(:notification, notifiable: proposal_notification, user: user1) }
|
||||
let!(:notification2) { create(:notification, notifiable: proposal_notification, user: user2) }
|
||||
let!(:notification3) { create(:notification, notifiable: proposal_notification, user: user3) }
|
||||
|
||||
before do
|
||||
create(:notification, notifiable: proposal_notification, user: user1)
|
||||
create(:notification, notifiable: proposal_notification, user: user2)
|
||||
create(:notification, notifiable: proposal_notification, user: user3)
|
||||
reset_mailer
|
||||
Delayed::Worker.delay_jobs = true
|
||||
end
|
||||
|
||||
@@ -63,12 +63,13 @@ describe "Poll Votation Type" do
|
||||
let(:poll_current) { create(:poll, :current) }
|
||||
let(:question) { create(:poll_question_multiple, poll: poll_current) }
|
||||
let!(:answer1) { create(:poll_question_answer, question: question, title: "answer_1") }
|
||||
let!(:answer2) { create(:poll_question_answer, question: question, title: "answer_2") }
|
||||
let!(:answer3) { create(:poll_question_answer, question: question, title: "answer_3") }
|
||||
let!(:answer4) { create(:poll_question_answer, question: question, title: "answer_4") }
|
||||
let!(:answer5) { create(:poll_question_answer, question: question, title: "answer_5") }
|
||||
|
||||
before do
|
||||
create(:poll_question_answer, question: question, title: "answer_2")
|
||||
create(:poll_question_answer, question: question, title: "answer_3")
|
||||
create(:poll_question_answer, question: question, title: "answer_4")
|
||||
create(:poll_question_answer, question: question, title: "answer_5")
|
||||
|
||||
login_as(user)
|
||||
end
|
||||
|
||||
@@ -152,13 +153,14 @@ describe "Poll Votation Type" do
|
||||
let(:user) { create(:user, :verified) }
|
||||
let(:poll_current) { create(:poll, :current) }
|
||||
let(:question) { create(:poll_question_prioritized, poll: poll_current) }
|
||||
let!(:answer1) { create(:poll_question_answer, question: question, title: "answer_1") }
|
||||
let!(:answer2) { create(:poll_question_answer, question: question, title: "answer_2") }
|
||||
let!(:answer3) { create(:poll_question_answer, question: question, title: "answer_3") }
|
||||
let!(:answer4) { create(:poll_question_answer, question: question, title: "answer_4") }
|
||||
let!(:answer5) { create(:poll_question_answer, question: question, title: "answer_5") }
|
||||
|
||||
before do
|
||||
create(:poll_question_answer, question: question, title: "answer_1")
|
||||
create(:poll_question_answer, question: question, title: "answer_2")
|
||||
create(:poll_question_answer, question: question, title: "answer_3")
|
||||
create(:poll_question_answer, question: question, title: "answer_4")
|
||||
create(:poll_question_answer, question: question, title: "answer_5")
|
||||
|
||||
login_as(user)
|
||||
end
|
||||
|
||||
@@ -218,12 +220,13 @@ describe "Poll Votation Type" do
|
||||
let(:poll_current) { create(:poll, :current) }
|
||||
let(:question) { create(:poll_question_positive_open, poll: poll_current) }
|
||||
let!(:answer1) { create(:poll_question_answer, question: question, title: "answer_1") }
|
||||
let!(:answer2) { create(:poll_question_answer, question: question, title: "answer_2") }
|
||||
let!(:answer3) { create(:poll_question_answer, question: question, title: "answer_3") }
|
||||
let!(:answer4) { create(:poll_question_answer, question: question, title: "answer_4") }
|
||||
let!(:answer5) { create(:poll_question_answer, question: question, title: "answer_5") }
|
||||
|
||||
before do
|
||||
create(:poll_question_answer, question: question, title: "answer_2")
|
||||
create(:poll_question_answer, question: question, title: "answer_3")
|
||||
create(:poll_question_answer, question: question, title: "answer_4")
|
||||
create(:poll_question_answer, question: question, title: "answer_5")
|
||||
|
||||
login_as(user)
|
||||
end
|
||||
|
||||
@@ -324,13 +327,14 @@ describe "Poll Votation Type" do
|
||||
let(:user) { create(:user, :verified) }
|
||||
let(:poll_current) { create(:poll, :current) }
|
||||
let(:question) { create(:poll_question_answer_set_open, poll: poll_current) }
|
||||
let!(:answer1) { create(:poll_question_answer, question: question, title: "answer_1") }
|
||||
let!(:answer2) { create(:poll_question_answer, question: question, title: "answer_2") }
|
||||
let!(:answer3) { create(:poll_question_answer, question: question, title: "answer_3") }
|
||||
let!(:answer4) { create(:poll_question_answer, question: question, title: "answer_4") }
|
||||
let!(:answer5) { create(:poll_question_answer, question: question, title: "answer_5") }
|
||||
|
||||
before do
|
||||
create(:poll_question_answer, question: question, title: "answer_1")
|
||||
create(:poll_question_answer, question: question, title: "answer_2")
|
||||
create(:poll_question_answer, question: question, title: "answer_3")
|
||||
create(:poll_question_answer, question: question, title: "answer_4")
|
||||
create(:poll_question_answer, question: question, title: "answer_5")
|
||||
|
||||
login_as(user)
|
||||
end
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ describe "Voter" do
|
||||
end
|
||||
|
||||
context "The person has decided not to vote at this time" do
|
||||
let!(:user) { create(:user, :in_census) }
|
||||
before { create(:user, :in_census) }
|
||||
|
||||
scenario "Show not to vote at this time button" do
|
||||
login_through_form_as_officer(officer.user)
|
||||
|
||||
@@ -1948,7 +1948,7 @@ describe "Successful proposals" do
|
||||
click_link "Create a proposal"
|
||||
end
|
||||
|
||||
expect(current_path).to eq(new_proposal_path)
|
||||
expect(page).to have_current_path(new_proposal_path)
|
||||
|
||||
fill_in "Proposal title", with: "Help refugees"
|
||||
fill_in "Proposal summary", with: "In summary what we want is..."
|
||||
|
||||
@@ -221,13 +221,12 @@ describe Dashboard::Mailer do
|
||||
|
||||
before do
|
||||
ActionMailer::Base.deliveries.clear
|
||||
|
||||
create(:dashboard_action, :resource, :active, day_offset: 0, published_proposal: true)
|
||||
create(:dashboard_action, :proposed_action, :active, day_offset: 0, published_proposal: true)
|
||||
end
|
||||
|
||||
let!(:proposal) { build(:proposal, :draft) }
|
||||
let!(:resource) { create(:dashboard_action, :resource, :active, day_offset: 0,
|
||||
published_proposal: true) }
|
||||
let!(:proposed_action) { create(:dashboard_action, :proposed_action, :active, day_offset: 0,
|
||||
published_proposal: true) }
|
||||
|
||||
it "Disables email delivery using setting" do
|
||||
Setting["dashboard.emails"] = nil
|
||||
|
||||
@@ -27,12 +27,6 @@ describe Abilities::Valuator do
|
||||
should_not be_able_to(:valuate, assigned_investment)
|
||||
end
|
||||
|
||||
it "cannot valuate an assigned investment with a finished valuation" do
|
||||
assigned_investment.update(valuation_finished: true)
|
||||
|
||||
should_not be_able_to(:valuate, assigned_investment)
|
||||
end
|
||||
|
||||
it { should_not be_able_to(:update, non_assigned_investment) }
|
||||
it { should_not be_able_to(:valuate, non_assigned_investment) }
|
||||
|
||||
|
||||
@@ -223,7 +223,7 @@ describe Budget do
|
||||
end
|
||||
|
||||
describe "#has_winning_investments?" do
|
||||
it "should return true if there is a winner investment" do
|
||||
it "returns true if there is a winner investment" do
|
||||
budget.investments << build(:budget_investment, :winner, price: 3, ballot_lines_count: 2)
|
||||
|
||||
expect(budget.has_winning_investments?).to eq true
|
||||
|
||||
@@ -240,7 +240,7 @@ describe Debate do
|
||||
it "remains the same for not voted debates" do
|
||||
new = create(:debate, created_at: now)
|
||||
old = create(:debate, created_at: 1.day.ago)
|
||||
older = create(:debate, created_at: 2.month.ago)
|
||||
older = create(:debate, created_at: 2.months.ago)
|
||||
expect(new.hot_score).to be 0
|
||||
expect(old.hot_score).to be 0
|
||||
expect(older.hot_score).to be 0
|
||||
|
||||
@@ -47,7 +47,7 @@ describe Legislation::PeopleProposal do
|
||||
it "remains the same for not voted people_proposals" do
|
||||
new = create(:legislation_people_proposal, created_at: now)
|
||||
old = create(:legislation_people_proposal, created_at: 1.day.ago)
|
||||
older = create(:legislation_people_proposal, created_at: 2.month.ago)
|
||||
older = create(:legislation_people_proposal, created_at: 2.months.ago)
|
||||
expect(new.hot_score).to be 0
|
||||
expect(old.hot_score).to be 0
|
||||
expect(older.hot_score).to be 0
|
||||
|
||||
@@ -47,7 +47,7 @@ describe Legislation::Proposal do
|
||||
it "remains the same for not voted proposals" do
|
||||
new = create(:legislation_proposal, created_at: now)
|
||||
old = create(:legislation_proposal, created_at: 1.day.ago)
|
||||
older = create(:legislation_proposal, created_at: 2.month.ago)
|
||||
older = create(:legislation_proposal, created_at: 2.months.ago)
|
||||
expect(new.hot_score).to be 0
|
||||
expect(old.hot_score).to be 0
|
||||
expect(older.hot_score).to be 0
|
||||
@@ -67,7 +67,7 @@ describe Legislation::Proposal do
|
||||
newer_proposal = create(:legislation_proposal, created_at: now)
|
||||
5.times { newer_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||
|
||||
older_proposal = create(:legislation_proposal, created_at: 2.day.ago)
|
||||
older_proposal = create(:legislation_proposal, created_at: 2.days.ago)
|
||||
5.times { older_proposal.vote_by(voter: create(:user), vote: "yes") }
|
||||
|
||||
expect(newer_proposal.hot_score).to be > older_proposal.hot_score
|
||||
|
||||
@@ -66,12 +66,12 @@ describe Newsletter do
|
||||
|
||||
describe "#deliver" do
|
||||
let!(:proposals) { Array.new(3) { create(:proposal) } }
|
||||
let!(:debate) { create(:debate) }
|
||||
|
||||
let!(:recipients) { proposals.map(&:author).map(&:email) }
|
||||
let!(:newsletter) { create(:newsletter, segment_recipient: "proposal_authors") }
|
||||
|
||||
before do
|
||||
create(:debate)
|
||||
reset_mailer
|
||||
Delayed::Worker.delay_jobs = true
|
||||
end
|
||||
|
||||
@@ -6,11 +6,11 @@ describe Notification do
|
||||
|
||||
context "validations" do
|
||||
|
||||
it "should be valid" do
|
||||
it "is valid" do
|
||||
expect(notification).to be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a user" do
|
||||
it "is not valid without a user" do
|
||||
notification.user = nil
|
||||
expect(notification).not_to be_valid
|
||||
end
|
||||
|
||||
@@ -9,7 +9,7 @@ describe Poll::Ballot do
|
||||
let(:poll) { create(:poll, budget: budget) }
|
||||
let(:poll_ballot_sheet) { create(:poll_ballot_sheet, poll: poll) }
|
||||
let(:poll_ballot) { create(:poll_ballot, ballot_sheet: poll_ballot_sheet, external_id: 1, data: investment.id) }
|
||||
let!(:ballot) { create(:budget_ballot, budget: budget, physical: true, poll_ballot: poll_ballot) }
|
||||
before { create(:budget_ballot, budget: budget, physical: true, poll_ballot: poll_ballot) }
|
||||
|
||||
describe "#verify" do
|
||||
|
||||
|
||||
@@ -109,19 +109,19 @@ describe Poll::Voter do
|
||||
end
|
||||
|
||||
context "assignments" do
|
||||
it "should not be valid without a booth_assignment_id when origin is booth" do
|
||||
it "is not valid without a booth_assignment_id when origin is booth" do
|
||||
voter.origin = "booth"
|
||||
voter.booth_assignment_id = nil
|
||||
expect(voter).not_to be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without an officer_assignment_id when origin is booth" do
|
||||
it "is not valid without an officer_assignment_id when origin is booth" do
|
||||
voter.origin = "booth"
|
||||
voter.officer_assignment_id = nil
|
||||
expect(voter).not_to be_valid
|
||||
end
|
||||
|
||||
it "should be valid without assignments when origin is web" do
|
||||
it "is valid without assignments when origin is web" do
|
||||
voter.origin = "web"
|
||||
voter.booth_assignment_id = nil
|
||||
voter.officer_assignment_id = nil
|
||||
|
||||
@@ -285,7 +285,7 @@ describe Proposal do
|
||||
it "remains the same for not voted proposals" do
|
||||
new = create(:proposal, created_at: now)
|
||||
old = create(:proposal, created_at: 1.day.ago)
|
||||
older = create(:proposal, created_at: 2.month.ago)
|
||||
older = create(:proposal, created_at: 2.months.ago)
|
||||
expect(new.hot_score).to be 0
|
||||
expect(old.hot_score).to be 0
|
||||
expect(older.hot_score).to be 0
|
||||
|
||||
@@ -9,7 +9,7 @@ describe Setting do
|
||||
expect(described_class["official_level_1_name"]).to eq("Stormtrooper")
|
||||
end
|
||||
|
||||
it "shoulds return nil" do
|
||||
it "returns nil" do
|
||||
expect(described_class["undefined_key"]).to eq(nil)
|
||||
end
|
||||
|
||||
|
||||
@@ -3,15 +3,15 @@ require "rails_helper"
|
||||
describe ValuatorGroup do
|
||||
|
||||
describe "Validations" do
|
||||
it "should be valid" do
|
||||
it "is valid" do
|
||||
expect(build(:valuator_group)).to be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a name" do
|
||||
it "is not valid without a name" do
|
||||
expect(build(:valuator_group, name: nil)).not_to be_valid
|
||||
end
|
||||
|
||||
it "should not be valid with the same name as an existing one" do
|
||||
it "is not valid with the same name as an existing one" do
|
||||
create(:valuator_group, name: "The Valuators")
|
||||
|
||||
expect(build(:valuator_group, name: "The Valuators")).not_to be_valid
|
||||
|
||||
@@ -14,14 +14,14 @@ shared_examples "acts as paranoid" do |factory_name|
|
||||
|
||||
describe "#{described_class} translations" do
|
||||
|
||||
it "should be hidden after parent resource destroy" do
|
||||
it "is hidden after parent resource destroy" do
|
||||
resource.destroy
|
||||
resource.reload
|
||||
|
||||
expect(resource.translations.with_deleted.first.hidden_at).not_to be_blank
|
||||
end
|
||||
|
||||
it "should be destroyed after parent resource really_destroy" do
|
||||
it "is destroyed after parent resource really_destroy" do
|
||||
expect { resource.really_destroy! }.to change { resource.translations.with_deleted.count }.from(1).to(0)
|
||||
end
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ module RequestSpecHelper
|
||||
include Warden::Test::Helpers
|
||||
|
||||
def self.included(base)
|
||||
base.before(:each) { Warden.test_mode! }
|
||||
base.after(:each) { Warden.test_reset! }
|
||||
base.before { Warden.test_mode! }
|
||||
base.after { Warden.test_reset! }
|
||||
end
|
||||
|
||||
def sign_in(resource)
|
||||
|
||||
@@ -54,7 +54,7 @@ module Users
|
||||
end
|
||||
|
||||
def confirm_email
|
||||
body = ActionMailer::Base.deliveries.last.try(:body)
|
||||
body = ActionMailer::Base.deliveries.last&.body
|
||||
expect(body).to be_present
|
||||
|
||||
sent_token = /.*confirmation_token=(.*)".*/.match(body.to_s)[1]
|
||||
|
||||
Reference in New Issue
Block a user