Sha256: b7166b81738a3a88f2ad9ba60461905163d83f85e8004be7d3c784a6457b13b8

Contents?: true

Size: 1.62 KB

Versions: 3

Compression:

Stored size: 1.62 KB

Contents

require File.dirname(__FILE__) + "/../../spec_helper"

describe Admin::SnippetsController do
  dataset :users, :snippets

  before :each do
    ActionController::Routing::Routes.reload
    login_as :existing
  end

  it "should be an ResourceController" do
    controller.should be_kind_of(Admin::ResourceController)
  end

  it "should handle Snippets" do
    controller.class.model_class.should == Snippet
  end

  {:get => [:index, :show, :new, :edit, :remove],
   :post => [:create],
   :put => [:update],
   :delete => [:destroy]}.each do |method, actions|
    actions.each do |action|
      it "should require login to access the #{action} action" do
        logout
        lambda { send(method, action, :id => snippet_id(:first)) }.should require_login
      end

      it "should allow access to developers for the #{action} action" do
        lambda { 
          send(method, action, :id => snippet_id(:first)) 
        }.should restrict_access(:allow => [users(:developer)], 
                                 :url => '/admin/pages')
      end

      it "should allow access to admins for the #{action} action" do
        lambda { 
          send(method, action, :id => snippet_id(:first)) 
        }.should restrict_access(:allow => [users(:developer)], 
                                 :url => '/admin/pages')
      end
      
      it "should allow non-developers and non-admins for the #{action} action" do
        lambda { 
          send(method, action, :id => Snippet.first.id) 
        }.should restrict_access(:allow => [users(:non_admin), users(:existing)],
                                 :url => '/admin/pages')
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
radiant-0.7.2 spec/controllers/admin/snippets_controller_spec.rb
radiant-0.7.0 spec/controllers/admin/snippets_controller_spec.rb
radiant-0.7.1 spec/controllers/admin/snippets_controller_spec.rb