aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamie Winsor <jamie@enmasse.com>2011-09-21 00:56:54 -0700
committerJamie Winsor <jamie@enmasse.com>2011-09-21 00:56:54 -0700
commit5e91670a80f3f4ed50f54d3d8fdf2709d981e9c8 (patch)
tree546558d17f3538967a8c6954a450f65bfbcb7824
parentdf0664b1420f03d8cdd3f7b6960a0e542a7eb374 (diff)
downloadrefinerycms-blog-5e91670a80f3f4ed50f54d3d8fdf2709d981e9c8.tar.gz
refinerycms-blog-5e91670a80f3f4ed50f54d3d8fdf2709d981e9c8.tar.bz2
refinerycms-blog-5e91670a80f3f4ed50f54d3d8fdf2709d981e9c8.zip
Fix draft preview of blog posts
-rw-r--r--app/helpers/refinery/blog/controller_helper.rb2
-rw-r--r--app/views/refinery/blog/posts/_post.html.erb2
-rw-r--r--spec/factories/blog_posts.rb4
-rw-r--r--spec/requests/refinery/blog/posts_spec.rb22
4 files changed, 28 insertions, 2 deletions
diff --git a/app/helpers/refinery/blog/controller_helper.rb b/app/helpers/refinery/blog/controller_helper.rb
index 74a189b..c1c2a6a 100644
--- a/app/helpers/refinery/blog/controller_helper.rb
+++ b/app/helpers/refinery/blog/controller_helper.rb
@@ -6,7 +6,7 @@ module Refinery
def find_blog_post
unless (@blog_post = Refinery::BlogPost.find(params[:id])).try(:live?)
- if refinery_user? and current_user.authorized_plugins.include?("refinerycms_blog")
+ if refinery_user? and current_refinery_user.authorized_plugins.include?("refinerycms_blog")
@blog_post = Refinery::BlogPost.find(params[:id])
else
error_404
diff --git a/app/views/refinery/blog/posts/_post.html.erb b/app/views/refinery/blog/posts/_post.html.erb
index 08587aa..f86f63a 100644
--- a/app/views/refinery/blog/posts/_post.html.erb
+++ b/app/views/refinery/blog/posts/_post.html.erb
@@ -27,5 +27,5 @@
<span class="st_sharethis" displayText="ShareThis"></span>
<% end %>
</article>
-<%= render :partial => '/shared/draft_page_message' unless @blog_post.nil? or @blog_post.live? -%>
+<%= render :partial => '/refinery/draft_page_message' unless @blog_post.nil? or @blog_post.live? -%>
<%= render 'nav' if next_or_previous?(@blog_post) %>
diff --git a/spec/factories/blog_posts.rb b/spec/factories/blog_posts.rb
index 0b8b888..b839d02 100644
--- a/spec/factories/blog_posts.rb
+++ b/spec/factories/blog_posts.rb
@@ -5,5 +5,9 @@ FactoryGirl.define do
draft false
tag_list "chicago, shopping, fun times"
published_at Time.now
+
+ factory :blog_post_draft do
+ draft true
+ end
end
end
diff --git a/spec/requests/refinery/blog/posts_spec.rb b/spec/requests/refinery/blog/posts_spec.rb
index 7c5a90f..025586c 100644
--- a/spec/requests/refinery/blog/posts_spec.rb
+++ b/spec/requests/refinery/blog/posts_spec.rb
@@ -83,5 +83,27 @@ module Refinery
end
end
end
+
+ describe "#show draft preview" do
+ let(:blog_post) { FactoryGirl.create(:blog_post_draft) }
+
+ context "when logged in as admin" do
+ it "should display the draft notification" do
+ visit 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 destroy_refinery_user_session_path }
+
+ it "should not display the blog post" do
+ visit blog_post_path(blog_post)
+
+ page.should have_content("The page you were looking for doesn't exist (404)")
+ end
+ end
+ end
end
end