Fix url to notifiable when it is a Legislation Question or Annotation
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
class NotificationsController < ApplicationController
|
class NotificationsController < ApplicationController
|
||||||
|
include CustomUrlsHelper
|
||||||
|
|
||||||
before_action :authenticate_user!
|
before_action :authenticate_user!
|
||||||
after_action :mark_as_read, only: :show
|
after_action :mark_as_read, only: :show
|
||||||
skip_authorization_check
|
skip_authorization_check
|
||||||
|
|||||||
9
app/helpers/custom_urls_helper.rb
Normal file
9
app/helpers/custom_urls_helper.rb
Normal 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
|
||||||
@@ -1,10 +1,17 @@
|
|||||||
require 'rails_helper'
|
require 'rails_helper'
|
||||||
|
|
||||||
feature "Notifications" do
|
feature "Notifications" do
|
||||||
|
let(:admin_user) { create :user }
|
||||||
|
let(:administrator) do
|
||||||
|
create(:administrator, user: admin_user)
|
||||||
|
admin_user
|
||||||
|
end
|
||||||
let(:author) { create :user }
|
let(:author) { create :user }
|
||||||
let(:user) { create :user }
|
let(:user) { create :user }
|
||||||
let(:debate) { create :debate, author: author }
|
let(:debate) { create :debate, author: author }
|
||||||
let(:proposal) { create :proposal, 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
|
scenario "User commented on my debate", :js do
|
||||||
login_as user
|
login_as user
|
||||||
@@ -28,6 +35,28 @@ feature "Notifications" do
|
|||||||
expect(page).to have_xpath "//a[@href='#{notification_path(Notification.last)}']"
|
expect(page).to have_xpath "//a[@href='#{notification_path(Notification.last)}']"
|
||||||
end
|
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
|
scenario "Multiple comments on my proposal", :js do
|
||||||
login_as user
|
login_as user
|
||||||
visit proposal_path proposal
|
visit proposal_path proposal
|
||||||
|
|||||||
Reference in New Issue
Block a user