Fix url to notifiable when it is a Legislation Question or Annotation

This commit is contained in:
Amaia Castro
2017-01-20 18:43:59 +01:00
parent 7613091d2e
commit 289b8e044b
3 changed files with 40 additions and 0 deletions

View File

@@ -1,4 +1,6 @@
class NotificationsController < ApplicationController
include CustomUrlsHelper
before_action :authenticate_user!
after_action :mark_as_read, only: :show
skip_authorization_check

View File

@@ -0,0 +1,9 @@
module CustomUrlsHelper
def legislation_question_url(question)
legislation_process_question_url(question.process, question)
end
def legislation_annotation_url(annotation)
legislation_process_question_url(annotation.draft_version.process, annotation.draft_version, annotation)
end
end

View File

@@ -1,10 +1,17 @@
require 'rails_helper'
feature "Notifications" do
let(:admin_user) { create :user }
let(:administrator) do
create(:administrator, user: admin_user)
admin_user
end
let(:author) { create :user }
let(:user) { create :user }
let(:debate) { create :debate, author: author }
let(:proposal) { create :proposal, author: author }
let(:legislation_question) { create(:legislation_question, author: administrator) }
let(:legislation_annotation) { create(:legislation_annotation, author: author) }
scenario "User commented on my debate", :js do
login_as user
@@ -28,6 +35,28 @@ feature "Notifications" do
expect(page).to have_xpath "//a[@href='#{notification_path(Notification.last)}']"
end
scenario "User commented on my legislation question", :js do
login_as user
visit legislation_process_question_path legislation_question.process, legislation_question
fill_in "comment-body-legislation_question_#{legislation_question.id}", with: "I answered your question"
click_button "Publish answer"
within "#comments" do
expect(page).to have_content "I answered your question"
end
logout
login_as administrator
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