Merge pull request #2172 from consul/notifications
Notifications for hidden resources
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
<li id="<%= dom_id(notification) %>" class="notification">
|
||||
<%= link_to notification do %>
|
||||
<p>
|
||||
<em>
|
||||
<%= t("notifications.index.#{notification.notifiable_action}",
|
||||
count: notification.counter) %>
|
||||
</em>
|
||||
<strong><%= notification.notifiable_title %></strong>
|
||||
</p>
|
||||
<% if notification.notifiable.present? %>
|
||||
<%= link_to notification do %>
|
||||
<p>
|
||||
<em>
|
||||
<%= t("notifications.index.#{notification.notifiable_action}",
|
||||
count: notification.counter) %>
|
||||
</em>
|
||||
<strong><%= notification.notifiable_title %></strong>
|
||||
</p>
|
||||
|
||||
<p class="time"><%= l notification.timestamp, format: :datetime %></p>
|
||||
<p class="time"><%= l notification.timestamp, format: :datetime %></p>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p>
|
||||
<strong>
|
||||
<%= t("notifications.index.notifiable_hidden") %>
|
||||
</strong>
|
||||
</p>
|
||||
<% end %>
|
||||
</li>
|
||||
@@ -264,6 +264,7 @@ en:
|
||||
one: Someone commented on
|
||||
other: There are %{count} new comments on
|
||||
empty_notifications: You don't have new notifications.
|
||||
notifiable_hidden: This resource is not available anymore.
|
||||
mark_all_as_read: Mark all as read
|
||||
proposal_notification:
|
||||
one: There is one new notification on
|
||||
|
||||
@@ -264,6 +264,7 @@ es:
|
||||
one: Hay un nuevo comentario en
|
||||
other: Hay %{count} comentarios nuevos en
|
||||
empty_notifications: No tienes notificaciones nuevas.
|
||||
notifiable_hidden: Este elemento ya no está disponible.
|
||||
mark_all_as_read: Marcar todas como leídas
|
||||
proposal_notification:
|
||||
one: Hay una nueva notificación en
|
||||
|
||||
@@ -8,6 +8,7 @@ describe InstallationController, type: :request do
|
||||
'debates' => nil,
|
||||
'spending_proposals' => 't',
|
||||
'polls' => nil,
|
||||
'proposals' => 't',
|
||||
'twitter_login' => nil,
|
||||
'facebook_login' => nil,
|
||||
'google_login' => nil,
|
||||
|
||||
@@ -298,7 +298,6 @@ feature "Notifications" do
|
||||
end
|
||||
|
||||
pending "group notifications for the same proposal"
|
||||
|
||||
end
|
||||
|
||||
context "mark as read" do
|
||||
@@ -334,6 +333,19 @@ feature "Notifications" do
|
||||
|
||||
end
|
||||
|
||||
scenario "Notifiable hidden", :js do
|
||||
create(:notification, notifiable: debate, user: author)
|
||||
debate.hide
|
||||
|
||||
login_as author
|
||||
visit root_path
|
||||
find(".icon-notification").click
|
||||
|
||||
expect(page).to have_css ".notification", count: 1
|
||||
expect(page).to have_content "This resource is not available anymore"
|
||||
expect(page).to_not have_xpath "//a[@href='#{notification_path(Notification.last)}']"
|
||||
end
|
||||
|
||||
scenario "no notifications" do
|
||||
login_as user
|
||||
visit notifications_path
|
||||
|
||||
@@ -48,33 +48,51 @@ describe Notification do
|
||||
end
|
||||
|
||||
describe "#notification_action" do
|
||||
it "returns correct text when someone comments on your commentable" do
|
||||
debate = create(:debate)
|
||||
notification = create(:notification, notifiable: debate)
|
||||
|
||||
context "when action was comment on a debate" do
|
||||
it "returns correct text when someone comments on your debate" do
|
||||
debate = create(:debate)
|
||||
notification = create :notification, notifiable: debate
|
||||
|
||||
expect(notification.notifiable_action).to eq "comments_on"
|
||||
end
|
||||
expect(notification.notifiable_action).to eq "comments_on"
|
||||
end
|
||||
|
||||
context "when action was comment on a debate" do
|
||||
it "returns correct text when someone replies to your comment" do
|
||||
debate = create(:debate)
|
||||
debate_comment = create :comment, commentable: debate
|
||||
notification = create :notification, notifiable: debate_comment
|
||||
it "returns correct text when someone replies to your comment" do
|
||||
debate = create(:debate)
|
||||
debate_comment = create(:comment, commentable: debate)
|
||||
notification = create(:notification, notifiable: debate_comment)
|
||||
|
||||
expect(notification.notifiable_action).to eq "replies_to"
|
||||
end
|
||||
expect(notification.notifiable_action).to eq "replies_to"
|
||||
end
|
||||
|
||||
context "when action was proposal notification" do
|
||||
it "returns correct text when the author created a proposal notification" do
|
||||
proposal_notification = create(:proposal_notification)
|
||||
notification = create :notification, notifiable: proposal_notification
|
||||
it "returns correct text when the author created a proposal notification" do
|
||||
proposal_notification = create(:proposal_notification)
|
||||
notification = create(:notification, notifiable: proposal_notification)
|
||||
|
||||
expect(notification.notifiable_action).to eq "proposal_notification"
|
||||
end
|
||||
expect(notification.notifiable_action).to eq "proposal_notification"
|
||||
end
|
||||
end
|
||||
|
||||
describe "#notification_title" do
|
||||
it "returns the commentable title when it's a root comment" do
|
||||
debate = create(:debate, title: "Save the whales")
|
||||
notification = create(:notification, notifiable: debate)
|
||||
|
||||
expect(notification.notifiable_title).to eq "Save the whales"
|
||||
end
|
||||
|
||||
it "returns the commentable title when it's a reply to a root comment" do
|
||||
debate = create(:debate, title: "Save the whales")
|
||||
debate_comment = create(:comment, commentable: debate)
|
||||
notification = create(:notification, notifiable: debate_comment)
|
||||
|
||||
expect(notification.notifiable_title).to eq "Save the whales"
|
||||
end
|
||||
|
||||
it "returns the commentable title when it's an author's proposals notification" do
|
||||
proposal = create(:proposal, title: "Save the whales")
|
||||
proposal_notification = create(:proposal_notification, proposal: proposal)
|
||||
notification = create(:notification, notifiable: proposal_notification)
|
||||
|
||||
expect(notification.notifiable_title).to eq "Save the whales"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user