Merge pull request #91 from medialab-prado/add-url-helpers-for-legislation-again

Add url helpers for legislation again
This commit is contained in:
Fernando Blat
2017-01-23 11:18:31 +01:00
committed by GitHub
4 changed files with 43 additions and 1 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

@@ -12,7 +12,9 @@ class CommentNotifier
private
def send_comment_email
Mailer.comment(@comment).deliver_later if email_on_comment?
unless @comment.commentable.is_a?(Legislation::Annotation)
Mailer.comment(@comment).deliver_later if email_on_comment?
end
end
def send_reply_email

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