Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
ta_ransack_mongo
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
ta_ransack_mongo
Commits
2212ee4a
Commit
2212ee4a
authored
Oct 31, 2014
by
Hugo Maia Vieira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parse must deal with nil param
parent
d9227a89
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
4 deletions
+10
-4
predicate.rb
lib/ransack_mongo/predicate.rb
+1
-1
query_spec.rb
spec/ransack_mongo/query_spec.rb
+9
-3
No files found.
lib/ransack_mongo/predicate.rb
View file @
2212ee4a
...
@@ -5,7 +5,7 @@ module RansackMongo
...
@@ -5,7 +5,7 @@ module RansackMongo
end
end
def
parse
(
params
)
def
parse
(
params
)
params
.
keys
.
inject
({})
do
|
query
,
query_param
|
(
params
||
{})
.
keys
.
inject
({})
do
|
query
,
query_param
|
attr
=
query_param
.
to_s
attr
=
query_param
.
to_s
p
,
attr
=
detect_and_strip_from_string
(
attr
)
p
,
attr
=
detect_and_strip_from_string
(
attr
)
...
...
spec/ransack_mongo/query_spec.rb
View file @
2212ee4a
...
@@ -19,7 +19,7 @@ module RansackMongo
...
@@ -19,7 +19,7 @@ module RansackMongo
end
end
end
end
describe
'
#
parse'
do
describe
'
.
parse'
do
context
'when not implement matcher'
do
context
'when not implement matcher'
do
it
'raises proper exception'
do
it
'raises proper exception'
do
params
=
{
'name_foo'
=>
'Pablo'
}
params
=
{
'name_foo'
=>
'Pablo'
}
...
@@ -32,7 +32,7 @@ module RansackMongo
...
@@ -32,7 +32,7 @@ module RansackMongo
end
end
context
'when MongoAdapter'
do
context
'when MongoAdapter'
do
describe
'
#
parse!'
do
describe
'
.
parse!'
do
it
'raises exception when query evaluates to an empty hash'
do
it
'raises exception when query evaluates to an empty hash'
do
params
=
{
'name'
=>
'Pablo'
}
params
=
{
'name'
=>
'Pablo'
}
expect
{
described_class
.
parse!
(
params
)
}.
to
raise_error
(
MatcherNotFound
)
expect
{
described_class
.
parse!
(
params
)
}.
to
raise_error
(
MatcherNotFound
)
...
@@ -45,13 +45,19 @@ module RansackMongo
...
@@ -45,13 +45,19 @@ module RansackMongo
end
end
end
end
describe
'
#
parse'
do
describe
'
.
parse'
do
it
'returns the query'
do
it
'returns the query'
do
params
=
{
'name_eq'
=>
'Pablo'
,
'fullname_cont'
=>
'Cantero'
}
params
=
{
'name_eq'
=>
'Pablo'
,
'fullname_cont'
=>
'Cantero'
}
expect
(
described_class
.
parse
(
params
)).
to
eq
(
'name'
=>
'Pablo'
,
'fullname'
=>
/Cantero/i
)
expect
(
described_class
.
parse
(
params
)).
to
eq
(
'name'
=>
'Pablo'
,
'fullname'
=>
/Cantero/i
)
end
end
context
'when nil query'
do
it
'return an empty query'
do
expect
(
described_class
.
parse
(
nil
)).
to
eq
({})
end
end
context
'when or'
do
context
'when or'
do
it
'returns the query'
do
it
'returns the query'
do
params
=
{
'name_or_fullname_eq'
=>
'Pablo'
}
params
=
{
'name_or_fullname_eq'
=>
'Pablo'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment