Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rendezvous
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VeNtura
rendezvous
Commits
95945274
Commit
95945274
authored
Jul 30, 2014
by
tady
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
通知を1周間より最近なものに限定
parent
ed89824d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
5 deletions
+20
-5
app/models/notification.rb
+4
-1
app/models/user.rb
+3
-1
app/views/partials/_app_header.html.slim
+3
-3
spec/models/notification_spec.rb
+10
-0
No files found.
app/models/notification.rb
View file @
95945274
...
...
@@ -19,11 +19,14 @@ class Notification < ActiveRecord::Base
# Named scope
######################################################################
# 最新のPostを取得
scope
:unread
,
->
{
where
(
is_read:
false
)
}
scope
:recent
,
->
{
where
(
arel_table
[
:created_at
].
gt
7
.
day
.
ago
)
}
######################################################################
# Instance method
######################################################################
...
...
app/models/user.rb
View file @
95945274
...
...
@@ -115,7 +115,9 @@ class User < ActiveRecord::Base
# push通知を追加
def
push_notification
(
detail_path
,
body
)
notifications
.
create
(
detail_path:
detail_path
,
body:
body
,
is_read:
false
)
unless
notifications
.
where
(
detail_path:
detail_path
).
unread
.
exists?
notifications
.
create
(
detail_path:
detail_path
,
body:
body
,
is_read:
false
)
end
end
# record footprint
...
...
app/views/partials/_app_header.html.slim
View file @
95945274
...
...
@@ -30,7 +30,7 @@ nav.navbar.navbar-fixed-top.navbar-original role="navigation"
a
#notifications
data-container
=
"body"
data-toggle
=
"popover"
data-placement
=
"bottom"
span
.glyphicon.glyphicon-flag
-
if
current_user
.
notifications
.
unread
.
any?
span
.badge
=
current_user
.
notifications
.
unread
.
count
span
.badge
=
current_user
.
notifications
.
unread
.
recent
.
count
li
.new-post-btn
form
a
.btn.navbar-btn
href
=
new_post_path
...
...
@@ -56,10 +56,10 @@ nav.navbar.navbar-fixed-top.navbar-original role="navigation"
a
href
=
destroy_user_session_path
data-method
=
"delete"
rel
=
"nofollow"
SignOut
script
#notification-content
type
=
"text/template"
-
if
current_user
.
notifications
.
unread
.
any?
-
if
current_user
.
notifications
.
unread
.
recent
.
any?
h4
通知一覧
.list-group
-
current_user
.
notifications
.
unread
.
each
do
|
notification
|
-
current_user
.
notifications
.
unread
.
recent
.
each
do
|
notification
|
a
.list-group-item
href
=
notification_bridge_path
(
notification
.
id
)
spen
.small
|
[
#{
notification
.
created_at
.
strftime
(
'%m/%d %H:%M'
)
}
]
...
...
spec/models/notification_spec.rb
View file @
95945274
...
...
@@ -32,6 +32,16 @@ describe Notification do
expect
(
@bob
.
notifications
.
size
).
to
eq
(
1
)
end
it
"not duplicated notifies on post edited"
do
@bob
.
watch!
(
post:
@post
)
expect
(
@bob
.
watching?
(
post:
@post
)).
to
be_truthy
@post
.
reload
expect
(
@post
.
watchers
).
to
include
(
@bob
)
@post
.
update!
(
title:
@post
.
title
+
' [New!]'
)
@post
.
update!
(
title:
@post
.
title
+
' [New!]'
)
expect
(
@bob
.
notifications
.
size
).
to
eq
(
1
)
end
it
"not notifies on post edited by him"
do
@bob
.
watch!
(
post:
@post
)
@post
.
reload
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment