Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

@_cancan_skipper should be inherited #683

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 21 additions & 0 deletions spec/cancan/controller_additions_spec.rb
Expand Up @@ -134,4 +134,25 @@
@controller_class.cancan_skipper[:load][:project].should == {:only => [:index, :show]} @controller_class.cancan_skipper[:load][:project].should == {:only => [:index, :show]}
@controller_class.cancan_skipper[:authorize][:project].should == {:only => [:index, :show]} @controller_class.cancan_skipper[:authorize][:project].should == {:only => [:index, :show]}
end end

describe "when inheriting" do
before(:each) do
@super_controller_class = Class.new
@super_controller = @super_controller_class.new
mock(@super_controller_class).helper_method(:can?, :cannot?, :current_ability)
@super_controller_class.send(:include, CanCan::ControllerAdditions)
@super_controller_class.send(:skip_load_and_authorize_resource, :only => [:index, :show])

@sub_controller_class = Class.new(@super_controller_class)
@sub_controller = @sub_controller_class.new
end

it "sub_classes should skip the same behaviors and actions as super_classes" do
@super_controller_class.cancan_skipper[:load][nil].should == {:only => [:index, :show]}
@super_controller_class.cancan_skipper[:authorize][nil].should == {:only => [:index, :show]}

@sub_controller_class.cancan_skipper[:load][nil].should == {:only => [:index, :show]}
@sub_controller_class.cancan_skipper[:authorize][nil].should == {:only => [:index, :show]}
end
end
end end