Merge pull request #570 from bsodmike/bsodmike-2.0
Cancan 2.0 fix for issue #565; fixes namespaced non-db/model backed resources authorization
This commit is contained in:
commit
4986de8b3e
|
@ -100,7 +100,7 @@ module CanCan
|
||||||
|
|
||||||
def matches_subject?(subject)
|
def matches_subject?(subject)
|
||||||
subject = subject_name(subject) if subject_object? subject
|
subject = subject_name(subject) if subject_object? subject
|
||||||
@expanded_subjects.include?(:all) || @expanded_subjects.include?(subject.to_sym) # || matches_subject_class?(subject)
|
@expanded_subjects.include?(:all) || @expanded_subjects.include?(subject.to_sym) || @expanded_subjects.include?(subject) # || matches_subject_class?(subject)
|
||||||
end
|
end
|
||||||
|
|
||||||
def matches_attribute?(attribute)
|
def matches_attribute?(attribute)
|
||||||
|
|
|
@ -384,6 +384,14 @@ describe CanCan::ControllerResource do
|
||||||
@controller.instance_variable_get(:@project).name.should == "foobar"
|
@controller.instance_variable_get(:@project).name.should == "foobar"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should properly authorize resource for namespaced controller" do
|
||||||
|
@ability.can(:index, "admin/dashboard")
|
||||||
|
@params.merge!(:controller => "admin/dashboard", :action => "index")
|
||||||
|
@controller.authorize!(:index, "admin/dashboard")
|
||||||
|
resource = CanCan::ControllerResource.new(@controller, :authorize => true).process
|
||||||
|
lambda { resource.process }.should_not raise_error(CanCan::Unauthorized)
|
||||||
|
end
|
||||||
|
|
||||||
# it "raises ImplementationRemoved when adding :name option" do
|
# it "raises ImplementationRemoved when adding :name option" do
|
||||||
# lambda {
|
# lambda {
|
||||||
# CanCan::ControllerResource.new(@controller, :name => :foo)
|
# CanCan::ControllerResource.new(@controller, :name => :foo)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user