Skip to content

Commit 7209d7d

Browse files
committed
Add fallback submission email address for database seed
Forms can't be made live without a submission email address, so if the `EMAIL` environment is not set or an email address can't be retrieved with git then initializing the database will fail. This commit uses an example email address as a fallback so that the database seed can always be applied. We also update the README to document the behaviour of the submission emails for test forms.
1 parent 23f44c7 commit 7209d7d

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ To run this project, your database will need to have a user in it. The `bin/setu
127127
./bin/rails db:seed
128128
```
129129

130+
The database seed will also create a number of test forms, by default the submissions for these forms will be sent by email to the email address that you have configured in Git. If you want to override this, or are running this app in a container where git or its configuration is not present, then you can use set the `EMAIL` environment variable. If neither `EMAIL` or the git email address are set, the database seed will fallback to a generic test email address.
131+
130132
## Changing configuration
131133

132134
### Changing settings

db/seeds.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@
134134

135135
Membership.create! user: default_user, group: end_to_end_group, added_by: default_user, role: :group_admin
136136

137-
submission_email = ENV["EMAIL"] || `git config --get user.email`.strip
137+
submission_email = ENV["EMAIL"].presence || `git config --get user.email`.strip.presence || "example@example.com"
138138

139139
all_question_types_form = Form.create!(
140140
name: "All question types form",

0 commit comments

Comments
 (0)