spec/authority/controller_spec.rb in authority-0.9.0 vs spec/authority/controller_spec.rb in authority-1.0.0.pre2

- old
+ new

@@ -19,34 +19,34 @@ ExampleController.send(:include, Authority::Controller) end describe "DSL (class) methods" do it "should allow specifying the model to protect" do - ExampleController.check_authorization_on AbilityModel + ExampleController.authorize_actions_on AbilityModel ExampleController.authority_resource.should eq(AbilityModel) end it "should pass the options provided to the before filter that is set up" do @options = {:only => [:show, :edit, :update]} ExampleController.should_receive(:before_filter).with(:run_authorization_check, @options) - ExampleController.check_authorization_on AbilityModel, @options + ExampleController.authorize_actions_on AbilityModel, @options end it "should give the controller its own copy of the authority actions map" do - ExampleController.check_authorization_on AbilityModel - ExampleController.authority_actions.should be_a(Hash) - ExampleController.authority_actions.should_not be(Authority.configuration.authority_actions) + ExampleController.authorize_actions_on AbilityModel + ExampleController.controller_action_map.should be_a(Hash) + ExampleController.controller_action_map.should_not be(Authority.configuration.controller_action_map) end - it "should allow specifying the authority action map in the `check_authorization_on` declaration" do - ExampleController.check_authorization_on AbilityModel, :actions => {:eat => 'delete'} - ExampleController.authority_actions[:eat].should eq('delete') + it "should allow specifying the authority action map in the `authorize_actions_on` declaration" do + ExampleController.authorize_actions_on AbilityModel, :actions => {:eat => 'delete'} + ExampleController.controller_action_map[:eat].should eq('delete') end it "should have a write into the authority actions map usuable in a DSL format" do ExampleController.authority_action :smite => 'delete' - ExampleController.authority_actions[:smite].should eq('delete') + ExampleController.controller_action_map[:smite].should eq('delete') end end describe "instance methods" do before :each do @@ -55,10 +55,10 @@ @controller.stub!(:action_name).and_return(:edit) @controller.stub!(Authority.configuration.user_method).and_return(@user) end it "should check authorization on the model specified" do - @controller.should_receive(:check_authorization_for).with(AbilityModel, @user) + @controller.should_receive(:authorize_action_on).with(AbilityModel, @user) @controller.send(:run_authorization_check) end it "should raise a SecurityTransgression if authorization fails" do expect { @controller.send(:run_authorization_check) }.to raise_error(Authority::SecurityTransgression)