diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 16a82de6a..7d833f6a1 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -29,6 +29,8 @@ class NotificationsController < ApplicationController case notification.linkable_resource.class.name when "Budget::Investment" budget_investment_path @notification.linkable_resource.budget, @notification.linkable_resource + when "Topic" + community_topic_path @notification.linkable_resource.community, @notification.linkable_resource else url_for @notification.linkable_resource end diff --git a/spec/features/notifications_spec.rb b/spec/features/notifications_spec.rb index 9925b0d56..75ed91857 100644 --- a/spec/features/notifications_spec.rb +++ b/spec/features/notifications_spec.rb @@ -14,6 +14,12 @@ feature "Notifications" do let(:legislation_question) { create(:legislation_question, process: process, author: administrator) } let(:legislation_annotation) { create(:legislation_annotation, author: author) } + let(:topic) { + proposal = create(:proposal) + community = proposal.community + create(:topic, community: community, author: author) + } + scenario "User commented on my debate", :js do create(:notification, notifiable: debate, user: author) login_as author @@ -40,6 +46,19 @@ feature "Notifications" do expect(page).to have_xpath "//a[@href='#{notification_path(Notification.last)}']" end + scenario "User commented on my topic", :js do + create(:notification, notifiable: topic, user: author) + login_as author + visit root_path + + find(".icon-notification").click + + expect(page).to have_css ".notification", count: 1 + + expect(page).to have_content "Someone commented on" + expect(page).to have_xpath "//a[@href='#{notification_path(Notification.last)}']" + end + scenario "Multiple comments on my proposal", :js do login_as user visit proposal_path proposal