Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cancan
Manage
Activity
Members
Plan
External wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Github Mirror
coopdevs
cancan
Commits
ce7d3fec
Commit
ce7d3fec
authored
12 years ago
by
Nugroho Herucahyono
Browse files
Options
Downloads
Patches
Plain Diff
porting #668 to 1.6.x
parent
1e89b31b
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/cancan/controller_resource.rb
+1
-1
1 addition, 1 deletion
lib/cancan/controller_resource.rb
spec/cancan/controller_resource_spec.rb
+10
-0
10 additions, 0 deletions
spec/cancan/controller_resource_spec.rb
with
11 additions
and
1 deletion
lib/cancan/controller_resource.rb
+
1
−
1
View file @
ce7d3fec
...
...
@@ -220,7 +220,7 @@ module CanCan
end
def
namespace
@params
[
:controller
].
split
(
"
::
"
)[
0
..-
2
]
@params
[
:controller
].
split
(
/
::
|\//
)[
0
..-
2
]
end
def
namespaced_name
...
...
This diff is collapsed.
Click to expand it.
spec/cancan/controller_resource_spec.rb
+
10
−
0
View file @
ce7d3fec
...
...
@@ -67,6 +67,16 @@ describe CanCan::ControllerResource do
@controller
.
instance_variable_get
(
:@project
).
should
==
project
end
it
"has the specified nested resource_class when using / for namespace"
do
module
Admin
class
Dashboard
;
end
end
@ability
.
can
(
:index
,
"admin/dashboard"
)
@params
.
merge!
(
:controller
=>
"admin/dashboard"
,
:action
=>
"index"
)
resource
=
CanCan
::
ControllerResource
.
new
(
@controller
,
:authorize
=>
true
)
resource
.
send
(
:resource_class
).
should
==
Admin
::
Dashboard
end
it
"should build a new resource with hash if params[:id] is not specified"
do
@params
.
merge!
(
:action
=>
"create"
,
:project
=>
{
:name
=>
"foobar"
})
resource
=
CanCan
::
ControllerResource
.
new
(
@controller
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment