
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
124 lines
3.7 KiB
Ruby
124 lines
3.7 KiB
Ruby
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
|