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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Add spec when no notifications present
Oliver Günther7dba98acaf7d
diff --git a/spec/factories/notification_factory.rb b/spec/factories/notification_factory.rbindex c7ec7f97b1c..b075e981505 100644--- a/spec/factories/notification_factory.rb+++ b/spec/factories/notification_factory.rb@@ -9,15 +9,11 @@ FactoryBot.define doproject { association :project }resource { association :work_package, project: project }actor { nil }+ journal { nil }- transient do- journal { nil }- end-- callback(:after_create) do |notification, evaluator|- notification.journal = evaluator.journal || notification.resource.journals.last+ callback(:after_build) do |notification, _|+ notification.journal ||= notification.resource.journals.lastnotification.actor ||= notification.journal.try(:user)- notification.save!endendenddiff --git a/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rb b/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rbindex f607e385a49..6a51511acab 100644--- a/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rb+++ b/spec/features/notifications/notification_center/notification_center_sidemenu_spec.rb@@ -17,7 +17,7 @@ describe "Notification center sidemenu", type: :feature, js: true doshared_let(:work_package3) { FactoryBot.create :work_package, project: project3, author: other_user }shared_let(:work_package4) { FactoryBot.create :work_package, project: project3, author: other_user }- let!(:notification) do+ let(:notification) doFactoryBot.create :notification,recipient: recipient,project: project,@@ -25,7 +25,7 @@ describe "Notification center sidemenu", type: :feature, js: true doreason: :watchedend- let!(:notification2) do+ let(:notification2) doFactoryBot.create :notification,recipient: recipient,project: project2,@@ -33,7 +33,7 @@ describe "Notification center sidemenu", type: :feature, js: true doreason: :assignedend- let!(:notification3) do+ let(:notification3) doFactoryBot.create :notification,recipient: recipient,project: project3,@@ -41,7 +41,7 @@ describe "Notification center sidemenu", type: :feature, js: true doreason: :responsibleend- let!(:notification4) do+ let(:notification4) doFactoryBot.create :notification,recipient: recipient,project: project3,@@ -49,102 +49,123 @@ describe "Notification center sidemenu", type: :feature, js: true doreason: :mentionedend- let(:center) { ::Components::Notifications::Center.new }+ let(:notifications) do+ [notification, notification2, notification3, notification4]+ end++ let(:center) { ::Pages::Notifications::Center.new }let(:side_menu) { ::Components::Notifications::Sidemenu.new }- describe 'showing the correct data:' do- before do- login_as recipient- visit notifications_center_path- end+ before do+ notifications+ login_as recipient+ center.visit!+ end++ context 'with no notifications to show' do+ let(:notifications) { nil }- it 'updates the numbers when a notification is read' do+ it 'still shows the sidebar and a placeholder' doside_menu.expect_open- # Expect standard filters- side_menu.expect_item_with_count 'Inbox', 4- side_menu.expect_item_with_count 'Assigned', 1- side_menu.expect_item_with_count '@mentioned', 1- side_menu.expect_item_with_count 'Accountable', 1- side_menu.expect_item_with_count 'Watching', 1-- # Expect project filters- side_menu.expect_item_with_count project.name, 1- side_menu.expect_item_with_count project2.name, 1- side_menu.expect_item_with_count "... #{project3.name}", 2-- # Reading a notification...- center.mark_notification_as_read notification-- # ... will change the filter counts- side_menu.expect_item_with_count 'Inbox', 3- side_menu.expect_item_with_count 'Assigned', 1- side_menu.expect_item_with_count '@mentioned', 1- side_menu.expect_item_with_count 'Accountable', 1- side_menu.expect_item_with_no_count 'Watching'+ expect(page).to have_text 'No unread notifications'- # ... and show only those projects with a notification- side_menu.expect_item_not_visible project.name- side_menu.expect_item_with_count project2.name, 1- side_menu.expect_item_with_count "... #{project3.name}", 2+ center.expect_no_notification- # Marking all as read- center.mark_all_readside_menu.expect_item_with_no_count 'Inbox'side_menu.expect_item_with_no_count 'Assigned'side_menu.expect_item_with_no_count '@mentioned'side_menu.expect_item_with_no_count 'Accountable'side_menu.expect_item_with_no_count 'Watching'-- side_menu.expect_item_not_visible project.name- side_menu.expect_item_not_visible project2.name- side_menu.expect_item_not_visible "... #{project3.name}"end+ end- it 'updates the content when a filter is clicked' do- # All notifications are shown- center.expect_work_package_item notification, notification2, notification3, notification4-- # Filter for "Watching"- side_menu.click_item 'Watching'- side_menu.finished_loading- center.expect_work_package_item notification- center.expect_no_item notification2, notification3, notification4-- # Filter for "Assignee"- side_menu.click_item 'Assigned'- side_menu.finished_loading- center.expect_work_package_item notification2- center.expect_no_item notification, notification3, notification4-- # Filter for "Accountable"- side_menu.click_item 'Accountable'- side_menu.finished_loading- center.expect_work_package_item notification3- center.expect_no_item notification, notification2, notification4-- # Filter for "@mentioned"- side_menu.click_item '@mentioned'- side_menu.finished_loading- center.expect_work_package_item notification4- center.expect_no_item notification, notification2, notification3-- # Filter for project1- side_menu.click_item project.name- side_menu.finished_loading- center.expect_work_package_item notification- center.expect_no_item notification2, notification3, notification4-- # Filter for project3- side_menu.click_item "... #{project3.name}"- side_menu.finished_loading- center.expect_work_package_item notification3, notification4- center.expect_no_item notification, notification2-- # Reset by clicking on the Inbox- side_menu.click_item 'Inbox'- side_menu.finished_loading- center.expect_work_package_item notification, notification2, notification3, notification4- end+ it 'updates the numbers when a notification is read' do+ side_menu.expect_open++ # Expect standard filters+ side_menu.expect_item_with_count 'Inbox', 4+ side_menu.expect_item_with_count 'Assigned', 1+ side_menu.expect_item_with_count '@mentioned', 1+ side_menu.expect_item_with_count 'Accountable', 1+ side_menu.expect_item_with_count 'Watching', 1++ # Expect project filters+ side_menu.expect_item_with_count project.name, 1+ side_menu.expect_item_with_count project2.name, 1+ side_menu.expect_item_with_count "... #{project3.name}", 2++ # Reading a notification...+ center.mark_notification_as_read notification++ # ... will change the filter counts+ side_menu.expect_item_with_count 'Inbox', 3+ side_menu.expect_item_with_count 'Assigned', 1+ side_menu.expect_item_with_count '@mentioned', 1+ side_menu.expect_item_with_count 'Accountable', 1+ side_menu.expect_item_with_no_count 'Watching'++ # ... and show only those projects with a notification+ side_menu.expect_item_not_visible project.name+ side_menu.expect_item_with_count project2.name, 1+ side_menu.expect_item_with_count "... #{project3.name}", 2++ # Marking all as read+ center.mark_all_read+ side_menu.expect_item_with_no_count 'Inbox'+ side_menu.expect_item_with_no_count 'Assigned'+ side_menu.expect_item_with_no_count '@mentioned'+ side_menu.expect_item_with_no_count 'Accountable'+ side_menu.expect_item_with_no_count 'Watching'++ side_menu.expect_item_not_visible project.name+ side_menu.expect_item_not_visible project2.name+ side_menu.expect_item_not_visible "... #{project3.name}"+ end++ it 'updates the content when a filter is clicked' do+ # All notifications are shown+ center.expect_work_package_item notification, notification2, notification3, notification4++ # Filter for "Watching"+ side_menu.click_item 'Watching'+ side_menu.finished_loading+ center.expect_work_package_item notification+ center.expect_no_item notification2, notification3, notification4++ # Filter for "Assignee"+ side_menu.click_item 'Assigned'+ side_menu.finished_loading+ center.expect_work_package_item notification2+ center.expect_no_item notification, notification3, notification4++ # Filter for "Accountable"+ side_menu.click_item 'Accountable'+ side_menu.finished_loading+ center.expect_work_package_item notification3+ center.expect_no_item notification, notification2, notification4++ # Filter for "@mentioned"+ side_menu.click_item '@mentioned'+ side_menu.finished_loading+ center.expect_work_package_item notification4+ center.expect_no_item notification, notification2, notification3++ # Filter for project1+ side_menu.click_item project.name+ side_menu.finished_loading+ center.expect_work_package_item notification+ center.expect_no_item notification2, notification3, notification4++ # Filter for project3+ side_menu.click_item "... #{project3.name}"+ side_menu.finished_loading+ center.expect_work_package_item notification3, notification4+ center.expect_no_item notification, notification2++ # Reset by clicking on the Inbox+ side_menu.click_item 'Inbox'+ side_menu.finished_loading+ center.expect_work_package_item notification, notification2, notification3, notification4endend