Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby

Fix DemoFamilyRefreshJob demo email config lookup (#1426)

Juan José Mata65c5f8eb077d
diff --git a/app/jobs/demo_family_refresh_job.rb b/app/jobs/demo_family_refresh_job.rb
index 65f6a8c9b0..2b7d85f175 100644
--- a/app/jobs/demo_family_refresh_job.rb
+++ b/app/jobs/demo_family_refresh_job.rb
@@ -5,7 +5,7 @@ class DemoFamilyRefreshJob < ApplicationJob
period_end = Time.current
period_start = period_end - 24.hours
- demo_email = Rails.application.config_for(:demo).fetch("email")
+ demo_email = Rails.application.config_for(:demo).with_indifferent_access.fetch(:email)
demo_user = User.find_by(email: demo_email)
old_family = demo_user&.family
diff --git a/test/jobs/demo_family_refresh_job_test.rb b/test/jobs/demo_family_refresh_job_test.rb
index 991b2ed3cd..48bd24167f 100644
--- a/test/jobs/demo_family_refresh_job_test.rb
+++ b/test/jobs/demo_family_refresh_job_test.rb
@@ -61,4 +61,14 @@ class DemoFamilyRefreshJobTest < ActiveJob::TestCase
assert_match(/\+deleting-/, @demo_user.email)
end
end
+
+ test "reads demo email when config_for returns symbol keys" do
+ Rails.application.stubs(:config_for).with(:demo).returns({ email: @demo_email })
+
+ generator = mock
+ generator.expects(:generate_default_data!).with(skip_clear: true, email: @demo_email)
+ Demo::Generator.expects(:new).returns(generator)
+
+ DemoFamilyRefreshJob.perform_now
+ end
end