rhoconnect 4.0.4 → 5.1.1
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.
- checksums.yaml +5 -13
- data/CHANGELOG.md +54 -5
- data/CREDITS +219 -219
- data/Gemfile +2 -2
- data/Gemfile.lock +68 -79
- data/Rakefile +1 -2
- data/bench/benchapp/spec/models/ruby/mock_adapter_spec.rb +17 -17
- data/bench/benchapp/spec/models/ruby/queue_mock_adapter_spec.rb +17 -17
- data/bench/benchapp/spec/spec_helper.rb +3 -3
- data/bench/blobapp/spec/models/ruby/blob_adapter_spec.rb +17 -17
- data/bench/blobapp/spec/spec_helper.rb +3 -3
- data/bench/lib/bench/runner.rb +1 -69
- data/bench/lib/bench.rb +18 -18
- data/bench/spec/mock_adapter_spec.rb +54 -55
- data/bench/spec/mock_client_spec.rb +47 -48
- data/bench/spec/result_spec.rb +41 -44
- data/bench/spec/utils_spec.rb +24 -25
- data/commands/generators/app.rb +7 -5
- data/commands/generators/controller.rb +7 -5
- data/commands/generators/model.rb +7 -5
- data/commands/generators/source.rb +7 -5
- data/commands/parser.rb +1 -1
- data/commands/redis/redis_download.rb +1 -1
- data/doc/async-jobs.txt +9 -9
- data/doc/supported-platforms.txt +0 -2
- data/generators/rhoconnect.rb +92 -212
- data/generators/templates/application/rcgemfile +3 -3
- data/generators/templates/application/spec/application_controller_spec.rb +14 -16
- data/generators/templates/application/spec/js_spec.rb +20 -20
- data/generators/templates/application/spec/spec_helper.rb +1 -1
- data/generators/templates/source/controllers/ruby/controller_spec.rb +18 -19
- data/generators/templates/source/models/ruby/model_spec.rb +17 -17
- data/install.sh +10 -21
- data/installer/unix-like/rho_connect_install_constants.rb +5 -5
- data/installer/unix-like/rho_connect_install_installers.rb +4 -4
- data/installer/utils/constants.rb +6 -6
- data/installer/utils/nix_install_test.rb +29 -29
- data/installer/utils/package_upload/repos.rake +16 -26
- data/js-adapters/node.rb +4 -4
- data/js-adapters/node_channel.rb +4 -8
- data/lib/rhoconnect/db_adapter.rb +13 -13
- data/lib/rhoconnect/handler/changes/engine.rb +1 -1
- data/lib/rhoconnect/jobs/bulk_data_job.rb +29 -29
- data/lib/rhoconnect/license.rb +7 -7
- data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +13 -13
- data/lib/rhoconnect/ping/apple.rb +4 -4
- data/lib/rhoconnect/server.rb +2 -2
- data/lib/rhoconnect/source.rb +2 -2
- data/lib/rhoconnect/store.rb +12 -6
- data/lib/rhoconnect/utilities.rb +2 -2
- data/lib/rhoconnect/version.rb +1 -1
- data/lib/rhoconnect.rb +6 -4
- data/rhoconnect.gemspec +5 -6
- data/spec/api/api_helper.rb +1 -1
- data/spec/api/app/fast_delete_spec.rb +22 -22
- data/spec/api/app/fast_insert_spec.rb +23 -23
- data/spec/api/app/fast_update_spec.rb +63 -63
- data/spec/api/app/push_deletes_spec.rb +11 -13
- data/spec/api/app/push_objects_spec.rb +39 -39
- data/spec/api/client/client_get_db_doc_spec.rb +29 -29
- data/spec/api/client/client_set_db_doc_spec.rb +11 -11
- data/spec/api/client/get_client_params_spec.rb +29 -29
- data/spec/api/client/list_client_docs_spec.rb +32 -34
- data/spec/api/client/reset_spec.rb +30 -30
- data/spec/api/readstate/set_refresh_time_spec.rb +43 -43
- data/spec/api/source/get_source_params_spec.rb +32 -34
- data/spec/api/source/list_sources_spec.rb +13 -13
- data/spec/api/source/update_source_params_spec.rb +19 -19
- data/spec/api/store/get_db_doc_spec.rb +27 -27
- data/spec/api/store/set_db_doc_spec.rb +38 -38
- data/spec/api/system/adapter_spec.rb +27 -29
- data/spec/api/system/get_license_info_spec.rb +11 -11
- data/spec/api/system/login_spec.rb +37 -37
- data/spec/api/system/reset_spec.rb +15 -15
- data/spec/api/system/stats_spec.rb +70 -71
- data/spec/api/user/create_user_spec.rb +37 -37
- data/spec/api/user/delete_client_spec.rb +7 -7
- data/spec/api/user/delete_user_spec.rb +62 -62
- data/spec/api/user/list_clients_spec.rb +24 -24
- data/spec/api/user/list_source_docs_spec.rb +29 -29
- data/spec/api/user/list_users_spec.rb +22 -22
- data/spec/api/user/ping_spec.rb +18 -18
- data/spec/api/user/show_user_spec.rb +10 -10
- data/spec/api/user/update_user_spec.rb +43 -43
- data/spec/api/user/user_get_db_doc_spec.rb +12 -12
- data/spec/api/user/user_set_db_doc_spec.rb +37 -37
- data/spec/api_token_spec.rb +8 -8
- data/spec/app_spec.rb +18 -17
- data/spec/apps/jstestapp/settings/settings.yml +2 -0
- data/spec/async_spec.rb +9 -11
- data/spec/bulk_data/bulk_data_spec.rb +120 -120
- data/spec/cli/cli_spec.rb +50 -53
- data/spec/client_spec.rb +105 -105
- data/spec/client_sync_spec.rb +529 -528
- data/spec/controllers/js_base_spec.rb +147 -141
- data/spec/doc/doc_spec.rb +51 -52
- data/spec/document_spec.rb +58 -58
- data/spec/dynamic_adapter_spec.rb +33 -36
- data/spec/generator/generator_spec.rb +76 -42
- data/spec/jobs/bulk_data_job_spec.rb +101 -102
- data/spec/jobs/ping_job_spec.rb +176 -177
- data/spec/jobs/source_job_spec.rb +24 -25
- data/spec/license_spec.rb +54 -55
- data/spec/models/js_base_spec.rb +121 -120
- data/spec/perf/bulk_data_perf_spec.rb +23 -24
- data/spec/perf/perf_spec_helper.rb +7 -7
- data/spec/perf/store_perf_spec.rb +139 -140
- data/spec/ping/apple_spec.rb +65 -65
- data/spec/ping/gcm_spec.rb +83 -84
- data/spec/ping/rhoconnect_push_spec.rb +52 -53
- data/spec/predefined_adapters/rho_internal_bench_adapter_controller_js_spec.rb +100 -101
- data/spec/predefined_adapters/rho_internal_js_bench_adapter_js_spec.rb +29 -31
- data/spec/read_state_spec.rb +24 -25
- data/spec/rhoconnect_spec.rb +7 -7
- data/spec/server/server_spec.rb +664 -662
- data/spec/server/stats_spec.rb +12 -12
- data/spec/source_adapter_spec.rb +124 -125
- data/spec/source_spec.rb +148 -149
- data/spec/source_sync_spec.rb +736 -736
- data/spec/spec_helper.rb +4 -5
- data/spec/stats/record_spec.rb +22 -21
- data/spec/store_orm_spec.rb +48 -48
- data/spec/store_spec.rb +428 -426
- data/spec/support/shared_examples.rb +5 -7
- data/spec/sync_states_spec.rb +67 -67
- data/spec/test_methods_spec.rb +121 -123
- data/spec/testdata/10000-data.txt +0 -0
- data/spec/testdata/5000-data.txt +0 -0
- data/spec/user_spec.rb +102 -102
- data/tasks/redis.rake +3 -3
- metadata +154 -195
- data/bench/benchapp/tmp/pids/passenger.9292.pid.lock +0 -0
- data/bench/benchapp/tmp/restart.txt +0 -0
- data/bench/blobapp/settings/license.key.bak +0 -2
- data/bench/blobapp/tmp/restart.txt +0 -0
- data/bench/lib/testdata/1-data.txt +0 -0
- data/bench/lib/testdata/10-data.txt +0 -0
- data/bench/lib/testdata/2-data.txt +0 -0
- data/bench/lib/testdata/250-data.txt +0 -0
- data/bench/lib/testdata/5-blob_data.txt +0 -0
- data/bench/lib/testdata/5-data.txt +0 -0
- data/bench/lib/testdata/50-data.txt +0 -0
- data/bench/lib/testdata/500-data.txt +0 -0
- data/doc/protocol.html +0 -1993
- data/spec/coverage/rcov/assets/0.2.3/jquery-1.3.2.min.js +0 -19
- data/spec/coverage/rcov/assets/0.2.3/jquery.tablesorter.min.js +0 -15
- data/spec/coverage/rcov/assets/0.2.3/print.css +0 -12
- data/spec/coverage/rcov/assets/0.2.3/rcov.js +0 -42
- data/spec/coverage/rcov/assets/0.2.3/screen.css +0 -270
- data/spec/coverage/rcov/index.html +0 -88
- data/spec/generator/generator_spec_helper.rb +0 -9
|
@@ -7,9 +7,9 @@ module Rhoconnect
|
|
|
7
7
|
base.extend Rhoconnect::Model::Helpers::FindDuplicatesOnUpdate::ClassMethods
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
def find_duplicates_on_update(options, invalid_meta, operation, operation_data, client_ids)
|
|
11
11
|
invalid_meta ||= {}
|
|
12
|
-
processed_ids = {}
|
|
12
|
+
# processed_ids = {}
|
|
13
13
|
processed_objs = {}
|
|
14
14
|
operation_data.each_with_index do |client_operation_data,index|
|
|
15
15
|
client_id = client_ids[index]
|
|
@@ -27,29 +27,29 @@ module Rhoconnect
|
|
|
27
27
|
processed_records = processed_source_objs[key]
|
|
28
28
|
processed_records.each do |processed_record|
|
|
29
29
|
master_obj = processed_record[:value]
|
|
30
|
-
master_client_id = processed_record[:client_id]
|
|
30
|
+
# master_client_id = processed_record[:client_id]
|
|
31
31
|
master_queue_index = processed_record[:queue_index].to_i
|
|
32
32
|
master_obj_index = processed_record[:index].to_i
|
|
33
33
|
|
|
34
34
|
if master_obj == objvalue
|
|
35
35
|
obj_not_a_duplicate = false
|
|
36
|
-
|
|
36
|
+
if options[:raise_error]
|
|
37
37
|
invalid_meta[index] ||= {}
|
|
38
38
|
invalid_meta[index][source_id] ||= {}
|
|
39
39
|
invalid_meta[index][source_id][objindex] ||= {}
|
|
40
40
|
invalid_meta[index][source_id][objindex][:error] = "Error during #{operation}: object confict detected"
|
|
41
|
-
|
|
41
|
+
else
|
|
42
42
|
invalid_meta[index] ||= {}
|
|
43
43
|
invalid_meta[index][source_id] ||= {}
|
|
44
44
|
invalid_meta[index][source_id][objindex] ||= {}
|
|
45
45
|
invalid_meta[index][source_id][objindex][:duplicate_of] = true
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
invalid_meta[master_queue_index] ||= {}
|
|
48
48
|
invalid_meta[master_queue_index][source_id] ||= {}
|
|
49
49
|
invalid_meta[master_queue_index][source_id][master_obj_index] ||= {}
|
|
50
50
|
invalid_meta[master_queue_index][source_id][master_obj_index][:duplicates] ||= []
|
|
51
|
-
invalid_meta[master_queue_index][source_id][master_obj_index][:duplicates] << {:client_id => client_id, :key => key, :value => objvalue}
|
|
52
|
-
|
|
51
|
+
invalid_meta[master_queue_index][source_id][master_obj_index][:duplicates] << {:client_id => client_id, :key => key, :value => objvalue}
|
|
52
|
+
end
|
|
53
53
|
break
|
|
54
54
|
end
|
|
55
55
|
end
|
|
@@ -62,15 +62,15 @@ module Rhoconnect
|
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
end
|
|
65
|
-
|
|
65
|
+
if options[:handler] and invalid_meta.size > 0
|
|
66
66
|
proc = bind_handler :find_duplicates_on_update, options[:handler]
|
|
67
67
|
invalid_meta = proc.call options, invalid_meta, operation, operation_data, client_ids
|
|
68
68
|
end
|
|
69
|
-
invalid_meta
|
|
70
|
-
|
|
69
|
+
invalid_meta
|
|
70
|
+
end
|
|
71
71
|
|
|
72
72
|
# methods that needs to be 'extended', not 'included'
|
|
73
|
-
|
|
73
|
+
module ClassMethods
|
|
74
74
|
def install_find_duplicates_on_update(options)
|
|
75
75
|
options ||= {}
|
|
76
76
|
options[:update] = true
|
|
@@ -78,7 +78,7 @@ module Rhoconnect
|
|
|
78
78
|
@validators[:find_duplicates_on_update] = options
|
|
79
79
|
options
|
|
80
80
|
end
|
|
81
|
-
|
|
81
|
+
end
|
|
82
82
|
end
|
|
83
83
|
end
|
|
84
84
|
end
|
|
@@ -9,10 +9,10 @@ module Rhoconnect
|
|
|
9
9
|
passphrase = settings[:iphonepassphrase]
|
|
10
10
|
host = settings[:iphoneserver]
|
|
11
11
|
port = settings[:iphoneport]
|
|
12
|
-
|
|
12
|
+
if(cert and host and port)
|
|
13
13
|
begin
|
|
14
14
|
ssl_ctx = OpenSSL::SSL::SSLContext.new
|
|
15
|
-
ssl_ctx.key = OpenSSL::PKey::RSA.new(cert, passphrase)
|
|
15
|
+
ssl_ctx.key = OpenSSL::PKey::RSA.new(cert, passphrase.to_s)
|
|
16
16
|
ssl_ctx.cert = OpenSSL::X509::Certificate.new(cert)
|
|
17
17
|
|
|
18
18
|
socket = TCPSocket.new(host, port)
|
|
@@ -23,10 +23,10 @@ module Rhoconnect
|
|
|
23
23
|
res = ssl_socket.write(apn_message(params))
|
|
24
24
|
ssl_socket.close
|
|
25
25
|
socket.close
|
|
26
|
-
|
|
26
|
+
rescue SocketError => error
|
|
27
27
|
log "Error while sending ping: #{error}"
|
|
28
28
|
raise error
|
|
29
|
-
|
|
29
|
+
end
|
|
30
30
|
else
|
|
31
31
|
log "Invalid APNS settings: ping is ignored."
|
|
32
32
|
log "cert_file: #{cert_file}, host: #{host}, port: #{port}"
|
data/lib/rhoconnect/server.rb
CHANGED
|
@@ -151,7 +151,7 @@ module Rhoconnect
|
|
|
151
151
|
return false if @dispatch_framework_initialized
|
|
152
152
|
|
|
153
153
|
@dispatch_framework_initialized ||=true
|
|
154
|
-
if RUBY_VERSION =~
|
|
154
|
+
if (RUBY_VERSION =~ /^1\.9\.\d/ || RUBY_VERSION =~ /^2\.\d+\.\d+/) and not defined?(JRUBY_VERSION)
|
|
155
155
|
begin
|
|
156
156
|
require 'rhoconnect/async'
|
|
157
157
|
register Rhoconnect::Synchrony
|
|
@@ -231,7 +231,7 @@ _INSTALL_ASYNC_GEMS
|
|
|
231
231
|
if rc_handler
|
|
232
232
|
rc_handler_method = "execute_#{rc_handler}_handler"
|
|
233
233
|
invoke_hook(:handler_installed, self, rc_handler, verb, route_url, options)
|
|
234
|
-
end
|
|
234
|
+
end
|
|
235
235
|
unless deprecated_route.nil?
|
|
236
236
|
deprecated_urls = deprecated_route[:url].is_a?(String) ? [deprecated_route[:url]] : deprecated_route[:url]
|
|
237
237
|
deprecated_urls.each do |deprecated_url|
|
data/lib/rhoconnect/source.rb
CHANGED
|
@@ -365,11 +365,11 @@ module Rhoconnect
|
|
|
365
365
|
return self.user_id if self.user_id == '*'
|
|
366
366
|
# default is user_id
|
|
367
367
|
pname = self.user_id
|
|
368
|
-
begin
|
|
368
|
+
begin
|
|
369
369
|
model_klass = Rhoconnect::Model::Base.load_source_model(self)
|
|
370
370
|
pname = model_klass ? model_klass.partition_name(self.user_id) : self.user_id
|
|
371
371
|
# eat the exception here
|
|
372
|
-
rescue Exception
|
|
372
|
+
rescue Exception #=> e
|
|
373
373
|
end
|
|
374
374
|
pname
|
|
375
375
|
end
|
data/lib/rhoconnect/store.rb
CHANGED
|
@@ -361,7 +361,7 @@ module Rhoconnect
|
|
|
361
361
|
|
|
362
362
|
collected_adds = {}
|
|
363
363
|
collected_rems = {}
|
|
364
|
-
my_bucket = nil
|
|
364
|
+
# my_bucket = nil
|
|
365
365
|
@db.pipelined do
|
|
366
366
|
data.each do |key,obj|
|
|
367
367
|
is_create = objs[key].nil?
|
|
@@ -688,7 +688,7 @@ module Rhoconnect
|
|
|
688
688
|
# ensure lock wasn't released between the setnx and get calls
|
|
689
689
|
if current_lock
|
|
690
690
|
current_lock_timeout = current_lock.to_i
|
|
691
|
-
|
|
691
|
+
if raise_on_expire or Rhoconnect.raise_on_expired_lock
|
|
692
692
|
if current_lock_timeout <= current_time
|
|
693
693
|
# lock expired before operation which set it up completed
|
|
694
694
|
# this process cannot continue without corrupting locked data
|
|
@@ -700,11 +700,11 @@ module Rhoconnect
|
|
|
700
700
|
# previous lock expired and we replaced it with our own
|
|
701
701
|
break
|
|
702
702
|
end
|
|
703
|
-
|
|
703
|
+
end
|
|
704
704
|
# lock was released between setnx and get - try to acquire it again
|
|
705
705
|
elsif @db.setnx(lock_key,ts)
|
|
706
706
|
break
|
|
707
|
-
|
|
707
|
+
end
|
|
708
708
|
sleep(1)
|
|
709
709
|
current_time = Time.now.to_i
|
|
710
710
|
else
|
|
@@ -885,8 +885,14 @@ module Rhoconnect
|
|
|
885
885
|
ConnectionPool::Wrapper.new(:size => Rhoconnect.connection_pool_size,
|
|
886
886
|
:timeout => Rhoconnect.connection_pool_timeout) do
|
|
887
887
|
host = '127.0.0.1' if host == 'localhost'
|
|
888
|
-
Redis.connect(
|
|
889
|
-
:
|
|
888
|
+
Redis.connect(
|
|
889
|
+
:thread_safe => true,
|
|
890
|
+
:host => host,
|
|
891
|
+
:port => port,
|
|
892
|
+
:db => db,
|
|
893
|
+
:password => password,
|
|
894
|
+
:timeout => Rhoconnect.redis_timeout
|
|
895
|
+
)
|
|
890
896
|
end
|
|
891
897
|
elsif server and (server.is_a?(Redis) or server.is_a?(ConnectionPool::Wrapper))
|
|
892
898
|
server
|
data/lib/rhoconnect/utilities.rb
CHANGED
data/lib/rhoconnect/version.rb
CHANGED
data/lib/rhoconnect.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'cgi'
|
|
|
3
3
|
require 'json'
|
|
4
4
|
require 'base64'
|
|
5
5
|
require 'securerandom'
|
|
6
|
-
require 'zip
|
|
6
|
+
require 'zip'
|
|
7
7
|
require 'yaml'
|
|
8
8
|
require 'rhoconnect/license'
|
|
9
9
|
require 'rhoconnect/version'
|
|
@@ -56,7 +56,8 @@ module Rhoconnect
|
|
|
56
56
|
:log_disabled, :license, :bulk_sync_poll_interval, :stats, :appserver, :api_token,
|
|
57
57
|
:raise_on_expired_lock, :lock_duration, :cookie_expire, :predefined_sources,
|
|
58
58
|
:connection_pool_size, :connection_pool_timeout, :redis_timeout, :store_key_ttl,
|
|
59
|
-
:disable_resque_console, :disable_rc_console, :use_node, :restart_node_on_error, :redis_url
|
|
59
|
+
:disable_resque_console, :disable_rc_console, :use_node, :restart_node_on_error, :redis_url,
|
|
60
|
+
:node_channel_timeout
|
|
60
61
|
end
|
|
61
62
|
|
|
62
63
|
# this mixin adds the controller into the Application's URL Map
|
|
@@ -123,6 +124,7 @@ module Rhoconnect
|
|
|
123
124
|
Rhoconnect.disable_resque_console ||= false
|
|
124
125
|
Rhoconnect.use_node = Rhoconnect.use_node.nil? ? true : Rhoconnect.use_node
|
|
125
126
|
Rhoconnect.restart_node_on_error ||= true if Rhoconnect.use_node
|
|
127
|
+
Rhoconnect.node_channel_timeout = get_setting(config, environment, :node_channel_timeout, 30)
|
|
126
128
|
if File.directory?(File.join(Rhoconnect.app_directory,'sources'))
|
|
127
129
|
check_and_add(File.join(Rhoconnect.app_directory,'sources'))
|
|
128
130
|
# post deprecation warning !!!
|
|
@@ -193,7 +195,7 @@ _MIGRATE_TO_NEW_RHOCONNECT
|
|
|
193
195
|
|
|
194
196
|
def start_nodejs_channels(opts = {})
|
|
195
197
|
Node.shell_node(opts)
|
|
196
|
-
NodeChannel.bootstrap if Node.started
|
|
198
|
+
NodeChannel.bootstrap(Rhoconnect.node_channel_timeout) if Node.started
|
|
197
199
|
end
|
|
198
200
|
|
|
199
201
|
# Generate admin user on first load
|
|
@@ -332,7 +334,7 @@ _MIGRATE_TO_NEW_RHOCONNECT
|
|
|
332
334
|
File.open(uploaded_file, 'wb') do |file|
|
|
333
335
|
file.write(params[:tempfile].read)
|
|
334
336
|
end
|
|
335
|
-
Zip::
|
|
337
|
+
Zip::File.open(uploaded_file) do |zip_file|
|
|
336
338
|
zip_file.each do |f|
|
|
337
339
|
f_path = File.join(file_dir,f.name)
|
|
338
340
|
FileUtils.mkdir_p(File.dirname(f_path))
|
data/rhoconnect.gemspec
CHANGED
|
@@ -41,14 +41,13 @@ Gem::Specification.new do |s|
|
|
|
41
41
|
|
|
42
42
|
s.add_dependency('bundler', '~> 1.0')
|
|
43
43
|
s.add_dependency('rack', '~> 1.5.2')
|
|
44
|
-
s.add_dependency('sinatra', '~> 1.
|
|
45
|
-
s.add_dependency('rake', '~> 10.
|
|
46
|
-
s.add_dependency('json', '~> 1.
|
|
47
|
-
s.add_dependency('rubyzip', '~>
|
|
48
|
-
s.add_dependency('connection_pool', '~> 1.
|
|
44
|
+
s.add_dependency('sinatra', '~> 1.4')
|
|
45
|
+
s.add_dependency('rake', '~> 10.4.0')
|
|
46
|
+
s.add_dependency('json', '~> 1.8')
|
|
47
|
+
s.add_dependency('rubyzip', '~> 1.1')
|
|
48
|
+
s.add_dependency('connection_pool', '~> 1.2.0')
|
|
49
49
|
s.add_dependency('redis', '>= 3.0.1')
|
|
50
50
|
s.add_dependency('resque', '>= 1.22.0')
|
|
51
51
|
s.add_dependency('rest-client', '~> 1.6.1')
|
|
52
|
-
s.add_dependency('templater', '~> 1.0.0')
|
|
53
52
|
s.add_dependency('thor', '~> 0.18.0')
|
|
54
53
|
end
|
data/spec/api/api_helper.rb
CHANGED
|
@@ -9,7 +9,7 @@ def compress(path)
|
|
|
9
9
|
path.sub!(%r[/$],'')
|
|
10
10
|
archive = File.join(path,File.basename(path))+'.zip'
|
|
11
11
|
FileUtils.rm archive, :force=>true
|
|
12
|
-
Zip::
|
|
12
|
+
Zip::File.open(archive, 'w') do |zipfile|
|
|
13
13
|
Dir["#{path}/**/**"].reject{|f|f==archive}.each do |file|
|
|
14
14
|
zipfile.add(file.sub(path+'/',''),file)
|
|
15
15
|
end
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiFastDelete" do
|
|
4
|
-
|
|
5
|
-
it "should delete an object from rhoconnect's :md" do
|
|
6
|
-
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
7
|
-
@s = Source.load(@s_fields[:name],@s_params)
|
|
8
|
-
set_doc_state(@s, {:md => data, :md_size => '3'})
|
|
9
|
-
post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_delete",
|
|
10
|
-
{:user_id => @u.id, :data => {'3' => @product3}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
11
|
-
last_response.should be_ok
|
|
12
|
-
data.delete('3')
|
|
13
|
-
verify_doc_result(@s, {:md => data, :md_size =>'2'})
|
|
14
|
-
end
|
|
4
|
+
include_examples "ApiHelper"
|
|
15
5
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
6
|
+
it "should delete an object from rhoconnect's :md" do
|
|
7
|
+
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
8
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
|
9
|
+
set_doc_state(@s, {:md => data, :md_size => '3'})
|
|
10
|
+
post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_delete",
|
|
11
|
+
{:user_id => @u.id, :data => {'3' => @product3}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
12
|
+
last_response.should be_ok
|
|
13
|
+
data.delete('3')
|
|
14
|
+
verify_doc_result(@s, {:md => data, :md_size =>'2'})
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should not properly delete the object if fast_delete is called without all the attributes (because fast_delete doesn't ensure any data integrity)" do
|
|
18
|
+
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
19
|
+
delete_data = {'3' => {'price' => '1.99'}}
|
|
20
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
|
21
|
+
set_doc_state(@s, {:md => data, :md_size => '3'})
|
|
22
|
+
post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_delete",
|
|
23
|
+
{:user_id => @u.id, :data => delete_data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
24
|
+
last_response.should be_ok
|
|
25
|
+
verify_doc_result(@s, {:md => data, :md_size=>'2'})
|
|
26
|
+
end
|
|
27
27
|
end
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiFastInsert" do
|
|
4
|
-
|
|
5
|
-
it "should append new objects to rhoconnect's :md" do
|
|
6
|
-
data = {'1' => @product1, '2' => @product2}
|
|
7
|
-
@s = Source.load(@s_fields[:name],@s_params)
|
|
8
|
-
set_doc_state(@s, {:md => data, :md_size => '2'})
|
|
9
|
-
post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_insert",
|
|
10
|
-
{:user_id => @u.id, :data => {'3' => @product3}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
11
|
-
last_response.should be_ok
|
|
12
|
-
data.merge!({'3' => @product3})
|
|
13
|
-
verify_doc_result(@s, {:md => data, :md_size=>'3'})
|
|
14
|
-
end
|
|
4
|
+
include_examples "ApiHelper"
|
|
15
5
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
6
|
+
it "should append new objects to rhoconnect's :md" do
|
|
7
|
+
data = {'1' => @product1, '2' => @product2}
|
|
8
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
|
9
|
+
set_doc_state(@s, {:md => data, :md_size => '2'})
|
|
10
|
+
post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_insert",
|
|
11
|
+
{:user_id => @u.id, :data => {'3' => @product3}}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
12
|
+
last_response.should be_ok
|
|
13
|
+
data.merge!({'3' => @product3})
|
|
14
|
+
verify_doc_result(@s, {:md => data, :md_size=>'3'})
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should incorrectly append data to existing object (because fast_insert doesn't ensure any data integrity)" do
|
|
18
|
+
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
19
|
+
incorrect_insert = {'3' => {'price' => '1.99', 'new_field' => 'value'}}
|
|
20
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
|
21
|
+
set_doc_state(@s, {:md => data, :md_size => '3'})
|
|
22
|
+
post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_insert",
|
|
23
|
+
{:user_id => @u.id, :data => incorrect_insert}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
24
|
+
last_response.should be_ok
|
|
25
|
+
data['3'].merge!(incorrect_insert['3'])
|
|
26
|
+
verify_doc_result(@s, :md_size=>'4')
|
|
27
|
+
end
|
|
28
28
|
end
|
|
@@ -1,67 +1,67 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiFastUpdate" do
|
|
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
|
-
end
|
|
4
|
+
include_examples "ApiHelper"
|
|
5
|
+
|
|
6
|
+
it "should update an attribute and add new one for an object in rhoconnect's :md" do
|
|
7
|
+
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
8
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
|
9
|
+
set_doc_state(@s, {:md => data, :md_size => '3'})
|
|
10
|
+
|
|
11
|
+
orig_obj_attrs = {'3' => {'price' => @product3['price']}}
|
|
12
|
+
new_obj_attrs = {'3' => {'price' => '0.99', 'new_attr' => 'new_value'}}
|
|
13
|
+
|
|
14
|
+
post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_update",
|
|
15
|
+
{:user_id => @u.id, :delete_data => orig_obj_attrs, :data => new_obj_attrs}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
16
|
+
last_response.should be_ok
|
|
17
|
+
data['3'].merge!(new_obj_attrs['3'])
|
|
18
|
+
verify_doc_result(@s, {:md => data, :md_size=>'3'})
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "should update an attribute and add new one for an object in rhoconnect's :md using old route with deprecation warning" do
|
|
22
|
+
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
23
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
|
24
|
+
set_doc_state(@s, {:md => data, :md_size => '3'})
|
|
25
|
+
|
|
26
|
+
orig_obj_attrs = {'3' => {'price' => @product3['price']}}
|
|
27
|
+
new_obj_attrs = {'3' => {'price' => '0.99', 'new_attr' => 'new_value'}}
|
|
28
|
+
|
|
29
|
+
post "/api/source/fast_update",
|
|
30
|
+
{:user_id => @u.id, :source_id => @s_fields[:name], :delete_data => orig_obj_attrs, :data => new_obj_attrs}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
31
|
+
last_response.should be_ok
|
|
32
|
+
last_response.headers["Warning"].index('deprecated').should_not == nil
|
|
33
|
+
data['3'].merge!(new_obj_attrs['3'])
|
|
34
|
+
verify_doc_result(@s, {:md => data, :md_size=>'3'})
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it "should update one attr, add one attr, and remove one attr for an object in rhoconnect's :md" do
|
|
38
|
+
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
39
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
|
40
|
+
set_doc_state(@s, {:md => data, :md_size => '3'})
|
|
41
|
+
|
|
42
|
+
orig_obj_attrs = {'3' => {'name' => @product3['name'], 'price' => @product3['price']}}
|
|
43
|
+
new_obj_attrs = {'3' => {'price' => '0.99', 'new_attr' => 'new_value'}}
|
|
44
|
+
|
|
45
|
+
post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_update",
|
|
46
|
+
{:user_id => @u.id, :delete_data => orig_obj_attrs, :data => new_obj_attrs}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
47
|
+
last_response.should be_ok
|
|
48
|
+
data['3'].delete('name')
|
|
49
|
+
data['3'].merge!(new_obj_attrs['3'])
|
|
50
|
+
verify_doc_result(@s, {:md => data, :md_size=>'3'})
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "should remove all attributes , and properly adjust md_size" do
|
|
54
|
+
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
55
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
|
56
|
+
set_doc_state(@s, {:md => data, :md_size => '3'})
|
|
57
|
+
|
|
58
|
+
orig_obj_attrs = {'3' => @product3}
|
|
59
|
+
new_obj_attrs = {}
|
|
60
|
+
|
|
61
|
+
post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/fast_update",
|
|
62
|
+
{:user_id => @u.id, :delete_data => orig_obj_attrs, :data => new_obj_attrs}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
63
|
+
last_response.should be_ok
|
|
64
|
+
data.delete('3')
|
|
65
|
+
verify_doc_result(@s, {:md => data, :md_size=>'2'})
|
|
66
|
+
end
|
|
67
67
|
end
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
require File.join(File.dirname(__FILE__),'..','api_helper')
|
|
2
2
|
|
|
3
3
|
describe "RhoconnectApiPushDeletes" do
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
|
|
4
|
+
include_examples "ApiHelper"
|
|
5
|
+
|
|
6
|
+
it "should delete object from :md" do
|
|
7
|
+
data = {'1' => @product1, '2' => @product2, '3' => @product3}
|
|
8
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
|
9
|
+
set_doc_state(@s, {:md => data, :md_size => '3'})
|
|
10
|
+
data.delete('2')
|
|
11
|
+
post "/app/#{Rhoconnect::API_VERSION}/#{@s_fields[:name]}/push_deletes",
|
|
12
|
+
{:user_id => @u.id, :objects => ['2']}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
|
|
13
|
+
last_response.should be_ok
|
|
14
|
+
verify_doc_result(@s, {:md => data, :md_size=>'2'})
|
|
17
15
|
end
|
|
18
16
|
end
|