forked from activeadmin/activeadmin
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
46 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Support for CanCan within Active Admin | ||
|
||
module ActiveAdmin | ||
module CanCan | ||
if defined?(::CanCan) | ||
|
||
class ControllerResource < ::CanCan::InheritedResource | ||
def resource_base | ||
@controller.send :collection | ||
end | ||
end | ||
|
||
module ControllerAdditions | ||
def cancan_resource_class | ||
::ActiveAdmin::CanCan::ControllerResource | ||
end | ||
end | ||
|
||
ActiveAdmin::ResourceController.send :include, ControllerAdditions | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Mock out CanCan | ||
module CanCan | ||
class InheritedResource | ||
def initialize(controller) | ||
@controller = controller | ||
end | ||
end | ||
end | ||
|
||
require 'spec_helper' | ||
|
||
describe ActiveAdmin::CanCan do | ||
|
||
describe ActiveAdmin::CanCan::ControllerResource do | ||
it "should return the collection for cancan to use" do | ||
controller = mock("MockController") | ||
controller.should_receive(:collection) | ||
ActiveAdmin::CanCan::ControllerResource.new(controller).resource_base | ||
end | ||
end | ||
|
||
end |