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
9c0346b9
Commit
9c0346b9
authored
14 years ago
by
Yura Sokolov
Browse files
Options
Downloads
Patches
Plain Diff
can accept array for sql sanitizing in conditions
parent
b473d882
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/cancan/ability.rb
+2
-1
2 additions, 1 deletion
lib/cancan/ability.rb
spec/cancan/ability_spec.rb
+15
-0
15 additions, 0 deletions
spec/cancan/ability_spec.rb
with
17 additions
and
1 deletion
lib/cancan/ability.rb
+
2
−
1
View file @
9c0346b9
...
@@ -302,7 +302,8 @@ module CanCan
...
@@ -302,7 +302,8 @@ module CanCan
can_definitions
.
each
do
|
can_definition
|
can_definitions
.
each
do
|
can_definition
|
merge_association_joins
(
joins
,
can_definition
.
association_joins
||
[])
merge_association_joins
(
joins
,
can_definition
.
association_joins
||
[])
end
end
clear_association_joins
(
joins
)
joins
=
clear_association_joins
(
joins
)
joins
unless
joins
.
empty?
end
end
def
merge_association_joins
(
what
,
with
)
def
merge_association_joins
(
what
,
with
)
...
...
This diff is collapsed.
Click to expand it.
spec/cancan/ability_spec.rb
+
15
−
0
View file @
9c0346b9
...
@@ -270,6 +270,21 @@ describe CanCan::Ability do
...
@@ -270,6 +270,21 @@ describe CanCan::Ability do
@ability
.
sql_conditions
(
:read
,
SqlSanitizer
).
should
==
'true=true'
@ability
.
sql_conditions
(
:read
,
SqlSanitizer
).
should
==
'true=true'
end
end
it
"should accept array condition for use in sql"
do
@ability
.
can
:read
,
SqlSanitizer
,
[
"user_id = ?"
,
1
]
@ability
.
sql_conditions
(
:read
,
SqlSanitizer
).
should
==
[
'user_id = ?'
,
1
]
@ability
.
association_joins
(
:read
,
SqlSanitizer
).
should
be_nil
end
it
"should accept array condition for use in sql and do sanitizing in complex conditions"
do
@ability
.
cannot
:read
,
SqlSanitizer
@ability
.
can
:read
,
SqlSanitizer
,
[
"user_id = ?"
,
1
]
@ability
.
sql_conditions
(
:read
,
SqlSanitizer
).
should
==
'user_id = 1'
@ability
.
association_joins
(
:read
,
SqlSanitizer
).
should
be_nil
end
it
"should has eated cheezburger"
do
it
"should has eated cheezburger"
do
lambda
{
lambda
{
@ability
.
can?
:has
,
:cheezburger
@ability
.
can?
:has
,
:cheezburger
...
...
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