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
0aeed735
Commit
0aeed735
authored
May 08, 2014
by
tady
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #89 from tadyjp/140508/fix_fork_date
[REVIEW] fork時に日付を今日にする
parents
2bdae23a
6abd709c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
2 deletions
+9
-2
app/models/post.rb
+3
-2
spec/factories/posts.rb
+1
-0
spec/models/post_spec.rb
+5
-0
No files found.
app/models/post.rb
View file @
0aeed735
...
...
@@ -13,6 +13,8 @@
#
# specified_dateは特定の日付を指定したい場合に使用
require
'date'
class
Post
<
ActiveRecord
::
Base
has_many
:post_tags
has_many
:tags
,
through: :post_tags
...
...
@@ -74,14 +76,13 @@ class Post < ActiveRecord::Base
# `%Name`をユーザー名に置換
_forked_post
.
title
=
_forked_post
.
title
.
gsub
(
/%Name/
,
user
.
name
)
# `%Y`などを日付に変換
_forked_post
.
title
=
Time
.
now
.
strftime
(
_forked_post
.
title
)
# TODO
_forked_post
.
title
=
_forked_post
.
title
+
' のコピー'
_forked_post
.
tag_ids
=
self
.
tag_ids
_forked_post
.
author
=
user
_forked_post
.
specified_date
=
Date
.
today
_forked_post
end
...
...
spec/factories/posts.rb
View file @
0aeed735
...
...
@@ -19,6 +19,7 @@ FactoryGirl.define do
factory
:post
do
title
'sample title'
body
'sample body'
specified_date
Date
.
new
(
2014
,
4
,
1
)
after
(
:create
)
do
|
post
|
create
(
:post_tag
,
post:
post
,
tag:
create
(
:tag_ruby
))
...
...
spec/models/post_spec.rb
View file @
0aeed735
...
...
@@ -13,6 +13,7 @@
#
require
'spec_helper'
require
'date'
describe
Post
do
...
...
@@ -50,6 +51,10 @@ describe Post do
expect
(
@new_post
.
tags
).
to
include
(
@post
.
tags
.
first
)
end
it
'valid specified_date'
do
expect
(
@new_post
.
specified_date
).
to
eq
(
Date
.
today
)
end
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