diff options
author | Philip Arndt <parndt@gmail.com> | 2012-02-22 20:11:14 -0800 |
---|---|---|
committer | Philip Arndt <parndt@gmail.com> | 2012-02-22 20:11:14 -0800 |
commit | 5440fad815b060f10892516ec97286d8dc4c3f80 (patch) | |
tree | 0385daa4cc7a5d3ef76b172655bd51b898299999 /spec | |
parent | 39fc08698209251dc7b5a2441487bac2a16ab650 (diff) | |
parent | 602759af1b89438435c59bffb10e2cbe4c60f834 (diff) | |
download | refinerycms-blog-5440fad815b060f10892516ec97286d8dc4c3f80.tar.gz refinerycms-blog-5440fad815b060f10892516ec97286d8dc4c3f80.tar.bz2 refinerycms-blog-5440fad815b060f10892516ec97286d8dc4c3f80.zip |
Merge pull request #200 from dmoose/rails-3-1-recent-popular
Rails 3 1 recent popular
Diffstat (limited to 'spec')
-rw-r--r-- | spec/requests/refinery/blog/posts_spec.rb | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/spec/requests/refinery/blog/posts_spec.rb b/spec/requests/refinery/blog/posts_spec.rb index 815ca26..6f34cb9 100644 --- a/spec/requests/refinery/blog/posts_spec.rb +++ b/spec/requests/refinery/blog/posts_spec.rb @@ -101,8 +101,42 @@ module Refinery comment.body.should eq(body) end end + + context "post popular" do + let(:blog_post) { FactoryGirl.create(:blog_post) } + let(:blog_post2) { FactoryGirl.create(:blog_post) } + + before do + visit refinery.blog_post_path(blog_post) + end + + it "should increment access count" do + blog_post.reload.access_count.should eq(1) + visit refinery.blog_post_path(blog_post) + blog_post.reload.access_count.should eq(2) + end + + it "should be most popular" do + Refinery::Blog::Post.popular(2).first.should eq(blog_post) + end + end + + context "post recent" do + let(:blog_post) { FactoryGirl.create(:blog_post) } + let(:blog_post2) { FactoryGirl.create(:blog_post) } + + before do + visit refinery.blog_post_path(blog_post2) + visit refinery.blog_post_path(blog_post) + end + + it "should be the most recent" do + Refinery::Blog::Post.recent(2).first.should eq(blog_post2) + end + end + end - + describe "#show draft preview" do let(:blog_post) { FactoryGirl.create(:blog_post_draft) } context "when logged in as admin" do |