spec/authority/controller_spec.rb in authority-2.4.1 vs spec/authority/controller_spec.rb in authority-2.4.2
- old
+ new
@@ -110,9 +110,34 @@
child_controller.authorize_actions_for(resource_class, :actions => new_actions)
end
end
+ describe "authority_resource" do
+
+ let(:child_controller) { Class.new(controller_class) }
+
+ before :each do
+ controller_class.authorize_actions_for(resource_class)
+ end
+
+ it "remembers what it was set to" do
+ expect(controller_class.authority_resource).to eq(resource_class)
+ end
+
+ it "uses its parent controller's value by default" do
+ expect(child_controller.authority_resource).to eq(resource_class)
+ end
+
+ it "can be modified without affecting the parent controller" do
+ fancy_array = Class.new(Array)
+ child_controller.authorize_actions_for(fancy_array)
+ expect(child_controller.authority_resource).to eq(fancy_array)
+ expect(controller_class.authority_resource).to eq(resource_class)
+ end
+
+ end
+
describe "authority_action" do
it "modifies this controller's authority action map" do
new_actions = {:show => :display, :synthesize => :create, :annihilate => 'delete'}
controller_class.authority_actions(new_actions)