elasticsearch-persistence 7.2.1 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/README.md +25 -53
- data/Rakefile +8 -7
- data/elasticsearch-persistence.gemspec +32 -35
- data/examples/notes/application.rb +0 -1
- data/examples/notes/test.rb +1 -1
- data/lib/elasticsearch/persistence/repository/dsl.rb +0 -14
- data/lib/elasticsearch/persistence/repository/find.rb +1 -4
- data/lib/elasticsearch/persistence/repository/search.rb +2 -4
- data/lib/elasticsearch/persistence/repository/store.rb +6 -9
- data/lib/elasticsearch/persistence/repository.rb +1 -17
- data/lib/elasticsearch/persistence/version.rb +1 -1
- data/spec/repository/find_spec.rb +14 -91
- data/spec/repository/response/results_spec.rb +18 -17
- data/spec/repository/search_spec.rb +27 -153
- data/spec/repository/store_spec.rb +8 -48
- data/spec/repository_spec.rb +50 -145
- data/spec/spec_helper.rb +3 -2
- metadata +55 -55
@@ -18,7 +18,6 @@
|
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
20
|
describe Elasticsearch::Persistence::Repository::Find do
|
21
|
-
|
22
21
|
after do
|
23
22
|
begin; repository.delete_index!; rescue; end
|
24
23
|
end
|
@@ -28,9 +27,7 @@ describe Elasticsearch::Persistence::Repository::Find do
|
|
28
27
|
end
|
29
28
|
|
30
29
|
describe '#exists?' do
|
31
|
-
|
32
30
|
context 'when the document exists' do
|
33
|
-
|
34
31
|
let(:id) do
|
35
32
|
repository.save(a: 1)['_id']
|
36
33
|
end
|
@@ -41,30 +38,15 @@ describe Elasticsearch::Persistence::Repository::Find do
|
|
41
38
|
end
|
42
39
|
|
43
40
|
context 'when the document does not exist' do
|
44
|
-
|
45
41
|
it 'returns false' do
|
46
42
|
expect(repository.exists?('1')).to be(false)
|
47
43
|
end
|
48
44
|
end
|
49
|
-
|
50
|
-
context 'when options are provided' do
|
51
|
-
|
52
|
-
let(:id) do
|
53
|
-
repository.save(a: 1)['_id']
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'applies the options' do
|
57
|
-
expect(repository.exists?(id, type: 'other_type')).to be(false)
|
58
|
-
end
|
59
|
-
end
|
60
45
|
end
|
61
46
|
|
62
47
|
describe '#find' do
|
63
|
-
|
64
48
|
context 'when options are not provided' do
|
65
|
-
|
66
49
|
context 'when a single id is provided' do
|
67
|
-
|
68
50
|
let!(:id) do
|
69
51
|
repository.save(a: 1)['_id']
|
70
52
|
end
|
@@ -75,7 +57,6 @@ describe Elasticsearch::Persistence::Repository::Find do
|
|
75
57
|
end
|
76
58
|
|
77
59
|
context 'when an array of ids is provided' do
|
78
|
-
|
79
60
|
let!(:ids) do
|
80
61
|
3.times.collect do |i|
|
81
62
|
repository.save(a: i)['_id']
|
@@ -83,28 +64,30 @@ describe Elasticsearch::Persistence::Repository::Find do
|
|
83
64
|
end
|
84
65
|
|
85
66
|
it 'retrieves the documents' do
|
86
|
-
expect(repository.find(ids)).to eq([
|
87
|
-
|
88
|
-
|
67
|
+
expect(repository.find(ids)).to eq([
|
68
|
+
{ 'a' =>0 },
|
69
|
+
{ 'a' => 1 },
|
70
|
+
{ 'a' => 2 }
|
71
|
+
])
|
89
72
|
end
|
90
73
|
|
91
74
|
context 'when some documents are found and some are not' do
|
92
|
-
|
93
75
|
before do
|
94
76
|
ids[1] = 22
|
95
77
|
ids
|
96
78
|
end
|
97
79
|
|
98
80
|
it 'returns nil in the result list for the documents not found' do
|
99
|
-
expect(repository.find(ids)).to eq([
|
81
|
+
expect(repository.find(ids)).to eq([
|
82
|
+
{ 'a' =>0 },
|
100
83
|
nil,
|
101
|
-
{ 'a' => 2 }
|
84
|
+
{ 'a' => 2 }
|
85
|
+
])
|
102
86
|
end
|
103
87
|
end
|
104
88
|
end
|
105
89
|
|
106
90
|
context 'when multiple ids are provided' do
|
107
|
-
|
108
91
|
let!(:ids) do
|
109
92
|
3.times.collect do |i|
|
110
93
|
repository.save(a: i)['_id']
|
@@ -112,14 +95,15 @@ describe Elasticsearch::Persistence::Repository::Find do
|
|
112
95
|
end
|
113
96
|
|
114
97
|
it 'retrieves the documents' do
|
115
|
-
expect(repository.find(*ids)).to eq([
|
116
|
-
|
117
|
-
|
98
|
+
expect(repository.find(*ids)).to eq([
|
99
|
+
{ 'a' =>0 },
|
100
|
+
{ 'a' => 1 },
|
101
|
+
{ 'a' => 2 }
|
102
|
+
])
|
118
103
|
end
|
119
104
|
end
|
120
105
|
|
121
106
|
context 'when the document cannot be found' do
|
122
|
-
|
123
107
|
before do
|
124
108
|
begin; repository.create_index!; rescue; end
|
125
109
|
end
|
@@ -131,66 +115,5 @@ describe Elasticsearch::Persistence::Repository::Find do
|
|
131
115
|
end
|
132
116
|
end
|
133
117
|
end
|
134
|
-
|
135
|
-
context 'when options are provided' do
|
136
|
-
|
137
|
-
context 'when a single id is passed' do
|
138
|
-
|
139
|
-
let!(:id) do
|
140
|
-
repository.save(a: 1)['_id']
|
141
|
-
end
|
142
|
-
|
143
|
-
it 'applies the options' do
|
144
|
-
expect {
|
145
|
-
repository.find(id, type: 'none')
|
146
|
-
}.to raise_exception(Elasticsearch::Persistence::Repository::DocumentNotFound)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
context 'when an array of ids is passed' do
|
151
|
-
|
152
|
-
let!(:ids) do
|
153
|
-
3.times.collect do |i|
|
154
|
-
repository.save(a: i)['_id']
|
155
|
-
end
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'applies the options' do
|
159
|
-
expect(repository.find(ids, type: 'none')).to eq([nil, nil, nil])
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
context 'when multiple ids are passed' do
|
164
|
-
|
165
|
-
let!(:ids) do
|
166
|
-
3.times.collect do |i|
|
167
|
-
repository.save(a: i)['_id']
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'applies the options' do
|
172
|
-
expect(repository.find(*ids, type: 'none')).to eq([nil, nil, nil])
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
context 'when a document_type is defined on the class' do
|
178
|
-
|
179
|
-
let(:repository) do
|
180
|
-
MyTestRepository.new(document_type:'other_type', client: DEFAULT_CLIENT, index_name: 'test')
|
181
|
-
end
|
182
|
-
|
183
|
-
let!(:ids) do
|
184
|
-
3.times.collect do |i|
|
185
|
-
repository.save(a: i)['_id']
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'uses the document type in the query' do
|
190
|
-
expect(repository.find(ids)).to eq([{ 'a' =>0 },
|
191
|
-
{ 'a' => 1 },
|
192
|
-
{ 'a' => 2 }])
|
193
|
-
end
|
194
|
-
end
|
195
118
|
end
|
196
119
|
end
|
@@ -43,23 +43,24 @@ describe Elasticsearch::Persistence::Repository::Response::Results do
|
|
43
43
|
{ "took" => 2,
|
44
44
|
"timed_out" => false,
|
45
45
|
"_shards" => {"total" => 5, "successful" => 5, "failed" => 0},
|
46
|
-
"hits" =>
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
46
|
+
"hits" => {
|
47
|
+
"total" => 2,
|
48
|
+
"max_score" => 0.19,
|
49
|
+
"hits" => [
|
50
|
+
{
|
51
|
+
"_index" => "my_index",
|
52
|
+
"_id" => "1",
|
53
|
+
"_score" => 0.19,
|
54
|
+
"_source" => {"id" => 1, "title" => "Test 1"}
|
55
|
+
},
|
56
|
+
{
|
57
|
+
"_index" => "my_index",
|
58
|
+
"_id" => "2",
|
59
|
+
"_score" => 0.19,
|
60
|
+
"_source" => {"id" => 2, "title" => "Test 2"}
|
61
|
+
}
|
62
|
+
]
|
63
|
+
}
|
63
64
|
}
|
64
65
|
end
|
65
66
|
|
@@ -18,180 +18,54 @@
|
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
20
|
describe Elasticsearch::Persistence::Repository::Search do
|
21
|
-
|
22
21
|
after do
|
23
22
|
begin; repository.delete_index!; rescue; end
|
24
23
|
end
|
25
24
|
|
26
|
-
|
25
|
+
let(:repository) do
|
26
|
+
DEFAULT_REPOSITORY
|
27
|
+
end
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
describe '#search' do
|
30
|
+
before do
|
31
|
+
repository.save({ name: 'user' }, refresh: true)
|
30
32
|
end
|
31
33
|
|
32
|
-
context 'when
|
33
|
-
|
34
|
-
|
35
|
-
repository.save({ name: 'user' }, refresh: true)
|
36
|
-
end
|
37
|
-
|
38
|
-
context 'when a query definition is provided as a hash' do
|
39
|
-
|
40
|
-
it 'uses the default document type' do
|
41
|
-
expect(repository.search({ query: { match: { name: 'user' } } }).first).to eq('name' => 'user')
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
context 'when a query definition is provided as a string' do
|
46
|
-
|
47
|
-
it 'uses the default document type' do
|
48
|
-
expect(repository.search('user').first).to eq('name' => 'user')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'when the query definition is neither a String nor a Hash' do
|
53
|
-
|
54
|
-
it 'raises an ArgumentError' do
|
55
|
-
expect {
|
56
|
-
repository.search(1)
|
57
|
-
}.to raise_exception(ArgumentError)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'when options are provided' do
|
62
|
-
|
63
|
-
context 'when a query definition is provided as a hash' do
|
64
|
-
|
65
|
-
it 'uses the default document type' do
|
66
|
-
expect(repository.search({ query: { match: { name: 'user' } } }, type: 'other').first).to be_nil
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'when a query definition is provided as a string' do
|
71
|
-
|
72
|
-
it 'uses the default document type' do
|
73
|
-
expect(repository.search('user', type: 'other').first).to be_nil
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
context 'when the query definition is neither a String nor a Hash' do
|
78
|
-
|
79
|
-
it 'raises an ArgumentError' do
|
80
|
-
expect {
|
81
|
-
repository.search(1)
|
82
|
-
}.to raise_exception(ArgumentError)
|
83
|
-
end
|
84
|
-
end
|
34
|
+
context 'when a query definition is provided as a hash' do
|
35
|
+
it 'searches' do
|
36
|
+
expect(repository.search({ query: { match: { name: 'user' } } }).first).to eq('name' => 'user')
|
85
37
|
end
|
86
38
|
end
|
87
39
|
|
88
|
-
context 'when
|
89
|
-
|
90
|
-
|
91
|
-
MyTestRepository.new(document_type: 'other_note')
|
92
|
-
end
|
93
|
-
|
94
|
-
before do
|
95
|
-
repository.save({ name: 'user' }, refresh: true)
|
40
|
+
context 'when a query definition is provided as a string' do
|
41
|
+
it 'searches' do
|
42
|
+
expect(repository.search('user').first).to eq('name' => 'user')
|
96
43
|
end
|
44
|
+
end
|
97
45
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
expect(repository.search({ query: { match: { name: 'user' } } }, type: 'other').first).to be_nil
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
context 'when a query definition is provided as a string' do
|
108
|
-
|
109
|
-
it 'uses the options' do
|
110
|
-
expect(repository.search('user', type: 'other').first).to be_nil
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
context 'when the query definition is neither a String nor a Hash' do
|
115
|
-
|
116
|
-
it 'raises an ArgumentError' do
|
117
|
-
expect {
|
118
|
-
repository.search(1)
|
119
|
-
}.to raise_exception(ArgumentError)
|
120
|
-
end
|
121
|
-
end
|
46
|
+
context 'when the query definition is neither a String nor a Hash' do
|
47
|
+
it 'raises an ArgumentError' do
|
48
|
+
expect {
|
49
|
+
repository.search(1)
|
50
|
+
}.to raise_exception(ArgumentError)
|
122
51
|
end
|
123
52
|
end
|
124
53
|
end
|
125
54
|
|
126
55
|
describe '#count' do
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
let(:repository) do
|
131
|
-
DEFAULT_REPOSITORY
|
132
|
-
end
|
133
|
-
|
134
|
-
before do
|
135
|
-
repository.save({ name: 'user' }, refresh: true)
|
136
|
-
end
|
137
|
-
|
138
|
-
context 'when a query definition is provided as a hash' do
|
139
|
-
|
140
|
-
it 'uses the default document type' do
|
141
|
-
expect(repository.count({ query: { match: { name: 'user' } } })).to eq(1)
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
context 'when a query definition is provided as a string' do
|
146
|
-
|
147
|
-
it 'uses the default document type' do
|
148
|
-
expect(repository.count('user')).to eq(1)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
context 'when options are provided' do
|
153
|
-
|
154
|
-
context 'when a query definition is provided as a hash' do
|
155
|
-
|
156
|
-
it 'uses the options' do
|
157
|
-
expect(repository.count({ query: { match: { name: 'user' } } }, type: 'other')).to eq(0)
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
context 'when a query definition is provided as a string' do
|
162
|
-
|
163
|
-
it 'uses the options' do
|
164
|
-
expect(repository.count('user', type: 'other')).to eq(0)
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
56
|
+
before do
|
57
|
+
repository.save({ name: 'usuario' }, refresh: true)
|
168
58
|
end
|
169
59
|
|
170
|
-
context 'when
|
171
|
-
|
172
|
-
|
173
|
-
MyTestRepository.new(document_type: 'other_note')
|
60
|
+
context 'when a query definition is provided as a hash' do
|
61
|
+
it 'uses the default document type' do
|
62
|
+
expect(repository.count({ query: { match: { name: 'usuario' } } })).to eq(1)
|
174
63
|
end
|
64
|
+
end
|
175
65
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
context 'when options are provided' do
|
181
|
-
|
182
|
-
context 'when a query definition is provided as a hash' do
|
183
|
-
|
184
|
-
it 'uses the options' do
|
185
|
-
expect(repository.count({ query: { match: { name: 'user' } } }, type: 'other')).to eq(0)
|
186
|
-
end
|
187
|
-
end
|
188
|
-
|
189
|
-
context 'when a query definition is provided as a string' do
|
190
|
-
|
191
|
-
it 'uses the options' do
|
192
|
-
expect(repository.count('user', type: 'other')).to eq(0)
|
193
|
-
end
|
194
|
-
end
|
66
|
+
context 'when a query definition is provided as a string' do
|
67
|
+
it 'uses the default document type' do
|
68
|
+
expect(repository.count('usuario')).to eq(1)
|
195
69
|
end
|
196
70
|
end
|
197
71
|
end
|
@@ -18,7 +18,6 @@
|
|
18
18
|
require 'spec_helper'
|
19
19
|
|
20
20
|
describe Elasticsearch::Persistence::Repository::Store do
|
21
|
-
|
22
21
|
let(:repository) do
|
23
22
|
DEFAULT_REPOSITORY
|
24
23
|
end
|
@@ -28,7 +27,6 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
28
27
|
end
|
29
28
|
|
30
29
|
describe '#save' do
|
31
|
-
|
32
30
|
let(:document) do
|
33
31
|
{ a: 1 }
|
34
32
|
end
|
@@ -42,7 +40,6 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
42
40
|
end
|
43
41
|
|
44
42
|
context 'when the repository defines a custom serialize method' do
|
45
|
-
|
46
43
|
before do
|
47
44
|
class OtherNoteRepository
|
48
45
|
include Elasticsearch::Persistence::Repository
|
@@ -70,24 +67,9 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
70
67
|
expect(repository.find(response['_id'])).to eq('b' => 1)
|
71
68
|
end
|
72
69
|
end
|
73
|
-
|
74
|
-
context 'when options are provided' do
|
75
|
-
|
76
|
-
let!(:response) do
|
77
|
-
repository.save(document, type: 'other_note')
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'saves the document using the options' do
|
81
|
-
expect {
|
82
|
-
repository.find(response['_id'])
|
83
|
-
}.to raise_exception(Elasticsearch::Persistence::Repository::DocumentNotFound)
|
84
|
-
expect(repository.find(response['_id'], type: 'other_note')).to eq('a' => 1)
|
85
|
-
end
|
86
|
-
end
|
87
70
|
end
|
88
71
|
|
89
72
|
describe '#update' do
|
90
|
-
|
91
73
|
before(:all) do
|
92
74
|
class Note
|
93
75
|
def to_hash
|
@@ -103,15 +85,12 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
103
85
|
end
|
104
86
|
|
105
87
|
context 'when the document exists' do
|
106
|
-
|
107
88
|
let!(:id) do
|
108
89
|
repository.save(Note.new)['_id']
|
109
90
|
end
|
110
91
|
|
111
92
|
context 'when an id is provided' do
|
112
|
-
|
113
93
|
context 'when a doc is specified in the options' do
|
114
|
-
|
115
94
|
before do
|
116
95
|
repository.update(id, doc: { text: 'testing_2' })
|
117
96
|
end
|
@@ -122,7 +101,6 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
122
101
|
end
|
123
102
|
|
124
103
|
context 'when a script is specified in the options' do
|
125
|
-
|
126
104
|
before do
|
127
105
|
repository.update(id, script: { inline: 'ctx._source.views += 1' })
|
128
106
|
end
|
@@ -133,7 +111,6 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
133
111
|
end
|
134
112
|
|
135
113
|
context 'when params are specified in the options' do
|
136
|
-
|
137
114
|
before do
|
138
115
|
repository.update(id, script: { inline: 'ctx._source.views += params.count',
|
139
116
|
params: { count: 2 } })
|
@@ -145,7 +122,6 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
145
122
|
end
|
146
123
|
|
147
124
|
context 'when upsert is specified in the options' do
|
148
|
-
|
149
125
|
before do
|
150
126
|
repository.update(id, script: { inline: 'ctx._source.views += 1' },
|
151
127
|
upsert: { text: 'testing_2' })
|
@@ -157,7 +133,6 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
157
133
|
end
|
158
134
|
|
159
135
|
context 'when doc_as_upsert is specified in the options' do
|
160
|
-
|
161
136
|
before do
|
162
137
|
repository.update(id, doc: { text: 'testing_2' },
|
163
138
|
doc_as_upsert: true)
|
@@ -170,9 +145,7 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
170
145
|
end
|
171
146
|
|
172
147
|
context 'when a document is provided as the query criteria' do
|
173
|
-
|
174
148
|
context 'when no options are provided' do
|
175
|
-
|
176
149
|
before do
|
177
150
|
repository.update(id: id, text: 'testing_2')
|
178
151
|
end
|
@@ -183,9 +156,7 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
183
156
|
end
|
184
157
|
|
185
158
|
context 'when options are provided' do
|
186
|
-
|
187
159
|
context 'when a doc is specified in the options' do
|
188
|
-
|
189
160
|
before do
|
190
161
|
repository.update({ id: id, text: 'testing' }, doc: { text: 'testing_2' })
|
191
162
|
end
|
@@ -196,10 +167,11 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
196
167
|
end
|
197
168
|
|
198
169
|
context 'when a script is specified in the options' do
|
199
|
-
|
200
170
|
before do
|
201
|
-
repository.update(
|
202
|
-
|
171
|
+
repository.update(
|
172
|
+
{ id: id, text: 'testing' },
|
173
|
+
script: { inline: 'ctx._source.views += 1' }
|
174
|
+
)
|
203
175
|
end
|
204
176
|
|
205
177
|
it 'updates using the id and script from the options' do
|
@@ -208,7 +180,6 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
208
180
|
end
|
209
181
|
|
210
182
|
context 'when params are specified in the options' do
|
211
|
-
|
212
183
|
before do
|
213
184
|
repository.update({ id: id, text: 'testing' },
|
214
185
|
script: { inline: 'ctx._source.views += params.count',
|
@@ -221,7 +192,6 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
221
192
|
end
|
222
193
|
|
223
194
|
context 'when upsert is specified in the options' do
|
224
|
-
|
225
195
|
before do
|
226
196
|
repository.update({ id: id, text: 'testing_2' },
|
227
197
|
doc_as_upsert: true)
|
@@ -236,17 +206,14 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
236
206
|
end
|
237
207
|
|
238
208
|
context 'when the document does not exist' do
|
239
|
-
|
240
209
|
context 'when an id is provided 'do
|
241
|
-
|
242
210
|
it 'raises an exception' do
|
243
211
|
expect {
|
244
212
|
repository.update(1, doc: { text: 'testing_2' })
|
245
|
-
}.to raise_exception(
|
213
|
+
}.to raise_exception(Elastic::Transport::Transport::Errors::NotFound)
|
246
214
|
end
|
247
215
|
|
248
216
|
context 'when upsert is provided' do
|
249
|
-
|
250
217
|
before do
|
251
218
|
repository.update(1, doc: { text: 'testing' }, doc_as_upsert: true)
|
252
219
|
end
|
@@ -258,15 +225,13 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
258
225
|
end
|
259
226
|
|
260
227
|
context 'when a document is provided' do
|
261
|
-
|
262
228
|
it 'raises an exception' do
|
263
229
|
expect {
|
264
230
|
repository.update(id: 1, text: 'testing_2')
|
265
|
-
}.to raise_exception(
|
231
|
+
}.to raise_exception(Elastic::Transport::Transport::Errors::NotFound)
|
266
232
|
end
|
267
233
|
|
268
234
|
context 'when upsert is provided' do
|
269
|
-
|
270
235
|
before do
|
271
236
|
repository.update({ id: 1, text: 'testing' }, doc_as_upsert: true)
|
272
237
|
end
|
@@ -280,7 +245,6 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
280
245
|
end
|
281
246
|
|
282
247
|
describe '#delete' do
|
283
|
-
|
284
248
|
before(:all) do
|
285
249
|
class Note
|
286
250
|
def to_hash
|
@@ -296,13 +260,11 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
296
260
|
end
|
297
261
|
|
298
262
|
context 'when the document exists' do
|
299
|
-
|
300
263
|
let!(:id) do
|
301
264
|
repository.save(Note.new)['_id']
|
302
265
|
end
|
303
266
|
|
304
267
|
context 'an id is provided' do
|
305
|
-
|
306
268
|
before do
|
307
269
|
repository.delete(id)
|
308
270
|
end
|
@@ -315,7 +277,6 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
315
277
|
end
|
316
278
|
|
317
279
|
context 'when a document is provided' do
|
318
|
-
|
319
280
|
before do
|
320
281
|
repository.delete(id: id, text: 'testing')
|
321
282
|
end
|
@@ -329,15 +290,14 @@ describe Elasticsearch::Persistence::Repository::Store do
|
|
329
290
|
end
|
330
291
|
|
331
292
|
context 'when the document does not exist' do
|
332
|
-
|
333
293
|
before do
|
334
|
-
repository.create_index!
|
294
|
+
repository.create_index!
|
335
295
|
end
|
336
296
|
|
337
297
|
it 'raises an exception' do
|
338
298
|
expect {
|
339
299
|
repository.delete(1)
|
340
|
-
}.to raise_exception(
|
300
|
+
}.to raise_exception(Elastic::Transport::Transport::Errors::NotFound)
|
341
301
|
end
|
342
302
|
end
|
343
303
|
end
|