This repository has been archived by the owner on Jun 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 533
/
index_store_test.rb
68 lines (45 loc) · 1.55 KB
/
index_store_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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
require 'test_helper'
module Tire
class IndexStoreIntegrationTest < Test::Unit::TestCase
include Test::Integration
context "Storing the documents in index" do
teardown { Tire.index('articles-test-ids').delete }
should "store hashes under their IDs" do
Tire.index 'articles-test-ids' do
delete
create
store :id => 1, :title => 'One'
store :id => 2, :title => 'Two'
store :id => 3, :title => 'Three'
store :id => 4, :title => 'Four'
store :id => 4, :title => 'Four'
refresh
end
s = Tire.search('articles-test-ids') { query { string '*' } }
assert_equal 4, s.results.count
document = Tire.index('articles-test-ids').retrieve :document, 4
assert_equal 'Four', document.title
assert_equal 2, document._version.to_i
end
end
context "Removing documents from the index" do
teardown { Tire.index('articles-test-remove').delete }
setup do
Tire.index 'articles-test-remove' do
delete
create
store :id => 1, :title => 'One'
store :id => 2, :title => 'Two'
refresh
end
end
should "remove document from the index" do
assert_equal 2, Tire.search('articles-test-remove') { query { string '*' } }.results.count
assert_nothing_raised do
assert Tire.index('articles-test-remove').remove 1
assert ! Tire.index('articles-test-remove').remove(1)
end
end
end
end
end