From f8007c0186c664c39b5678b14c2f0c4f8a9f0518 Mon Sep 17 00:00:00 2001 From: Phil Lee Date: Mon, 27 Nov 2023 10:25:01 +0000 Subject: [PATCH] seed staff user in review apps --- bin/start-review-app.sh | 4 ++-- db/test_data_seeds.rb | 10 ++++++++++ lib/tasks/seed.rake | 8 ++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 db/test_data_seeds.rb create mode 100644 lib/tasks/seed.rake diff --git a/bin/start-review-app.sh b/bin/start-review-app.sh index 603855ee8..898410fe5 100755 --- a/bin/start-review-app.sh +++ b/bin/start-review-app.sh @@ -2,6 +2,6 @@ /usr/sbin/sshd -bundle exec rails db:schema_load_or_migrate -bundle exec rails runner "%i(eligibility_screener referral_form).each {|flag| FeatureFlags::FeatureFlag.activate(flag)}" +bundle exec rails db:schema_load_or_migrate db:seed:test_data +bundle exec rails runner "%i(eligibility_screener referral_form).each {|flag| FeatureFlags::FeatureFlag.activate(flag)}" bundle exec rails server -b 0.0.0.0 diff --git a/db/test_data_seeds.rb b/db/test_data_seeds.rb new file mode 100644 index 000000000..e5019bf17 --- /dev/null +++ b/db/test_data_seeds.rb @@ -0,0 +1,10 @@ +staff = Staff.find_or_initialize_by( + email: "staff@example.com", + manage_referrals: true, + view_support: true, + confirmed_at: 1.second.ago, +) do |s| + s.password = ENV.fetch("SUPPORT_PASSWORD", nil) +end + +staff.save(validate: false) diff --git a/lib/tasks/seed.rake b/lib/tasks/seed.rake new file mode 100644 index 000000000..9b258bde8 --- /dev/null +++ b/lib/tasks/seed.rake @@ -0,0 +1,8 @@ +namespace(:db) do + namespace(:seed) do + desc "Seeds database with test data" + task test_data: :environment do + load Rails.root.join("db/test_data_seeds.rb") + end + end +end