From 796fe333e30eb7523ef92584bf39b2fb347d5c90 Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 20 Oct 2017 17:05:23 +0200 Subject: [PATCH 1/2] adds case when topic on notifications controller --- app/controllers/notifications_controller.rb | 2 ++ 1 file changed, 2 insertions(+) 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 From 45133a917fb742a9d2eb43a5a10d60806c57648a Mon Sep 17 00:00:00 2001 From: decabeza Date: Fri, 20 Oct 2017 17:07:44 +0200 Subject: [PATCH 2/2] adds topic notifications specs --- spec/features/notifications_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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