Permalink
Browse files

Make all tests of LayoutsControllerSpec pass

  • Loading branch information...
1 parent 252800c commit cb1237d0b7f4677d240d6032b1df68361e967e73 @jomz jomz committed Feb 24, 2014
Showing with 17 additions and 11 deletions.
  1. +17 −11 spec/controllers/radiant/layouts_controller_spec.rb
@@ -3,9 +3,16 @@
describe Radiant::Admin::LayoutsController do
routes { Radiant::Engine.routes }
#dataset :users, :pages_with_layouts
-
+ include AuthenticationHelper
+
+ let(:layout){ FactoryGirl.create(:layout) }
+ let(:utf8_layout){ FactoryGirl.create(:utf8_layout) }
+ let(:admin){ FactoryGirl.create(:admin) }
+ let(:non_admin){ FactoryGirl.create(:user) }
+ let(:designer){ FactoryGirl.create(:designer) }
+
before :each do
- login_as :designer
+ login_as designer
end
it "should be a ResourceController" do
@@ -20,11 +27,10 @@
describe "show" do
it "should redirect to the edit action" do
get :show, :id => 1
- response.should redirect_to(edit_admin_layout_path(params[:id]))
+ response.should redirect_to(edit_admin_layout_path(1))
end
it "should show xml when format is xml" do
- layout = Layout.first
get :show, :id => layout.id, :format => "xml"
response.body.should == layout.to_xml
end
@@ -74,30 +80,30 @@
it "should allow access to designers for the #{action} action" do
lambda {
- send(method, action, :id => layout_id(:main))
- }.should restrict_access(:allow => [users(:designer)],
+ send(method, action, :id => layout.id)
+ }.should restrict_access(:allow => [designer],
:url => '/admin/pages')
end
it "should allow access to admins for the #{action} action" do
lambda {
- send(method, action, :id => layout_id(:main))
- }.should restrict_access(:allow => [users(:designer)],
+ send(method, action, :id => layout.id)
+ }.should restrict_access(:allow => [designer],
:url => '/admin/pages')
end
it "should deny non-designers and non-admins for the #{action} action" do
lambda {
- send(method, action, :id => layout_id(:main))
- }.should restrict_access(:deny => [users(:non_admin), users(:existing)],
+ send(method, action, :id => layout.id)
+ }.should restrict_access(:deny => non_admin,
:url => '/admin/pages')
end
end
end
it "should clear the page cache when saved" do
Radiant::Cache.should_receive(:clear)
- put :update, :id => layout_id(:utf8), :layout => {:content_type => "application/xhtml+xml;charset=utf8"}
+ put :update, :id => utf8_layout.id, :layout => {:content_type => "application/xhtml+xml;charset=utf8"}
end
end

0 comments on commit cb1237d

Please sign in to comment.