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
174b1847
Commit
174b1847
authored
Jul 21, 2014
by
tady
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
通知view修正
parent
e15ce817
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
16 deletions
+47
-16
app/assets/javascripts/application.js
+2
-0
app/assets/stylesheets/application.css
+4
-0
app/decorators/user_decorator.rb
+0
-1
app/models/comment.rb
+2
-0
app/models/post.rb
+2
-0
app/views/partials/_app_header.html.slim
+23
-15
spec/models/notification_spec.rb
+14
-0
No files found.
app/assets/javascripts/application.js
View file @
174b1847
...
@@ -21,3 +21,5 @@
...
@@ -21,3 +21,5 @@
_
.
mixin
(
_
.
string
.
exports
());
_
.
mixin
(
_
.
string
.
exports
());
// $('[data-toggle="tooltip"]').tooltip();
// $('[data-toggle="popover"]').popover();
app/assets/stylesheets/application.css
View file @
174b1847
...
@@ -26,3 +26,7 @@ a .text-link {
...
@@ -26,3 +26,7 @@ a .text-link {
a
:visited
.text-link
{
a
:visited
.text-link
{
color
:
#609
;
color
:
#609
;
}
}
.popover
{
max-width
:
400px
;
}
app/decorators/user_decorator.rb
View file @
174b1847
...
@@ -4,5 +4,4 @@ class UserDecorator < Draper::Decorator
...
@@ -4,5 +4,4 @@ class UserDecorator < Draper::Decorator
def
draft_count
def
draft_count
model
.
posts
.
where
(
is_draft:
true
).
count
model
.
posts
.
where
(
is_draft:
true
).
count
end
end
end
end
app/models/comment.rb
View file @
174b1847
...
@@ -37,6 +37,8 @@ class Comment < ActiveRecord::Base
...
@@ -37,6 +37,8 @@ class Comment < ActiveRecord::Base
def
notify_watchers!
def
notify_watchers!
post
.
watchers
.
each
do
|
watcher
|
post
.
watchers
.
each
do
|
watcher
|
next
if
watcher
==
author
watcher
.
push_notification
(
post
.
decorate
.
show_path
,
"
#{
author
.
name
}
さんが「
#{
post
.
title
}
」にコメントしました。"
)
watcher
.
push_notification
(
post
.
decorate
.
show_path
,
"
#{
author
.
name
}
さんが「
#{
post
.
title
}
」にコメントしました。"
)
end
end
end
end
...
...
app/models/post.rb
View file @
174b1847
...
@@ -122,6 +122,8 @@ class Post < ActiveRecord::Base
...
@@ -122,6 +122,8 @@ class Post < ActiveRecord::Base
def
notify_watchers!
def
notify_watchers!
watchers
.
each
do
|
watcher
|
watchers
.
each
do
|
watcher
|
next
if
watcher
==
author
watcher
.
push_notification
(
decorate
.
show_path
,
"
#{
author
.
name
}
さんが「
#{
title
}
」を編集しました"
)
watcher
.
push_notification
(
decorate
.
show_path
,
"
#{
author
.
name
}
さんが「
#{
title
}
」を編集しました"
)
end
end
end
end
...
...
app/views/partials/_app_header.html.slim
View file @
174b1847
...
@@ -24,6 +24,11 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
...
@@ -24,6 +24,11 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
ul
.nav.navbar-nav.navbar-right
ul
.nav.navbar-nav.navbar-right
li
li
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
li
form
form
a
.btn.btn-primary.navbar-btn
href
=
new_post_path
a
.btn.btn-primary.navbar-btn
href
=
new_post_path
|
New Post
|
New Post
...
@@ -46,21 +51,24 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
...
@@ -46,21 +51,24 @@ nav.navbar.navbar-default.navbar-fixed-top role="navigation"
li
.divider
li
.divider
li
li
a
href
=
destroy_user_session_path
data-method
=
"delete"
rel
=
"nofollow"
SignOut
a
href
=
destroy_user_session_path
data-method
=
"delete"
rel
=
"nofollow"
SignOut
li
.dropdown
a
.dropdown-toggle
data-toggle
=
"dropdown"
|
通知
-
if
current_user
.
notifications
.
unread
.
any?
span
.badge
=
current_user
.
notifications
.
unread
.
count
b
.caret
ul
.dropdown-menu
-
if
current_user
.
notifications
.
unread
.
any?
-
current_user
.
notifications
.
unread
.
each
do
|
notification
|
li
a
href
=
notification_bridge_path
(
notification
.
id
)
=
notification
.
body
-
else
li
a
通知はありません
script
#notification-content
type
=
"text/template"
-
if
current_user
.
notifications
.
unread
.
any?
h4
通知一覧
.list-group
-
current_user
.
notifications
.
unread
.
each
do
|
notification
|
a
.list-group-item
href
=
notification_bridge_path
(
notification
.
id
)
spen
.small
|
[
#{
notification
.
created_at
.
strftime
(
'%m/%d %H:%M'
)
}
]
=
notification
.
body
-
else
h4
通知はありません
-
content_for
:footer_js
do
javascript:
$
(
'#notifications'
).
popover
({
html
:
true
,
content
:
$
(
'#notification-content'
).
html
()
});
spec/models/notification_spec.rb
View file @
174b1847
...
@@ -32,6 +32,13 @@ describe Notification do
...
@@ -32,6 +32,13 @@ describe Notification do
expect
(
@bob
.
notifications
.
size
).
to
eq
(
1
)
expect
(
@bob
.
notifications
.
size
).
to
eq
(
1
)
end
end
it
"not notifies on post edited by him"
do
@bob
.
watch!
(
post:
@post
)
@post
.
reload
@post
.
update!
(
title:
@post
.
title
+
' [New!]'
,
author:
@bob
)
expect
(
@bob
.
notifications
.
size
).
to
eq
(
0
)
end
it
"notifies on post commented"
do
it
"notifies on post commented"
do
@bob
.
watch!
(
post:
@post
)
@bob
.
watch!
(
post:
@post
)
expect
(
@bob
.
watching?
(
post:
@post
)).
to
be_truthy
expect
(
@bob
.
watching?
(
post:
@post
)).
to
be_truthy
...
@@ -41,6 +48,13 @@ describe Notification do
...
@@ -41,6 +48,13 @@ describe Notification do
expect
(
@bob
.
notifications
.
size
).
to
eq
(
1
)
expect
(
@bob
.
notifications
.
size
).
to
eq
(
1
)
end
end
it
"not notifies on post commented by him"
do
@bob
.
watch!
(
post:
@post
)
@post
.
reload
@post
.
comments
.
create!
(
author:
@bob
,
body:
'new comment'
)
expect
(
@bob
.
notifications
.
size
).
to
eq
(
0
)
end
it
"set watch on user create a new post"
do
it
"set watch on user create a new post"
do
new_post
=
Post
.
create!
(
author:
@bob
,
title:
'title'
,
body:
'body'
)
new_post
=
Post
.
create!
(
author:
@bob
,
title:
'title'
,
body:
'body'
)
expect
(
@bob
.
watching?
(
post:
new_post
)).
to
be_truthy
expect
(
@bob
.
watching?
(
post:
new_post
)).
to
be_truthy
...
...
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