update seeds to use factories. update admin users view.
This commit is contained in:
parent
7969a0e920
commit
27e954adc2
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
ActiveAdmin.register User do
|
||||
permit_params :email, :password, :password_confirmation
|
||||
permit_params proc: User.attribute_names
|
||||
|
||||
index do
|
||||
selectable_column
|
|
@ -9,4 +9,5 @@
|
|||
# Character.create(name: 'Luke', movie: movies.first)
|
||||
return unless Rails.env.development?
|
||||
|
||||
User.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password', admin: true)
|
||||
FactoryBot.create(:user, :admin)
|
||||
FactoryBot.create_list(:user, 10)
|
||||
|
|
|
@ -12,8 +12,6 @@ services:
|
|||
environment:
|
||||
POSTGRES_USER: "user"
|
||||
POSTGRES_PASSWORD: "password"
|
||||
ports:
|
||||
- "5432:5432"
|
||||
volumes:
|
||||
- ./tmp/postgres/data:/var/lib/postgresql/data
|
||||
|
||||
|
|
|
@ -2,7 +2,25 @@
|
|||
|
||||
FactoryBot.define do
|
||||
factory :user do
|
||||
email { Faker::Internet.email }
|
||||
password { Faker::Internet.password }
|
||||
sequence(:email) { |n| "user_#{n}@example.com" }
|
||||
sequence(:username) { |n| "user_#{n}" }
|
||||
password { 'password' }
|
||||
password_confirmation { 'password' }
|
||||
|
||||
confirmed # default trait
|
||||
|
||||
trait :admin do
|
||||
sequence(:email) { |n| "admin_#{n}@example.com" }
|
||||
sequence(:username) { |n| "admin_#{n}" }
|
||||
admin { true }
|
||||
end
|
||||
|
||||
trait :confirmed do
|
||||
confirmed_at { Time.current }
|
||||
end
|
||||
|
||||
trait :unconfirmed do
|
||||
confirmed_at { nil }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue