diff options
-rw-r--r-- | app/controllers/refinery/blog/posts_controller.rb | 2 | ||||
-rw-r--r-- | app/models/refinery/blog/post.rb | 9 | ||||
-rw-r--r-- | spec/models/refinery/blog/post_spec.rb | 6 |
3 files changed, 11 insertions, 6 deletions
diff --git a/app/controllers/refinery/blog/posts_controller.rb b/app/controllers/refinery/blog/posts_controller.rb index b453d72..caa46ec 100644 --- a/app/controllers/refinery/blog/posts_controller.rb +++ b/app/controllers/refinery/blog/posts_controller.rb @@ -60,7 +60,7 @@ module Refinery date = "#{params[:month]}/#{params[:year]}" @archive_date = Time.parse(date) @date_title = @archive_date.strftime('%B %Y') - @posts = Post.live.by_archive(@archive_date).page(params[:page]) + @posts = Post.live.by_month(@archive_date).page(params[:page]) else date = "01/#{params[:year]}" @archive_date = Time.parse(date) diff --git a/app/models/refinery/blog/post.rb b/app/models/refinery/blog/post.rb index b078272..6a2d7c2 100644 --- a/app/models/refinery/blog/post.rb +++ b/app/models/refinery/blog/post.rb @@ -53,10 +53,15 @@ module Refinery end class << self - def by_archive(date) + def by_month(date) where(:published_at => date.beginning_of_month..date.end_of_month) end - + + def by_archive(date) + Refinery.deprecate("Refinery::Blog::Post.by_archive(date)", {:replacement => "Refinery::Blog::Post.by_month(date)", :when => 2.2 }) + by_month(date) + end + def by_year(date) where(:published_at => date.beginning_of_year..date.end_of_year) end diff --git a/spec/models/refinery/blog/post_spec.rb b/spec/models/refinery/blog/post_spec.rb index 2f34eb8..7b0c9be 100644 --- a/spec/models/refinery/blog/post_spec.rb +++ b/spec/models/refinery/blog/post_spec.rb @@ -53,7 +53,7 @@ module Refinery end end - describe "by_archive" do + describe "by_month" do before do @post1 = FactoryGirl.create(:blog_post, :published_at => Date.new(2011, 3, 11)) @post2 = FactoryGirl.create(:blog_post, :published_at => Date.new(2011, 3, 12)) @@ -65,8 +65,8 @@ module Refinery it "returns all posts from specified month" do #check for this month date = "03/2011" - described_class.by_archive(Time.parse(date)).count.should be == 2 - described_class.by_archive(Time.parse(date)).should == [@post2, @post1] + described_class.by_month(Time.parse(date)).count.should be == 2 + described_class.by_month(Time.parse(date)).should == [@post2, @post1] end end |