mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-22 15:04:26 -04:00
Show unread notifications as bold
The view here isn't as DRY as we'd like, but all the options were kind of ugly, and this one was easiest.
This commit is contained in:
1 parent
cdee808933
commit
d3d0ff42b2
3 files changed
+30
-4
No files matched your search
@@ -15,6 +15,8 @@ class NotificationsController < ApplicationController
|
||||
# GET /notifications/1.json
|
||||
def show
|
||||
@notification = Notification.find(params[:id])
|
||||
@notification.read = true
|
||||
@notification.save
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
|
||||
@@ -11,9 +11,25 @@
|
||||
- @notifications.each do |n|
|
||||
- if can? :read, n
|
||||
%tr
|
||||
%td= link_to n.sender
|
||||
%td= link_to n.subject, notification_path(n)
|
||||
%td= n.created_at.to_s(:date)
|
||||
%td= link_to 'Delete', n, method: :delete, data: { confirm: 'Are you sure?' }
|
||||
%td
|
||||
- if n.read
|
||||
= link_to n.sender
|
||||
- else
|
||||
%strong= link_to n.sender
|
||||
%td
|
||||
- if n.read
|
||||
= link_to n.subject, notification_path(n)
|
||||
- else
|
||||
%strong= link_to n.subject, notification_path(n)
|
||||
%td
|
||||
- if n.read
|
||||
= n.created_at.to_s(:date)
|
||||
- else
|
||||
%strong= n.created_at.to_s(:date)
|
||||
%td
|
||||
- if n.read
|
||||
= link_to 'Delete', n, method: :delete, data: { confirm: 'Are you sure?' }
|
||||
- else
|
||||
%strong= link_to 'Delete', n, method: :delete, data: { confirm: 'Are you sure?' }
|
||||
- else
|
||||
You have no messages.
|
||||
@@ -26,6 +26,14 @@ describe NotificationsController do
|
||||
get :show, {:id => notification.to_param}
|
||||
assigns(:notification).should eq(notification)
|
||||
end
|
||||
|
||||
it "marks notifications as read" do
|
||||
notification = Notification.create! valid_attributes
|
||||
get :show, {:id => notification.to_param}
|
||||
# we need to fetch it from the db again, can't test against the old one
|
||||
n = Notification.find(notification.id)
|
||||
n.read.should eq true
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE destroy" do
|
||||
|
||||
Reference in new issue
Block a user