displays notifications in proposal view
This commit is contained in:
@@ -2,7 +2,6 @@ class ProposalsController < ApplicationController
|
||||
include CommentableActions
|
||||
include FlagActions
|
||||
|
||||
|
||||
before_action :parse_search_terms, only: [:index, :suggest]
|
||||
before_action :parse_advanced_search_terms, only: :index
|
||||
before_action :parse_tag_filter, only: :index
|
||||
@@ -22,6 +21,7 @@ class ProposalsController < ApplicationController
|
||||
|
||||
def show
|
||||
super
|
||||
@notifications = @proposal.notifications
|
||||
redirect_to proposal_path(@proposal), status: :moved_permanently if request.path != proposal_path(@proposal)
|
||||
end
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ class Proposal < ActiveRecord::Base
|
||||
belongs_to :author, -> { with_hidden }, class_name: 'User', foreign_key: 'author_id'
|
||||
belongs_to :geozone
|
||||
has_many :comments, as: :commentable
|
||||
has_many :proposal_notifications
|
||||
|
||||
validates :title, presence: true
|
||||
validates :question, presence: true
|
||||
@@ -154,6 +155,10 @@ class Proposal < ActiveRecord::Base
|
||||
Setting['votes_for_proposal_success'].to_i
|
||||
end
|
||||
|
||||
def notifications
|
||||
proposal_notifications
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_responsible_name
|
||||
|
||||
6
app/views/proposals/_notifications.html.erb
Normal file
6
app/views/proposals/_notifications.html.erb
Normal file
@@ -0,0 +1,6 @@
|
||||
<div>
|
||||
<% @notifications.each do |notification| %>
|
||||
<div><%= notification.title %></div>
|
||||
<div><%= notification.body %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -118,4 +118,5 @@
|
||||
</div>
|
||||
</section>
|
||||
<% end %>
|
||||
<%= render "proposals/notifications" %>
|
||||
<%= render "proposals/comments" %>
|
||||
|
||||
@@ -24,6 +24,20 @@ feature 'Proposal Notifications' do
|
||||
expect(page).to have_content "Please share it with others so we can make it happen!"
|
||||
end
|
||||
|
||||
scenario "Show notifications" do
|
||||
proposal = create(:proposal)
|
||||
notification1 = create(:proposal_notification, proposal: proposal, title: "Hey guys", body: "Just wanted to let you know that...")
|
||||
notification2 = create(:proposal_notification, proposal: proposal, title: "Another update", body: "We are almost there please share with your peoples!")
|
||||
|
||||
visit proposal_path(proposal)
|
||||
|
||||
expect(page).to have_content "Hey guys"
|
||||
expect(page).to have_content "Just wanted to let you know that..."
|
||||
|
||||
expect(page).to have_content "Another update"
|
||||
expect(page).to have_content "We are almost there please share with your peoples!"
|
||||
end
|
||||
|
||||
context "Permissions" do
|
||||
|
||||
scenario "Link to send the message" do
|
||||
|
||||
Reference in New Issue
Block a user