Skip to content

Commit

Permalink
Update seeds.rb file to create global admin and confirmed users
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccaoneill committed Jan 16, 2025
1 parent 9e58c9a commit 772958f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ git submodule update --init --recursive

This links the main repo to the [BOPS applicants project](https://github.com/unboxed/bops-applicants/).

If it's your first time setting up the project or you are changing the docker file first run:

```sh
docker compose build
```

Then build and launch the images:

```sh
Expand Down Expand Up @@ -231,3 +237,7 @@ After adding a new Stimulus controller run `./bin/rails stimulus:manifest:update
## Front-end components

As much as possible, we follow the GOV.UK Design System. The HTML components can be found here [here](https://design-system.service.gov.uk/get-started). For help with forms we use the [GOV.UK Ruby on Rails Form Builder gem](https://govuk-form-builder.netlify.app). See [here](https://github.com/unboxed/bops/blob/main/app/views/users/_form.html.erb) for a simple example of implementation.

## Creating users

The seed file will automatically create and confirm users for each role and subdomain as well as a global admin user. You will need to update the password for this user.
12 changes: 12 additions & 0 deletions db/seeds.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@
end
end

User.find_or_create_by!(role: "global_administrator") do |user|
user.role = "global_administrator"
user.password = PasswordGenerator.call
user.otp_required_for_login = false
user.name = "#{Faker::Name.first_name} #{Faker::Name.last_name}"
user.email = "[email protected]"
end

User.find_each do |user|
user.confirm unless user.confirmed?
end

fixture["decisions"].each do |attrs|
Decision.find_or_create_by!(attrs.slice("code")) do |decision|
decision.assign_attributes(attrs)
Expand Down

0 comments on commit 772958f

Please sign in to comment.