Commit 6abd709c by tady

fork時に日付を今日にする

fix #87
parent e4b41f69
GIT GIT
remote: git://github.com/amatsuda/kaminari.git remote: git://github.com/amatsuda/kaminari.git
revision: 754808dacaa84496faf8a79377d8076bdb3fd05c revision: 3cfffc11be813ddca9311d3b3e2f1e74bc5ca347
specs: specs:
kaminari (0.15.1) kaminari (0.15.1)
actionpack (>= 3.0.0) actionpack (>= 3.0.0)
...@@ -106,7 +106,7 @@ GEM ...@@ -106,7 +106,7 @@ GEM
css_parser (1.3.5) css_parser (1.3.5)
addressable addressable
daemons (1.1.9) daemons (1.1.9)
database_rewinder (0.0.3) database_rewinder (0.1.0)
debug_inspector (0.0.2) debug_inspector (0.0.2)
devise (3.2.4) devise (3.2.4)
bcrypt (~> 3.0) bcrypt (~> 3.0)
...@@ -143,7 +143,7 @@ GEM ...@@ -143,7 +143,7 @@ GEM
github-markdown (0.6.5) github-markdown (0.6.5)
gmail_xoauth (0.4.1) gmail_xoauth (0.4.1)
oauth (>= 0.3.6) oauth (>= 0.3.6)
guard (2.6.0) guard (2.6.1)
formatador (>= 0.2.4) formatador (>= 0.2.4)
listen (~> 2.7) listen (~> 2.7)
lumberjack (~> 1.0) lumberjack (~> 1.0)
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
# #
# specified_dateは特定の日付を指定したい場合に使用 # specified_dateは特定の日付を指定したい場合に使用
require 'date'
class Post < ActiveRecord::Base class Post < ActiveRecord::Base
has_many :post_tags has_many :post_tags
has_many :tags, through: :post_tags has_many :tags, through: :post_tags
...@@ -74,14 +76,13 @@ class Post < ActiveRecord::Base ...@@ -74,14 +76,13 @@ class Post < ActiveRecord::Base
# `%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 = self.tag_ids _forked_post.tag_ids = self.tag_ids
_forked_post.author = user _forked_post.author = user
_forked_post.specified_date = Date.today
_forked_post _forked_post
end end
......
...@@ -19,6 +19,7 @@ FactoryGirl.define do ...@@ -19,6 +19,7 @@ FactoryGirl.define do
factory :post do factory :post do
title 'sample title' title 'sample title'
body 'sample body' body 'sample body'
specified_date Date.new(2014, 4, 1)
after(:create) do |post| after(:create) do |post|
create(:post_tag, post: post, tag: create(:tag_ruby)) create(:post_tag, post: post, tag: create(:tag_ruby))
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
# #
require 'spec_helper' require 'spec_helper'
require 'date'
describe Post do describe Post do
...@@ -50,6 +51,10 @@ describe Post do ...@@ -50,6 +51,10 @@ describe Post do
expect(@new_post.tags).to include(@post.tags.first) expect(@new_post.tags).to include(@post.tags.first)
end end
it 'valid specified_date' do
expect(@new_post.specified_date).to eq(Date.today)
end
end 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