diff --git a/app/controllers/proposals_controller.rb b/app/controllers/proposals_controller.rb index 0b350f687..578395ab3 100644 --- a/app/controllers/proposals_controller.rb +++ b/app/controllers/proposals_controller.rb @@ -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 diff --git a/app/models/proposal.rb b/app/models/proposal.rb index f9ef60303..7d2bddb30 100644 --- a/app/models/proposal.rb +++ b/app/models/proposal.rb @@ -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 diff --git a/app/views/proposals/_notifications.html.erb b/app/views/proposals/_notifications.html.erb new file mode 100644 index 000000000..576ed8cc6 --- /dev/null +++ b/app/views/proposals/_notifications.html.erb @@ -0,0 +1,6 @@ +
+ <% @notifications.each do |notification| %> +
<%= notification.title %>
+
<%= notification.body %>
+ <% end %> +
\ No newline at end of file diff --git a/app/views/proposals/show.html.erb b/app/views/proposals/show.html.erb index cb2773c65..9d8c3b739 100644 --- a/app/views/proposals/show.html.erb +++ b/app/views/proposals/show.html.erb @@ -118,4 +118,5 @@ <% end %> +<%= render "proposals/notifications" %> <%= render "proposals/comments" %> diff --git a/spec/features/proposal_notifications_spec.rb b/spec/features/proposal_notifications_spec.rb index b014aa162..1662475b1 100644 --- a/spec/features/proposal_notifications_spec.rb +++ b/spec/features/proposal_notifications_spec.rb @@ -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