2021-02-04 21:08:20 +08:00
|
|
|
FactoryBot.define do
|
|
|
|
factory :user_role do
|
2021-05-02 17:22:59 +08:00
|
|
|
factory :owner_role do
|
|
|
|
name { I18n.t('user_roles.predefined.owner') }
|
|
|
|
permissions { ProjectPermissions.constants.map { |const| ProjectPermissions.const_get(const) } +
|
|
|
|
ExperimentPermissions.constants.map { |const| ExperimentPermissions.const_get(const) } +
|
|
|
|
MyModulePermissions.constants.map { |const| MyModulePermissions.const_get(const) } }
|
|
|
|
predefined { true }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :normal_user_role do
|
|
|
|
name { I18n.t('user_roles.predefined.normal_user') }
|
|
|
|
permissions {
|
|
|
|
[
|
|
|
|
ProjectPermissions::READ,
|
2021-09-07 17:27:52 +08:00
|
|
|
ProjectPermissions::EXPERIMENTS_CREATE,
|
|
|
|
ProjectPermissions::COMMENTS_CREATE,
|
2021-05-02 17:22:59 +08:00
|
|
|
ExperimentPermissions::READ,
|
|
|
|
ExperimentPermissions::MANAGE,
|
|
|
|
ExperimentPermissions::ARCHIVE,
|
|
|
|
ExperimentPermissions::RESTORE,
|
|
|
|
ExperimentPermissions::CLONE,
|
2021-09-14 17:08:35 +08:00
|
|
|
ExperimentPermissions::MY_MODULES_CREATE,
|
2021-05-02 17:22:59 +08:00
|
|
|
MyModulePermissions::READ,
|
2021-09-14 17:08:35 +08:00
|
|
|
MyModulePermissions::COMMENTS_CREATE,
|
|
|
|
MyModulePermissions::UPDATE_STATUS,
|
|
|
|
MyModulePermissions::REPOSITORY_ROWS_ASSIGN
|
2021-05-02 17:22:59 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
predefined { true }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :technician_role do
|
|
|
|
name { I18n.t('user_roles.predefined.technician') }
|
|
|
|
permissions {
|
|
|
|
[
|
|
|
|
ProjectPermissions::READ,
|
2021-09-07 17:27:52 +08:00
|
|
|
ProjectPermissions::COMMENTS_CREATE,
|
2021-05-02 17:22:59 +08:00
|
|
|
ExperimentPermissions::READ,
|
|
|
|
MyModulePermissions::READ,
|
2021-09-14 17:08:35 +08:00
|
|
|
MyModulePermissions::COMMENTS_CREATE,
|
|
|
|
MyModulePermissions::UPDATE_STATUS,
|
|
|
|
MyModulePermissions::REPOSITORY_ROWS_ASSIGN
|
2021-05-02 17:22:59 +08:00
|
|
|
]
|
|
|
|
}
|
|
|
|
predefined { true }
|
|
|
|
end
|
|
|
|
|
|
|
|
factory :viewer_role do
|
|
|
|
name { I18n.t('user_roles.predefined.viewer') }
|
|
|
|
permissions {
|
|
|
|
[
|
|
|
|
ProjectPermissions::READ,
|
|
|
|
ExperimentPermissions::READ,
|
|
|
|
MyModulePermissions::READ
|
|
|
|
]
|
|
|
|
}
|
|
|
|
predefined { true }
|
|
|
|
end
|
2021-02-04 21:08:20 +08:00
|
|
|
end
|
|
|
|
end
|