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

Fix upsale in notifications

Oliver Günther219581665d03
diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb
index 394d8243cd0..6551f019f2b 100644
--- a/app/controllers/notifications_controller.rb
+++ b/app/controllers/notifications_controller.rb
@@ -33,6 +33,8 @@ class NotificationsController < ApplicationController
before_action :filtered_query, only: :mark_all_read
no_authorization_required! :index, :split_view, :update_counter, :mark_all_read, :date_alerts, :share_upsale
+ before_action :check_filter, only: %i[index]
+
def index
render_notifications_layout
end
@@ -93,4 +95,12 @@ class NotificationsController < ApplicationController
@filtered_query = query
end
+
+ def check_filter
+ return if EnterpriseToken.allows_to?(:date_alerts)
+
+ if params[:filter] == "reason" && params[:name] == "dateAlert"
+ redirect_to notifications_date_alert_upsale_path
+ end
+ end
end
diff --git a/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb b/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb
index 729c4e2cbc9..185e8704a06 100644
--- a/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb
+++ b/spec/features/notifications/notification_center/notification_center_date_alerts_spec.rb
@@ -195,15 +195,13 @@ RSpec.describe "Notification center date alerts", :js, with_settings: { journal_
side_menu.click_item "Date alert"
expect(page).to have_current_path(/notifications\/date_alerts/)
- expect(page).to have_enterprise_upsale_page
- expect(page).to have_text "Available only through the Basic enterprise plan"
+ expect(page).to have_enterprise_upsale_page(:basic)
# It does not allows direct url access
visit notifications_center_path(filter: "reason", name: "dateAlert")
expect(page).to have_current_path(/notifications\/date_alerts/)
- expect(page).to have_enterprise_upsale_page
- expect(page).to have_text "Available only through the Basic enterprise plan"
+ expect(page).to have_enterprise_upsale_page(:basic)
end
end