Add method to get the archived proposals date limit
This commit is contained in:
@@ -72,8 +72,8 @@ class Proposal < ApplicationRecord
|
||||
scope :sort_by_flags, -> { order(flags_count: :desc, updated_at: :desc) }
|
||||
scope :sort_by_archival_date, -> { archived.sort_by_confidence_score }
|
||||
scope :sort_by_recommendations, -> { order(cached_votes_up: :desc) }
|
||||
scope :archived, -> { where("proposals.created_at <= ?", Setting["months_to_archive_proposals"].to_i.months.ago) }
|
||||
scope :not_archived, -> { where("proposals.created_at > ?", Setting["months_to_archive_proposals"].to_i.months.ago) }
|
||||
scope :archived, -> { where("proposals.created_at <= ?", Setting.archived_proposals_date_limit) }
|
||||
scope :not_archived, -> { where("proposals.created_at > ?", Setting.archived_proposals_date_limit) }
|
||||
scope :last_week, -> { where("proposals.created_at >= ?", 7.days.ago) }
|
||||
scope :retired, -> { where.not(retired_at: nil) }
|
||||
scope :not_retired, -> { where(retired_at: nil) }
|
||||
@@ -221,7 +221,7 @@ class Proposal < ApplicationRecord
|
||||
end
|
||||
|
||||
def archived?
|
||||
created_at <= Setting["months_to_archive_proposals"].to_i.months.ago
|
||||
created_at <= Setting.archived_proposals_date_limit
|
||||
end
|
||||
|
||||
def notifications
|
||||
|
||||
@@ -229,5 +229,9 @@ class Setting < ApplicationRecord
|
||||
Setting["feature.remote_census"].present? &&
|
||||
Setting["remote_census.request.postal_code"].present?
|
||||
end
|
||||
|
||||
def archived_proposals_date_limit
|
||||
Setting["months_to_archive_proposals"].to_i.months.ago
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -49,7 +49,6 @@ section "Creating Archived Proposals" do
|
||||
5.times do
|
||||
author = User.all.sample
|
||||
description = "<p>#{Faker::Lorem.paragraphs.join("</p><p>")}</p>"
|
||||
months_to_archive_proposals = Setting["months_to_archive_proposals"]
|
||||
proposal = Proposal.create!(author: author,
|
||||
title: Faker::Lorem.sentence(word_count: 3).truncate(60),
|
||||
summary: Faker::Lorem.sentence(word_count: 3),
|
||||
@@ -58,8 +57,8 @@ section "Creating Archived Proposals" do
|
||||
tag_list: tags.sample(3).join(","),
|
||||
geozone: Geozone.all.sample,
|
||||
terms_of_service: "1",
|
||||
created_at: months_to_archive_proposals.to_i.months.ago,
|
||||
published_at: months_to_archive_proposals.to_i.months.ago)
|
||||
created_at: Setting.archived_proposals_date_limit,
|
||||
published_at: Setting.archived_proposals_date_limit)
|
||||
random_locales.map do |locale|
|
||||
Globalize.with_locale(locale) do
|
||||
proposal.title = "Archived proposal title for locale #{locale}"
|
||||
|
||||
@@ -7,12 +7,11 @@ module Proposals
|
||||
end
|
||||
|
||||
def create_archived_proposals
|
||||
months_to_archive_proposals = Setting["months_to_archive_proposals"].to_i
|
||||
[
|
||||
create(:proposal, title: "This is an expired proposal",
|
||||
created_at: months_to_archive_proposals.months.ago),
|
||||
created_at: Setting.archived_proposals_date_limit),
|
||||
create(:proposal, title: "This is an oldest expired proposal",
|
||||
created_at: (months_to_archive_proposals + 2).months.ago)
|
||||
created_at: Setting.archived_proposals_date_limit - 2.months)
|
||||
]
|
||||
end
|
||||
|
||||
|
||||
@@ -313,7 +313,7 @@ describe "Proposal's dashboard" do
|
||||
|
||||
scenario "Resource admin request button do not appear on archived proposals" do
|
||||
feature = create(:dashboard_action, :resource, :active)
|
||||
archived = Setting["months_to_archive_proposals"].to_i.months.ago
|
||||
archived = Setting.archived_proposals_date_limit
|
||||
archived_proposal = create(:proposal, created_at: archived)
|
||||
|
||||
login_as(archived_proposal.author)
|
||||
|
||||
Reference in New Issue
Block a user