Add coverage for TermsOfService scopes/validations (#35204)
				
					
				
			This commit is contained in:
		@@ -15,9 +15,9 @@
 | 
			
		||||
#
 | 
			
		||||
class TermsOfService < ApplicationRecord
 | 
			
		||||
  scope :published, -> { where.not(published_at: nil).order(Arel.sql('coalesce(effective_date, published_at) DESC')) }
 | 
			
		||||
  scope :live, -> { published.where('effective_date IS NULL OR effective_date < now()').limit(1) }
 | 
			
		||||
  scope :upcoming, -> { published.reorder(effective_date: :asc).where('effective_date IS NOT NULL AND effective_date > now()').limit(1) }
 | 
			
		||||
  scope :draft, -> { where(published_at: nil).order(id: :desc).limit(1) }
 | 
			
		||||
  scope :live, -> { published.where('effective_date IS NULL OR effective_date < now()') }
 | 
			
		||||
  scope :upcoming, -> { published.reorder(effective_date: :asc).where('effective_date IS NOT NULL AND effective_date > now()') }
 | 
			
		||||
  scope :draft, -> { where(published_at: nil).order(id: :desc) }
 | 
			
		||||
 | 
			
		||||
  validates :text, presence: true
 | 
			
		||||
  validates :changelog, :effective_date, presence: true, if: -> { published? }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user