rhosync 2.0.0.beta1 → 2.0.0.beta2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +5 -20
- data/Rakefile +7 -5
- data/bench/lib/bench.rb +1 -2
- data/doc/protocol.html +154 -80
- data/lib/rhosync/client_sync.rb +7 -6
- data/lib/rhosync/console/app/routes/auth.rb +0 -2
- data/lib/rhosync/console/app/routes/client.rb +4 -5
- data/lib/rhosync/console/app/routes/docs.rb +25 -7
- data/lib/rhosync/console/app/routes/home.rb +1 -1
- data/lib/rhosync/console/app/routes/user.rb +6 -7
- data/lib/rhosync/console/app/views/doc.erb +3 -51
- data/lib/rhosync/console/app/views/docdata.erb +28 -0
- data/lib/rhosync/console/app/views/docs.erb +2 -1
- data/lib/rhosync/console/app/views/index.erb +1 -1
- data/lib/rhosync/console/app/views/select_doc.erb +19 -0
- data/lib/rhosync/console/app/views/upload_doc.erb +23 -0
- data/lib/rhosync/console/rhosync_api.rb +31 -30
- data/lib/rhosync/license.rb +1 -1
- data/lib/rhosync/tasks.rb +26 -12
- data/lib/rhosync/version.rb +1 -1
- data/spec/api/create_client_spec.rb +1 -1
- data/spec/api/create_user_spec.rb +1 -1
- data/spec/api/delete_client_spec.rb +1 -1
- data/spec/api/delete_user_spec.rb +2 -2
- data/spec/api/get_api_token_spec.rb +1 -2
- data/spec/api/get_source_params_spec.rb +1 -1
- data/spec/api/list_client_docs_spec.rb +1 -1
- data/spec/api/list_clients_spec.rb +2 -2
- data/spec/api/list_source_docs_spec.rb +2 -2
- data/spec/api/list_sources_spec.rb +4 -4
- data/spec/api/list_users_spec.rb +3 -3
- data/spec/api/set_refresh_time_spec.rb +8 -8
- data/spec/api/upload_file_spec.rb +2 -2
- data/spec/apps/rhotestapp/sources/simple_adapter.rb +3 -2
- data/spec/client_spec.rb +1 -1
- data/spec/client_sync_spec.rb +45 -17
- data/spec/doc/doc_spec.rb +21 -7
- data/spec/license_spec.rb +1 -1
- data/spec/perf/bulk_data_perf_spec.rb +0 -1
- data/spec/perf/perf_spec_helper.rb +2 -0
- data/spec/perf/store_perf_spec.rb +0 -1
- data/spec/server/server_spec.rb +8 -10
- metadata +39 -37
@@ -4,7 +4,7 @@ describe "RhosyncApiListUsers" do
|
|
4
4
|
it_should_behave_like "ApiHelper"
|
5
5
|
|
6
6
|
it "should list clients" do
|
7
|
-
post "/api/list_clients", {:
|
7
|
+
post "/api/list_clients", {:api_token => @api_token,
|
8
8
|
:user_id => @u_fields[:login]}
|
9
9
|
res = JSON.parse(last_response.body)
|
10
10
|
res.is_a?(Array).should == true
|
@@ -15,7 +15,7 @@ describe "RhosyncApiListUsers" do
|
|
15
15
|
|
16
16
|
it "should handle empty client's list" do
|
17
17
|
@u.clients.delete(@c.id)
|
18
|
-
post "/api/list_clients", {:
|
18
|
+
post "/api/list_clients", {:api_token => @api_token,
|
19
19
|
:user_id => @u_fields[:login]}
|
20
20
|
JSON.parse(last_response.body).should == []
|
21
21
|
end
|
@@ -4,7 +4,7 @@ describe "RhosyncApiListSourceDocs" do
|
|
4
4
|
it_should_behave_like "ApiHelper"
|
5
5
|
|
6
6
|
it "should list of shared source documents" do
|
7
|
-
post "/api/list_source_docs", {:
|
7
|
+
post "/api/list_source_docs", {:api_token => @api_token,
|
8
8
|
:source_id => "SimpleAdapter", :user_id => '*'}
|
9
9
|
JSON.parse(last_response.body).should == {
|
10
10
|
"md"=>"source:application:__shared__:SimpleAdapter:md",
|
@@ -14,7 +14,7 @@ describe "RhosyncApiListSourceDocs" do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should list user source documents" do
|
17
|
-
post "/api/list_source_docs", {:
|
17
|
+
post "/api/list_source_docs", {:api_token => @api_token,
|
18
18
|
:source_id => "SampleAdapter", :user_id => @u.id}
|
19
19
|
JSON.parse(last_response.body).should == {
|
20
20
|
"md"=>"source:application:testuser:SampleAdapter:md",
|
@@ -4,23 +4,23 @@ describe "RhosyncApiListSources" do
|
|
4
4
|
it_should_behave_like "ApiHelper"
|
5
5
|
|
6
6
|
it "should list all application sources" do
|
7
|
-
post "/api/list_sources", {:
|
7
|
+
post "/api/list_sources", {:api_token => @api_token}
|
8
8
|
JSON.parse(last_response.body).should == ["SimpleAdapter", "SampleAdapter"]
|
9
9
|
end
|
10
10
|
|
11
11
|
it "should list all application sources using partition_type param" do
|
12
12
|
post "/api/list_sources",
|
13
|
-
{:
|
13
|
+
{:api_token => @api_token, :partition_type => 'all'}
|
14
14
|
JSON.parse(last_response.body).should == ["SimpleAdapter", "SampleAdapter"]
|
15
15
|
end
|
16
16
|
|
17
17
|
it "should list app partition sources" do
|
18
|
-
post "/api/list_sources", {:
|
18
|
+
post "/api/list_sources", {:api_token => @api_token, :partition_type => :app}
|
19
19
|
JSON.parse(last_response.body).should == ["SimpleAdapter"]
|
20
20
|
end
|
21
21
|
|
22
22
|
it "should list user partition sources" do
|
23
|
-
post "/api/list_sources", {:
|
23
|
+
post "/api/list_sources", {:api_token => @api_token, :partition_type => :user}
|
24
24
|
JSON.parse(last_response.body).should == ["SampleAdapter"]
|
25
25
|
end
|
26
26
|
|
data/spec/api/list_users_spec.rb
CHANGED
@@ -4,17 +4,17 @@ describe "RhosyncApiListUsers" do
|
|
4
4
|
it_should_behave_like "ApiHelper"
|
5
5
|
|
6
6
|
it "should list users" do
|
7
|
-
params = {:
|
7
|
+
params = {:api_token => @api_token,
|
8
8
|
:attributes => {:login => 'testuser1', :password => 'testpass1'}}
|
9
9
|
post "/api/create_user", params
|
10
10
|
last_response.should be_ok
|
11
|
-
post "/api/list_users", {:
|
11
|
+
post "/api/list_users", {:api_token => @api_token}
|
12
12
|
JSON.parse(last_response.body).should == ["testuser", "testuser1"]
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should handle empty user's list" do
|
16
16
|
@a.delete; @a = App.create(@a_fields)
|
17
|
-
post "/api/list_users", {:
|
17
|
+
post "/api/list_users", {:api_token => @api_token}
|
18
18
|
JSON.parse(last_response.body).should == []
|
19
19
|
end
|
20
20
|
|
@@ -5,8 +5,8 @@ describe "RhosyncApiSetRefreshTime" do
|
|
5
5
|
|
6
6
|
it "should set refresh time to 100s from 'now'" do
|
7
7
|
before = Time.now.to_i
|
8
|
-
post "/api/set_refresh_time", :api_token => @api_token,
|
9
|
-
:
|
8
|
+
post "/api/set_refresh_time", :api_token => @api_token,
|
9
|
+
:source_name => @s_fields[:name], :user_name => @u_fields[:login], :refresh_time => 100
|
10
10
|
after = Time.now.to_i
|
11
11
|
last_response.should be_ok
|
12
12
|
@s = Source.load(@s.id,@s_params)
|
@@ -16,8 +16,8 @@ describe "RhosyncApiSetRefreshTime" do
|
|
16
16
|
|
17
17
|
it "should set refresh time to 'now' if no refresh_time provided" do
|
18
18
|
before = Time.now.to_i
|
19
|
-
post "/api/set_refresh_time", :api_token => @api_token,
|
20
|
-
:
|
19
|
+
post "/api/set_refresh_time", :api_token => @api_token,
|
20
|
+
:source_name => @s_fields[:name], :user_name => @u_fields[:login]
|
21
21
|
after = Time.now.to_i
|
22
22
|
last_response.should be_ok
|
23
23
|
@s = Source.load(@s.id,@s_params)
|
@@ -26,16 +26,16 @@ describe "RhosyncApiSetRefreshTime" do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should set poll interval" do
|
29
|
-
post "/api/set_refresh_time", :api_token => @api_token,
|
30
|
-
:
|
29
|
+
post "/api/set_refresh_time", :api_token => @api_token,
|
30
|
+
:source_name => @s_fields[:name], :user_name => @u_fields[:login], :poll_interval => 100
|
31
31
|
last_response.should be_ok
|
32
32
|
@s = Source.load(@s.id,@s_params)
|
33
33
|
@s.poll_interval.should == 100
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should should not set nil poll interval" do
|
37
|
-
post "/api/set_refresh_time", :api_token => @api_token,
|
38
|
-
:
|
37
|
+
post "/api/set_refresh_time", :api_token => @api_token,
|
38
|
+
:source_name => @s_fields[:name], :user_name => @u_fields[:login], :poll_interval => nil
|
39
39
|
last_response.should be_ok
|
40
40
|
@s = Source.load(@s.id,@s_params)
|
41
41
|
@s.poll_interval.should == 300
|
@@ -7,7 +7,7 @@ describe "RhosyncApiUploadFile" do
|
|
7
7
|
file = File.join(File.dirname(__FILE__),'..','testdata','compressed')
|
8
8
|
compress(file)
|
9
9
|
zipfile = File.join(file,"compressed.zip")
|
10
|
-
post "/api/upload_file", :
|
10
|
+
post "/api/upload_file", :api_token => @api_token,
|
11
11
|
:upload_file => Rack::Test::UploadedFile.new(zipfile, "application/octet-stream")
|
12
12
|
FileUtils.rm zipfile
|
13
13
|
expected = File.join(Rhosync.app_directory,'compress-data.txt')
|
@@ -18,7 +18,7 @@ describe "RhosyncApiUploadFile" do
|
|
18
18
|
|
19
19
|
it "should fail to upload a non-zip file" do
|
20
20
|
file = File.join(File.dirname(__FILE__),'..','testdata','compressed','compress-data.txt')
|
21
|
-
post "/api/upload_file", :
|
21
|
+
post "/api/upload_file", :api_token => @api_token,
|
22
22
|
:upload_file => Rack::Test::UploadedFile.new(file, "application/octet-stream")
|
23
23
|
last_response.status.should == 500
|
24
24
|
File.exists?(File.join(Rhosync.app_directory,'compress-data.txt')).should == false
|
@@ -16,10 +16,11 @@ class SimpleAdapter < SourceAdapter
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def search(params=nil,txt='')
|
19
|
-
params[:foo] = 'bar'
|
19
|
+
params[:foo] = 'bar' # this is for 'chaining' test
|
20
20
|
if params['search'] == 'bar'
|
21
21
|
@result = {'obj'=>{'foo'=>'bar'}}
|
22
|
-
|
22
|
+
# this is for 'chaining' test, addind 'iPhone' to trogger Sample adapter search result
|
23
|
+
params['name'] = 'iPhone'
|
23
24
|
end
|
24
25
|
@result
|
25
26
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -31,7 +31,7 @@ describe "Client" do
|
|
31
31
|
it "should raise exception if license seats exceeded" do
|
32
32
|
Store.put_value(License::CLIENT_DOCKEY,100)
|
33
33
|
lambda { Client.create(@c_fields,{}) }.should raise_error(
|
34
|
-
LicenseSeatsExceededException, "WARNING: Maximum # of
|
34
|
+
LicenseSeatsExceededException, "WARNING: Maximum # of devices exceeded for this license."
|
35
35
|
)
|
36
36
|
end
|
37
37
|
|
data/spec/client_sync_spec.rb
CHANGED
@@ -152,7 +152,7 @@ describe "ClientSync" do
|
|
152
152
|
set_state('test_db_storage' => @data)
|
153
153
|
res = @cs.search(params)
|
154
154
|
token = @c.get_value(:search_token)
|
155
|
-
res.should == [{'version'=>ClientSync::VERSION},{'
|
155
|
+
res.should == [{'version'=>ClientSync::VERSION},{'token'=>token},
|
156
156
|
{'source'=>@s.name},{'count'=>1},{'insert'=>{'1'=>@product1}}]
|
157
157
|
verify_result(@c.docname(:search) => {'1'=>@product1},
|
158
158
|
@c.docname(:search_errors) => {})
|
@@ -170,8 +170,8 @@ describe "ClientSync" do
|
|
170
170
|
@source = @s
|
171
171
|
set_state({@c.docname(:search) => {'1'=>@product1}})
|
172
172
|
token = compute_token @cs.client.docname(:search_token)
|
173
|
-
@cs.search({:resend => true,:
|
174
|
-
{'
|
173
|
+
@cs.search({:resend => true,:token => token}).should == [{'version'=>ClientSync::VERSION},
|
174
|
+
{'token'=>token},{'source'=>@s.name},{'count'=>1},{'insert'=>{'1'=>@product1}}]
|
175
175
|
verify_result(@c.docname(:search) => {'1'=>@product1},
|
176
176
|
@c.docname(:search_errors) => {},
|
177
177
|
@cs.client.docname(:search_token) => token)
|
@@ -181,42 +181,42 @@ describe "ClientSync" do
|
|
181
181
|
@source = @s
|
182
182
|
set_state({@c.docname(:search) => {'1'=>@product1}})
|
183
183
|
token = compute_token @cs.client.docname(:search_token)
|
184
|
-
@cs.search({:
|
184
|
+
@cs.search({:token => token}).should == []
|
185
185
|
verify_result(@c.docname(:search) => {},
|
186
186
|
@c.docname(:search_errors) => {},
|
187
187
|
@cs.client.docname(:search_token) => nil)
|
188
188
|
end
|
189
189
|
|
190
190
|
it "should handle search all" do
|
191
|
-
sources = ['SampleAdapter']
|
191
|
+
sources = [{'name'=>'SampleAdapter'}]
|
192
192
|
set_state('test_db_storage' => @data)
|
193
193
|
res = ClientSync.search_all(@c,{:sources => sources,:search => {'name' => 'iPhone'}})
|
194
194
|
token = Store.get_value(@cs.client.docname(:search_token))
|
195
|
-
res.should == [[{'version'=>ClientSync::VERSION},{'
|
196
|
-
{'source'=>sources[0]},{'count'=>1},{'insert'=>{'1'=>@product1}}]]
|
195
|
+
res.should == [[{'version'=>ClientSync::VERSION},{'token'=>token},
|
196
|
+
{'source'=>sources[0]['name']},{'count'=>1},{'insert'=>{'1'=>@product1}}]]
|
197
197
|
verify_result(@c.docname(:search) => {'1'=>@product1},
|
198
198
|
@c.docname(:search_errors) => {})
|
199
199
|
end
|
200
200
|
|
201
201
|
it "should handle search all error" do
|
202
|
-
sources = ['SampleAdapter']
|
202
|
+
sources = [{'name'=>'SampleAdapter'}]
|
203
203
|
msg = "Error during search"
|
204
204
|
error = set_test_data('test_db_storage',@data,msg,'search error')
|
205
205
|
res = ClientSync.search_all(@c,{:sources => sources,:search => {'name' => 'iPhone'}})
|
206
206
|
token = Store.get_value(@cs.client.docname(:search_token))
|
207
207
|
res.should == [[{'version'=>ClientSync::VERSION},
|
208
|
-
{'source'=>sources[0]},{'search-error'=>{'search-error'=>{'message'=>msg}}}]]
|
208
|
+
{'source'=>sources[0]['name']},{'search-error'=>{'search-error'=>{'message'=>msg}}}]]
|
209
209
|
verify_result(@c.docname(:search) => {},
|
210
210
|
@c.docname(:search_errors) => {'search-error'=>{'message'=>msg}})
|
211
211
|
end
|
212
212
|
|
213
213
|
it "should handle search all login error" do
|
214
214
|
@u.login = nil
|
215
|
-
sources = ['SampleAdapter']
|
215
|
+
sources = [{'name'=>'SampleAdapter'}]
|
216
216
|
msg = "Error logging in"
|
217
217
|
error = set_test_data('test_db_storage',@data,msg,'search error')
|
218
218
|
ClientSync.search_all(@c,{:sources => sources,:search => {'name' => 'iPhone'}}).should == [
|
219
|
-
[{'version'=>ClientSync::VERSION},{'source'=>sources[0]},
|
219
|
+
[{'version'=>ClientSync::VERSION},{'source'=>sources[0]['name']},
|
220
220
|
{'search-error'=>{'login-error'=>{'message'=>msg}}}]]
|
221
221
|
verify_result(@c.docname(:search) => {},
|
222
222
|
@c.docname(:search_errors) => {'login-error'=>{'message'=>msg}},
|
@@ -225,27 +225,55 @@ describe "ClientSync" do
|
|
225
225
|
|
226
226
|
it "should handle multiple source search all" do
|
227
227
|
set_test_data('test_db_storage',@data)
|
228
|
-
sources = ['
|
228
|
+
sources = [{'name'=>'SimpleAdapter'},{'name'=>'SampleAdapter'}]
|
229
229
|
res = ClientSync.search_all(@c,{:sources => sources,:search => {'name' => 'iPhone'}})
|
230
230
|
@c.source_name = 'SampleAdapter'
|
231
231
|
token = Store.get_value(@c.docname(:search_token))
|
232
|
-
res.should == [[{"version"=>ClientSync::VERSION},{'
|
233
|
-
{"source"=>"SampleAdapter"},{"count"=>1},{"insert"=>{'1'=>@product1}}],[]]
|
232
|
+
res.sort.should == [[{"version"=>ClientSync::VERSION},{'token'=>token},
|
233
|
+
{"source"=>"SampleAdapter"},{"count"=>1},{"insert"=>{'1'=>@product1}}],[]].sort
|
234
234
|
end
|
235
235
|
|
236
236
|
it "should handle search and accumulate params" do
|
237
237
|
set_test_data('test_db_storage',@data)
|
238
|
-
sources = ['SimpleAdapter','SampleAdapter']
|
238
|
+
sources = [{'name'=>'SimpleAdapter'},{'name'=>'SampleAdapter'}]
|
239
239
|
res = ClientSync.search_all(@c,{:sources => sources,:search => {'search'=>'bar'}})
|
240
240
|
@c.source_name = 'SimpleAdapter'
|
241
241
|
token = Store.get_value(@c.docname(:search_token))
|
242
242
|
@c.source_name = 'SampleAdapter'
|
243
243
|
token1 = Store.get_value(@c.docname(:search_token))
|
244
|
-
res.should == [[{"version"=>ClientSync::VERSION}, {'
|
244
|
+
res.should == [[{"version"=>ClientSync::VERSION}, {'token'=>token},
|
245
245
|
{"source"=>"SimpleAdapter"},{"count"=>1},{"insert"=>{'obj'=>{'foo'=>'bar'}}}],
|
246
|
-
[{"version"=>ClientSync::VERSION},{'
|
246
|
+
[{"version"=>ClientSync::VERSION},{'token'=>token1},{"source"=>"SampleAdapter"},
|
247
247
|
{"count"=>1}, {"insert"=>{'1'=>@product1}}]]
|
248
248
|
end
|
249
|
+
|
250
|
+
it "should handle search and ack of search results" do
|
251
|
+
set_test_data('test_db_storage',@data)
|
252
|
+
sources = [{'name'=>'SimpleAdapter'},{'name'=>'SampleAdapter'}]
|
253
|
+
ClientSync.search_all(@c,{:sources => sources,:search => {'search'=>'bar'}})
|
254
|
+
@c.source_name = 'SimpleAdapter'
|
255
|
+
token = Store.get_value(@c.docname(:search_token))
|
256
|
+
token.should_not be_nil
|
257
|
+
sources[0]['token'] = token
|
258
|
+
Store.get_data(@c.docname(:search)).should == {'obj'=>{'foo'=>'bar'}}
|
259
|
+
@c.source_name = 'SampleAdapter'
|
260
|
+
token1 = Store.get_value(@c.docname(:search_token))
|
261
|
+
token1.should_not be_nil
|
262
|
+
sources[1]['token'] = token1
|
263
|
+
Store.get_data(@c.docname(:search)).should == {'1'=>@product1}
|
264
|
+
# do ask on multiple sources
|
265
|
+
res = ClientSync.search_all(@c,{:sources => sources})
|
266
|
+
puts "res: #{res.inspect}"
|
267
|
+
@c.source_name = 'SimpleAdapter'
|
268
|
+
token = Store.get_value(@c.docname(:search_token))
|
269
|
+
token.should be_nil
|
270
|
+
Store.get_data(@c.docname(:search)).should == {}
|
271
|
+
@c.source_name = 'SampleAdapter'
|
272
|
+
token1 = Store.get_value(@c.docname(:search_token))
|
273
|
+
token1.should be_nil
|
274
|
+
Store.get_data(@c.docname(:search)).should == {}
|
275
|
+
end
|
276
|
+
|
249
277
|
end
|
250
278
|
|
251
279
|
describe "page methods" do
|
data/spec/doc/doc_spec.rb
CHANGED
@@ -7,14 +7,13 @@ require 'spec/interop/test'
|
|
7
7
|
require File.join(File.dirname(__FILE__),'..','..','lib','rhosync','server.rb')
|
8
8
|
|
9
9
|
describe "Protocol" do
|
10
|
+
it_should_behave_like "SpecBootstrapHelper"
|
10
11
|
it_should_behave_like "SourceAdapterHelper"
|
11
|
-
it_should_behave_like "TestappHelper"
|
12
12
|
|
13
13
|
include Rack::Test::Methods
|
14
14
|
include Rhosync
|
15
15
|
|
16
16
|
Rhosync.log_disabled = true
|
17
|
-
it_should_behave_like "SourceAdapterHelper"
|
18
17
|
|
19
18
|
before(:each) do
|
20
19
|
$rand_id ||= 0
|
@@ -231,7 +230,7 @@ eol
|
|
231
230
|
end
|
232
231
|
|
233
232
|
it "server send search results" do
|
234
|
-
sources = ['SampleAdapter']
|
233
|
+
sources = [{:name=>'SampleAdapter'}]
|
235
234
|
Store.put_data('test_db_storage',@data)
|
236
235
|
params = {:client_id => @c.id,:sources => sources,:search => {'name' => 'iPhone'},
|
237
236
|
:version => ClientSync::VERSION}
|
@@ -240,7 +239,7 @@ eol
|
|
240
239
|
end
|
241
240
|
|
242
241
|
it "should get search results with error" do
|
243
|
-
sources = ['SampleAdapter']
|
242
|
+
sources = [{:name=>'SampleAdapter'}]
|
244
243
|
msg = "Error during search"
|
245
244
|
error = set_test_data('test_db_storage',@data,msg,'search error')
|
246
245
|
params = {:client_id => @c.id,:sources => sources,:search => {'name' => 'iPhone'},
|
@@ -250,16 +249,31 @@ eol
|
|
250
249
|
end
|
251
250
|
|
252
251
|
it "should get multiple source search results" do
|
253
|
-
@s_fields[:name] = 'SimpleAdapter'
|
254
|
-
@s1 = Source.load(@s_fields,@s_params)
|
255
252
|
Store.put_data('test_db_storage',@data)
|
256
|
-
sources = ['SimpleAdapter','SampleAdapter']
|
253
|
+
sources = [{:name=>'SimpleAdapter'},{:name=>'SampleAdapter'}]
|
257
254
|
params = {:client_id => @c.id,:sources => sources,:search => {'search' => 'bar'},
|
258
255
|
:version => ClientSync::VERSION}
|
259
256
|
get "/#{@a.name}/search",params
|
260
257
|
@title,@description = 'multi source search', 'send multiple sources in search results'
|
261
258
|
end
|
262
259
|
|
260
|
+
it "should ack multiple sources search results" do
|
261
|
+
set_test_data('test_db_storage',@data)
|
262
|
+
sources = [{'name'=>'SimpleAdapter'},{'name'=>'SampleAdapter'}]
|
263
|
+
ClientSync.search_all(@c,{:sources => sources,:search => {'search'=>'bar'}})
|
264
|
+
@c.source_name = 'SimpleAdapter'
|
265
|
+
token = Store.get_value(@c.docname(:search_token))
|
266
|
+
sources[0]['token'] = token
|
267
|
+
Store.get_data(@c.docname(:search)).should == {'obj'=>{'foo'=>'bar'}}
|
268
|
+
@c.source_name = 'SampleAdapter'
|
269
|
+
token = Store.get_value(@c.docname(:search_token))
|
270
|
+
sources[1]['token'] = token
|
271
|
+
params = {:client_id => @c.id,:sources => sources,
|
272
|
+
:version => ClientSync::VERSION}
|
273
|
+
get "/#{@a.name}/search",params
|
274
|
+
@title,@description = 'multi source search ack', 'acknowledge search result on multiple sources'
|
275
|
+
end
|
276
|
+
|
263
277
|
private
|
264
278
|
def _print_markdown
|
265
279
|
$content_table << {$rand_id => "#{@title} - #{@description}"}
|
data/spec/license_spec.rb
CHANGED
@@ -29,7 +29,7 @@ describe "License" do
|
|
29
29
|
it "should raise exception when seats are exceeded" do
|
30
30
|
Store.put_value(License::CLIENT_DOCKEY,10)
|
31
31
|
lambda { License.new.check_and_use_seat }.should raise_error(
|
32
|
-
LicenseSeatsExceededException, "WARNING: Maximum # of
|
32
|
+
LicenseSeatsExceededException, "WARNING: Maximum # of devices exceeded for this license."
|
33
33
|
)
|
34
34
|
end
|
35
35
|
|
data/spec/server/server_spec.rb
CHANGED
@@ -223,7 +223,7 @@ describe "Server" do
|
|
223
223
|
end
|
224
224
|
|
225
225
|
it "should get search results" do
|
226
|
-
sources = ['SampleAdapter']
|
226
|
+
sources = [{:name=>'SampleAdapter'}]
|
227
227
|
cs = ClientSync.new(@s,@c,1)
|
228
228
|
Store.put_data('test_db_storage',@data)
|
229
229
|
params = {:client_id => @c.id,:sources => sources,:search => {'name' => 'iPhone'},
|
@@ -231,26 +231,24 @@ describe "Server" do
|
|
231
231
|
get "/application/search",params
|
232
232
|
last_response.content_type.should == 'application/json'
|
233
233
|
token = @c.get_value(:search_token)
|
234
|
-
JSON.parse(last_response.body).should == [[{'version'=>ClientSync::VERSION},{'
|
235
|
-
{'source'=>sources[0]},{'count'=>1},{'insert'=>{'1'=>@product1}}]]
|
234
|
+
JSON.parse(last_response.body).should == [[{'version'=>ClientSync::VERSION},{'token'=>token},
|
235
|
+
{'source'=>sources[0][:name]},{'count'=>1},{'insert'=>{'1'=>@product1}}]]
|
236
236
|
end
|
237
237
|
|
238
238
|
it "should get search results with error" do
|
239
|
-
sources = ['SampleAdapter']
|
239
|
+
sources = [{:name=>'SampleAdapter'}]
|
240
240
|
msg = "Error during search"
|
241
241
|
error = set_test_data('test_db_storage',@data,msg,'search error')
|
242
242
|
params = {:client_id => @c.id,:sources => sources,:search => {'name' => 'iPhone'},
|
243
243
|
:version => ClientSync::VERSION}
|
244
244
|
get "/application/search",params
|
245
245
|
JSON.parse(last_response.body).should == [[{'version'=>ClientSync::VERSION},
|
246
|
-
{'source'=>sources[0]},{'search-error'=>{'search-error'=>{'message'=>msg}}}]]
|
246
|
+
{'source'=>sources[0][:name]},{'search-error'=>{'search-error'=>{'message'=>msg}}}]]
|
247
247
|
end
|
248
248
|
|
249
249
|
it "should get multiple source search results" do
|
250
|
-
@s_fields[:name] = 'SimpleAdapter'
|
251
|
-
@s1 = Source.load(@s_fields,@s_params)
|
252
250
|
Store.put_data('test_db_storage',@data)
|
253
|
-
sources = ['SimpleAdapter','SampleAdapter']
|
251
|
+
sources = [{:name=>'SimpleAdapter'},{:name=>'SampleAdapter'}]
|
254
252
|
params = {:client_id => @c.id,:sources => sources,:search => {'search' => 'bar'},
|
255
253
|
:version => ClientSync::VERSION}
|
256
254
|
get "/application/search",params
|
@@ -259,9 +257,9 @@ describe "Server" do
|
|
259
257
|
@c.source_name = 'SampleAdapter'
|
260
258
|
token = @c.get_value(:search_token)
|
261
259
|
JSON.parse(last_response.body).should == [
|
262
|
-
[{"version"=>ClientSync::VERSION},{'
|
260
|
+
[{"version"=>ClientSync::VERSION},{'token'=>token1},{"source"=>"SimpleAdapter"},
|
263
261
|
{"count"=>1}, {"insert"=>{'obj'=>{'foo'=>'bar'}}}],
|
264
|
-
[{"version"=>ClientSync::VERSION},{'
|
262
|
+
[{"version"=>ClientSync::VERSION},{'token'=>token},{"source"=>"SampleAdapter"},
|
265
263
|
{"count"=>1}, {"insert"=>{'1'=>@product1}}]]
|
266
264
|
end
|
267
265
|
end
|
metadata
CHANGED
@@ -6,8 +6,8 @@ version: !ruby/object:Gem::Version
|
|
6
6
|
- 2
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.0.
|
9
|
+
- beta2
|
10
|
+
version: 2.0.0.beta2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rhomobile
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-05-07 00:00:00 -07:00
|
19
19
|
default_executable: rhosync
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -23,13 +23,13 @@ dependencies:
|
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- -
|
26
|
+
- - <=
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 1
|
30
|
+
- 4
|
30
31
|
- 2
|
31
|
-
|
32
|
-
version: 1.2.3
|
32
|
+
version: 1.4.2
|
33
33
|
type: :runtime
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -96,10 +96,10 @@ dependencies:
|
|
96
96
|
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
segments:
|
99
|
+
- 1
|
99
100
|
- 0
|
100
|
-
-
|
101
|
-
|
102
|
-
version: 0.2.0
|
101
|
+
- 7
|
102
|
+
version: 1.0.7
|
103
103
|
type: :runtime
|
104
104
|
version_requirements: *id006
|
105
105
|
- !ruby/object:Gem::Dependency
|
@@ -138,10 +138,9 @@ dependencies:
|
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
segments:
|
141
|
+
- 1
|
141
142
|
- 0
|
142
|
-
|
143
|
-
- 2
|
144
|
-
version: 0.9.2
|
143
|
+
version: "1.0"
|
145
144
|
type: :runtime
|
146
145
|
version_requirements: *id009
|
147
146
|
- !ruby/object:Gem::Dependency
|
@@ -159,21 +158,21 @@ dependencies:
|
|
159
158
|
type: :runtime
|
160
159
|
version_requirements: *id010
|
161
160
|
- !ruby/object:Gem::Dependency
|
162
|
-
name:
|
161
|
+
name: rake
|
163
162
|
prerelease: false
|
164
163
|
requirement: &id011 !ruby/object:Gem::Requirement
|
165
164
|
requirements:
|
166
165
|
- - ">="
|
167
166
|
- !ruby/object:Gem::Version
|
168
167
|
segments:
|
169
|
-
- 1
|
170
|
-
- 4
|
171
168
|
- 0
|
172
|
-
|
173
|
-
|
169
|
+
- 8
|
170
|
+
- 7
|
171
|
+
version: 0.8.7
|
172
|
+
type: :runtime
|
174
173
|
version_requirements: *id011
|
175
174
|
- !ruby/object:Gem::Dependency
|
176
|
-
name:
|
175
|
+
name: jeweler
|
177
176
|
prerelease: false
|
178
177
|
requirement: &id012 !ruby/object:Gem::Requirement
|
179
178
|
requirements:
|
@@ -181,27 +180,27 @@ dependencies:
|
|
181
180
|
- !ruby/object:Gem::Version
|
182
181
|
segments:
|
183
182
|
- 1
|
184
|
-
-
|
183
|
+
- 4
|
185
184
|
- 0
|
186
|
-
version: 1.
|
185
|
+
version: 1.4.0
|
187
186
|
type: :development
|
188
187
|
version_requirements: *id012
|
189
188
|
- !ruby/object:Gem::Dependency
|
190
|
-
name:
|
189
|
+
name: rspec
|
191
190
|
prerelease: false
|
192
191
|
requirement: &id013 !ruby/object:Gem::Requirement
|
193
192
|
requirements:
|
194
193
|
- - ">="
|
195
194
|
- !ruby/object:Gem::Version
|
196
195
|
segments:
|
196
|
+
- 1
|
197
|
+
- 3
|
197
198
|
- 0
|
198
|
-
|
199
|
-
- 8
|
200
|
-
version: 0.9.8
|
199
|
+
version: 1.3.0
|
201
200
|
type: :development
|
202
201
|
version_requirements: *id013
|
203
202
|
- !ruby/object:Gem::Dependency
|
204
|
-
name:
|
203
|
+
name: rcov
|
205
204
|
prerelease: false
|
206
205
|
requirement: &id014 !ruby/object:Gem::Requirement
|
207
206
|
requirements:
|
@@ -209,13 +208,13 @@ dependencies:
|
|
209
208
|
- !ruby/object:Gem::Version
|
210
209
|
segments:
|
211
210
|
- 0
|
212
|
-
-
|
213
|
-
-
|
214
|
-
version: 0.
|
211
|
+
- 9
|
212
|
+
- 8
|
213
|
+
version: 0.9.8
|
215
214
|
type: :development
|
216
215
|
version_requirements: *id014
|
217
216
|
- !ruby/object:Gem::Dependency
|
218
|
-
name:
|
217
|
+
name: faker
|
219
218
|
prerelease: false
|
220
219
|
requirement: &id015 !ruby/object:Gem::Requirement
|
221
220
|
requirements:
|
@@ -223,27 +222,27 @@ dependencies:
|
|
223
222
|
- !ruby/object:Gem::Version
|
224
223
|
segments:
|
225
224
|
- 0
|
226
|
-
- 5
|
227
225
|
- 3
|
228
|
-
|
226
|
+
- 1
|
227
|
+
version: 0.3.1
|
229
228
|
type: :development
|
230
229
|
version_requirements: *id015
|
231
230
|
- !ruby/object:Gem::Dependency
|
232
|
-
name:
|
231
|
+
name: rack-test
|
233
232
|
prerelease: false
|
234
233
|
requirement: &id016 !ruby/object:Gem::Requirement
|
235
234
|
requirements:
|
236
235
|
- - ">="
|
237
236
|
- !ruby/object:Gem::Version
|
238
237
|
segments:
|
239
|
-
- 1
|
240
|
-
- 0
|
241
238
|
- 0
|
242
|
-
|
239
|
+
- 5
|
240
|
+
- 3
|
241
|
+
version: 0.5.3
|
243
242
|
type: :development
|
244
243
|
version_requirements: *id016
|
245
|
-
description: Rhosync
|
246
|
-
email:
|
244
|
+
description: Rhosync library and related command-line utilities for using Rhosync
|
245
|
+
email: dev@rhomobile.com
|
247
246
|
executables:
|
248
247
|
- rhosync
|
249
248
|
extensions: []
|
@@ -343,12 +342,15 @@ files:
|
|
343
342
|
- lib/rhosync/console/app/routes/user.rb
|
344
343
|
- lib/rhosync/console/app/views/client.erb
|
345
344
|
- lib/rhosync/console/app/views/doc.erb
|
345
|
+
- lib/rhosync/console/app/views/docdata.erb
|
346
346
|
- lib/rhosync/console/app/views/docs.erb
|
347
347
|
- lib/rhosync/console/app/views/index.erb
|
348
348
|
- lib/rhosync/console/app/views/layout.erb
|
349
349
|
- lib/rhosync/console/app/views/newuser.erb
|
350
350
|
- lib/rhosync/console/app/views/ping.erb
|
351
351
|
- lib/rhosync/console/app/views/result.erb
|
352
|
+
- lib/rhosync/console/app/views/select_doc.erb
|
353
|
+
- lib/rhosync/console/app/views/upload_doc.erb
|
352
354
|
- lib/rhosync/console/app/views/user.erb
|
353
355
|
- lib/rhosync/console/app/views/users.erb
|
354
356
|
- lib/rhosync/console/rhosync_api.rb
|