fix post sorting issue
This commit is contained in:
parent
4f3d33c322
commit
33953445b7
2
Gemfile
2
Gemfile
@ -1,7 +1,5 @@
|
|||||||
source 'https://rubygems.org'
|
source 'https://rubygems.org'
|
||||||
|
|
||||||
ruby '2.4.1'
|
|
||||||
|
|
||||||
gem 'rails'
|
gem 'rails'
|
||||||
gem 'sqlite3'
|
gem 'sqlite3'
|
||||||
gem 'puma', '~> 3.11'
|
gem 'puma', '~> 3.11'
|
||||||
|
@ -318,8 +318,5 @@ DEPENDENCIES
|
|||||||
uglifier
|
uglifier
|
||||||
web-console (>= 3.3.0)
|
web-console (>= 3.3.0)
|
||||||
|
|
||||||
RUBY VERSION
|
|
||||||
ruby 2.4.1p111
|
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
1.16.0
|
1.16.1
|
||||||
|
@ -21,10 +21,10 @@ class Post
|
|||||||
@words.join(" ")
|
@words.join(" ")
|
||||||
end
|
end
|
||||||
def template_name
|
def template_name
|
||||||
"#{date}-#{@words.join("-")}"
|
"#{year}-#{month.to_s.rjust(2, '0')}-#{day.to_s.rjust(2, '0')}-#{@words.join("-")}"
|
||||||
end
|
end
|
||||||
def date
|
def date
|
||||||
"#{year}-#{month}-#{day}"
|
Date.new(year,month,day)
|
||||||
end
|
end
|
||||||
def parse_int( value , max)
|
def parse_int( value , max)
|
||||||
ret = value.to_i
|
ret = value.to_i
|
||||||
|
@ -31,10 +31,10 @@ RSpec.describe Post, type: :model do
|
|||||||
expect(@post.month).to eq 2
|
expect(@post.month).to eq 2
|
||||||
end
|
end
|
||||||
it "returns date" do
|
it "returns date" do
|
||||||
expect(@post.date).to eq "1993-2-4"
|
expect(@post.date).to eq Date.new(1993,2,4)
|
||||||
end
|
end
|
||||||
it "returns file_name" do
|
it "returns file_name" do
|
||||||
expect(@post.template_name).to eq "1993-2-4-title"
|
expect(@post.template_name).to eq "1993-02-04-title"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user