Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update seeds.rb file to create global admin and confirmed users #2118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading