Commit 0aeed735 by tady

Merge pull request #89 from tadyjp/140508/fix_fork_date

[REVIEW] fork時に日付を今日にする
parents 2bdae23a 6abd709c
......@@ -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
......
......@@ -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))
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment