-
Notifications
You must be signed in to change notification settings - Fork 467
/
mongodb_test.rb
41 lines (33 loc) · 1.15 KB
/
mongodb_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
require_relative "../test_helper"
class MongodbTest < ActionDispatch::IntegrationTest
include AdapterTest
def data_source
"mongodb"
end
def setup
@@once ||= begin
client = Mongo::Client.new(["127.0.0.1:27017"], database: "blazer_test")
client[:items].drop
client[:items].insert_one({hello: "world"})
client[:items].insert_one({hello: "'"})
client[:items].insert_one({hello: '"'})
client[:items].insert_one({hello: "\\"})
true
end
end
def test_run
assert_result [{"hello" => "world"}], "db.items.find({hello: 'world'}, {hello: 1, _id: 0})"
end
def test_audit
assert_audit "db.items.find({hello: 'world'}, {hello: 1, _id: 0})", "db.items.find({hello: {var}}, {hello: 1, _id: 0})", var: "world"
end
def test_single_quote
assert_result [{"hello" => "'"}], "db.items.find({hello: {var}}, {hello: 1, _id: 0})", var: "'"
end
def test_double_quote
assert_result [{"hello" => '"'}], "db.items.find({hello: {var}}, {hello: 1, _id: 0})", var: '"'
end
def test_backslash
assert_result [{"hello" => "\\"}], "db.items.find({hello: {var}}, {hello: 1, _id: 0})", var: "\\"
end
end