rummageable 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/rummageable.rb CHANGED
@@ -36,9 +36,9 @@ module Rummageable
36
36
  end
37
37
  end
38
38
 
39
- def delete(link)
39
+ def delete(id, type = 'edition')
40
40
  repeatedly do
41
- make_request(:delete, documents_url(link: link))
41
+ make_request(:delete, documents_url(id: id, type: type))
42
42
  end
43
43
  end
44
44
 
@@ -89,8 +89,11 @@ module Rummageable
89
89
  end
90
90
 
91
91
  def documents_url(options = {})
92
+ options[:id] ||= options[:link]
93
+
92
94
  parts = [@index_url, 'documents']
93
- parts << CGI.escape(options[:link]) if options[:link]
95
+ parts << CGI.escape(options[:type]) if options[:type]
96
+ parts << CGI.escape(options[:id]) if options[:id]
94
97
  parts.join('/')
95
98
  end
96
99
  end
@@ -1,3 +1,3 @@
1
1
  module Rummageable
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
data/test/delete_test.rb CHANGED
@@ -6,11 +6,11 @@ class DeleteTest < MiniTest::Unit::TestCase
6
6
  end
7
7
 
8
8
  def stub_successful_delete_request
9
- stub_request(:delete, link_url).to_return(status(200))
9
+ stub_request(:delete, documents_url(id: link, type: 'edition')).to_return(status(200))
10
10
  end
11
11
 
12
12
  def stub_one_failed_delete_request
13
- stub_request(:delete, link_url).
13
+ stub_request(:delete, documents_url(id: link, type: 'edition')).
14
14
  to_return(status(502)).times(1).then.to_return(status(200))
15
15
  end
16
16
 
@@ -18,7 +18,19 @@ class DeleteTest < MiniTest::Unit::TestCase
18
18
  stub_successful_delete_request
19
19
  index = Rummageable::Index.new(rummager_url, index_name)
20
20
  index.delete(link)
21
- assert_requested :delete, link_url do |request|
21
+ assert_requested :delete, documents_url(id: link, type: 'edition') do |request|
22
+ request.headers['Content-Type'] == 'application/json' &&
23
+ request.headers['Accept'] == 'application/json'
24
+ end
25
+ end
26
+
27
+ def test_should_delete_a_document_by_its_type_and_id
28
+ stub_request(:delete, documents_url(id: 'jobs-exact', type: 'best_bet')).to_return(status(200))
29
+
30
+ index = Rummageable::Index.new(rummager_url, index_name)
31
+ index.delete('jobs-exact', 'best_bet')
32
+
33
+ assert_requested :delete, documents_url(id: 'jobs-exact', type: 'best_bet') do |request|
22
34
  request.headers['Content-Type'] == 'application/json' &&
23
35
  request.headers['Accept'] == 'application/json'
24
36
  end
@@ -39,7 +51,7 @@ class DeleteTest < MiniTest::Unit::TestCase
39
51
  Rummageable::Index.any_instance.expects(:sleep).once
40
52
  index = Rummageable::Index.new(rummager_url, index_name)
41
53
  index.delete(link)
42
- assert_requested :delete, link_url, times: 2
54
+ assert_requested :delete, documents_url(id: link, type: 'edition'), times: 2
43
55
  end
44
56
 
45
57
  def test_delete_should_log_attempts_to_delete_documents_from_rummager
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rummageable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-03-21 00:00:00.000000000 Z
12
+ date: 2014-06-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -139,6 +139,22 @@ dependencies:
139
139
  - - '='
140
140
  - !ruby/object:Gem::Version
141
141
  version: 1.1.0
142
+ - !ruby/object:Gem::Dependency
143
+ name: debugger
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
142
158
  description: Mediator for apps that want their content to be in the search index
143
159
  email:
144
160
  executables: []
@@ -166,7 +182,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
166
182
  version: '0'
167
183
  segments:
168
184
  - 0
169
- hash: 1064356095318215702
185
+ hash: 4581626904595307404
170
186
  required_rubygems_version: !ruby/object:Gem::Requirement
171
187
  none: false
172
188
  requirements:
@@ -175,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
175
191
  version: '0'
176
192
  segments:
177
193
  - 0
178
- hash: 1064356095318215702
194
+ hash: 4581626904595307404
179
195
  requirements: []
180
196
  rubyforge_project:
181
197
  rubygems_version: 1.8.23