Class: UffizziCore::UserGeneratorService

Inherits:
Object
  • Object
show all
Defined in:
app/services/uffizzi_core/user_generator_service.rb

Constant Summary collapse

DEFAULT_USER_EMAIL =
'[email protected]'
DEFAULT_PROJECT_NAME =
'default'
DEFAULT_ACCOUNT_NAME =
'default'

Class Method Summary collapse

Class Method Details

.generate(email, password, project_name) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/services/uffizzi_core/user_generator_service.rb', line 15

def generate(email, password, project_name)
  user_attributes = build_user_attributes(email, password)
  project_attributes = build_project_attributes(project_name)

  ActiveRecord::Base.transaction do
    user = UffizziCore::User.create!(user_attributes)

     = (user)
     = UffizziCore::Account.create!()
    user.memberships.create!(account: , role: UffizziCore::Membership.role.admin)
    project = .projects.create!(project_attributes)
    project.user_projects.create!(user: user, role: UffizziCore::UserProject.role.admin)
  end
end

.safe_generate(email, password, project_name) ⇒ Object



9
10
11
12
13
# File 'app/services/uffizzi_core/user_generator_service.rb', line 9

def safe_generate(email, password, project_name)
  generate(email, password, project_name)
rescue StandardError => e
  puts e.message
end