aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorJeff Shumate <jeff@catapulsion.net>2012-02-22 20:37:08 -0700
committerJeff Shumate <jeff@catapulsion.net>2012-02-22 20:37:08 -0700
commit4f0b5f8223426644924807fc38f86ec245f4827b (patch)
tree28f4f4f2e59ea65e6c68adf416fa8220e1404a01 /spec
parent45cad84f4986ec9a1d78a5ced1a842f7a9048b5d (diff)
downloadrefinerycms-blog-4f0b5f8223426644924807fc38f86ec245f4827b.tar.gz
refinerycms-blog-4f0b5f8223426644924807fc38f86ec245f4827b.tar.bz2
refinerycms-blog-4f0b5f8223426644924807fc38f86ec245f4827b.zip
add popularity counter to blog posts as well as accessor for recent posts
Diffstat (limited to 'spec')
-rw-r--r--spec/requests/refinery/blog/posts_spec.rb36
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