aboutsummaryrefslogtreecommitdiffstats
path: root/spec/requests/refinery/blog/posts_spec.rb
diff options
context:
space:
mode:
authorAdrien Coquio <adrien.coquio@gmail.com>2012-06-03 21:37:41 +0200
committerPhilip Arndt <parndt@gmail.com>2012-06-09 11:19:38 +1200
commitd0c249af2a2e630ac993eb23a691ef996613b55f (patch)
tree6992cf3816a6f5b1e022637a6780a7d24f1753cf /spec/requests/refinery/blog/posts_spec.rb
parent7743fab73a5c60d9f5f0cf2ce65a3f0914b1376f (diff)
downloadrefinerycms-blog-d0c249af2a2e630ac993eb23a691ef996613b55f.tar.gz
refinerycms-blog-d0c249af2a2e630ac993eb23a691ef996613b55f.tar.bz2
refinerycms-blog-d0c249af2a2e630ac993eb23a691ef996613b55f.zip
Added i18n support to models through globalize3.
* Added Post translation * Added Category translation * Use friendly_id globalize with category * Added migrate_data option on migrations for translations * Use Refinery locale instead of I18n * Refactored duplicate locale_picker partial * Removed useless .all call * Use presence instead if / blank? * Added with_globalize scopes when loading posts of one category * Use Globalize when creating post factory * Fix failing specs by creating blog posts/categories using needed locale.
Diffstat (limited to 'spec/requests/refinery/blog/posts_spec.rb')
-rw-r--r--spec/requests/refinery/blog/posts_spec.rb80
1 files changed, 49 insertions, 31 deletions
diff --git a/spec/requests/refinery/blog/posts_spec.rb b/spec/requests/refinery/blog/posts_spec.rb
index 3422dd2..b6cc7ca 100644
--- a/spec/requests/refinery/blog/posts_spec.rb
+++ b/spec/requests/refinery/blog/posts_spec.rb
@@ -4,45 +4,68 @@ module Refinery
describe "Blog::Posts" do
refinery_login_with :refinery_user
- context "when has blog posts" do
+ 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 refinery.blog_post_path(blog_post)
-
+
page.should have_content(blog_post.title)
end
-
+
it "should display the blog rss feed" do
get refinery.blog_rss_feed_path
-
+
response.should be_success
response.content_type.should eq("application/rss+xml")
end
+
+ describe "visit blog" do
+
+ before(:each) do
+ Factory.create(:page, :link_url => "/")
+ Factory.create(:page, :link_url => "/blog", :title => "Blog")
+ end
+
+ it "shows blog link in menu" do
+ visit "/"
+ within "#menu" do
+ page.should have_content("Blog")
+ page.should have_selector("a[href='/blog']")
+ end
+ end
+
+ it "shows blog posts" do
+ visit refinery.blog_root_path
+ page.should have_content blog_post.title
+ end
+
+ end
+
end
-
- describe "list tagged posts" do
- context "when has tagged blog posts" do
+
+ describe "list tagged posts" do
+ context "when has tagged blog posts" do
before(:each) do
@tag_name = "chicago"
@post = FactoryGirl.create(:blog_post,
:title => "I Love my city",
:tag_list => @tag_name)
- @tag = ::Refinery::Blog::Post.tag_counts_on(:tags).first
+ @tag = ::Refinery::Blog::Post.tag_counts_on(:tags).first
end
it "should have one tagged post" do
visit refinery.blog_tagged_posts_path(@tag.id, @tag_name.parameterize)
-
+
page.should have_content(@tag_name)
page.should have_content(@post.title)
end
end
end
-
+
describe "#show" do
context "when has no comments" do
let(:blog_post) { FactoryGirl.create(:blog_post) }
-
+
it "should display the blog post" do
visit refinery.blog_post_path(blog_post)
page.should have_content(blog_post.title)
@@ -51,29 +74,29 @@ module Refinery
end
context "when has approved comments" do
let(:approved_comment) { FactoryGirl.create(:approved_comment) }
-
+
it "should display the comments" do
visit refinery.blog_post_path(approved_comment.post)
-
+
page.should have_content(approved_comment.body)
page.should have_content("Posted by #{approved_comment.name}")
end
end
context "when has rejected comments" do
let(:rejected_comment) { FactoryGirl.create(:rejected_comment) }
-
- it "should not display the comments" do
+
+ it "should not display the comments" do
visit refinery.blog_post_path(rejected_comment.post)
-
+
page.should_not have_content(rejected_comment.body)
end
end
context "when has new comments" do
let(:blog_comment) { FactoryGirl.create(:blog_comment) }
-
+
it "should not display the comments" do
visit refinery.blog_post_path(blog_comment.post)
-
+
page.should_not have_content(blog_comment.body)
end
end
@@ -122,16 +145,11 @@ module Refinery
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
+ let!(:blog_post) { FactoryGirl.create(:blog_post, :published_at => Time.now - 5.minutes) }
+ let!(:blog_post2) { FactoryGirl.create(:blog_post, :published_at => Time.now - 2.minutes) }
it "should be the most recent" do
- Refinery::Blog::Post.recent(2).first.should eq(blog_post2)
+ Refinery::Blog::Post.recent(2).first.id.should eq(blog_post2.id)
end
end
@@ -139,19 +157,19 @@ module Refinery
describe "#show draft preview" do
let(:blog_post) { FactoryGirl.create(:blog_post_draft) }
- context "when logged in as admin" do
+ context "when logged in as admin" do
it "should display the draft notification" do
visit refinery.blog_post_path(blog_post)
-
+
page.should have_content('This page is NOT live for public viewing.')
end
end
context "when not logged in as an admin" do
before(:each) { visit refinery.destroy_refinery_user_session_path }
-
+
it "should not display the blog post" do
visit refinery.blog_post_path(blog_post)
-
+
page.should have_content("The page you were looking for doesn't exist (404)")
end
end