Apply Rails/SaveBang rubocop rule
Having exceptions is better than having silent bugs.
There are a few methods I've kept the same way they were.
The `RelatedContentScore#score_with_opposite` method is a bit peculiar:
it creates scores for both itself and the opposite related content,
which means the opposite related content will try to create the same
scores as well.
We've already got a test to check `Budget::Ballot#add_investment` when
creating a line fails ("Edge case voting a non-elegible investment").
Finally, the method `User#send_oauth_confirmation_instructions` doesn't
update the record when the email address isn't already present, leading
to the test "Try to register with the email of an already existing user,
when an unconfirmed email was provided by oauth" fo fail if we raise an
exception for an invalid user. That's because updating a user's email
doesn't update the database automatically, but instead a confirmation
email is sent.
There are also a few false positives for classes which don't have bang
methods (like the GraphQL classes) or destroying attachments.
For these reasons, I'm adding the rule with a "Refactor" severity,
meaning it's a rule we can break if necessary.
This commit is contained in:
@@ -51,9 +51,6 @@ Rails/OutputSafety:
|
||||
Rails/ReversibleMigration:
|
||||
Enabled: true
|
||||
|
||||
Rails/SaveBang:
|
||||
Enabled: true
|
||||
|
||||
Rails/SkipsModelValidations:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -181,6 +181,10 @@ Rails/SafeNavigation:
|
||||
Enabled: true
|
||||
ConvertTry: true
|
||||
|
||||
Rails/SaveBang:
|
||||
Enabled: true
|
||||
Severity: refactor
|
||||
|
||||
Rails/TimeZone:
|
||||
Enabled: true
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class Admin::AdminNotificationsController < Admin::BaseController
|
||||
|
||||
def destroy
|
||||
@admin_notification = AdminNotification.find(params[:id])
|
||||
@admin_notification.destroy
|
||||
@admin_notification.destroy!
|
||||
|
||||
notice = t("admin.admin_notifications.delete_success")
|
||||
redirect_to admin_admin_notifications_path, notice: notice
|
||||
|
||||
@@ -14,7 +14,7 @@ class Admin::AdministratorsController < Admin::BaseController
|
||||
|
||||
def create
|
||||
@administrator.user_id = params[:user_id]
|
||||
@administrator.save
|
||||
@administrator.save!
|
||||
|
||||
redirect_to admin_administrators_path
|
||||
end
|
||||
|
||||
@@ -31,7 +31,7 @@ class Admin::BannersController < Admin::BaseController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@banner.destroy
|
||||
@banner.destroy!
|
||||
redirect_to admin_banners_path
|
||||
end
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class Admin::BudgetGroupsController < Admin::BaseController
|
||||
if @group.headings.any?
|
||||
redirect_to groups_index, alert: t("admin.budget_groups.destroy.unable_notice")
|
||||
else
|
||||
@group.destroy
|
||||
@group.destroy!
|
||||
redirect_to groups_index, notice: t("admin.budget_groups.destroy.success_notice")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -37,7 +37,7 @@ class Admin::BudgetHeadingsController < Admin::BaseController
|
||||
|
||||
def destroy
|
||||
if @heading.can_be_deleted?
|
||||
@heading.destroy
|
||||
@heading.destroy!
|
||||
redirect_to headings_index, notice: t("admin.budget_headings.destroy.success_notice")
|
||||
else
|
||||
redirect_to headings_index, alert: t("admin.budget_headings.destroy.unable_notice")
|
||||
|
||||
@@ -62,7 +62,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||
|
||||
def toggle_selection
|
||||
@investment.toggle :selected
|
||||
@investment.save
|
||||
@investment.save!
|
||||
load_investments
|
||||
end
|
||||
|
||||
@@ -127,7 +127,7 @@ class Admin::BudgetInvestmentsController < Admin::BaseController
|
||||
|
||||
def load_ballot
|
||||
query = Budget::Ballot.where(user: current_user, budget: @budget)
|
||||
@ballot = @budget.balloting? ? query.first_or_create : query.first_or_initialize
|
||||
@ballot = @budget.balloting? ? query.first_or_create! : query.first_or_initialize
|
||||
end
|
||||
|
||||
def parse_valuation_filters
|
||||
|
||||
@@ -66,7 +66,7 @@ class Admin::BudgetsController < Admin::BaseController
|
||||
elsif @budget.poll.present?
|
||||
redirect_to admin_budgets_path, alert: t("admin.budgets.destroy.unable_notice_polls")
|
||||
else
|
||||
@budget.destroy
|
||||
@budget.destroy!
|
||||
redirect_to admin_budgets_path, notice: t("admin.budgets.destroy.success_notice")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class Admin::Dashboard::AdministratorTasksController < Admin::Dashboard::BaseCon
|
||||
def update
|
||||
authorize! :update, administrator_task
|
||||
|
||||
administrator_task.update(user: current_user, executed_at: Time.current)
|
||||
administrator_task.update!(user: current_user, executed_at: Time.current)
|
||||
redirect_to admin_dashboard_administrator_tasks_path,
|
||||
{ flash: { notice: t("admin.dashboard.administrator_tasks.update.success") }}
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ class Admin::GeozonesController < Admin::BaseController
|
||||
|
||||
def destroy
|
||||
if @geozone.safe_to_destroy?
|
||||
@geozone.destroy
|
||||
@geozone.destroy!
|
||||
redirect_to admin_geozones_path, notice: t("admin.geozones.delete.success")
|
||||
else
|
||||
redirect_to admin_geozones_path, flash: { error: t("admin.geozones.delete.error") }
|
||||
|
||||
@@ -32,7 +32,7 @@ class Admin::Legislation::DraftVersionsController < Admin::Legislation::BaseCont
|
||||
end
|
||||
|
||||
def destroy
|
||||
@draft_version.destroy
|
||||
@draft_version.destroy!
|
||||
notice = t("admin.legislation.draft_versions.destroy.notice")
|
||||
redirect_to admin_legislation_process_draft_versions_path, notice: notice
|
||||
end
|
||||
|
||||
@@ -46,7 +46,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
end
|
||||
|
||||
def destroy
|
||||
@process.destroy
|
||||
@process.destroy!
|
||||
notice = t("admin.legislation.processes.destroy.notice")
|
||||
redirect_to admin_legislation_processes_path, notice: notice
|
||||
end
|
||||
@@ -93,7 +93,7 @@ class Admin::Legislation::ProcessesController < Admin::Legislation::BaseControll
|
||||
|
||||
def set_tag_list
|
||||
@process.set_tag_list_on(:customs, process_params[:custom_list])
|
||||
@process.save
|
||||
@process.save!
|
||||
end
|
||||
|
||||
def resource
|
||||
|
||||
@@ -33,7 +33,7 @@ class Admin::Legislation::QuestionsController < Admin::Legislation::BaseControll
|
||||
end
|
||||
|
||||
def destroy
|
||||
@question.destroy
|
||||
@question.destroy!
|
||||
notice = t("admin.legislation.questions.destroy.notice")
|
||||
redirect_to admin_legislation_process_questions_path, notice: notice
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ class Admin::LocalCensusRecordsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@local_census_record.destroy
|
||||
@local_census_record.destroy!
|
||||
redirect_to admin_local_census_records_path,
|
||||
notice: t("admin.local_census_records.destroy.notice")
|
||||
end
|
||||
|
||||
@@ -14,13 +14,13 @@ class Admin::ManagersController < Admin::BaseController
|
||||
|
||||
def create
|
||||
@manager.user_id = params[:user_id]
|
||||
@manager.save
|
||||
@manager.save!
|
||||
|
||||
redirect_to admin_managers_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
@manager.destroy
|
||||
@manager.destroy!
|
||||
redirect_to admin_managers_path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,7 +34,7 @@ class Admin::MilestoneStatusesController < Admin::BaseController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@status.destroy
|
||||
@status.destroy!
|
||||
redirect_to admin_milestone_statuses_path,
|
||||
notice: t("admin.statuses.delete.notice")
|
||||
end
|
||||
|
||||
@@ -14,13 +14,13 @@ class Admin::ModeratorsController < Admin::BaseController
|
||||
|
||||
def create
|
||||
@moderator.user_id = params[:user_id]
|
||||
@moderator.save
|
||||
@moderator.save!
|
||||
|
||||
redirect_to admin_moderators_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
@moderator.destroy
|
||||
@moderator.destroy!
|
||||
redirect_to admin_moderators_path
|
||||
end
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ class Admin::NewslettersController < Admin::BaseController
|
||||
|
||||
def destroy
|
||||
@newsletter = Newsletter.find(params[:id])
|
||||
@newsletter.destroy
|
||||
@newsletter.destroy!
|
||||
|
||||
redirect_to admin_newsletters_path, notice: t("admin.newsletters.delete_success")
|
||||
end
|
||||
@@ -49,7 +49,7 @@ class Admin::NewslettersController < Admin::BaseController
|
||||
|
||||
if @newsletter.valid?
|
||||
@newsletter.delay.deliver
|
||||
@newsletter.update(sent_at: Time.current)
|
||||
@newsletter.update!(sent_at: Time.current)
|
||||
flash[:notice] = t("admin.newsletters.send_success")
|
||||
else
|
||||
flash[:error] = t("admin.segment_recipient.invalid_recipients_segment")
|
||||
|
||||
@@ -14,7 +14,7 @@ class Admin::OfficialsController < Admin::BaseController
|
||||
|
||||
def update
|
||||
@user = User.find(params[:id])
|
||||
@user.update(user_params)
|
||||
@user.update!(user_params)
|
||||
redirect_to admin_officials_path, notice: t("admin.officials.flash.official_updated")
|
||||
end
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
|
||||
@booth_assignment = ::Poll::BoothAssignment.new(poll: @poll,
|
||||
booth: @booth)
|
||||
|
||||
@booth_assignment.save
|
||||
@booth_assignment.save!
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render layout: false }
|
||||
@@ -41,7 +41,7 @@ class Admin::Poll::BoothAssignmentsController < Admin::Poll::BaseController
|
||||
@booth = Poll::Booth.find(booth_assignment_params[:booth_id])
|
||||
@booth_assignment = ::Poll::BoothAssignment.find(params[:id])
|
||||
|
||||
@booth_assignment.destroy
|
||||
@booth_assignment.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render layout: false }
|
||||
|
||||
@@ -20,13 +20,13 @@ class Admin::Poll::OfficersController < Admin::Poll::BaseController
|
||||
|
||||
def create
|
||||
@officer.user_id = params[:user_id]
|
||||
@officer.save
|
||||
@officer.save!
|
||||
|
||||
redirect_to admin_officers_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
@officer.destroy
|
||||
@officer.destroy!
|
||||
redirect_to admin_officers_path
|
||||
end
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ class Admin::Poll::PollsController < Admin::Poll::BaseController
|
||||
if ::Poll::Voter.where(poll: @poll).any?
|
||||
redirect_to admin_poll_path(@poll), alert: t("admin.polls.destroy.unable_notice")
|
||||
else
|
||||
@poll.destroy
|
||||
@poll.destroy!
|
||||
|
||||
redirect_to admin_polls_path, notice: t("admin.polls.destroy.success_notice")
|
||||
end
|
||||
|
||||
@@ -22,7 +22,7 @@ class Admin::Poll::Questions::Answers::ImagesController < Admin::Poll::BaseContr
|
||||
|
||||
def destroy
|
||||
@image = ::Image.find(params[:id])
|
||||
@image.destroy
|
||||
@image.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
format.js { render layout: false }
|
||||
|
||||
@@ -30,7 +30,7 @@ class Admin::Poll::ShiftsController < Admin::Poll::BaseController
|
||||
alert = t("admin.poll_shifts.flash.unable_to_destroy")
|
||||
redirect_to new_admin_booth_shift_path(@booth), alert: alert
|
||||
else
|
||||
@shift.destroy
|
||||
@shift.destroy!
|
||||
notice = t("admin.poll_shifts.flash.destroy")
|
||||
redirect_to new_admin_booth_shift_path(@booth), notice: notice
|
||||
end
|
||||
|
||||
@@ -22,7 +22,7 @@ class Admin::SettingsController < Admin::BaseController
|
||||
|
||||
def update
|
||||
@setting = Setting.find(params[:id])
|
||||
@setting.update(settings_params)
|
||||
@setting.update!(settings_params)
|
||||
redirect_to request_referer, notice: t("admin.settings.flash.updated")
|
||||
end
|
||||
|
||||
@@ -39,7 +39,7 @@ class Admin::SettingsController < Admin::BaseController
|
||||
mime_type_values = content_type_params.keys.map do |content_type|
|
||||
Setting.mime_types[group][content_type]
|
||||
end
|
||||
setting.update value: mime_type_values.join(" ")
|
||||
setting.update! value: mime_type_values.join(" ")
|
||||
redirect_to admin_settings_path, notice: t("admin.settings.flash.updated")
|
||||
end
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
|
||||
if is_heading_content_block?(params[:site_customization_content_block][:name])
|
||||
heading_content_block = new_heading_content_block
|
||||
if heading_content_block.save
|
||||
@content_block.destroy
|
||||
@content_block.destroy!
|
||||
notice = t("admin.site_customization.content_blocks.create.notice")
|
||||
redirect_to admin_site_customization_content_blocks_path, notice: notice
|
||||
else
|
||||
@@ -61,13 +61,13 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
|
||||
end
|
||||
|
||||
def destroy
|
||||
@content_block.destroy
|
||||
@content_block.destroy!
|
||||
notice = t("admin.site_customization.content_blocks.destroy.notice")
|
||||
redirect_to admin_site_customization_content_blocks_path, notice: notice
|
||||
end
|
||||
|
||||
def delete_heading_content_block
|
||||
Budget::ContentBlock.find(params[:id]).destroy
|
||||
Budget::ContentBlock.find(params[:id]).destroy!
|
||||
notice = t("admin.site_customization.content_blocks.destroy.notice")
|
||||
redirect_to admin_site_customization_content_blocks_path, notice: notice
|
||||
end
|
||||
@@ -101,7 +101,7 @@ class Admin::SiteCustomization::ContentBlocksController < Admin::SiteCustomizati
|
||||
@content_block.locale = params[:locale]
|
||||
@content_block.body = params[:body]
|
||||
if @content_block.save
|
||||
heading_content_block.destroy
|
||||
heading_content_block.destroy!
|
||||
notice = t("admin.site_customization.content_blocks.update.notice")
|
||||
redirect_to admin_site_customization_content_blocks_path, notice: notice
|
||||
else
|
||||
|
||||
@@ -21,7 +21,7 @@ class Admin::SiteCustomization::DocumentsController < Admin::SiteCustomization::
|
||||
|
||||
def destroy
|
||||
@document = Document.find(params[:id])
|
||||
@document.destroy
|
||||
@document.destroy!
|
||||
|
||||
notice = t("admin.documents.destroy.success_notice")
|
||||
redirect_to admin_site_customization_documents_path, notice: notice
|
||||
|
||||
@@ -17,9 +17,9 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
|
||||
if value == t(content[:id], locale: locale) || value.match(/translation missing/)
|
||||
next
|
||||
else
|
||||
text = I18nContent.find_or_create_by(key: content[:id])
|
||||
text = I18nContent.find_or_create_by!(key: content[:id])
|
||||
Globalize.locale = locale
|
||||
text.update(value: value)
|
||||
text.update!(value: value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -27,7 +27,7 @@ class Admin::SiteCustomization::PagesController < Admin::SiteCustomization::Base
|
||||
end
|
||||
|
||||
def destroy
|
||||
@page.destroy
|
||||
@page.destroy!
|
||||
notice = t("admin.site_customization.pages.destroy.notice")
|
||||
redirect_to admin_site_customization_pages_path, notice: notice
|
||||
end
|
||||
|
||||
@@ -9,12 +9,12 @@ class Admin::TagsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def create
|
||||
Tag.category.create(tag_params)
|
||||
Tag.category.create!(tag_params)
|
||||
redirect_to admin_tags_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
@tag.destroy
|
||||
@tag.destroy!
|
||||
redirect_to admin_tags_path
|
||||
end
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class Admin::TrackersController < Admin::BaseController
|
||||
|
||||
def create
|
||||
@tracker = Tracker.new(tracker_params)
|
||||
@tracker.save
|
||||
@tracker.save!
|
||||
|
||||
redirect_to admin_trackers_path
|
||||
end
|
||||
@@ -40,7 +40,7 @@ class Admin::TrackersController < Admin::BaseController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@tracker.destroy
|
||||
@tracker.destroy!
|
||||
redirect_to admin_trackers_path
|
||||
end
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class Admin::ValuatorGroupsController < Admin::BaseController
|
||||
|
||||
def destroy
|
||||
@group = ValuatorGroup.find(params[:id])
|
||||
@group.destroy
|
||||
@group.destroy!
|
||||
notice = t("flash.actions.destroy.valuator_group")
|
||||
redirect_to [:admin, :valuator_groups], notice: notice
|
||||
end
|
||||
|
||||
@@ -18,7 +18,7 @@ class Admin::ValuatorsController < Admin::BaseController
|
||||
|
||||
def create
|
||||
@valuator = Valuator.new(valuator_params)
|
||||
@valuator.save
|
||||
@valuator.save!
|
||||
|
||||
redirect_to admin_valuators_path
|
||||
end
|
||||
@@ -39,7 +39,7 @@ class Admin::ValuatorsController < Admin::BaseController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@valuator.destroy
|
||||
@valuator.destroy!
|
||||
redirect_to admin_valuators_path
|
||||
end
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class Admin::Widget::CardsController < Admin::BaseController
|
||||
|
||||
def destroy
|
||||
@card = ::Widget::Card.find(params[:id])
|
||||
@card.destroy
|
||||
@card.destroy!
|
||||
|
||||
redirect_to_customization_page_cards_or_homepage
|
||||
end
|
||||
|
||||
@@ -2,7 +2,7 @@ class Admin::Widget::FeedsController < Admin::BaseController
|
||||
|
||||
def update
|
||||
@feed = ::Widget::Feed.find(params[:id])
|
||||
@feed.update(feed_params)
|
||||
@feed.update!(feed_params)
|
||||
|
||||
head :ok
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@ module Budgets
|
||||
load_heading
|
||||
load_map
|
||||
|
||||
@line.destroy
|
||||
@line.destroy!
|
||||
load_investments
|
||||
end
|
||||
|
||||
@@ -41,7 +41,7 @@ module Budgets
|
||||
end
|
||||
|
||||
def load_ballot
|
||||
@ballot = Budget::Ballot.where(user: current_user, budget: @budget).first_or_create
|
||||
@ballot = Budget::Ballot.where(user: current_user, budget: @budget).first_or_create!
|
||||
end
|
||||
|
||||
def load_investment
|
||||
|
||||
@@ -20,7 +20,7 @@ module Budgets
|
||||
|
||||
def load_ballot
|
||||
query = Budget::Ballot.where(user: current_user, budget: @budget)
|
||||
@ballot = @budget.balloting? ? query.first_or_create : query.first_or_initialize
|
||||
@ballot = @budget.balloting? ? query.first_or_create! : query.first_or_initialize
|
||||
end
|
||||
|
||||
def store_referer
|
||||
|
||||
@@ -86,7 +86,7 @@ module Budgets
|
||||
end
|
||||
|
||||
def destroy
|
||||
@investment.destroy
|
||||
@investment.destroy!
|
||||
redirect_to user_path(current_user, filter: "budget_investments"), notice: t("flash.actions.destroy.budget_investment")
|
||||
end
|
||||
|
||||
@@ -143,7 +143,7 @@ module Budgets
|
||||
|
||||
def load_ballot
|
||||
query = Budget::Ballot.where(user: current_user, budget: @budget)
|
||||
@ballot = @budget.balloting? ? query.first_or_create : query.first_or_initialize
|
||||
@ballot = @budget.balloting? ? query.first_or_create! : query.first_or_initialize
|
||||
end
|
||||
|
||||
def load_heading
|
||||
|
||||
@@ -17,7 +17,7 @@ class Dashboard::ActionsController < Dashboard::BaseController
|
||||
|
||||
@dashboard_executed_action = Dashboard::ExecutedAction.new(source_params)
|
||||
if @dashboard_executed_action.save
|
||||
Dashboard::AdministratorTask.create(source: @dashboard_executed_action)
|
||||
Dashboard::AdministratorTask.create!(source: @dashboard_executed_action)
|
||||
|
||||
redirect_to progress_proposal_dashboard_path(proposal.to_param),
|
||||
{ flash: { info: t("dashboard.create_request.success") }}
|
||||
@@ -38,7 +38,7 @@ class Dashboard::ActionsController < Dashboard::BaseController
|
||||
def unexecute
|
||||
authorize! :dashboard, proposal
|
||||
|
||||
Dashboard::ExecutedAction.where(proposal: proposal, action: dashboard_action).first.destroy
|
||||
Dashboard::ExecutedAction.where(proposal: proposal, action: dashboard_action).first.destroy!
|
||||
|
||||
redirect_to request.referer
|
||||
end
|
||||
|
||||
@@ -42,7 +42,7 @@ class Dashboard::PollsController < Dashboard::BaseController
|
||||
if ::Poll::Voter.where(poll: poll).any?
|
||||
redirect_to proposal_dashboard_polls_path(proposal), alert: t("dashboard.polls.poll.unable_notice")
|
||||
else
|
||||
poll.destroy
|
||||
poll.destroy!
|
||||
|
||||
redirect_to proposal_dashboard_polls_path(proposal), notice: t("dashboard.polls.poll.success_notice")
|
||||
end
|
||||
|
||||
@@ -3,14 +3,14 @@ class FollowsController < ApplicationController
|
||||
load_and_authorize_resource
|
||||
|
||||
def create
|
||||
@follow = Follow.create(user: current_user, followable: find_followable)
|
||||
@follow = Follow.create!(user: current_user, followable: find_followable)
|
||||
flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow.followable)}.create.notice")
|
||||
render :refresh_follow_button
|
||||
end
|
||||
|
||||
def destroy
|
||||
@follow = Follow.find(params[:id])
|
||||
@follow.destroy
|
||||
@follow.destroy!
|
||||
flash.now[:notice] = t("shared.followable.#{followable_translation_key(@follow.followable)}.destroy.notice")
|
||||
render :refresh_follow_button
|
||||
end
|
||||
|
||||
@@ -11,7 +11,7 @@ class Legislation::AnswersController < Legislation::BaseController
|
||||
def create
|
||||
if @process.debate_phase.open?
|
||||
@answer.user = current_user
|
||||
@answer.save
|
||||
@answer.save!
|
||||
track_event
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
||||
@@ -7,7 +7,7 @@ class Polls::AnswersController < ApplicationController
|
||||
def create
|
||||
@question = Poll::Question.find_by(id: params[:id])
|
||||
if @question.votation_type.open? && !check_question_answer_exist
|
||||
@question.question_answers.create(
|
||||
@question.question_answers.create!(
|
||||
title: params[:answer],
|
||||
given_order: @question.question_answers.maximum(:given_order).to_i + 1,
|
||||
hidden: false
|
||||
|
||||
@@ -7,7 +7,7 @@ class RelatedContentsController < ApplicationController
|
||||
if relationable_object && related_object
|
||||
|
||||
if relationable_object.url != related_object.url
|
||||
RelatedContent.create(parent_relationable: @relationable, child_relationable: @related, author: current_user)
|
||||
RelatedContent.create!(parent_relationable: @relationable, child_relationable: @related, author: current_user)
|
||||
|
||||
flash[:success] = t("related_content.success")
|
||||
else
|
||||
|
||||
@@ -6,7 +6,7 @@ class RemoteTranslationsController < ApplicationController
|
||||
|
||||
def create
|
||||
@remote_translations.each do |remote_translation|
|
||||
RemoteTranslation.create(remote_translation) unless translations_enqueued?(remote_translation)
|
||||
RemoteTranslation.create!(remote_translation) unless translations_enqueued?(remote_translation)
|
||||
end
|
||||
redirect_to request.referer, notice: t("remote_translations.create.enqueue_remote_translation")
|
||||
end
|
||||
|
||||
@@ -40,7 +40,7 @@ class TopicsController < ApplicationController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@topic.destroy
|
||||
@topic.destroy!
|
||||
redirect_to community_path(@community), notice: I18n.t("flash.actions.destroy.topic")
|
||||
end
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class Tracking::MilestonesController < Tracking::BaseController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@milestone.destroy
|
||||
@milestone.destroy!
|
||||
redirect_to milestoneable_path, notice: t("tracking.milestones.delete.notice")
|
||||
end
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class Tracking::ProgressBarsController < Tracking::BaseController
|
||||
end
|
||||
|
||||
def destroy
|
||||
@progress_bar.destroy
|
||||
@progress_bar.destroy!
|
||||
redirect_to progress_bars_index, notice: t("tracking.progress_bars.delete.notice")
|
||||
end
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||
resource.assign_attributes(resource_params)
|
||||
|
||||
if resource.valid? # password is set correctly
|
||||
resource.save
|
||||
resource.save!
|
||||
set_official_position if resource.has_official_email?
|
||||
resource.confirm
|
||||
set_flash_message(:notice, :confirmed) if is_flashing_format?
|
||||
|
||||
@@ -31,7 +31,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
|
||||
@user = current_user || identity.user || User.first_or_initialize_for_oauth(auth)
|
||||
|
||||
if save_user
|
||||
identity.update(user: @user)
|
||||
identity.update!(user: @user)
|
||||
sign_in_and_redirect @user, event: :authentication
|
||||
set_flash_message(:notice, :success, kind: provider.to_s.capitalize) if is_navigational_format?
|
||||
else
|
||||
|
||||
@@ -6,7 +6,7 @@ class Verification::EmailController < ApplicationController
|
||||
|
||||
def show
|
||||
if Verification::Email.find(current_user, params[:email_verification_token])
|
||||
current_user.update(verified_at: Time.current)
|
||||
current_user.update!(verified_at: Time.current)
|
||||
redirect_to account_path, notice: t("verification.email.show.flash.success")
|
||||
else
|
||||
redirect_to verified_user_path, alert: t("verification.email.show.alert.failure")
|
||||
|
||||
@@ -29,7 +29,7 @@ class Verification::LetterController < ApplicationController
|
||||
def update
|
||||
@letter = Verification::Letter.new(letter_params.merge(user: current_user, verify: true))
|
||||
if @letter.valid?
|
||||
current_user.update(verified_at: Time.current)
|
||||
current_user.update!(verified_at: Time.current)
|
||||
redirect_to account_path, notice: t("verification.letter.update.flash.success")
|
||||
else
|
||||
Lock.increase_tries(@letter.user) if @letter.user
|
||||
|
||||
@@ -27,7 +27,7 @@ class Verification::SmsController < ApplicationController
|
||||
def update
|
||||
@sms = Verification::Sms.new(sms_params.merge(user: current_user))
|
||||
if @sms.verified?
|
||||
current_user.update(confirmed_phone: current_user.unconfirmed_phone)
|
||||
current_user.update!(confirmed_phone: current_user.unconfirmed_phone)
|
||||
ahoy.track(:level_2_user, user_id: current_user.id) rescue nil
|
||||
|
||||
if VerifiedUser.phone?(current_user)
|
||||
|
||||
@@ -15,7 +15,7 @@ class Activity < ApplicationRecord
|
||||
scope :for_render, -> { includes(user: [:moderator, :administrator]).includes(:actionable) }
|
||||
|
||||
def self.log(user, action, actionable)
|
||||
create(user: user, action: action.to_s, actionable: actionable)
|
||||
create!(user: user, action: action.to_s, actionable: actionable)
|
||||
end
|
||||
|
||||
def self.on(actionable)
|
||||
|
||||
@@ -30,7 +30,7 @@ class AdminNotification < ApplicationRecord
|
||||
|
||||
def deliver
|
||||
list_of_recipients.each { |user| Notification.add(user, self) }
|
||||
self.update(sent_at: Time.current, recipients_count: list_of_recipients.count)
|
||||
update!(sent_at: Time.current, recipients_count: list_of_recipients.count)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -256,7 +256,7 @@ class Budget
|
||||
|
||||
def send_unfeasible_email
|
||||
Mailer.budget_investment_unfeasible(self).deliver_later
|
||||
update(unfeasible_email_sent_at: Time.current)
|
||||
update!(unfeasible_email_sent_at: Time.current)
|
||||
end
|
||||
|
||||
def reason_for_not_being_selectable_by(user)
|
||||
|
||||
@@ -42,7 +42,7 @@ class Budget
|
||||
|
||||
def set_winner
|
||||
@money_spent += @current_investment.price
|
||||
@current_investment.update(winner: true)
|
||||
@current_investment.update!(winner: true)
|
||||
end
|
||||
|
||||
def winners
|
||||
|
||||
@@ -7,7 +7,7 @@ module Communitable
|
||||
end
|
||||
|
||||
def associate_community
|
||||
community = Community.create
|
||||
community = Community.create!
|
||||
self.community_id = community.id
|
||||
end
|
||||
|
||||
|
||||
@@ -7,10 +7,10 @@ class DownloadSetting < ApplicationRecord
|
||||
name_field: field_name,
|
||||
config: config)
|
||||
if download_setting.nil?
|
||||
download_setting = DownloadSetting.create(downloadable: false,
|
||||
name_model: model.name,
|
||||
name_field: field_name,
|
||||
config: config)
|
||||
download_setting = DownloadSetting.create!(downloadable: false,
|
||||
name_model: model.name,
|
||||
name_field: field_name,
|
||||
config: config)
|
||||
end
|
||||
download_setting
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class Flag < ApplicationRecord
|
||||
|
||||
def self.flag(user, flaggable)
|
||||
return false if flagged?(user, flaggable)
|
||||
create(user: user, flaggable: flaggable)
|
||||
create!(user: user, flaggable: flaggable)
|
||||
end
|
||||
|
||||
def self.unflag(user, flaggable)
|
||||
|
||||
@@ -5,6 +5,6 @@ class Identity < ApplicationRecord
|
||||
validates :uid, presence: true, uniqueness: { scope: :provider }
|
||||
|
||||
def self.first_or_create_from_oauth(auth)
|
||||
where(uid: auth.uid, provider: auth.provider).first_or_create
|
||||
where(uid: auth.uid, provider: auth.provider).first_or_create!
|
||||
end
|
||||
end
|
||||
|
||||
@@ -45,7 +45,7 @@ class LocalCensusRecords::Import
|
||||
if local_census_record.invalid?
|
||||
invalid_records << local_census_record
|
||||
else
|
||||
local_census_record.save
|
||||
local_census_record.save!
|
||||
created_records << local_census_record
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ class Lock < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.increase_tries(user)
|
||||
Lock.find_or_create_by(user: user).increment!(:tries).save
|
||||
find_or_create_by!(user: user).increment!(:tries).save!
|
||||
end
|
||||
|
||||
def self.max_tries
|
||||
|
||||
@@ -29,7 +29,7 @@ class Officing::Residence
|
||||
|
||||
if user_exists?
|
||||
self.user = find_user_by_document
|
||||
user.update(verified_at: Time.current)
|
||||
user.update!(verified_at: Time.current)
|
||||
else
|
||||
user_params = {
|
||||
document_number: document_number,
|
||||
|
||||
@@ -27,7 +27,7 @@ class Poll::BallotSheet < ApplicationRecord
|
||||
def create_ballots(investment_ids, index)
|
||||
poll_ballot = Poll::Ballot.where(ballot_sheet: self,
|
||||
data: investment_ids,
|
||||
external_id: index).first_or_create
|
||||
external_id: index).first_or_create!
|
||||
create_ballot(poll_ballot)
|
||||
poll_ballot
|
||||
end
|
||||
@@ -36,7 +36,7 @@ class Poll::BallotSheet < ApplicationRecord
|
||||
Budget::Ballot.where(physical: true,
|
||||
user: nil,
|
||||
poll_ballot: poll_ballot,
|
||||
budget: poll.budget).first_or_create
|
||||
budget: poll.budget).first_or_create!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -73,12 +73,12 @@ class Poll::Question::Answer < ApplicationRecord
|
||||
answers = question.question_answers.visibles
|
||||
.map { |a| count_positive_negative(a, true) - count_positive_negative(a, false) }
|
||||
is_most_voted = answers.none? { |a| a > total_votes_positive_negative }
|
||||
update(most_voted: is_most_voted)
|
||||
update!(most_voted: is_most_voted)
|
||||
when "prioritized"
|
||||
answers = question.question_answers.visibles
|
||||
.map { |a| Poll::Answer.where(question_id: a.question, answer: a.title).sum(:value) }
|
||||
is_most_voted = answers.none? { |a| a > total_votes_prioritized }
|
||||
update(most_voted: is_most_voted)
|
||||
update!(most_voted: is_most_voted)
|
||||
else
|
||||
for_only_votes
|
||||
end
|
||||
@@ -95,7 +95,7 @@ class Poll::Question::Answer < ApplicationRecord
|
||||
answers = question.question_answers.visibles
|
||||
.map { |a| Poll::Answer.where(question_id: a.question, answer: a.title).count }
|
||||
is_most_voted = answers.none? { |a| a > total_votes }
|
||||
update(most_voted: is_most_voted)
|
||||
update!(most_voted: is_most_voted)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -96,7 +96,7 @@ class Proposal < ApplicationRecord
|
||||
end
|
||||
|
||||
def publish
|
||||
update(published_at: Time.current)
|
||||
update!(published_at: Time.current)
|
||||
send_new_actions_notification_on_published
|
||||
end
|
||||
|
||||
|
||||
@@ -28,10 +28,10 @@ class SignatureSheet < ApplicationRecord
|
||||
|
||||
signature = signatures.where(document_number: document_number,
|
||||
date_of_birth: date_of_birth,
|
||||
postal_code: postal_code).first_or_create
|
||||
postal_code: postal_code).first_or_create!
|
||||
signature.verify
|
||||
end
|
||||
update(processed: true)
|
||||
update!(processed: true)
|
||||
end
|
||||
|
||||
def parsed_required_fields_to_verify_groups
|
||||
|
||||
@@ -181,11 +181,11 @@ class User < ApplicationRecord
|
||||
|
||||
def add_official_position!(position, level)
|
||||
return if position.blank? || level.blank?
|
||||
update official_position: position, official_level: level.to_i
|
||||
update! official_position: position, official_level: level.to_i
|
||||
end
|
||||
|
||||
def remove_official_position!
|
||||
update official_position: nil, official_level: 0
|
||||
update! official_position: nil, official_level: 0
|
||||
end
|
||||
|
||||
def has_official_email?
|
||||
@@ -215,7 +215,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def erase(erase_reason = nil)
|
||||
update(
|
||||
update!(
|
||||
erased_at: Time.current,
|
||||
erase_reason: erase_reason,
|
||||
username: nil,
|
||||
@@ -241,7 +241,7 @@ class User < ApplicationRecord
|
||||
.where(document_type: document_type).first
|
||||
if erased_user.present?
|
||||
take_votes_from(erased_user)
|
||||
erased_user.update(document_number: nil, document_type: nil)
|
||||
erased_user.update!(document_number: nil, document_type: nil)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -251,11 +251,11 @@ class User < ApplicationRecord
|
||||
Budget::Ballot.where(user_id: other_user.id).update_all(user_id: id)
|
||||
Vote.where("voter_id = ? AND voter_type = ?", other_user.id, "User").update_all(voter_id: id)
|
||||
data_log = "id: #{other_user.id} - #{Time.current.strftime("%Y-%m-%d %H:%M:%S")}"
|
||||
update(former_users_data_log: "#{former_users_data_log} | #{data_log}")
|
||||
update!(former_users_data_log: "#{former_users_data_log} | #{data_log}")
|
||||
end
|
||||
|
||||
def locked?
|
||||
Lock.find_or_create_by(user: self).locked?
|
||||
Lock.find_or_create_by!(user: self).locked?
|
||||
end
|
||||
|
||||
def self.search(term)
|
||||
@@ -315,11 +315,11 @@ class User < ApplicationRecord
|
||||
def save_requiring_finish_signup
|
||||
begin
|
||||
self.registering_with_oauth = true
|
||||
save(validate: false)
|
||||
save!(validate: false)
|
||||
# Devise puts unique constraints for the email the db, so we must detect & handle that
|
||||
rescue ActiveRecord::RecordNotUnique
|
||||
self.email = nil
|
||||
save(validate: false)
|
||||
save!(validate: false)
|
||||
end
|
||||
true
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ class Verification::Email
|
||||
return false unless valid?
|
||||
|
||||
generate_token
|
||||
user.update(email_verification_token: @plain_token)
|
||||
user.update!(email_verification_token: @plain_token)
|
||||
end
|
||||
|
||||
def user
|
||||
|
||||
@@ -25,11 +25,11 @@ class Verification::Management::Email
|
||||
|
||||
plain_token, encrypted_token = Devise.token_generator.generate(User, :email_verification_token)
|
||||
|
||||
user.update(document_type: document_type,
|
||||
document_number: document_number,
|
||||
residence_verified_at: Time.current,
|
||||
level_two_verified_at: Time.current,
|
||||
email_verification_token: plain_token)
|
||||
user.update!(document_type: document_type,
|
||||
document_number: document_number,
|
||||
residence_verified_at: Time.current,
|
||||
level_two_verified_at: Time.current,
|
||||
email_verification_token: plain_token)
|
||||
|
||||
Mailer.email_verification(user, email, encrypted_token, document_type, document_number).deliver_later
|
||||
true
|
||||
|
||||
@@ -81,9 +81,9 @@ class VotationType < ApplicationRecord
|
||||
result = votes.by_author(user.id).find_by(answer: answer)
|
||||
if result.nil?
|
||||
if check_max_votes(user, votes)
|
||||
result = votes.create(author: user,
|
||||
answer: answer,
|
||||
positive: options[:positive])
|
||||
result = votes.create!(author: user,
|
||||
answer: answer,
|
||||
positive: options[:positive])
|
||||
end
|
||||
else
|
||||
!result.update(positive: options[:positive])
|
||||
@@ -91,7 +91,7 @@ class VotationType < ApplicationRecord
|
||||
|
||||
when "answer_couples_closed", "answer_couples_open"
|
||||
if check_max_votes(user, votes)
|
||||
result = votes.create(
|
||||
result = votes.create!(
|
||||
answer: answer,
|
||||
author: user,
|
||||
positive: true,
|
||||
@@ -114,7 +114,7 @@ class VotationType < ApplicationRecord
|
||||
return if questionable.question_answers.where(title: answer).any?
|
||||
|
||||
questionable.question_answers
|
||||
.create(
|
||||
.create!(
|
||||
title: answer,
|
||||
given_order: questionable.question_answers.maximum(:given_order).to_i + 1,
|
||||
hidden: hidden
|
||||
@@ -140,7 +140,7 @@ class VotationType < ApplicationRecord
|
||||
|
||||
def self.create_by_type(questionable, params)
|
||||
votation_type = build_by_type(questionable, params)
|
||||
votation_type.save
|
||||
votation_type.save!
|
||||
end
|
||||
|
||||
def update_priorized_values(user)
|
||||
|
||||
@@ -13,7 +13,7 @@ class Widget::Feed < ApplicationRecord
|
||||
|
||||
def self.active
|
||||
KINDS.collect do |kind|
|
||||
feed = find_or_create_by(kind: kind)
|
||||
feed = find_or_create_by!(kind: kind)
|
||||
feed if feed.active?
|
||||
end.compact
|
||||
end
|
||||
|
||||
@@ -20,9 +20,9 @@ section "Creating banners" do
|
||||
end
|
||||
|
||||
section "Creating web sections" do
|
||||
WebSection.create(name: "homepage")
|
||||
WebSection.create(name: "debates")
|
||||
WebSection.create(name: "proposals")
|
||||
WebSection.create(name: "budgets")
|
||||
WebSection.create(name: "help_page")
|
||||
WebSection.create!(name: "homepage")
|
||||
WebSection.create!(name: "debates")
|
||||
WebSection.create!(name: "proposals")
|
||||
WebSection.create!(name: "budgets")
|
||||
WebSection.create!(name: "help_page")
|
||||
end
|
||||
|
||||
@@ -21,18 +21,18 @@ def add_image_to(imageable)
|
||||
attachment: INVESTMENT_IMAGE_FILES.sample,
|
||||
user: imageable.author
|
||||
})
|
||||
imageable.save
|
||||
imageable.save!
|
||||
end
|
||||
|
||||
section "Creating Budgets" do
|
||||
Budget.create(
|
||||
Budget.create!(
|
||||
name_en: "#{I18n.t("seeds.budgets.budget", locale: :en)} #{Date.current.year - 1}",
|
||||
name_es: "#{I18n.t("seeds.budgets.budget", locale: :es)} #{Date.current.year - 1}",
|
||||
currency_symbol: I18n.t("seeds.budgets.currency"),
|
||||
phase: "finished"
|
||||
)
|
||||
|
||||
Budget.create(
|
||||
Budget.create!(
|
||||
name_en: "#{I18n.t("seeds.budgets.budget", locale: :en)} #{Date.current.year}",
|
||||
name_es: "#{I18n.t("seeds.budgets.budget", locale: :es)} #{Date.current.year}",
|
||||
currency_symbol: I18n.t("seeds.budgets.currency"),
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
section "Creating Geozones" do
|
||||
Geozone.create(name: I18n.t("seeds.geozones.north_district"),
|
||||
external_code: "001", census_code: "01",
|
||||
html_map_coordinates: "30,139,45,153,77,148,107,165,138,201,146,218,186,198,216,"\
|
||||
"196,233,203,240,215,283,194,329,185,377,184,388,165,369,126,333,113,334,84,320,"\
|
||||
"66,286,73,258,65,265,57,249,47,207,58,159,84,108,85,72,101,51,114")
|
||||
Geozone.create(name: I18n.t("seeds.geozones.west_district"),
|
||||
external_code: "002", census_code: "02",
|
||||
html_map_coordinates: "42,153,31,176,24,202,20,221,44,235,59,249,55,320,30,354,"\
|
||||
"31,372,52,396,64,432,89,453,116,432,149,419,162,412,165,377,172,357,189,352,228,"\
|
||||
"327,246,313,262,297,234,291,210,284,193,284,176,294,158,303,154,310,146,289,140,"\
|
||||
"268,138,246,135,236,139,222,151,214,136,197,120,179,99,159,85,149,65,149,56,149")
|
||||
Geozone.create(name: I18n.t("seeds.geozones.east_district"),
|
||||
external_code: "003", census_code: "03",
|
||||
html_map_coordinates: "175,353,162,378,161,407,153,416,167,432,184,447,225,426,"\
|
||||
"250,409,283,390,298,369,344,363,351,334,356,296,361,267,376,245,378,185,327,188,"\
|
||||
"281,195,239,216,245,221,245,232,261,244,281,238,300,242,304,251,285,262,278,277,"\
|
||||
"267,294,249,312,219,333,198,346,184,353")
|
||||
Geozone.create(name: I18n.t("seeds.geozones.central_district"),
|
||||
external_code: "004", census_code: "04",
|
||||
html_map_coordinates: "152,308,137,258,133,235,147,216,152,214,186,194,210,196,"\
|
||||
"228,202,240,216,241,232,263,243,293,241,301,245,302,254,286,265,274,278,267,296,"\
|
||||
"243,293,226,289,209,285,195,283,177,297")
|
||||
Geozone.create!(name: I18n.t("seeds.geozones.north_district"),
|
||||
external_code: "001", census_code: "01",
|
||||
html_map_coordinates: "30,139,45,153,77,148,107,165,138,201,146,218,186,198,216,"\
|
||||
"196,233,203,240,215,283,194,329,185,377,184,388,165,369,126,333,113,334,84,320,"\
|
||||
"66,286,73,258,65,265,57,249,47,207,58,159,84,108,85,72,101,51,114")
|
||||
Geozone.create!(name: I18n.t("seeds.geozones.west_district"),
|
||||
external_code: "002", census_code: "02",
|
||||
html_map_coordinates: "42,153,31,176,24,202,20,221,44,235,59,249,55,320,30,354,"\
|
||||
"31,372,52,396,64,432,89,453,116,432,149,419,162,412,165,377,172,357,189,352,228,"\
|
||||
"327,246,313,262,297,234,291,210,284,193,284,176,294,158,303,154,310,146,289,140,"\
|
||||
"268,138,246,135,236,139,222,151,214,136,197,120,179,99,159,85,149,65,149,56,149")
|
||||
Geozone.create!(name: I18n.t("seeds.geozones.east_district"),
|
||||
external_code: "003", census_code: "03",
|
||||
html_map_coordinates: "175,353,162,378,161,407,153,416,167,432,184,447,225,426,"\
|
||||
"250,409,283,390,298,369,344,363,351,334,356,296,361,267,376,245,378,185,327,188,"\
|
||||
"281,195,239,216,245,221,245,232,261,244,281,238,300,242,304,251,285,262,278,277,"\
|
||||
"267,294,249,312,219,333,198,346,184,353")
|
||||
Geozone.create!(name: I18n.t("seeds.geozones.central_district"),
|
||||
external_code: "004", census_code: "04",
|
||||
html_map_coordinates: "152,308,137,258,133,235,147,216,152,214,186,194,210,196,"\
|
||||
"228,202,240,216,241,232,263,243,293,241,301,245,302,254,286,265,274,278,267,296,"\
|
||||
"243,293,226,289,209,285,195,283,177,297")
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
section "Creating default Milestone Statuses" do
|
||||
Milestone::Status.create(name: I18n.t("seeds.budgets.statuses.studying_project"))
|
||||
Milestone::Status.create(name: I18n.t("seeds.budgets.statuses.bidding"))
|
||||
Milestone::Status.create(name: I18n.t("seeds.budgets.statuses.executing_project"))
|
||||
Milestone::Status.create(name: I18n.t("seeds.budgets.statuses.executed"))
|
||||
Milestone::Status.create!(name: I18n.t("seeds.budgets.statuses.studying_project"))
|
||||
Milestone::Status.create!(name: I18n.t("seeds.budgets.statuses.bidding"))
|
||||
Milestone::Status.create!(name: I18n.t("seeds.budgets.statuses.executing_project"))
|
||||
Milestone::Status.create!(name: I18n.t("seeds.budgets.statuses.executed"))
|
||||
end
|
||||
|
||||
section "Creating investment milestones" do
|
||||
|
||||
@@ -3,36 +3,35 @@ require_dependency "poll/question/answer"
|
||||
|
||||
section "Creating polls" do
|
||||
|
||||
Poll.create(name: I18n.t("seeds.polls.current_poll"),
|
||||
slug: I18n.t("seeds.polls.current_poll").parameterize,
|
||||
starts_at: 7.days.ago,
|
||||
ends_at: 7.days.from_now,
|
||||
geozone_restricted: false)
|
||||
Poll.create!(name: I18n.t("seeds.polls.current_poll"),
|
||||
slug: I18n.t("seeds.polls.current_poll").parameterize,
|
||||
starts_at: 7.days.ago,
|
||||
ends_at: 7.days.from_now,
|
||||
geozone_restricted: false)
|
||||
|
||||
Poll.create(name: I18n.t("seeds.polls.current_poll_geozone_restricted"),
|
||||
slug: I18n.t("seeds.polls.current_poll_geozone_restricted").parameterize,
|
||||
starts_at: 5.days.ago,
|
||||
ends_at: 5.days.from_now,
|
||||
geozone_restricted: true,
|
||||
geozones: Geozone.reorder("RANDOM()").limit(3))
|
||||
Poll.create!(name: I18n.t("seeds.polls.current_poll_geozone_restricted"),
|
||||
slug: I18n.t("seeds.polls.current_poll_geozone_restricted").parameterize,
|
||||
starts_at: 5.days.ago,
|
||||
ends_at: 5.days.from_now,
|
||||
geozone_restricted: true,
|
||||
geozones: Geozone.reorder("RANDOM()").limit(3))
|
||||
|
||||
Poll.create(name: I18n.t("seeds.polls.recounting_poll"),
|
||||
slug: I18n.t("seeds.polls.recounting_poll").parameterize,
|
||||
starts_at: 15.days.ago,
|
||||
ends_at: 2.days.ago)
|
||||
Poll.create!(name: I18n.t("seeds.polls.recounting_poll"),
|
||||
slug: I18n.t("seeds.polls.recounting_poll").parameterize,
|
||||
starts_at: 15.days.ago,
|
||||
ends_at: 2.days.ago)
|
||||
|
||||
Poll.create(name: I18n.t("seeds.polls.expired_poll_without_stats"),
|
||||
slug: I18n.t("seeds.polls.expired_poll_without_stats").parameterize,
|
||||
Poll.create!(name: I18n.t("seeds.polls.expired_poll_without_stats"),
|
||||
slug: I18n.t("seeds.polls.expired_poll_without_stats").parameterize,
|
||||
starts_at: 2.months.ago,
|
||||
ends_at: 1.month.ago)
|
||||
|
||||
starts_at: 2.months.ago,
|
||||
ends_at: 1.month.ago)
|
||||
|
||||
Poll.create(name: I18n.t("seeds.polls.expired_poll_with_stats"),
|
||||
slug: I18n.t("seeds.polls.expired_poll_with_stats").parameterize,
|
||||
starts_at: 2.months.ago,
|
||||
ends_at: 1.month.ago,
|
||||
results_enabled: true,
|
||||
stats_enabled: true)
|
||||
Poll.create!(name: I18n.t("seeds.polls.expired_poll_with_stats"),
|
||||
slug: I18n.t("seeds.polls.expired_poll_with_stats").parameterize,
|
||||
starts_at: 2.months.ago,
|
||||
ends_at: 1.month.ago,
|
||||
results_enabled: true,
|
||||
stats_enabled: true)
|
||||
|
||||
Poll.find_each do |poll|
|
||||
name = poll.name
|
||||
|
||||
@@ -18,7 +18,7 @@ def add_image_to(imageable)
|
||||
attachment: IMAGE_FILES.sample,
|
||||
user: imageable.author
|
||||
})
|
||||
imageable.save
|
||||
imageable.save!
|
||||
end
|
||||
|
||||
section "Creating Proposals" do
|
||||
|
||||
@@ -22,49 +22,49 @@ section "Creating Users" do
|
||||
|
||||
admin = create_user("admin@consul.dev", "admin")
|
||||
admin.create_administrator
|
||||
admin.update(residence_verified_at: Time.current,
|
||||
admin.update!(residence_verified_at: Time.current,
|
||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
||||
verified_at: Time.current, document_number: unique_document_number)
|
||||
|
||||
moderator = create_user("mod@consul.dev", "moderator")
|
||||
moderator.create_moderator
|
||||
moderator.update(residence_verified_at: Time.current,
|
||||
moderator.update!(residence_verified_at: Time.current,
|
||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
||||
verified_at: Time.current, document_number: unique_document_number)
|
||||
|
||||
manager = create_user("manager@consul.dev", "manager")
|
||||
manager.create_manager
|
||||
manager.update(residence_verified_at: Time.current,
|
||||
manager.update!(residence_verified_at: Time.current,
|
||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
||||
verified_at: Time.current, document_number: unique_document_number)
|
||||
|
||||
valuator = create_user("valuator@consul.dev", "valuator")
|
||||
valuator.create_valuator
|
||||
valuator.update(residence_verified_at: Time.current,
|
||||
valuator.update!(residence_verified_at: Time.current,
|
||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
||||
verified_at: Time.current, document_number: unique_document_number)
|
||||
|
||||
poll_officer = create_user("poll_officer@consul.dev", "Paul O. Fisher")
|
||||
poll_officer.create_poll_officer
|
||||
poll_officer.update(residence_verified_at: Time.current,
|
||||
poll_officer.update!(residence_verified_at: Time.current,
|
||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
||||
verified_at: Time.current, document_number: unique_document_number)
|
||||
|
||||
poll_officer2 = create_user("poll_officer2@consul.dev", "Pauline M. Espinosa")
|
||||
poll_officer2.create_poll_officer
|
||||
poll_officer2.update(residence_verified_at: Time.current,
|
||||
poll_officer2.update!(residence_verified_at: Time.current,
|
||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
||||
verified_at: Time.current, document_number: unique_document_number)
|
||||
|
||||
create_user("unverified@consul.dev", "unverified")
|
||||
|
||||
level_2 = create_user("leveltwo@consul.dev", "level 2")
|
||||
level_2.update(residence_verified_at: Time.current,
|
||||
level_2.update!(residence_verified_at: Time.current,
|
||||
confirmed_phone: Faker::PhoneNumber.phone_number,
|
||||
document_number: unique_document_number, document_type: "1")
|
||||
|
||||
verified = create_user("verified@consul.dev", "verified")
|
||||
verified.update(residence_verified_at: Time.current,
|
||||
verified.update!(residence_verified_at: Time.current,
|
||||
confirmed_phone: Faker::PhoneNumber.phone_number, document_type: "1",
|
||||
verified_at: Time.current, document_number: unique_document_number)
|
||||
|
||||
@@ -80,7 +80,7 @@ section "Creating Users" do
|
||||
|
||||
5.times do |i|
|
||||
official = create_user("official#{i}@consul.dev", "Official #{i}")
|
||||
official.update(official_level: i, official_position: "Official position #{i}")
|
||||
official.update!(official_level: i, official_position: "Official position #{i}")
|
||||
end
|
||||
|
||||
30.times do |i|
|
||||
|
||||
10
db/seeds.rb
10
db/seeds.rb
@@ -9,11 +9,11 @@ end
|
||||
|
||||
Setting.reset_defaults
|
||||
|
||||
WebSection.where(name: "homepage").first_or_create
|
||||
WebSection.where(name: "debates").first_or_create
|
||||
WebSection.where(name: "proposals").first_or_create
|
||||
WebSection.where(name: "budgets").first_or_create
|
||||
WebSection.where(name: "help_page").first_or_create
|
||||
WebSection.where(name: "homepage").first_or_create!
|
||||
WebSection.where(name: "debates").first_or_create!
|
||||
WebSection.where(name: "proposals").first_or_create!
|
||||
WebSection.where(name: "budgets").first_or_create!
|
||||
WebSection.where(name: "help_page").first_or_create!
|
||||
|
||||
# Default custom pages
|
||||
load Rails.root.join("db", "pages.rb")
|
||||
|
||||
@@ -23,7 +23,7 @@ class EmailDigest
|
||||
|
||||
def mark_as_emailed
|
||||
notifications.update_all(emailed_at: Time.current)
|
||||
user.update(failed_email_digests_count: 0)
|
||||
user.update!(failed_email_digests_count: 0)
|
||||
end
|
||||
|
||||
def valid_email?
|
||||
|
||||
@@ -431,6 +431,6 @@ namespace :proposal_actions do
|
||||
end
|
||||
|
||||
Setting["proposals.successful_proposal_id"] = proposal.id
|
||||
proposal.update(cached_votes_up: cached_votes_up)
|
||||
proposal.update!(cached_votes_up: cached_votes_up)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -105,7 +105,7 @@ describe "Admin budget investments" do
|
||||
expect(page).to have_content("Health")
|
||||
end
|
||||
|
||||
budget_investment3.update(administrator_id: admin.id)
|
||||
budget_investment3.update!(administrator_id: admin.id)
|
||||
visit admin_budget_budget_investments_path(budget_id: budget.id)
|
||||
|
||||
within("#budget_investment_#{budget_investment3.id}") do
|
||||
@@ -518,8 +518,8 @@ describe "Admin budget investments" do
|
||||
investment1.set_tag_list_on(:valuation, "Teachers")
|
||||
investment2.set_tag_list_on(:valuation, "Hospitals")
|
||||
|
||||
investment1.save
|
||||
investment2.save
|
||||
investment1.save!
|
||||
investment2.save!
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_id: budget.id)
|
||||
|
||||
@@ -534,8 +534,8 @@ describe "Admin budget investments" do
|
||||
investment1.set_tag_list_on(:valuation, "Roads")
|
||||
investment2.set_tag_list_on(:valuation, "Accessibility")
|
||||
|
||||
investment1.save
|
||||
investment2.save
|
||||
investment1.save!
|
||||
investment2.save!
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_id: budget.id)
|
||||
|
||||
@@ -544,7 +544,7 @@ describe "Admin budget investments" do
|
||||
end
|
||||
|
||||
scenario "Disable 'Calculate winner' button if incorrect phase" do
|
||||
budget.update(phase: "reviewing_ballots")
|
||||
budget.update!(phase: "reviewing_ballots")
|
||||
|
||||
visit admin_budget_budget_investments_path(budget)
|
||||
|
||||
@@ -558,7 +558,7 @@ describe "Admin budget investments" do
|
||||
|
||||
expect(page).to have_link "Calculate Winner Investments"
|
||||
|
||||
budget.update(phase: "accepting")
|
||||
budget.update!(phase: "accepting")
|
||||
|
||||
visit admin_budget_budget_investments_path(budget)
|
||||
|
||||
@@ -1202,7 +1202,7 @@ describe "Admin budget investments" do
|
||||
scenario "Adds existing valuation tags", :js do
|
||||
budget_investment1 = create(:budget_investment)
|
||||
budget_investment1.set_tag_list_on(:valuation, "Education, Health")
|
||||
budget_investment1.save
|
||||
budget_investment1.save!
|
||||
|
||||
budget_investment2 = create(:budget_investment)
|
||||
|
||||
@@ -1240,7 +1240,7 @@ describe "Admin budget investments" do
|
||||
scenario "Changes valuation and user generated tags" do
|
||||
budget_investment = create(:budget_investment, tag_list: "Park")
|
||||
budget_investment.set_tag_list_on(:valuation, "Education")
|
||||
budget_investment.save
|
||||
budget_investment.save!
|
||||
|
||||
visit admin_budget_budget_investment_path(budget_investment.budget, budget_investment)
|
||||
|
||||
@@ -1480,7 +1480,7 @@ describe "Admin budget investments" do
|
||||
end
|
||||
|
||||
scenario "Show only selected text when budget is finished" do
|
||||
budget.update(phase: "finished")
|
||||
budget.update!(phase: "finished")
|
||||
|
||||
visit admin_budget_budget_investments_path(budget)
|
||||
|
||||
@@ -1582,8 +1582,8 @@ describe "Admin budget investments" do
|
||||
scenario "Mark as visible to valuator", :js do
|
||||
investment1.valuators << valuator
|
||||
investment2.valuators << valuator
|
||||
investment1.update(administrator: admin)
|
||||
investment2.update(administrator: admin)
|
||||
investment1.update!(administrator: admin)
|
||||
investment2.update!(administrator: admin)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget)
|
||||
click_link "Advanced filters"
|
||||
@@ -1605,13 +1605,13 @@ describe "Admin budget investments" do
|
||||
end
|
||||
|
||||
scenario "Shows the correct investments to valuators" do
|
||||
investment1.update(visible_to_valuators: true)
|
||||
investment2.update(visible_to_valuators: false)
|
||||
investment1.update!(visible_to_valuators: true)
|
||||
investment2.update!(visible_to_valuators: false)
|
||||
|
||||
investment1.valuators << valuator
|
||||
investment2.valuators << valuator
|
||||
investment1.update(administrator: admin)
|
||||
investment2.update(administrator: admin)
|
||||
investment1.update!(administrator: admin)
|
||||
investment2.update!(administrator: admin)
|
||||
|
||||
login_as(valuator.user.reload)
|
||||
visit root_path
|
||||
@@ -1627,12 +1627,12 @@ describe "Admin budget investments" do
|
||||
end
|
||||
|
||||
scenario "Unmark as visible to valuator", :js do
|
||||
budget.update(phase: "valuating")
|
||||
budget.update!(phase: "valuating")
|
||||
|
||||
investment1.valuators << valuator
|
||||
investment2.valuators << valuator
|
||||
investment1.update(administrator: admin, visible_to_valuators: true)
|
||||
investment2.update(administrator: admin, visible_to_valuators: true)
|
||||
investment1.update!(administrator: admin, visible_to_valuators: true)
|
||||
investment2.update!(administrator: admin, visible_to_valuators: true)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget)
|
||||
|
||||
@@ -1682,7 +1682,7 @@ describe "Admin budget investments" do
|
||||
|
||||
scenario "Keeps the valuation tags", :js do
|
||||
investment1.set_tag_list_on(:valuation, %w[Possimpible Truthiness])
|
||||
investment1.save
|
||||
investment1.save!
|
||||
|
||||
visit admin_budget_budget_investments_path(budget)
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ describe "Admin budgets" do
|
||||
let!(:budget) { create(:budget) }
|
||||
|
||||
scenario "Show phases table" do
|
||||
budget.update(phase: "selecting")
|
||||
budget.update!(phase: "selecting")
|
||||
|
||||
visit admin_budgets_path
|
||||
click_link "Edit budget"
|
||||
@@ -217,7 +217,7 @@ describe "Admin budgets" do
|
||||
end
|
||||
|
||||
scenario "Changing name for current locale will update the slug if budget is in draft phase", :js do
|
||||
budget.update(phase: "drafting")
|
||||
budget.update!(phase: "drafting")
|
||||
old_slug = budget.slug
|
||||
|
||||
visit edit_admin_budget_path(budget)
|
||||
|
||||
@@ -48,7 +48,7 @@ describe "Admin change log" do
|
||||
expect(page).to have_content(budget_investment.heading.name)
|
||||
expect(page).to have_content("There are not changes logged")
|
||||
|
||||
budget_investment.update(title: "test")
|
||||
budget_investment.update!(title: "test")
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_investment.budget)
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ describe "Admin milestone statuses" do
|
||||
status1 = create(:milestone_status)
|
||||
status2 = create(:milestone_status)
|
||||
|
||||
status1.destroy
|
||||
status1.destroy!
|
||||
|
||||
visit admin_milestone_statuses_path
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ describe "Admin shifts" do
|
||||
officer = create(:poll_officer)
|
||||
|
||||
create(:poll_shift, officer: officer, booth: booth)
|
||||
officer.destroy
|
||||
officer.destroy!
|
||||
|
||||
visit new_admin_booth_shift_path(booth)
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ describe "Admin settings" do
|
||||
describe "Update content types" do
|
||||
|
||||
scenario "stores the correct mime types" do
|
||||
setting = Setting.create(key: "upload.images.content_types", value: "image/png")
|
||||
setting = Setting.create!(key: "upload.images.content_types", value: "image/png")
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
@@ -194,7 +194,7 @@ describe "Admin settings" do
|
||||
end
|
||||
|
||||
scenario "On #tab-configuration", :js do
|
||||
configuration_setting = Setting.create(key: "whatever")
|
||||
configuration_setting = Setting.create!(key: "whatever")
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
@@ -216,7 +216,7 @@ describe "Admin settings" do
|
||||
end
|
||||
|
||||
scenario "On #tab-map-configuration", :js do
|
||||
map_setting = Setting.create(key: "map.whatever")
|
||||
map_setting = Setting.create!(key: "map.whatever")
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
@@ -233,7 +233,7 @@ describe "Admin settings" do
|
||||
end
|
||||
|
||||
scenario "On #tab-proposals", :js do
|
||||
proposal_dashboard_setting = Setting.create(key: "proposals.whatever")
|
||||
proposal_dashboard_setting = Setting.create!(key: "proposals.whatever")
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
@@ -249,7 +249,7 @@ describe "Admin settings" do
|
||||
end
|
||||
|
||||
scenario "On #tab-participation-processes", :js do
|
||||
process_setting = Setting.create(key: "process.whatever")
|
||||
process_setting = Setting.create!(key: "process.whatever")
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
@@ -264,7 +264,7 @@ describe "Admin settings" do
|
||||
end
|
||||
|
||||
scenario "On #tab-feature-flags", :js do
|
||||
feature_setting = Setting.create(key: "feature.whatever")
|
||||
feature_setting = Setting.create!(key: "feature.whatever")
|
||||
admin = create(:administrator).user
|
||||
login_as(admin)
|
||||
visit admin_settings_path
|
||||
|
||||
@@ -55,7 +55,7 @@ describe "Signature sheets" do
|
||||
scenario "Budget Investment" do
|
||||
investment = create(:budget_investment)
|
||||
budget = investment.budget
|
||||
budget.update(phase: "selecting")
|
||||
budget.update!(phase: "selecting")
|
||||
|
||||
visit new_admin_signature_sheet_path
|
||||
|
||||
@@ -108,7 +108,7 @@ describe "Signature sheets" do
|
||||
scenario "Budget Investment" do
|
||||
investment = create(:budget_investment)
|
||||
budget = investment.budget
|
||||
budget.update(phase: "selecting")
|
||||
budget.update!(phase: "selecting")
|
||||
|
||||
visit new_admin_signature_sheet_path
|
||||
|
||||
|
||||
@@ -285,7 +285,7 @@ describe "Stats" do
|
||||
|
||||
scenario "Deleted proposals" do
|
||||
proposal_notification = create(:proposal_notification)
|
||||
proposal_notification.proposal.destroy
|
||||
proposal_notification.proposal.destroy!
|
||||
|
||||
visit admin_stats_path
|
||||
click_link "Proposal notifications"
|
||||
|
||||
@@ -2,7 +2,7 @@ require "rails_helper"
|
||||
|
||||
describe "Admin edit translatable records" do
|
||||
before do
|
||||
translatable.update(attributes)
|
||||
translatable.update!(attributes)
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
@@ -311,7 +311,7 @@ describe "Admin edit translatable records" do
|
||||
|
||||
before do
|
||||
translatable.translations.destroy_all
|
||||
translatable.translations.create(locale: :fr, title: "Titre en Français")
|
||||
translatable.translations.create!(locale: :fr, title: "Titre en Français")
|
||||
end
|
||||
|
||||
scenario "Does not add a translation for the current locale" do
|
||||
@@ -398,7 +398,7 @@ describe "Admin edit translatable records" do
|
||||
let(:translatable) { create(:admin_notification, segment_recipient: "all_users") }
|
||||
|
||||
scenario "Shows first available fallback" do
|
||||
translatable.update({ title_fr: "Titre en Français", body_fr: "Texte en Français" })
|
||||
translatable.update!({ title_fr: "Titre en Français", body_fr: "Texte en Français" })
|
||||
|
||||
visit edit_admin_admin_notification_path(translatable)
|
||||
|
||||
@@ -417,7 +417,7 @@ describe "Admin edit translatable records" do
|
||||
let(:translatable) { create(:budget).phases.last }
|
||||
|
||||
scenario "Shows first available fallback" do
|
||||
translatable.update({ description_fr: "Phase en Français", summary_fr: "Phase résumé" })
|
||||
translatable.update!({ description_fr: "Phase en Français", summary_fr: "Phase résumé" })
|
||||
|
||||
visit edit_admin_budget_budget_phase_path(translatable.budget, translatable)
|
||||
|
||||
@@ -438,7 +438,7 @@ describe "Admin edit translatable records" do
|
||||
let(:translatable) { create(:active_poll) }
|
||||
|
||||
scenario "Shows first available fallback" do
|
||||
translatable.update({ description_fr: "Sondage en Français" })
|
||||
translatable.update!({ description_fr: "Sondage en Français" })
|
||||
|
||||
visit edit_admin_active_polls_path(translatable)
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ describe "Valuator groups" do
|
||||
end
|
||||
|
||||
scenario "Update a valuator's group" do
|
||||
valuator.update(valuator_group: create(:valuator_group, name: "Economy"))
|
||||
valuator.update!(valuator_group: create(:valuator_group, name: "Economy"))
|
||||
create(:valuator_group, name: "Health")
|
||||
|
||||
visit edit_admin_valuator_path(valuator)
|
||||
@@ -108,7 +108,7 @@ describe "Valuator groups" do
|
||||
end
|
||||
|
||||
scenario "Remove a valuator from a group" do
|
||||
valuator.update(valuator_group: create(:valuator_group, name: "Health"))
|
||||
valuator.update!(valuator_group: create(:valuator_group, name: "Health"))
|
||||
|
||||
visit edit_admin_valuator_path(valuator)
|
||||
select "", from: "valuator_valuator_group_id"
|
||||
|
||||
@@ -14,7 +14,7 @@ describe "Ballots" do
|
||||
end
|
||||
|
||||
before do
|
||||
budget.update(slug: "budget_slug")
|
||||
budget.update!(slug: "budget_slug")
|
||||
login_as(user)
|
||||
end
|
||||
|
||||
@@ -41,7 +41,7 @@ describe "Ballots" do
|
||||
context "Lines Load" do
|
||||
before do
|
||||
create(:budget_investment, :selected, heading: california, title: "More rain")
|
||||
budget.update(slug: "budget_slug")
|
||||
budget.update!(slug: "budget_slug")
|
||||
login_as(user)
|
||||
end
|
||||
|
||||
@@ -687,7 +687,7 @@ describe "Ballots" do
|
||||
click_link "States"
|
||||
click_link "New York"
|
||||
|
||||
new_york.update(price: 10)
|
||||
new_york.update!(price: 10)
|
||||
|
||||
within("#budget_investment_#{investment1.id}") do
|
||||
expect(page).to have_selector(".in-favor a", visible: true)
|
||||
@@ -701,7 +701,7 @@ describe "Ballots" do
|
||||
end
|
||||
|
||||
scenario "Balloting is disabled when budget isn't in the balotting phase", :js do
|
||||
budget.update(phase: "accepting")
|
||||
budget.update!(phase: "accepting")
|
||||
|
||||
bi1 = create(:budget_investment, :selected, heading: california, price: 600)
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ describe "Budgets" do
|
||||
heading1 = create(:budget_heading, group: group1)
|
||||
heading2 = create(:budget_heading, group: group2)
|
||||
|
||||
budget.update_attributes(phase: "informing")
|
||||
budget.update_attributes!(phase: "informing")
|
||||
|
||||
visit budgets_path
|
||||
|
||||
@@ -51,7 +51,7 @@ describe "Budgets" do
|
||||
expect(page).to have_link("See all phases")
|
||||
end
|
||||
|
||||
budget.update_attributes(phase: "publishing_prices")
|
||||
budget.update_attributes!(phase: "publishing_prices")
|
||||
visit budgets_path
|
||||
|
||||
within("#budget_heading") do
|
||||
@@ -114,7 +114,7 @@ describe "Budgets" do
|
||||
end
|
||||
|
||||
scenario "Show informing index without links" do
|
||||
budget.update_attributes(phase: "informing")
|
||||
budget.update_attributes!(phase: "informing")
|
||||
heading = create(:budget_heading, budget: budget)
|
||||
|
||||
visit budgets_path
|
||||
@@ -132,7 +132,7 @@ describe "Budgets" do
|
||||
end
|
||||
|
||||
scenario "Show finished index without heading links" do
|
||||
budget.update_attributes(phase: "finished")
|
||||
budget.update_attributes!(phase: "finished")
|
||||
heading = create(:budget_heading, budget: budget)
|
||||
|
||||
visit budgets_path
|
||||
@@ -159,7 +159,7 @@ describe "Budgets" do
|
||||
create(:budget_heading, budget: budget)
|
||||
|
||||
allowed_phase_list.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
budget.update!(phase: phase)
|
||||
|
||||
visit budgets_path
|
||||
|
||||
@@ -178,7 +178,7 @@ describe "Budgets" do
|
||||
allowed_phase_list
|
||||
|
||||
not_allowed_phase_list.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
budget.update!(phase: phase)
|
||||
|
||||
visit budgets_path
|
||||
|
||||
@@ -197,7 +197,7 @@ describe "Budgets" do
|
||||
end
|
||||
|
||||
scenario "Accepting" do
|
||||
budget.update(phase: "accepting")
|
||||
budget.update!(phase: "accepting")
|
||||
login_as(create(:user, :level_two))
|
||||
|
||||
visit budgets_path
|
||||
@@ -208,41 +208,41 @@ describe "Budgets" do
|
||||
|
||||
scenario "Index shows only published phases" do
|
||||
|
||||
budget.update(phase: :finished)
|
||||
budget.update!(phase: :finished)
|
||||
phases = budget.phases
|
||||
phases.drafting.update(starts_at: "30-12-2017", ends_at: "31-12-2017", enabled: true,
|
||||
phases.drafting.update!(starts_at: "30-12-2017", ends_at: "31-12-2017", enabled: true,
|
||||
description: "Description of drafting phase",
|
||||
summary: "<p>This is the summary for drafting phase</p>")
|
||||
|
||||
phases.accepting.update(starts_at: "01-01-2018", ends_at: "10-01-2018", enabled: true,
|
||||
phases.accepting.update!(starts_at: "01-01-2018", ends_at: "10-01-2018", enabled: true,
|
||||
description: "Description of accepting phase",
|
||||
summary: "This is the summary for accepting phase")
|
||||
|
||||
phases.reviewing.update(starts_at: "11-01-2018", ends_at: "20-01-2018", enabled: false,
|
||||
phases.reviewing.update!(starts_at: "11-01-2018", ends_at: "20-01-2018", enabled: false,
|
||||
description: "Description of reviewing phase",
|
||||
summary: "This is the summary for reviewing phase")
|
||||
|
||||
phases.selecting.update(starts_at: "21-01-2018", ends_at: "01-02-2018", enabled: true,
|
||||
phases.selecting.update!(starts_at: "21-01-2018", ends_at: "01-02-2018", enabled: true,
|
||||
description: "Description of selecting phase",
|
||||
summary: "This is the summary for selecting phase")
|
||||
|
||||
phases.valuating.update(starts_at: "10-02-2018", ends_at: "20-02-2018", enabled: false,
|
||||
phases.valuating.update!(starts_at: "10-02-2018", ends_at: "20-02-2018", enabled: false,
|
||||
description: "Description of valuating phase",
|
||||
summary: "This is the summary for valuating phase")
|
||||
|
||||
phases.publishing_prices.update(starts_at: "21-02-2018", ends_at: "01-03-2018", enabled: false,
|
||||
phases.publishing_prices.update!(starts_at: "21-02-2018", ends_at: "01-03-2018", enabled: false,
|
||||
description: "Description of publishing prices phase",
|
||||
summary: "This is the summary for publishing_prices phase")
|
||||
|
||||
phases.balloting.update(starts_at: "02-03-2018", ends_at: "10-03-2018", enabled: true,
|
||||
phases.balloting.update!(starts_at: "02-03-2018", ends_at: "10-03-2018", enabled: true,
|
||||
description: "Description of balloting phase",
|
||||
summary: "This is the summary for balloting phase")
|
||||
|
||||
phases.reviewing_ballots.update(starts_at: "11-03-2018", ends_at: "20-03-2018", enabled: false,
|
||||
phases.reviewing_ballots.update!(starts_at: "11-03-2018", ends_at: "20-03-2018", enabled: false,
|
||||
description: "Description of reviewing ballots phase",
|
||||
summary: "This is the summary for reviewing_ballots phase")
|
||||
|
||||
phases.finished.update(starts_at: "21-03-2018", ends_at: "30-03-2018", enabled: true,
|
||||
phases.finished.update!(starts_at: "21-03-2018", ends_at: "30-03-2018", enabled: true,
|
||||
description: "Description of finished phase",
|
||||
summary: "This is the summary for finished phase")
|
||||
|
||||
@@ -295,7 +295,7 @@ describe "Budgets" do
|
||||
end
|
||||
|
||||
scenario "Display all investment's map location if there are no selected", :js do
|
||||
budget.update(phase: :publishing_prices)
|
||||
budget.update!(phase: :publishing_prices)
|
||||
|
||||
investment1 = create(:budget_investment, heading: heading)
|
||||
investment2 = create(:budget_investment, heading: heading)
|
||||
@@ -315,7 +315,7 @@ describe "Budgets" do
|
||||
end
|
||||
|
||||
scenario "Display only selected investment's map location from publishing prices phase", :js do
|
||||
budget.update(phase: :publishing_prices)
|
||||
budget.update!(phase: :publishing_prices)
|
||||
|
||||
investment1 = create(:budget_investment, :selected, heading: heading)
|
||||
investment2 = create(:budget_investment, :selected, heading: heading)
|
||||
@@ -389,7 +389,7 @@ describe "Budgets" do
|
||||
expect(page).not_to have_link "See unfeasible investments"
|
||||
expect(page).not_to have_link "See investments not selected for balloting phase"
|
||||
|
||||
budget.update(phase: :publishing_prices)
|
||||
budget.update!(phase: :publishing_prices)
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
@@ -401,7 +401,7 @@ describe "Budgets" do
|
||||
expect(page).not_to have_link "See unfeasible investments"
|
||||
expect(page).not_to have_link "See investments not selected for balloting phase"
|
||||
|
||||
budget.update(phase: :balloting)
|
||||
budget.update!(phase: :balloting)
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
@@ -413,7 +413,7 @@ describe "Budgets" do
|
||||
expect(page).to have_link "See unfeasible investments"
|
||||
expect(page).to have_link "See investments not selected for balloting phase"
|
||||
|
||||
budget.update(phase: :finished)
|
||||
budget.update!(phase: :finished)
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
@@ -486,7 +486,7 @@ describe "Budgets" do
|
||||
|
||||
before do
|
||||
logout
|
||||
budget.update(phase: "drafting")
|
||||
budget.update!(phase: "drafting")
|
||||
create(:budget)
|
||||
end
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ describe "Executions" do
|
||||
let!(:investment3) { create(:budget_investment, :incompatible, heading: heading) }
|
||||
|
||||
scenario "finds budget by id or slug" do
|
||||
budget.update(slug: "budget_slug")
|
||||
budget.update!(slug: "budget_slug")
|
||||
|
||||
visit budget_executions_path("budget_slug")
|
||||
within(".budgets-stats") { expect(page).to have_content budget.name }
|
||||
@@ -230,11 +230,11 @@ describe "Executions" do
|
||||
create(:milestone, milestoneable: investment2, status: status2)
|
||||
create(:milestone, milestoneable: investment3, status: status2)
|
||||
investment1.milestone_tag_list.add("tag1", "tag2")
|
||||
investment1.save
|
||||
investment1.save!
|
||||
investment2.milestone_tag_list.add("tag2")
|
||||
investment2.save
|
||||
investment2.save!
|
||||
investment3.milestone_tag_list.add("tag2")
|
||||
investment3.save
|
||||
investment3.save!
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ describe "Budget Investments" do
|
||||
let(:investment) { create(:budget_investment, heading: heading) }
|
||||
|
||||
before do
|
||||
budget.update(slug: "budget_slug")
|
||||
heading.update(slug: "heading_slug")
|
||||
budget.update!(slug: "budget_slug")
|
||||
heading.update!(slug: "heading_slug")
|
||||
end
|
||||
|
||||
scenario "finds investment using budget slug" do
|
||||
@@ -536,7 +536,7 @@ describe "Budget Investments" do
|
||||
end
|
||||
|
||||
scenario "by unfeasibilty link for group with one heading" do
|
||||
budget.update(phase: :balloting)
|
||||
budget.update!(phase: :balloting)
|
||||
group = create(:budget_group, name: "All City", budget: budget)
|
||||
heading = create(:budget_heading, name: "Madrid", group: group)
|
||||
|
||||
@@ -550,7 +550,7 @@ describe "Budget Investments" do
|
||||
end
|
||||
|
||||
scenario "by unfeasibilty link for group with many headings" do
|
||||
budget.update(phase: :balloting)
|
||||
budget.update!(phase: :balloting)
|
||||
group = create(:budget_group, name: "Districts", budget: budget)
|
||||
|
||||
barajas = create(:budget_heading, name: "Barajas", group: group)
|
||||
@@ -823,7 +823,7 @@ describe "Budget Investments" do
|
||||
scenario "Order is random if budget is finished" do
|
||||
per_page.times { create(:budget_investment, :winner, heading: heading) }
|
||||
|
||||
budget.update(phase: "finished")
|
||||
budget.update!(phase: "finished")
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
order = all(".budget-investment h3").collect { |i| i.text }
|
||||
@@ -837,7 +837,7 @@ describe "Budget Investments" do
|
||||
|
||||
scenario "Order always is random for unfeasible and unselected investments" do
|
||||
Budget::Phase::PHASE_KINDS.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
budget.update!(phase: phase)
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id, filter: "unfeasible")
|
||||
|
||||
@@ -1086,7 +1086,7 @@ describe "Budget Investments" do
|
||||
|
||||
scenario "Price & explanation is shown when Budget is on published prices phase" do
|
||||
Budget::Phase::PUBLISHED_PRICES_PHASES.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
budget.update!(phase: phase)
|
||||
visit budget_investment_path(budget, id: investment.id)
|
||||
|
||||
expect(page).to have_content(investment.formatted_price)
|
||||
@@ -1105,7 +1105,7 @@ describe "Budget Investments" do
|
||||
|
||||
scenario "Price & explanation isn't shown when Budget is not on published prices phase" do
|
||||
(Budget::Phase::PHASE_KINDS - Budget::Phase::PUBLISHED_PRICES_PHASES).each do |phase|
|
||||
budget.update(phase: phase)
|
||||
budget.update!(phase: phase)
|
||||
visit budget_investment_path(budget, id: investment.id)
|
||||
|
||||
expect(page).not_to have_content(investment.formatted_price)
|
||||
@@ -1127,7 +1127,7 @@ describe "Budget Investments" do
|
||||
|
||||
scenario "Price & explanation isn't shown for any Budget's phase" do
|
||||
Budget::Phase::PHASE_KINDS.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
budget.update!(phase: phase)
|
||||
visit budget_investment_path(budget, id: investment.id)
|
||||
|
||||
expect(page).not_to have_content(investment.formatted_price)
|
||||
@@ -1191,7 +1191,7 @@ describe "Budget Investments" do
|
||||
end
|
||||
|
||||
scenario "Budget in selecting phase" do
|
||||
budget.update(phase: "selecting")
|
||||
budget.update!(phase: "selecting")
|
||||
visit budget_investment_path(budget, id: investment.id)
|
||||
|
||||
expect(page).not_to have_content("Unfeasibility explanation")
|
||||
@@ -1250,7 +1250,7 @@ describe "Budget Investments" do
|
||||
end
|
||||
|
||||
scenario "Show (winner budget investment) only if budget is finished" do
|
||||
budget.update(phase: "balloting")
|
||||
budget.update!(phase: "balloting")
|
||||
|
||||
investment = create(:budget_investment,
|
||||
:feasible,
|
||||
@@ -1267,7 +1267,7 @@ describe "Budget Investments" do
|
||||
|
||||
expect(page).not_to have_content("Winning investment project")
|
||||
|
||||
budget.update(phase: "finished")
|
||||
budget.update!(phase: "finished")
|
||||
|
||||
visit budget_investment_path(budget, id: investment.id)
|
||||
|
||||
@@ -1275,7 +1275,7 @@ describe "Budget Investments" do
|
||||
end
|
||||
|
||||
scenario "Show (not selected budget investment)" do
|
||||
budget.update(phase: "balloting")
|
||||
budget.update!(phase: "balloting")
|
||||
|
||||
investment = create(:budget_investment,
|
||||
:feasible,
|
||||
@@ -1599,7 +1599,7 @@ describe "Budget Investments" do
|
||||
end
|
||||
|
||||
scenario "Confirm", :js do
|
||||
budget.update(phase: "balloting")
|
||||
budget.update!(phase: "balloting")
|
||||
user = create(:user, :level_two)
|
||||
|
||||
global_group = create(:budget_group, budget: budget, name: "Global Group")
|
||||
@@ -1664,7 +1664,7 @@ describe "Budget Investments" do
|
||||
end
|
||||
|
||||
scenario "Highlight voted heading except with unfeasible filter", :js do
|
||||
budget.update(phase: "balloting")
|
||||
budget.update!(phase: "balloting")
|
||||
user = create(:user, :level_two)
|
||||
|
||||
heading_1 = create(:budget_heading, group: group, name: "Heading 1")
|
||||
@@ -1799,7 +1799,7 @@ describe "Budget Investments" do
|
||||
expect(page).to have_content("You have voted one investment")
|
||||
|
||||
investment.heading = heading2
|
||||
investment.save
|
||||
investment.save!
|
||||
|
||||
visit budget_ballot_path(budget)
|
||||
|
||||
@@ -1817,7 +1817,7 @@ describe "Budget Investments" do
|
||||
|
||||
investment.feasibility = "unfeasible"
|
||||
investment.unfeasibility_explanation = "too expensive"
|
||||
investment.save
|
||||
investment.save!
|
||||
|
||||
visit budget_ballot_path(budget)
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ describe "Results" do
|
||||
end
|
||||
|
||||
scenario "No links to budget results with results disabled" do
|
||||
budget.update(results_enabled: false)
|
||||
budget.update!(results_enabled: false)
|
||||
|
||||
visit budgets_path
|
||||
|
||||
@@ -105,7 +105,7 @@ describe "Results" do
|
||||
end
|
||||
|
||||
scenario "If budget is in a phase different from finished results can't be accessed" do
|
||||
budget.update(phase: (Budget::Phase::PHASE_KINDS - ["drafting", "finished"]).sample)
|
||||
budget.update!(phase: (Budget::Phase::PHASE_KINDS - ["drafting", "finished"]).sample)
|
||||
visit budget_path(budget)
|
||||
expect(page).not_to have_link "See results"
|
||||
|
||||
@@ -115,7 +115,7 @@ describe "Results" do
|
||||
|
||||
scenario "No incompatible investments", :js do
|
||||
investment3.incompatible = false
|
||||
investment3.save
|
||||
investment3.save!
|
||||
|
||||
visit budget_path(budget)
|
||||
click_link "See results"
|
||||
|
||||
@@ -32,7 +32,7 @@ describe "Stats" do
|
||||
describe "Show" do
|
||||
describe "advanced stats" do
|
||||
scenario "advanced stats enabled" do
|
||||
budget.update(advanced_stats_enabled: true)
|
||||
budget.update!(advanced_stats_enabled: true)
|
||||
|
||||
visit budget_stats_path(budget)
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user