aboutsummaryrefslogtreecommitdiffstats
path: root/spec/requests/refinery/admin/blog/posts_spec.rb
diff options
context:
space:
mode:
authorJamie Winsor <jamie@enmasse.com>2011-09-02 16:01:58 -0700
committerJamie Winsor <jamie@enmasse.com>2011-09-03 21:55:30 -0700
commit6212e60f9e4d144f9a136f6c82b33abd47ddb237 (patch)
tree3ba02acc7861ef51045f0196dff6bac9efda40d5 /spec/requests/refinery/admin/blog/posts_spec.rb
parent80ca7c1bf99befac70803309e542a4db54f1f198 (diff)
downloadrefinerycms-blog-6212e60f9e4d144f9a136f6c82b33abd47ddb237.tar.gz
refinerycms-blog-6212e60f9e4d144f9a136f6c82b33abd47ddb237.tar.bz2
refinerycms-blog-6212e60f9e4d144f9a136f6c82b33abd47ddb237.zip
index action of blog post controller now caches and sweeps on changes
fix various views which were broken and untested with rails-3-1 upgrade add request spec tests for admin blog comments Factory is now FactoryGirl Fix multiple issues around listing unmoderated comments use cleaner definitions to set per_page willpaginate attribute on models update all paginate calls to use new arel representation reorganize filter sections to be located at top of controller modify uncategorized class method to activerecord scope and perform a left outer join instead of iterate through an array to find uncategorized posts move request specs into their proper places update guardfile to ensure that request specs get run when their respective controllers are modified Fix show action for AdminBlogComments and added test Fix redirection link after approving or rejecting a comment
Diffstat (limited to 'spec/requests/refinery/admin/blog/posts_spec.rb')
-rw-r--r--spec/requests/refinery/admin/blog/posts_spec.rb143
1 files changed, 143 insertions, 0 deletions
diff --git a/spec/requests/refinery/admin/blog/posts_spec.rb b/spec/requests/refinery/admin/blog/posts_spec.rb
new file mode 100644
index 0000000..73bdf93
--- /dev/null
+++ b/spec/requests/refinery/admin/blog/posts_spec.rb
@@ -0,0 +1,143 @@
+require "spec_helper"
+
+module Refinery
+ describe "AdminBlogPosts" do
+ login_refinery_user
+
+ let!(:blog_category) { FactoryGirl.create(:blog_category, :title => "Video Games") }
+
+ context "when no blog posts" do
+ before(:each) { Refinery::BlogPost.destroy_all }
+
+ describe "blog post listing" do
+ before(:each) { visit refinery_admin_blog_posts_path }
+
+ it "invites to create new post" do
+ page.should have_content("There are no Blog Posts yet. Click \"Create new post\" to add your first blog post.")
+ end
+ end
+
+ describe "new blog post form" do
+ before(:each) do
+ visit refinery_admin_blog_posts_path
+ click_link "Create new post"
+ end
+
+ it "should have Tags" do
+ page.should have_content("Tags")
+ end
+
+ it "should have Video Games" do
+ page.should have_content(blog_category.title)
+ end
+
+ describe "create blog post" do
+ before(:each) do
+ fill_in "Title", :with => "This is my blog post"
+ fill_in "blog_post_body", :with => "And I love it"
+ check blog_category.title
+ click_button "Save"
+ end
+
+ it "should succeed" do
+ page.should have_content("was successfully added.")
+ end
+
+ it "should be the only blog post" do
+ ::Refinery::BlogPost.all.size.should eq(1)
+ end
+
+ it "should belong to me" do
+ ::Refinery::BlogPost.first.author.login.should eq(::Refinery::User.last.login)
+ end
+
+ it "should save categories" do
+ ::Refinery::BlogPost.last.categories.count.should eq(1)
+ ::Refinery::BlogPost.last.categories.first.title.should eq(blog_category.title)
+ end
+ end
+
+ describe "create blog post with tags" do
+ before(:each) do
+ @tag_list = "chicago, bikes, beers, babes"
+ fill_in "Title", :with => "This is a tagged blog post"
+ fill_in "blog_post_body", :with => "And I also love it"
+ fill_in "Tags", :with => @tag_list
+ click_button "Save"
+ end
+
+ it "should succeed" do
+ page.should have_content("was successfully added.")
+ end
+
+ it "should be the only blog post" do
+ ::Refinery::BlogPost.all.size.should eq(1)
+ end
+
+ it "should have the specified tags" do
+ ::Refinery::BlogPost.last.tag_list.should eq(@tag_list.split(', '))
+ end
+ end
+ end
+ end
+
+ context "when has blog posts" do
+ let!(:blog_post) { FactoryGirl.create(:blog_post) }
+
+ describe "blog post listing" do
+ before(:each) { visit refinery_admin_blog_posts_path }
+
+ describe "edit blog post" do
+ it "should succeed" do
+ page.should have_content(blog_post.title)
+
+ click_link("Edit this blog post")
+ current_path.should == edit_refinery_admin_blog_post_path(blog_post)
+
+ fill_in "Title", :with => "hax0r"
+ click_button "Save"
+
+ page.should_not have_content(blog_post.title)
+ page.should have_content("'hax0r' was successfully updated.")
+ end
+ end
+
+ describe "deleting blog post" do
+ it "should succeed" do
+ page.should have_content(blog_post.title)
+
+ click_link "Remove this blog post forever"
+
+ page.should have_content("'#{blog_post.title}' was successfully removed.")
+ end
+ end
+
+ describe "view live" do
+ it "redirects to blog post in the frontend" do
+ click_link "View this blog post live"
+
+ current_path.should == blog_post_path(blog_post)
+ page.should have_content(blog_post.title)
+ end
+ end
+ end
+
+ context "when uncategorized post" do
+ it "shows up in the list" do
+ visit uncategorized_refinery_admin_blog_posts_path
+ page.should have_content(blog_post.title)
+ end
+ end
+
+ context "when categorized post" do
+ it "won't show up in the list" do
+ blog_post.categories << blog_category
+ blog_post.save!
+
+ visit uncategorized_refinery_admin_blog_posts_path
+ page.should_not have_content(blog_post.title)
+ end
+ end
+ end
+ end
+end