aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/dummy/config/environments/development.rb2
-rw-r--r--spec/requests/blog_categories_spec.rb23
-rw-r--r--spec/requests/blog_posts_spec.rb38
-rw-r--r--spec/requests/manage_blog_posts_spec.rb141
-rw-r--r--spec/requests/refinery/admin/blog/comments_spec.rb124
-rw-r--r--spec/requests/refinery/admin/blog/posts_spec.rb143
-rw-r--r--spec/requests/refinery/blog/categories_spec.rb25
-rw-r--r--spec/requests/refinery/blog/posts_spec.rb40
8 files changed, 333 insertions, 203 deletions
diff --git a/spec/dummy/config/environments/development.rb b/spec/dummy/config/environments/development.rb
index 8604338..c777820 100644
--- a/spec/dummy/config/environments/development.rb
+++ b/spec/dummy/config/environments/development.rb
@@ -11,7 +11,7 @@ Dummy::Application.configure do
# Show full error reports and disable caching
config.consider_all_requests_local = true
- config.action_controller.perform_caching = false
+ config.action_controller.perform_caching = true
# Don't care if the mailer can't send
config.action_mailer.raise_delivery_errors = false
diff --git a/spec/requests/blog_categories_spec.rb b/spec/requests/blog_categories_spec.rb
deleted file mode 100644
index a554891..0000000
--- a/spec/requests/blog_categories_spec.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-require "spec_helper"
-
-describe "blog categories" do
- login_refinery_user
-
- context "has one category and post" do
- before(:each) do
- @blog_post = FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post")
- @blog_category = FactoryGirl.create(:blog_category, :title => "Video Games")
- @blog_post.categories << @blog_category
- @blog_post.save!
- end
-
- describe "show categories blog posts" do
- before(:each) { visit blog_category_path(@blog_category) }
-
- it "should displays categories blog posts" do
- page.should have_content("Refinery CMS blog post")
- page.should have_content("Video Games")
- end
- end
- end
-end
diff --git a/spec/requests/blog_posts_spec.rb b/spec/requests/blog_posts_spec.rb
deleted file mode 100644
index ec84b90..0000000
--- a/spec/requests/blog_posts_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-require "spec_helper"
-
-describe "blog posts" do
- login_refinery_user
-
- context "when has blog posts" do
- let(:blog_post) { Factory(:blog_post, :title => "Refinery CMS blog post") }
-
- it "should display blog post" do
- visit blog_post_path(blog_post)
- page.should have_content("Refinery CMS blog post")
- end
-
- it "should display the blog rss feed" do
- get blog_rss_feed_path
- response.should be_success
- response.content_type.should eq("application/rss+xml")
- end
- end
-
- describe "list tagged posts" do
- context "when has tagged blog posts" do
- before(:each) do
- @tag_name = "chicago"
- @blog_post = FactoryGirl.create(:blog_post,
- :title => "I Love my city",
- :tag_list => @tag_name)
- tag = ::Refinery::BlogPost.tag_counts_on(:tags).first
- visit tagged_posts_path(tag.id, @tag_name.parameterize)
- end
-
- it "should have one tagged post" do
- page.should have_content(@tag_name)
- page.should have_content(@blog_post.title)
- end
- end
- end
-end
diff --git a/spec/requests/manage_blog_posts_spec.rb b/spec/requests/manage_blog_posts_spec.rb
deleted file mode 100644
index 2a299d0..0000000
--- a/spec/requests/manage_blog_posts_spec.rb
+++ /dev/null
@@ -1,141 +0,0 @@
-require "spec_helper"
-
-describe "manage blog posts" 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) { Factory(: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
diff --git a/spec/requests/refinery/admin/blog/comments_spec.rb b/spec/requests/refinery/admin/blog/comments_spec.rb
new file mode 100644
index 0000000..a0213f6
--- /dev/null
+++ b/spec/requests/refinery/admin/blog/comments_spec.rb
@@ -0,0 +1,124 @@
+require "spec_helper"
+
+module Refinery
+ describe "AdminBlogComments" do
+ login_refinery_user
+
+ describe "#index" do
+ context "when has no new unapproved comments" do
+ before(:each) do
+ BlogComment.delete_all
+ visit refinery_admin_blog_comments_path
+ end
+
+ it "should list no comments" do
+ visit refinery_admin_blog_comments_path
+
+ page.should have_content('there are no new comments')
+ end
+ end
+
+ context "when has new unapproved comments" do
+ let!(:blog_comment) { FactoryGirl.create(:blog_comment) }
+ before(:each) { visit refinery_admin_blog_comments_path }
+
+ it "should list comments" do
+ page.should have_content(blog_comment.body)
+ page.should have_content(blog_comment.name)
+ end
+
+ it "should allow me to approve a comment" do
+ click_link "Approve this comment"
+
+ page.should have_content("has been approved")
+ end
+
+ it "should allow me to reject a comment" do
+ click_link "Reject this comment"
+
+ page.should have_content("has been rejected")
+ end
+ end
+ end
+
+ describe "#approved" do
+ context "when has no approved comments" do
+ before(:each) do
+ BlogComment.delete_all
+ visit approved_refinery_admin_blog_comments_path
+ end
+
+ it "should list no comments" do
+ page.should have_content('there are no approved comments')
+ end
+ end
+
+ context "when has approved comments" do
+ let!(:blog_comment) do
+ FactoryGirl.create(:blog_comment,
+ :state => 'approved')
+ end
+ before(:each) { visit approved_refinery_admin_blog_comments_path }
+
+ it "should list comments" do
+ page.should have_content(blog_comment.body)
+ page.should have_content(blog_comment.name)
+ end
+
+ it "should allow me to reject a comment" do
+ click_link "Reject this comment"
+
+ page.should have_content("has been rejected")
+ end
+ end
+ end
+
+ describe "#rejected" do
+ context "when has no rejected comments" do
+ before(:each) do
+ BlogComment.delete_all
+ visit rejected_refinery_admin_blog_comments_path
+ end
+
+ it "should list no comments" do
+ page.should have_content('there are no rejected comments')
+ end
+ end
+
+ context "when has rejected comments" do
+ let!(:blog_comment) do
+ FactoryGirl.create(:blog_comment,
+ :state => 'rejected')
+ end
+ before(:each) { visit rejected_refinery_admin_blog_comments_path }
+
+ it "should list comments" do
+ page.should have_content(blog_comment.body)
+ page.should have_content(blog_comment.name)
+ end
+
+ it "should allow me to approve a comment" do
+ click_link "Approve this comment"
+
+ page.should have_content("has been approved")
+ end
+ end
+ end
+
+ describe "#show" do
+ let!(:blog_comment) { FactoryGirl.create(:blog_comment) }
+ before(:each) { visit refinery_admin_blog_comment_path(blog_comment) }
+
+ it "should display the comment" do
+ page.should have_content(blog_comment.body)
+ page.should have_content(blog_comment.name)
+ end
+
+ it "should allow me to approve the comment" do
+ click_link "Approve this comment"
+
+ page.should have_content("has been approved")
+ end
+ end
+ end
+end
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
diff --git a/spec/requests/refinery/blog/categories_spec.rb b/spec/requests/refinery/blog/categories_spec.rb
new file mode 100644
index 0000000..48a3417
--- /dev/null
+++ b/spec/requests/refinery/blog/categories_spec.rb
@@ -0,0 +1,25 @@
+require "spec_helper"
+
+module Refinery
+ describe "BlogCategories" do
+ login_refinery_user
+
+ context "has one category and post" do
+ before(:each) do
+ @blog_post = FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post")
+ @blog_category = FactoryGirl.create(:blog_category, :title => "Video Games")
+ @blog_post.categories << @blog_category
+ @blog_post.save!
+ end
+
+ describe "show categories blog posts" do
+ before(:each) { visit blog_category_path(@blog_category) }
+
+ it "should displays categories blog posts" do
+ page.should have_content("Refinery CMS blog post")
+ page.should have_content("Video Games")
+ end
+ end
+ end
+ end
+end
diff --git a/spec/requests/refinery/blog/posts_spec.rb b/spec/requests/refinery/blog/posts_spec.rb
new file mode 100644
index 0000000..eba6131
--- /dev/null
+++ b/spec/requests/refinery/blog/posts_spec.rb
@@ -0,0 +1,40 @@
+require "spec_helper"
+
+module Refinery
+ describe "BlogPosts" do
+ login_refinery_user
+
+ context "when has blog posts" do
+ let(:blog_post) { FactoryGirl.create(:blog_post, :title => "Refinery CMS blog post") }
+
+ it "should display blog post" do
+ visit blog_post_path(blog_post)
+ page.should have_content("Refinery CMS blog post")
+ end
+
+ it "should display the blog rss feed" do
+ get blog_rss_feed_path
+ response.should be_success
+ response.content_type.should eq("application/rss+xml")
+ end
+ end
+
+ describe "list tagged posts" do
+ context "when has tagged blog posts" do
+ before(:each) do
+ @tag_name = "chicago"
+ @blog_post = FactoryGirl.create(:blog_post,
+ :title => "I Love my city",
+ :tag_list => @tag_name)
+ tag = ::Refinery::BlogPost.tag_counts_on(:tags).first
+ visit tagged_posts_path(tag.id, @tag_name.parameterize)
+ end
+
+ it "should have one tagged post" do
+ page.should have_content(@tag_name)
+ page.should have_content(@blog_post.title)
+ end
+ end
+ end
+ end
+end