Sha256: a8440e99067a8f3721d8d93b6744903d33954626cd557b14d39574b87a154acb

Contents?: true

Size: 1.94 KB

Versions: 31

Compression:

Stored size: 1.94 KB

Contents

require File.join(File.dirname(__FILE__), %w[.. spec_helper])
require File.join(File.dirname(__FILE__), %w[.. .. lib lockdown rules])

describe Lockdown::System do
  it "should fetch the option" do
    Lockdown::System.options = {}
    Lockdown::System.options['test'] = "my test"
    Lockdown::System.fetch('test').should == "my test"
  end

  it "should fetch the controller class" do
    klass = mock("User Controller Class")
    Lockdown.stub!(:controller_class_name).and_return(:users)
    Lockdown::System.controller_classes = {}
    Lockdown::System.controller_classes[:users] = klass
    Lockdown::System.fetch_controller_class(:users).should equal(klass)
  end

  describe "#configure" do
    it "should call the methods responsible for defining the rules" do
      Lockdown::System.stub!(:skip_sync?).and_return(false)

      Lockdown::System.should_receive :set_defaults 
 
      Lockdown::System.should_receive :load_controller_classes

      Lockdown::System.should_receive :instance_eval
 
      Lockdown::System.should_receive :process_rules
 
      Lockdown::Database.should_receive :sync_with_db 
     
      Lockdown::System.configure do
      end
    end
  end

  describe "#paths_for" do
    it "should join the str_sym to the methods" do 
      Lockdown::System.paths_for(:users, :show, :edit).
        should == ["users/show", "users/edit"]
    end

    it "should add users to the array if access is granted on index" do 
      Lockdown::System.paths_for(:users, :index, :show, :edit).
        should == ["users/index", "users/show", "users/edit", "users"]
    end

    it "should build the paths from the controller class if no methods specified" do
      methods = ["new","edit","create","update"]
      Lockdown::System.stub!(:fetch_controller_class)
      Lockdown::System.stub!(:available_actions).
        and_return(methods)

      Lockdown::System.paths_for(:users).
        should == ["users/new","users/edit","users/create","users/update"]
    end
  end
end

Version data entries

31 entries across 31 versions & 5 rubygems

Version Path
andrewzielinski-lockdown-0.9.6 spec/lockdown/system_spec.rb
blaxter-lockdown-0.9.8.99 spec/lockdown/system_spec.rb
blaxter-lockdown-0.9.9 spec/lockdown/system_spec.rb
hone-lockdown-1.2.1 spec/lockdown/system_spec.rb
hone-lockdown-1.2.2 spec/lockdown/system_spec.rb
hone-lockdown-1.2.3 spec/lockdown/system_spec.rb
revo-lockdown-0.9.6 spec/lockdown/system_spec.rb
lockdown-1.2.1 spec/lockdown/system_spec.rb
lockdown-1.2.0 spec/lockdown/system_spec.rb
lockdown-1.1.5 spec/lockdown/system_spec.rb
lockdown-1.1.6 spec/lockdown/system_spec.rb
lockdown-1.1.3 spec/lockdown/system_spec.rb
lockdown-1.0.0 spec/lockdown/system_spec.rb
lockdown-1.0.1 spec/lockdown/system_spec.rb
lockdown-1.0.2 spec/lockdown/system_spec.rb
lockdown-1.0.3 spec/lockdown/system_spec.rb
lockdown-1.0.4 spec/lockdown/system_spec.rb
lockdown-1.0.5 spec/lockdown/system_spec.rb
lockdown-1.0.6 spec/lockdown/system_spec.rb
lockdown-1.1.0 spec/lockdown/system_spec.rb