@ -2,14 +2,36 @@ require "rails_helper"
# rubocop:disable RSpec/AnyInstance
RSpec . shared_examples " shared log examples " do | log_type |
include CollectionTimeHelper
describe " status " do
[
{
start_date : :current_collection_start_date ,
label : " current " ,
} ,
{
start_date : :next_collection_start_date ,
label : " next " ,
} ,
] . each do | scenario |
context " when creating a log for #{ scenario [ :label ] } year " do
around do | example |
start_date = Timecop . return { send ( scenario [ :start_date ] ) }
Timecop . freeze ( start_date ) do
Singleton . __init__ ( FormHandler )
example . run
end
end
let ( :empty_log ) { create ( log_type ) }
let ( :in_progress_log ) { create ( log_type , :in_progress ) }
let ( :completed_log ) { create ( log_type , :completed ) }
it " is set to not started for an empty #{ log_type } log " do
expect ( empty_log . not_started? ) . to be ( true )
expect ( empty_log . in_progress? ) . to be ( false )
expect ( empty_log . not_started? ) . to be ( true )
expect ( empty_log . completed? ) . to be ( false )
expect ( empty_log . deleted? ) . to be ( false )
end
@ -21,6 +43,9 @@ RSpec.shared_examples "shared log examples" do |log_type|
expect ( in_progress_log . deleted? ) . to be ( false )
end
# if this test starts failing, likely because a new question has been added
# and the :completed trait in spec/factories/lettings_log.rb (or sales_log.rb)
# needs to be updated to set the database col with that questions answer
it " is set to completed for a completed #{ log_type } log " do
expect ( completed_log . in_progress? ) . to be ( false )
expect ( completed_log . not_started? ) . to be ( false )
@ -28,6 +53,8 @@ RSpec.shared_examples "shared log examples" do |log_type|
expect ( completed_log . deleted? ) . to be ( false )
end
end
end
end
describe " discard! " do
around do | example |