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
3a981ef7
Commit
3a981ef7
authored
Nov 02, 2014
by
tady
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
conform to rubocop
parent
cc5dc7dc
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
102 additions
and
95 deletions
+102
-95
.rubocop.yml
+8
-0
.travis.yml
+1
-1
app/controllers/apis_controller.rb
+1
-1
app/controllers/application_controller.rb
+5
-5
app/controllers/posts_controller.rb
+8
-8
app/controllers/tags_controller.rb
+1
-1
app/decorators/post_decorator.rb
+3
-3
app/decorators/posts_decorator.rb
+2
-2
app/decorators/tag_decorator.rb
+9
-9
app/decorators/tags_decorator.rb
+7
-7
app/helpers/application_helper.rb
+0
-5
app/models/markdown_renderer.rb
+2
-1
app/models/notification.rb
+4
-4
app/models/post.rb
+25
-25
app/models/tag.rb
+4
-4
app/models/user.rb
+12
-12
lib/tasks/migrations.rake
+3
-3
spec/models/markdown_renderer_spec.rb
+5
-2
spec/models/tag_spec.rb
+2
-2
No files found.
.rubocop.yml
View file @
3a981ef7
...
@@ -47,3 +47,11 @@ Style/RescueModifier:
...
@@ -47,3 +47,11 @@ Style/RescueModifier:
# and/orを許容
# and/orを許容
Style/AndOr
:
Style/AndOr
:
Enabled
:
false
Enabled
:
false
# ABCチェックを無効
Metrics/AbcSize
:
Enabled
:
false
# ???
Style/RaiseArgs
:
Enabled
:
false
.travis.yml
View file @
3a981ef7
...
@@ -22,4 +22,4 @@ before_script:
...
@@ -22,4 +22,4 @@ before_script:
-
mysql -e 'CREATE DATABASE rendezvous_test;'
-
mysql -e 'CREATE DATABASE rendezvous_test;'
after_script
:
after_script
:
-
ruby script/travis/bundle_cache.rb
-
ruby script/travis/bundle_cache.rb
script
:
bundle exec rake db:create db:test:load spec teaspoon
script
:
bundle exec rake db:create db:test:load spec teaspoon
; bundle exec rubocop
app/controllers/apis_controller.rb
View file @
3a981ef7
...
@@ -48,7 +48,7 @@ class ApisController < ApplicationController
...
@@ -48,7 +48,7 @@ class ApisController < ApplicationController
end
end
def
user_mention
def
user_mention
name_list
=
User
.
search
(
params
[
:q
]).
map
{
|
_user
|
"
#{
_user
.
nickname
}
[
#{
_
user
.
name
}
]"
}
name_list
=
User
.
search
(
params
[
:q
]).
map
{
|
user
|
"
#{
user
.
nickname
}
[
#{
user
.
name
}
]"
}
render
json:
name_list
render
json:
name_list
end
end
...
...
app/controllers/application_controller.rb
View file @
3a981ef7
...
@@ -8,11 +8,11 @@ class ApplicationController < ActionController::Base
...
@@ -8,11 +8,11 @@ class ApplicationController < ActionController::Base
before_action
:redirect_unless_signed_in
before_action
:redirect_unless_signed_in
def
redirect_unless_signed_in
def
redirect_unless_signed_in
unless
user_signed_in?
return
if
user_signed_in?
flash
[
:alert
]
=
'You need Login!'
session
[
:login_redirect_to
]
=
request
.
url
flash
[
:alert
]
=
'You need Login!'
redirect_to
root_path
session
[
:login_redirect_to
]
=
request
.
url
end
redirect_to
root_path
end
end
def
after_sign_in_path_for
(
resource
)
def
after_sign_in_path_for
(
resource
)
...
...
app/controllers/posts_controller.rb
View file @
3a981ef7
...
@@ -10,8 +10,8 @@ class PostsController < ApplicationController
...
@@ -10,8 +10,8 @@ class PostsController < ApplicationController
def
show
def
show
current_user
.
visit_post!
(
@post
)
current_user
.
visit_post!
(
@post
)
@post
.
tags
.
each
do
|
_
tag
|
@post
.
tags
.
each
do
|
tag
|
add_breadcrumb
(
"#
#{
_tag
.
name
}
"
,
_
tag
.
decorate
.
show_path
)
add_breadcrumb
(
"#
#{
tag
.
name
}
"
,
tag
.
decorate
.
show_path
)
end
end
add_breadcrumb
(
@post
.
title
)
add_breadcrumb
(
@post
.
title
)
end
end
...
@@ -131,17 +131,17 @@ class PostsController < ApplicationController
...
@@ -131,17 +131,17 @@ class PostsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
# Never trust parameters from the scary internet, only allow the white list through.
def
post_params
def
post_params
@post_params
||=
begin
@post_params
||=
begin
_
param_hash
=
params
.
require
(
:post
).
permit
(
:title
,
:body
,
:tags
,
:is_draft
,
:specified_date
).
to_hash
param_hash
=
params
.
require
(
:post
).
permit
(
:title
,
:body
,
:tags
,
:is_draft
,
:specified_date
).
to_hash
# tags_text == 'Javascript,Ruby'
# tags_text == 'Javascript,Ruby'
tags_text
=
_
param_hash
.
delete
(
'tags'
)
tags_text
=
param_hash
.
delete
(
'tags'
)
tags
=
tags_text
.
split
(
','
).
map
do
|
_
tag_name
|
tags
=
tags_text
.
split
(
','
).
map
do
|
tag_name
|
Tag
.
find_or_create_by
(
name:
_
tag_name
)
Tag
.
find_or_create_by
(
name:
tag_name
)
end
end
_
param_hash
[
'tag_ids'
]
=
tags
.
map
(
&
:id
)
param_hash
[
'tag_ids'
]
=
tags
.
map
(
&
:id
)
_
param_hash
param_hash
end
end
end
end
...
...
app/controllers/tags_controller.rb
View file @
3a981ef7
...
@@ -66,7 +66,7 @@ class TagsController < ApplicationController
...
@@ -66,7 +66,7 @@ class TagsController < ApplicationController
def
move_to
def
move_to
@move_to_tag
=
Tag
.
find_by
(
name:
params
[
:move_to_name
])
or
fail
ActiveRecord
::
RecordNotFound
@move_to_tag
=
Tag
.
find_by
(
name:
params
[
:move_to_name
])
or
fail
ActiveRecord
::
RecordNotFound
@tag
.
set_parent!
(
@move_to_tag
)
@tag
.
parent_tag
=
@move_to_tag
flash
[
:notice
]
=
"「
#{
@tag
.
name
}
」は「
#{
@move_to_tag
.
name
}
」の下に移動しました"
flash
[
:notice
]
=
"「
#{
@tag
.
name
}
」は「
#{
@move_to_tag
.
name
}
」の下に移動しました"
...
...
app/decorators/post_decorator.rb
View file @
3a981ef7
...
@@ -12,12 +12,12 @@ class PostDecorator < Draper::Decorator
...
@@ -12,12 +12,12 @@ class PostDecorator < Draper::Decorator
# 読了時間
# 読了時間
# 500文字/1分換算
# 500文字/1分換算
def
read_time
def
read_time
_
time_min
=
model
.
body
.
length
/
500
time_min
=
model
.
body
.
length
/
500
case
_
time_min
case
time_min
when
0
when
0
'< 1 min.'
'< 1 min.'
when
1
..
10
when
1
..
10
"
#{
_
time_min
}
min."
"
#{
time_min
}
min."
else
else
'> 10 min.'
'> 10 min.'
end
end
...
...
app/decorators/posts_decorator.rb
View file @
3a981ef7
class
PostsDecorator
<
Draper
::
CollectionDecorator
class
PostsDecorator
<
Draper
::
CollectionDecorator
def
related_tags
def
related_tags
_
tags
=
map
(
&
:tags
).
flatten
.
uniq
tags
=
map
(
&
:tags
).
flatten
.
uniq
TagDecorator
.
decorate_collection
(
_
tags
)
TagDecorator
.
decorate_collection
(
tags
)
end
end
def
related_authors
def
related_authors
...
...
app/decorators/tag_decorator.rb
View file @
3a981ef7
...
@@ -28,22 +28,22 @@ class TagDecorator < Draper::Decorator
...
@@ -28,22 +28,22 @@ class TagDecorator < Draper::Decorator
# tagをtree viewで表示する
# tagをtree viewで表示する
def
tree_view_node
def
tree_view_node
_
html
=
''
html
=
''
_
html
+=
%(
html
+=
%(
<a href="#{ show_path }" data-name="#{model.name}">
<a href="#{ show_path }" data-name="#{model.name}">
#{model.name} <span class="badge">#{model.posts.size}</span>
#{model.name} <span class="badge">#{model.posts.size}</span>
</a>
</a>
)
)
_
html
+=
'<ul>'
html
+=
'<ul>'
model
.
children
.
each
do
|
_
child
|
model
.
children
.
each
do
|
child
|
_
html
+=
'<li>'
html
+=
'<li>'
_html
<<
_
child
.
decorate
.
tree_view_node
html
<<
child
.
decorate
.
tree_view_node
_
html
+=
'</li>'
html
+=
'</li>'
end
end
_
html
+=
'</ul>'
html
+=
'</ul>'
_
html
.
html_safe
html
.
html_safe
end
end
end
end
app/decorators/tags_decorator.rb
View file @
3a981ef7
class
TagsDecorator
<
Draper
::
CollectionDecorator
class
TagsDecorator
<
Draper
::
CollectionDecorator
# tagをtree viewで表示する
# tagをtree viewで表示する
def
tree_view
def
tree_view
_
html
=
''
html
=
''
_
html
+=
%(
html
+=
%(
<ul class="mod-tag-tree">
<ul class="mod-tag-tree">
<input type="search" class="mod-tag-tree-filter form-control" placeholder="filter...">
<input type="search" class="mod-tag-tree-filter form-control" placeholder="filter...">
)
)
each
do
|
_
node
|
each
do
|
node
|
_
html
+=
%(
html
+=
%(
<li>
<li>
#{
_
node.decorate.tree_view_node}
#{node.decorate.tree_view_node}
</li>
</li>
)
)
end
end
_
html
+=
'</ul>'
html
+=
'</ul>'
_
html
.
html_safe
html
.
html_safe
end
end
end
end
app/helpers/application_helper.rb
View file @
3a981ef7
module
ApplicationHelper
module
ApplicationHelper
def
h_application_format_markdown
(
text
)
fail
'deplicated error'
text
=
GitHub
::
Markdown
.
render_gfm
(
text
)
text
.
html_safe
end
end
end
app/models/markdown_renderer.rb
View file @
3a981ef7
...
@@ -11,7 +11,8 @@ class MarkdownRenderer
...
@@ -11,7 +11,8 @@ class MarkdownRenderer
text
=
@text
.
gsub
(
/!slide!\(([^\)]+)\)/
)
do
|
_
|
text
=
@text
.
gsub
(
/!slide!\(([^\)]+)\)/
)
do
|
_
|
slide_urls
<<
%(
slide_urls
<<
%(
<div class="embed-responsive embed-responsive-4by3">
<div class="embed-responsive embed-responsive-4by3">
<iframe style="text-align:center;" src="/ViewerJS/##{Regexp.last_match[1]}" width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe>
<iframe style="text-align:center;" src="/ViewerJS/##{Regexp.last_match[1]}"
width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe>
</div>
</div>
)
)
"%%slide:
#{
slide_urls
.
size
-
1
}
%%"
"%%slide:
#{
slide_urls
.
size
-
1
}
%%"
...
...
app/models/notification.rb
View file @
3a981ef7
...
@@ -19,13 +19,13 @@ class Notification < ActiveRecord::Base
...
@@ -19,13 +19,13 @@ class Notification < ActiveRecord::Base
# Named scope
# Named scope
######################################################################
######################################################################
scope
:unread
,
->
{
scope
:unread
,
(
lambda
do
where
(
is_read:
false
)
where
(
is_read:
false
)
}
end
)
scope
:recent
,
->
{
scope
:recent
,
(
lambda
do
where
(
arel_table
[
:created_at
].
gt
7
.
day
.
ago
)
where
(
arel_table
[
:created_at
].
gt
7
.
day
.
ago
)
}
end
)
######################################################################
######################################################################
# Instance method
# Instance method
...
...
app/models/post.rb
View file @
3a981ef7
...
@@ -47,40 +47,40 @@ class Post < ActiveRecord::Base
...
@@ -47,40 +47,40 @@ class Post < ActiveRecord::Base
# Named scope
# Named scope
######################################################################
######################################################################
scope
:search
,
(
lambda
do
|
query
|
scope
:search
,
(
lambda
do
|
query
|
_
where_list
=
includes
(
:author
,
:tags
).
order
(
updated_at: :desc
)
where_list
=
includes
(
:author
,
:tags
).
order
(
updated_at: :desc
)
# Convert spaces to one space.
# Convert spaces to one space.
query_list
=
query
.
split
(
/[\s ]+/
)
query_list
=
query
.
split
(
/[\s ]+/
)
query_list
.
each
do
|
_query
|
query_list
.
each
do
|
where
_query
|
case
_query
case
where
_query
when
/\Aid:(.+)/
when
/\Aid:(.+)/
_where_list
=
_
where_list
.
where
(
id:
Regexp
.
last_match
[
1
])
where_list
=
where_list
.
where
(
id:
Regexp
.
last_match
[
1
])
when
/\Atitle:(.+)/
when
/\Atitle:(.+)/
_where_list
=
_
where_list
.
where
(
'posts.title LIKE ?'
,
"%
#{
Regexp
.
last_match
[
1
]
}
%"
)
where_list
=
where_list
.
where
(
'posts.title LIKE ?'
,
"%
#{
Regexp
.
last_match
[
1
]
}
%"
)
when
/\Abody:(.+)/
when
/\Abody:(.+)/
_where_list
=
_
where_list
.
where
(
'posts.body LIKE ?'
,
"%
#{
Regexp
.
last_match
[
1
]
}
%"
)
where_list
=
where_list
.
where
(
'posts.body LIKE ?'
,
"%
#{
Regexp
.
last_match
[
1
]
}
%"
)
when
/\A@(.+)/
when
/\A@(.+)/
_where_list
=
_
where_list
.
where
(
users:
{
nickname:
Regexp
.
last_match
[
1
]
})
where_list
=
where_list
.
where
(
users:
{
nickname:
Regexp
.
last_match
[
1
]
})
when
/\A#(.+)/
when
/\A#(.+)/
_where_list
=
_
where_list
.
where
(
tags:
{
name:
Regexp
.
last_match
[
1
]
})
where_list
=
where_list
.
where
(
tags:
{
name:
Regexp
.
last_match
[
1
]
})
when
/\Adate:(\d+)-(\d+)-(\d+)/
when
/\Adate:(\d+)-(\d+)-(\d+)/
_
date
=
Time
.
new
(
Regexp
.
last_match
[
1
],
Regexp
.
last_match
[
2
],
Regexp
.
last_match
[
3
])
date
=
Time
.
new
(
Regexp
.
last_match
[
1
],
Regexp
.
last_match
[
2
],
Regexp
.
last_match
[
3
])
_where_list
=
_where_list
.
where
(
'posts.updated_at > ? AND posts.updated_at < ?'
,
_date
,
_
date
+
1
.
day
)
where_list
=
where_list
.
where
(
'posts.updated_at > ? AND posts.updated_at < ?'
,
date
,
date
+
1
.
day
)
when
/\Adraft:1/
when
/\Adraft:1/
_where_list
=
_
where_list
.
where
(
is_draft:
true
)
where_list
=
where_list
.
where
(
is_draft:
true
)
else
else
_where_list
=
_where_list
.
where
(
'posts.title LIKE ? OR posts.body LIKE ?'
,
"%
#{
_query
}
%"
,
"%
#{
_query
}
%"
)
where_list
=
where_list
.
where
(
'posts.title LIKE ? OR posts.body LIKE ?'
,
"%
#{
where_query
}
%"
,
"%
#{
where
_query
}
%"
)
end
end
end
end
_
where_list
where_list
end
)
end
)
# 最新のPostを取得
# 最新のPostを取得
scope
:recent
,
->
(
limit
=
10
)
{
scope
:recent
,
(
lambda
do
|
limit
=
10
|
order
(
updated_at: :desc
).
limit
(
limit
)
order
(
updated_at: :desc
).
limit
(
limit
)
}
end
)
######################################################################
######################################################################
# Instance method
# Instance method
...
@@ -89,19 +89,19 @@ class Post < ActiveRecord::Base
...
@@ -89,19 +89,19 @@ class Post < ActiveRecord::Base
# generate forked post (not saved)
# generate forked post (not saved)
def
generate_fork
(
user
)
def
generate_fork
(
user
)
# `id`以外をコピーする
# `id`以外をコピーする
_
forked_post
=
Post
.
new
(
attributes
.
except
(
'id'
))
forked_post
=
Post
.
new
(
attributes
.
except
(
'id'
))
# `%name`をユーザー名に置換
# `%name`をユーザー名に置換
_forked_post
.
title
=
_
forked_post
.
title
.
gsub
(
/%name/
,
user
.
name
)
forked_post
.
title
=
forked_post
.
title
.
gsub
(
/%name/
,
user
.
name
)
# `%Y`などを日付に変換
# `%Y`などを日付に変換
_forked_post
.
title
=
Time
.
now
.
strftime
(
_
forked_post
.
title
)
# TODO
forked_post
.
title
=
Time
.
now
.
strftime
(
forked_post
.
title
)
# TODO
_forked_post
.
title
=
_
forked_post
.
title
forked_post
.
title
=
forked_post
.
title
_
forked_post
.
tag_ids
=
tag_ids
forked_post
.
tag_ids
=
tag_ids
_
forked_post
.
author
=
user
forked_post
.
author
=
user
_
forked_post
.
specified_date
=
Date
.
today
forked_post
.
specified_date
=
Date
.
today
_
forked_post
forked_post
end
end
# slideshow用のbody
# slideshow用のbody
...
@@ -113,9 +113,9 @@ class Post < ActiveRecord::Base
...
@@ -113,9 +113,9 @@ class Post < ActiveRecord::Base
footprints
.
select
(
:user_id
).
uniq
.
count
footprints
.
select
(
:user_id
).
uniq
.
count
end
end
# FIXME:
# FIXME:
正常に動作しないため動作しないため一時的にメソッドを作成
# has_many :watchers, :through => :watches
# has_many :watchers, :through => :watches
#
正常に動作しないため動作しないため一時的にメソッドを作成
#
# def watchers
# def watchers
# watches.map { |watch| watch.watcher }
# watches.map { |watch| watch.watcher }
# end
# end
...
...
app/models/tag.rb
View file @
3a981ef7
...
@@ -43,14 +43,14 @@ class Tag < ActiveRecord::Base
...
@@ -43,14 +43,14 @@ class Tag < ActiveRecord::Base
# 自分のタグに紐づくPostをすべて`other_tag`へ移動する
# 自分のタグに紐づくPostをすべて`other_tag`へ移動する
def
move_all_posts_to!
(
other_tag
)
def
move_all_posts_to!
(
other_tag
)
posts
.
each
do
|
_post
|
posts
.
each
do
|
moving
_post
|
_post
.
tags
.
delete
(
self
)
moving
_post
.
tags
.
delete
(
self
)
_post
.
tags
<<
other_tag
unless
_post
.
tags
.
include?
(
other_tag
)
moving_post
.
tags
<<
other_tag
unless
moving
_post
.
tags
.
include?
(
other_tag
)
end
end
end
end
# 親タグを設定する
# 親タグを設定する
def
set_parent!
(
other_tag
)
def
parent_tag
=
(
other_tag
)
self
.
parent
=
other_tag
self
.
parent
=
other_tag
self
.
save!
self
.
save!
end
end
...
...
app/models/user.rb
View file @
3a981ef7
...
@@ -46,12 +46,12 @@ class User < ActiveRecord::Base
...
@@ -46,12 +46,12 @@ class User < ActiveRecord::Base
######################################################################
######################################################################
# scope
# scope
######################################################################
######################################################################
scope
:post_recently
,
->
{
scope
:post_recently
,
(
lambda
do
User
.
joins
(
:posts
).
group
(
'id'
).
order
(
'posts.updated_at desc'
)
User
.
joins
(
:posts
).
group
(
'id'
).
order
(
'posts.updated_at desc'
)
}
end
)
scope
:search
,
(
lambda
do
|
_
query
|
scope
:search
,
(
lambda
do
|
query
|
where
(
'name LIKE ? OR nickname LIKE ?'
,
"%
#{
_query
}
%"
,
"%
#{
_
query
}
%"
)
where
(
'name LIKE ? OR nickname LIKE ?'
,
"%
#{
query
}
%"
,
"%
#{
query
}
%"
)
end
)
end
)
######################################################################
######################################################################
...
@@ -66,11 +66,11 @@ class User < ActiveRecord::Base
...
@@ -66,11 +66,11 @@ class User < ActiveRecord::Base
# Device
# Device
def
self
.
find_for_google_oauth2
(
access_token
,
_signed_in_resource
=
nil
)
def
self
.
find_for_google_oauth2
(
access_token
,
_signed_in_resource
=
nil
)
user
=
where
(
email:
access_token
.
info
[
'email'
]).
first_or_create
do
|
_user
|
user
=
where
(
email:
access_token
.
info
[
'email'
]).
first_or_create
do
|
u
|
_user
.
name
=
access_token
.
info
[
'name'
]
u
.
name
=
access_token
.
info
[
'name'
]
_user
.
image_url
=
access_token
.
info
[
'image'
]
u
.
image_url
=
access_token
.
info
[
'image'
]
_user
.
password
=
Devise
.
friendly_token
[
0
,
20
]
u
.
password
=
Devise
.
friendly_token
[
0
,
20
]
_user
.
nickname
=
((
'a'
..
'z'
).
to_a
+
(
'A'
..
'Z'
).
to_a
+
(
0
..
9
).
to_a
).
shuffle
[
0
..
4
].
join
u
.
nickname
=
((
'a'
..
'z'
).
to_a
+
(
'A'
..
'Z'
).
to_a
+
(
0
..
9
).
to_a
).
shuffle
[
0
..
4
].
join
end
end
user
.
update
(
user
.
update
(
...
@@ -113,9 +113,9 @@ class User < ActiveRecord::Base
...
@@ -113,9 +113,9 @@ 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?
return
if
notifications
.
where
(
detail_path:
detail_path
).
unread
.
exists?
notifications
.
create
(
detail_path:
detail_path
,
body:
body
,
is_read:
false
)
end
notifications
.
create
(
detail_path:
detail_path
,
body:
body
,
is_read:
false
)
end
end
# record footprint
# record footprint
...
...
lib/tasks/migrations.rake
View file @
3a981ef7
...
@@ -3,11 +3,11 @@ namespace :migrations do
...
@@ -3,11 +3,11 @@ namespace :migrations do
desc
'001 nicknameを自動付与'
desc
'001 nicknameを自動付与'
task
task_001_user_nickname: :environment
do
task
task_001_user_nickname: :environment
do
User
.
all
.
each
do
|
_
user
|
User
.
all
.
each
do
|
user
|
next
if
_
user
.
nickname
.
present?
next
if
user
.
nickname
.
present?
new_nickname
=
((
'a'
..
'z'
).
to_a
+
(
'A'
..
'Z'
).
to_a
+
(
0
..
9
).
to_a
).
shuffle
[
0
..
4
].
join
new_nickname
=
((
'a'
..
'z'
).
to_a
+
(
'A'
..
'Z'
).
to_a
+
(
0
..
9
).
to_a
).
shuffle
[
0
..
4
].
join
_
user
.
update_attributes!
(
nickname:
new_nickname
)
user
.
update_attributes!
(
nickname:
new_nickname
)
end
end
end
end
...
...
spec/models/markdown_renderer_spec.rb
View file @
3a981ef7
...
@@ -8,6 +8,7 @@ RSpec.describe MarkdownRenderer, type: :model do
...
@@ -8,6 +8,7 @@ RSpec.describe MarkdownRenderer, type: :model do
- body
- body
- test
- test
EOS
EOS
expect
(
renderer
.
render
.
to_s
.
gsub
(
/^ +/
,
''
)).
to
eq
(
<<
EOS
)
expect
(
renderer
.
render
.
to_s
.
gsub
(
/^ +/
,
''
)).
to
eq
(
<<
EOS
)
<h1>title</h1>
<h1>title</h1>
...
@@ -26,12 +27,14 @@ EOS
...
@@ -26,12 +27,14 @@ EOS
expect
(
renderer
.
render
.
to_s
.
gsub
(
/^ +/
,
''
)).
to
eq
(
<<
EOS
)
expect
(
renderer
.
render
.
to_s
.
gsub
(
/^ +/
,
''
)).
to
eq
(
<<
EOS
)
<p>
<p>
<div class="embed-responsive embed-responsive-4by3">
<div class="embed-responsive embed-responsive-4by3">
<iframe style="text-align:center;" src="/ViewerJS/#http://test.com/slide-1.pdf" width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe>
<iframe style="text-align:center;" src="/ViewerJS/#http://test.com/slide-1.pdf"
width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe>
</div>
</div>
<br>
<br>
<div class="embed-responsive embed-responsive-4by3">
<div class="embed-responsive embed-responsive-4by3">
<iframe style="text-align:center;" src="/ViewerJS/#http://test.com/slide-2.pdf" width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe>
<iframe style="text-align:center;" src="/ViewerJS/#http://test.com/slide-2.pdf"
width="400" height="300" allowfullscreen="true" webkitallowfullscreen="true"></iframe>
</div>
</div>
</p>
</p>
EOS
EOS
...
...
spec/models/tag_spec.rb
View file @
3a981ef7
...
@@ -33,7 +33,7 @@ describe Tag do
...
@@ -33,7 +33,7 @@ describe Tag do
end
end
end
end
describe
'#
set_parent!
'
do
describe
'#
parent_tag=
'
do
before
:each
do
before
:each
do
@tag_ruby
=
Tag
.
create
(
name:
'ruby'
)
@tag_ruby
=
Tag
.
create
(
name:
'ruby'
)
@tag_lang
=
Tag
.
create
(
name:
'lang'
)
@tag_lang
=
Tag
.
create
(
name:
'lang'
)
...
@@ -42,7 +42,7 @@ describe Tag do
...
@@ -42,7 +42,7 @@ describe Tag do
it
'successfully moved'
do
it
'successfully moved'
do
expect
(
@tag_ruby
.
parent
).
not_to
eq
(
@tag_lang
)
expect
(
@tag_ruby
.
parent
).
not_to
eq
(
@tag_lang
)
expect
(
@tag_lang
.
children
).
not_to
include
(
@tag_ruby
)
expect
(
@tag_lang
.
children
).
not_to
include
(
@tag_ruby
)
@tag_ruby
.
set_parent!
(
@tag_lang
)
@tag_ruby
.
parent_tag
=
@tag_lang
expect
(
@tag_ruby
.
parent
).
to
eq
(
@tag_lang
)
expect
(
@tag_ruby
.
parent
).
to
eq
(
@tag_lang
)
expect
(
@tag_lang
.
children
).
to
include
(
@tag_ruby
)
expect
(
@tag_lang
.
children
).
to
include
(
@tag_ruby
)
end
end
...
...
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