Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use FactoryBot.create_list to create 100+ notifications in spec

Dombi Attila679e6b22b0fb
diff --git a/spec/features/notifications/notification_center/notification_center_spec.rb b/spec/features/notifications/notification_center/notification_center_spec.rb
index 8057f11a6ec..d04e41e18b2 100644
--- a/spec/features/notifications/notification_center/notification_center_spec.rb
+++ b/spec/features/notifications/notification_center/notification_center_spec.rb
@@ -97,19 +97,9 @@ describe "Notification center",
context 'with more the 100 notifications' do
let(:notifications) do
- Array(0..204).map do |item|
- reason = if item < 100
- :mentioned
- else
- :watched
- end
-
- create(:notification,
- recipient:,
- project: project1,
- resource: work_package,
- reason:)
- end
+ attributes = { recipient:, project: project1, resource: work_package }
+ create_list(:notification, 100, attributes.merge(reason: :mentioned)) +
+ create_list(:notification, 105, attributes.merge(reason: :watched))
end
it 'can dismiss all notifications of the currently selected filter' do