Guest User

Untitled

a guest
May 25th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. require File.dirname(__FILE__) + "/../../spec_helper"
  2.  
  3. describe Admin::LayoutController do
  4. scenario :users, :pages_with_layouts
  5.  
  6. before :each do
  7. login_as :developer
  8. end
  9.  
  10. it "should be a ResourceController" do
  11. controller.should be_kind_of(Admin::ResourceController)
  12. end
  13.  
  14. it "should handle Layouts" do
  15. controller.class.model_class.should == Layout
  16. end
  17.  
  18. { :get => [:index, :new, :edit, :remove],
  19. :post => [:create],
  20. :put => [:update],
  21. :delete => [:destroy] }.each do |method, actions|
  22. actions.each do |action|
  23. it "should require login to access the #{action} action" do
  24. logout
  25. lambda { send(method, action).should require_login }
  26. end
  27.  
  28. it "should allow access to developers for the #{action} action" do
  29. lambda {
  30. send(method, action, :id => layout_id(:main))
  31. }.should restrict_access(:allow => [users(:developer)],
  32. :url => '/admin/page')
  33. end
  34.  
  35. it "should allow access to admins for the #{action} action" do
  36. lambda {
  37. send(method, action, :id => layout_id(:main))
  38. }.should restrict_access(:allow => [users(:developer)],
  39. :url => '/admin/page')
  40. end
  41.  
  42. it "should deny non-developers and non-admins for the #{action} action" do
  43. lambda {
  44. send(method, action)
  45. }.should restrict_access(:deny => [users(:non_admin), users(:existing)],
  46. :url => '/admin/page')
  47. end
  48. end
  49. end
  50.  
  51. it "should clear the cache of associated pages when saved" do
  52. ResponseCache.instance.should_receive(:expire_response).with(pages(:utf8).url)
  53. put :update, :id => layout_id(:utf8), :layout => {:content_type => "application/xhtml+xml;charset=utf8"}
  54. response.should be_redirect
  55. end
  56.  
  57. end
Add Comment
Please, Sign In to add comment