Rakefile: move first user creation to db/seeds.rb
This commit is contained in:
parent
b0c5d8ec66
commit
e50cc68e75
3 changed files with 15 additions and 30 deletions
10
README.md
10
README.md
|
@ -45,8 +45,8 @@ Les informations nécessaire à l'initialisation de la base doivent être pré-c
|
|||
|
||||
Afin de générer la BDD de l'application, il est nécessaire d'exécuter les commandes suivantes :
|
||||
|
||||
# Create and load the schema for both databases
|
||||
bin/rails db:create db:schema:load
|
||||
# Create and initialize the database
|
||||
bin/rails db:create db:schema:load db:seed
|
||||
|
||||
# Migrate the development database and the test database
|
||||
bin/rails db:migrate
|
||||
|
@ -81,14 +81,12 @@ Dans le fichier `config/intializers/token.rb`, ajouter
|
|||
|
||||
*Note : les valeurs pour ces paramètres sont renseignées dans le Keepass*
|
||||
|
||||
## Création d'un compte de test initial en local
|
||||
|
||||
bin/rake create_test_account -- --email=EMAIL --password=PASSWORD
|
||||
|
||||
## Lancement de l'application
|
||||
|
||||
overmind s
|
||||
|
||||
Un utilisateur de test est disponible, avec les identifiants `test@exemple.fr`/`testpassword`.
|
||||
|
||||
## Programmation des jobs
|
||||
|
||||
AutoArchiveProcedureJob.set(cron: "* * * * *").perform_later
|
||||
|
|
21
Rakefile
21
Rakefile
|
@ -5,27 +5,6 @@ require File.expand_path('config/application', __dir__)
|
|||
|
||||
Rails.application.load_tasks
|
||||
|
||||
desc "Create a test account that includes all roles"
|
||||
task :create_test_account => :environment do
|
||||
email, password = nil
|
||||
optparse = OptionParser.new do |opts|
|
||||
opts.banner = "Usage: rake create_test_account -- --email=EMAIL --password=PASSWORD"
|
||||
opts.on("--email ARG", String) { |e| email = e }
|
||||
opts.on("--password ARG", String) { |p| password = p }
|
||||
end
|
||||
args = optparse.order!(ARGV) {}
|
||||
optparse.parse!(args)
|
||||
|
||||
raise optparse.banner if email.nil? || password.nil?
|
||||
raise "Password must be at least 8 characters." if password.length < 8
|
||||
|
||||
Administration.create!(email: email, password: password)
|
||||
Administrateur.create!(email: email, password: password)
|
||||
Gestionnaire.create!(email: email, password: password)
|
||||
User.create!(email: email, password: password, confirmed_at: DateTime.now)
|
||||
puts "Test account #{email} created"
|
||||
end
|
||||
|
||||
task :deploy do
|
||||
domains = %w(37.187.249.111 149.202.72.152 149.202.198.6)
|
||||
domains.each do |domain|
|
||||
|
|
14
db/seeds.rb
14
db/seeds.rb
|
@ -1,7 +1,15 @@
|
|||
# This file should contain all the record creation needed to seed the database with its default values.
|
||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
||||
|
||||
#
|
||||
# Examples:
|
||||
# Create an initial user who can use all roles
|
||||
#
|
||||
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
||||
# Mayor.create(name: 'Emanuel', city: cities.first)
|
||||
|
||||
default_user = "test@exemple.fr"
|
||||
default_password = "testpassword"
|
||||
|
||||
puts "Create test user '#{default_user}'"
|
||||
Administration.create!(email: default_user, password: default_password)
|
||||
Administrateur.create!(email: default_user, password: default_password)
|
||||
Gestionnaire.create!(email: default_user, password: default_password)
|
||||
User.create!(email: default_user, password: default_password, confirmed_at: DateTime.now)
|
||||
|
|
Loading…
Reference in a new issue