Add projects to group seeder

pull/7495/head
Henriette Dinger 5 years ago
parent 21a5d0d5fe
commit 90ab2cbfcc
  1. 15
      app/seeders/demo_data/group_seeder.rb
  2. 4
      app/seeders/demo_data_seeder.rb

@ -52,7 +52,9 @@ module DemoData
groups.each do |group_attr|
print '.'
group = create_group group_attr[:name]
add_user_to_group group
add_projects_to_group group, group_attr[:projects]
end
end
@ -63,5 +65,18 @@ module DemoData
def add_user_to_group(group)
group.users << user
end
def add_projects_to_group(group, projects)
projects.each do |project_attr|
project = Project.find(project_attr[:name])
role = Role.find_by(name: project_attr[:role])
Member.create!(
project: project,
principal: group,
roles: [role]
)
end
end
end
end

@ -28,8 +28,8 @@
class DemoDataSeeder < CompositeSeeder
def data_seeder_classes
[
DemoData::GroupSeeder,
DemoData::ProjectSeeder
DemoData::ProjectSeeder,
DemoData::GroupSeeder
]
end

Loading…
Cancel
Save