Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
colinxfleming committed Feb 14, 2025
1 parent 114f09e commit bd6d149
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions test/models/config_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -367,18 +367,18 @@ class ConfigTest < ActiveSupport::TestCase
c = Config.find_or_create_by(config_key: 'use_appointment_date_for_budget_bar_hard_pledges')
c.config_value = { options: ["Yes"] }
c.save!
assert(Config.use_appointment_date_for_budget_bar_hard_pledges == true)
assert(Config.use_appointment_date_for_budget_bar_hard_pledges? == true)
end

it 'can return false' do
c = Config.find_or_create_by(config_key: 'use_appointment_date_for_budget_bar_hard_pledges')
c.config_value = { options: ["No"] }
c.save!
assert(Config.use_appointment_date_for_budget_bar_hard_pledges == false)
assert(Config.use_appointment_date_for_budget_bar_hard_pledges? == false)
end

it "returns false by default" do
assert(Config.use_appointment_date_for_budget_bar_hard_pledges == false)
assert(Config.use_appointment_date_for_budget_bar_hard_pledges? == false)
end
end
end
Expand Down
17 changes: 8 additions & 9 deletions test/models/patient_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ class PatientTest < ActiveSupport::TestCase

it "should swap to appointment date as the hinge if the config is on" do
Config.create config_key: :use_appointment_date_for_budget_bar_hard_pledges,
config_value: {options: ['yes']}
config_value: {options: ['Yes']}

noon = Time.zone.today.beginning_of_day + 12.hours
# to ensure this spec isn't flaky if someone runs it between 12am - 4am ET
Timecop.freeze(noon) do
@patient.update appointment_date: 1.day.from_now, fund_pledge: 300, pledge_sent: true, name: 'a', clinic: create(:clinic)
@patient.update appointment_date: 2.days.from_now, fund_pledge: 300, name: 'a', clinic: create(:clinic), fund_pledged_at: 1.day.from_now
@patient2.update appointment_date: 1.day.from_now, fund_pledge: 500, name: 'b',
pledge_sent: true, clinic: create(:clinic)
# Removed because next week
Expand All @@ -279,13 +279,12 @@ class PatientTest < ActiveSupport::TestCase

# Testing dates is hard, so we use name as a proxy here
summary = Patient.pledged_status_summary(@line)
assert_not_nil summary[:pledged].find { |pt| pt[:name] == @shaped_patient.name }
assert_not_nil summary[:pledged].find { |pt| pt[:name] == @shaped_patient2.name }
assert_nil summary[:sent].find { |pt| pt[:name] == @filtered_pt.name }
assert_nil summary[:pledged].find { |pt| pt[:name] == @filtered_pt.name }
assert_nil summary[:sent].find { |pt| pt[:name] == @filtered_pt.name }
assert_equal summary[:pledged].count, 2
assert_equal summary[:sent].count, 0
assert_not_nil summary[:pledged].find { |pt| pt[:name] == @shaped_patient[:name] }
assert_not_nil summary[:sent].find { |pt| pt[:name] == @shaped_patient2[:name] }
assert_nil summary[:sent].find { |pt| pt[:name] == @filtered_pt[:name] }
assert_nil summary[:pledged].find { |pt| pt[:name] == @filtered_pt[:name] }
assert_equal summary[:pledged].count, 1
assert_equal summary[:sent].count, 1
end
end
end
Expand Down

0 comments on commit bd6d149

Please sign in to comment.