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
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
4 deletions
+19
-4
app/models/notification.rb
+4
-1
app/models/user.rb
+2
-0
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
...
@@ -19,11 +19,14 @@ class Notification < ActiveRecord::Base
# Named scope
# Named scope
######################################################################
######################################################################
# 最新のPostを取得
scope
:unread
,
->
{
scope
:unread
,
->
{
where
(
is_read:
false
)
where
(
is_read:
false
)
}
}
scope
:recent
,
->
{
where
(
arel_table
[
:created_at
].
gt
7
.
day
.
ago
)
}
######################################################################
######################################################################
# Instance method
# Instance method
######################################################################
######################################################################
...
...
app/models/user.rb
View file @
95945274
...
@@ -115,8 +115,10 @@ class User < ActiveRecord::Base
...
@@ -115,8 +115,10 @@ class User < ActiveRecord::Base
# push通知を追加
# push通知を追加
def
push_notification
(
detail_path
,
body
)
def
push_notification
(
detail_path
,
body
)
unless
notifications
.
where
(
detail_path:
detail_path
).
unread
.
exists?
notifications
.
create
(
detail_path:
detail_path
,
body:
body
,
is_read:
false
)
notifications
.
create
(
detail_path:
detail_path
,
body:
body
,
is_read:
false
)
end
end
end
# record footprint
# record footprint
def
visit_post!
(
post
)
def
visit_post!
(
post
)
...
...
app/views/partials/_app_header.html.slim
View file @
95945274
...
@@ -30,7 +30,7 @@ nav.navbar.navbar-fixed-top.navbar-original role="navigation"
...
@@ -30,7 +30,7 @@ nav.navbar.navbar-fixed-top.navbar-original role="navigation"
a
#notifications
data-container
=
"body"
data-toggle
=
"popover"
data-placement
=
"bottom"
a
#notifications
data-container
=
"body"
data-toggle
=
"popover"
data-placement
=
"bottom"
span
.glyphicon.glyphicon-flag
span
.glyphicon.glyphicon-flag
-
if
current_user
.
notifications
.
unread
.
any?
-
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
li
.new-post-btn
form
form
a
.btn.navbar-btn
href
=
new_post_path
a
.btn.navbar-btn
href
=
new_post_path
...
@@ -56,10 +56,10 @@ nav.navbar.navbar-fixed-top.navbar-original role="navigation"
...
@@ -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
a
href
=
destroy_user_session_path
data-method
=
"delete"
rel
=
"nofollow"
SignOut
script
#notification-content
type
=
"text/template"
script
#notification-content
type
=
"text/template"
-
if
current_user
.
notifications
.
unread
.
any?
-
if
current_user
.
notifications
.
unread
.
recent
.
any?
h4
通知一覧
h4
通知一覧
.list-group
.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
)
a
.list-group-item
href
=
notification_bridge_path
(
notification
.
id
)
spen
.small
spen
.small
|
[
#{
notification
.
created_at
.
strftime
(
'%m/%d %H:%M'
)
}
]
|
[
#{
notification
.
created_at
.
strftime
(
'%m/%d %H:%M'
)
}
]
...
...
spec/models/notification_spec.rb
View file @
95945274
...
@@ -32,6 +32,16 @@ describe Notification do
...
@@ -32,6 +32,16 @@ describe Notification do
expect
(
@bob
.
notifications
.
size
).
to
eq
(
1
)
expect
(
@bob
.
notifications
.
size
).
to
eq
(
1
)
end
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
it
"not notifies on post edited by him"
do
@bob
.
watch!
(
post:
@post
)
@bob
.
watch!
(
post:
@post
)
@post
.
reload
@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