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
9e2e52e8
Commit
9e2e52e8
authored
Nov 03, 2014
by
Pablo Cantero
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'algorich-parse-deal-with-nil'
parents
d9227a89
af6fb677
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 @
9e2e52e8
...
...
@@ -5,7 +5,7 @@ module RansackMongo
end
def
parse
(
params
)
params
.
keys
.
inject
({})
do
|
query
,
query_param
|
(
params
||
{})
.
keys
.
inject
({})
do
|
query
,
query_param
|
attr
=
query_param
.
to_s
p
,
attr
=
detect_and_strip_from_string
(
attr
)
...
...
spec/ransack_mongo/query_spec.rb
View file @
9e2e52e8
...
...
@@ -19,7 +19,7 @@ module RansackMongo
end
end
describe
'
#
parse'
do
describe
'
.
parse'
do
context
'when not implement matcher'
do
it
'raises proper exception'
do
params
=
{
'name_foo'
=>
'Pablo'
}
...
...
@@ -32,7 +32,7 @@ module RansackMongo
end
context
'when MongoAdapter'
do
describe
'
#
parse!'
do
describe
'
.
parse!'
do
it
'raises exception when query evaluates to an empty hash'
do
params
=
{
'name'
=>
'Pablo'
}
expect
{
described_class
.
parse!
(
params
)
}.
to
raise_error
(
MatcherNotFound
)
...
...
@@ -45,13 +45,19 @@ module RansackMongo
end
end
describe
'
#
parse'
do
describe
'
.
parse'
do
it
'returns the query'
do
params
=
{
'name_eq'
=>
'Pablo'
,
'fullname_cont'
=>
'Cantero'
}
expect
(
described_class
.
parse
(
params
)).
to
eq
(
'name'
=>
'Pablo'
,
'fullname'
=>
/Cantero/i
)
end
context
'when nil query'
do
it
'returns an empty query'
do
expect
(
described_class
.
parse
(
nil
)).
to
eq
({})
end
end
context
'when or'
do
it
'returns the query'
do
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