OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openproject/modules/dashboards/spec/factories/grid_factory.rb

63 lines
1.8 KiB

FactoryBot.define do
factory :dashboard, class: 'Grids::Dashboard' do
project
row_count { 7 }
column_count { 4 }
widgets do
[
Grids::Widget.new(
identifier: 'work_packages_table',
start_row: 1,
end_row: 7,
start_column: 1,
end_column: 3
)
]
end
end
factory :dashboard_with_table, class: 'Grids::Dashboard' do
project
row_count { 7 }
column_count { 4 }
callback(:after_build) do |dashboard|
query = FactoryBot.create(:query, project: dashboard.project, hidden: true, is_public: true)
widget = FactoryBot.build(:grid_widget,
identifier: 'work_packages_table',
start_row: 1,
end_row: 7,
start_column: 1,
end_column: 3,
options: {
name: 'Work package table',
queryId: query.id
})
dashboard.widgets = [widget]
end
end
factory :dashboard_with_custom_text, class: 'Grids::Dashboard' do
project
row_count { 7 }
column_count { 4 }
callback(:after_build) do |dashboard|
widget = FactoryBot.build(:grid_widget,
identifier: 'custom_text',
start_row: 1,
end_row: 7,
start_column: 1,
end_column: 3,
options: {
name: 'Custom text',
text: 'Lorem ipsum'
})
dashboard.widgets = [widget]
end
end
end