rhoconnect 4.0.0.beta.12 → 4.0.0.beta.24
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/CHANGELOG.md +34 -0
- data/Gemfile +5 -8
- data/Gemfile.lock +34 -32
- data/Rakefile +2 -12
- data/bench/run_bench.sh +1 -1
- data/bench/spec/bench_spec_helper.rb +3 -5
- data/bin/rhoconnect +20 -13
- data/commands/dtach/dtach_install.rb +3 -3
- data/commands/generators/update.rb +1 -0
- data/commands/parser.rb +180 -0
- data/commands/rhoconnect/config.rb +8 -4
- data/commands/rhoconnect/get_token.rb +3 -1
- data/commands/rhoconnect/routes.rb +34 -0
- data/commands/rhoconnect/secret.rb +1 -1
- data/commands/rhoconnect/set_admin_password.rb +2 -1
- data/commands/rhoconnect/startbg.rb +4 -4
- data/commands/rhoconnect/stop.rb +2 -2
- data/commands/rhoconnect_console/console.rb +6 -6
- data/commands/rhoconnect_spec/spec.rb +2 -1
- data/commands/rhoconnect_war/war.rb +1 -0
- data/commands/utilities/redis_runner.rb +2 -2
- data/doc/data-partitioning.txt +20 -7
- data/doc/extending-rhoconnect-server.txt +36 -7
- data/doc/push-client-setup-rps.txt +3 -3
- data/doc/source-adapters-js.txt +41 -4
- data/doc/source-adapters.txt +3 -0
- data/generators/templates/application/rcgemfile +1 -5
- data/generators/templates/application/spec/spec_helper.rb +0 -9
- data/generators/templates/source/models/js/model.js +8 -0
- data/generators/templates/source/models/ruby/model.rb +5 -11
- data/install.sh +2 -2
- data/installer/unix-like/rho_connect_install_constants.rb +3 -3
- data/installer/utils/delete_from_s3.rb +3 -6
- data/installer/utils/download_from_s3.rb +5 -9
- data/installer/utils/verify_checksum.rb +16 -11
- data/js-adapters/ballroom.js +9 -0
- data/js-adapters/exceptions.js +60 -0
- data/js-adapters/node.rb +14 -5
- data/js-adapters/node_channel.rb +68 -48
- data/js-adapters/rhoconnect_helpers.js +8 -2
- data/js-adapters/router.js +16 -14
- data/lib/rhoconnect.rb +5 -5
- data/lib/rhoconnect/client.rb +2 -2
- data/lib/rhoconnect/condition/add_parameter.rb +21 -0
- data/lib/rhoconnect/controller/clients_controller.rb +1 -1
- data/lib/rhoconnect/controller/js_base.rb +1 -2
- data/lib/rhoconnect/controller/system_controller.rb +33 -10
- data/lib/rhoconnect/db_adapter.rb +1 -1
- data/lib/rhoconnect/document.rb +11 -3
- data/lib/rhoconnect/handler/changes.rb +20 -19
- data/lib/rhoconnect/handler/changes/engine.rb +48 -25
- data/lib/rhoconnect/handler/changes/hooks.rb +36 -0
- data/lib/rhoconnect/handler/changes/runner.rb +12 -2
- data/lib/rhoconnect/handler/helpers.rb +4 -4
- data/lib/rhoconnect/jobs/source_job.rb +1 -1
- data/lib/rhoconnect/model/base.rb +32 -8
- data/lib/rhoconnect/model/helpers.rb +15 -0
- data/lib/rhoconnect/model/helpers/find_duplicates_on_update.rb +85 -0
- data/lib/rhoconnect/model/js_base.rb +23 -28
- data/lib/rhoconnect/server.rb +23 -18
- data/lib/rhoconnect/source.rb +10 -17
- data/lib/rhoconnect/store.rb +36 -57
- data/lib/rhoconnect/test_methods.rb +5 -4
- data/lib/rhoconnect/utilities.rb +7 -5
- data/lib/rhoconnect/version.rb +2 -2
- data/lib/rhoconnect/web-console/server.rb +17 -16
- data/rhoconnect.gemspec +23 -24
- data/spec/apps/rhotestapp/controllers/js/js_sample_controller.js +4 -0
- data/spec/apps/rhotestapp/models/js/js_sample.js +36 -0
- data/spec/apps/rhotestapp/models/ruby/sample_adapter.rb +34 -19
- data/spec/async_spec.rb +1 -1
- data/spec/cli/cli_spec.rb +69 -31
- data/spec/client_sync_spec.rb +30 -13
- data/spec/controllers/js_base_spec.rb +10 -4
- data/spec/jobs/source_job_spec.rb +1 -1
- data/spec/models/{js_model_spec.rb → js_base_spec.rb} +63 -13
- data/spec/server/server_spec.rb +20 -0
- data/spec/server/stats_spec.rb +7 -17
- data/spec/source_adapter_spec.rb +6 -0
- data/spec/source_sync_spec.rb +219 -54
- data/spec/spec_helper.rb +8 -13
- data/spec/store_spec.rb +6 -4
- data/spec/test_methods_spec.rb +4 -4
- metadata +14 -27
- data/commands/execute.rb +0 -48
- data/commands/utilities/utilities.rb +0 -6
- data/generators/templates/application/controllers/application_controller.rb +0 -17
- data/lib/rhoconnect/js_adapter.rb +0 -79
@@ -25,29 +25,38 @@ class SampleAdapter < SourceAdapter
|
|
25
25
|
super
|
26
26
|
end
|
27
27
|
|
28
|
-
def validate(operation,
|
28
|
+
def validate(operation,operation_data,client_ids)
|
29
29
|
invalid_meta = {}
|
30
30
|
used_ids = {}
|
31
|
-
|
31
|
+
operation_data.each_with_index do |client_operation_data,index|
|
32
32
|
client_id = client_ids[index]
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
33
|
+
client_operation_data.each do |source_operation_entry|
|
34
|
+
source_id = source_operation_entry[0]
|
35
|
+
list_of_objs = source_operation_entry[1]
|
36
|
+
list_of_objs.each_with_index do |obj_entry, objindex|
|
37
|
+
key = obj_entry[0]
|
38
|
+
objvalue = obj_entry[1]
|
39
|
+
if objvalue['force_duplicate_error'] == '1'
|
40
|
+
invalid_meta[index] ||= {}
|
41
|
+
invalid_meta[index][source_id] ||= {}
|
42
|
+
invalid_meta[index][source_id][objindex] ||= {}
|
43
|
+
invalid_meta[index][source_id][objindex][:error] = "Error during #{operation}: object confict detected"
|
44
|
+
end
|
45
|
+
if objvalue['duplicate_of_cid']
|
46
|
+
invalid_meta[index] ||= {}
|
47
|
+
invalid_meta[index][source_id] ||= {}
|
48
|
+
invalid_meta[index][source_id][objindex] ||= {}
|
49
|
+
invalid_meta[index][source_id][objindex][:duplicate_of] = true
|
50
|
+
master_client_id = objvalue['duplicate_of_cid']
|
51
|
+
master_objindex = objvalue['duplicate_of_entry_index'].to_i
|
52
|
+
master_index = objvalue['duplicate_of_queue_index'].to_i
|
46
53
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
54
|
+
invalid_meta[master_index] ||= {}
|
55
|
+
invalid_meta[master_index][source_id] ||= {}
|
56
|
+
invalid_meta[master_index][source_id][master_objindex] ||= {}
|
57
|
+
invalid_meta[master_index][source_id][master_objindex][:duplicates] ||= []
|
58
|
+
invalid_meta[master_index][source_id][master_objindex][:duplicates] << {:client_id => client_id, :key => key, :value => objvalue}
|
59
|
+
end
|
51
60
|
end
|
52
61
|
end
|
53
62
|
end
|
@@ -72,6 +81,12 @@ class SampleAdapter < SourceAdapter
|
|
72
81
|
raise SourceAdapterServerErrorException.new("Error delete record") if delete_hash['id'] == ERROR
|
73
82
|
Store.put_data('test_delete_storage',{delete_hash['id']=>delete_hash},true)
|
74
83
|
end
|
84
|
+
|
85
|
+
# This is not correect (tempfile should not be used)
|
86
|
+
# but - for specs - it is sufficient
|
87
|
+
def store_blob(obj,field_name,blob)
|
88
|
+
blob[:tempfile].path if blob[:tempfile]
|
89
|
+
end
|
75
90
|
|
76
91
|
def logoff
|
77
92
|
@result = Store.get_data('test_db_storage')
|
data/spec/async_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'api','api_helper')
|
2
2
|
|
3
3
|
# these specs are executed only with Async support
|
4
|
-
if
|
4
|
+
if not defined?(JRUBY_VERSION)
|
5
5
|
describe "BasicEventMachineTest with Threads" do
|
6
6
|
it_should_behave_like "ApiHelper" do
|
7
7
|
it "should run EventMachine gracefully and schedule callback execution in thread" do
|
data/spec/cli/cli_spec.rb
CHANGED
@@ -1,35 +1,44 @@
|
|
1
1
|
require 'rspec'
|
2
2
|
require 'thor'
|
3
|
-
require 'tmpdir'
|
3
|
+
require 'tmpdir'
|
4
|
+
|
5
|
+
require_relative '../../lib/rhoconnect'
|
6
|
+
include Rhoconnect
|
7
|
+
|
8
|
+
require_relative '../../commands/utilities/redis_runner'
|
9
|
+
require_relative "../../lib/rhoconnect/utilities"
|
10
|
+
include Utilities
|
11
|
+
|
12
|
+
RHOCONNECT_PORT = 9292
|
13
|
+
REDIS_SERVER_URL = "localhost:6379"
|
14
|
+
PUSH_SERVER_URL = "http://someappname@localhost:8675/"
|
15
|
+
API_TOKEN = "my-rhoconnect-token"
|
4
16
|
|
5
17
|
describe "RhoconnectCommandLineInterface" do
|
6
|
-
RHOCONNECT_PORT = 9292
|
7
|
-
REDIS_SERVER_URL = "localhost:6379"
|
8
|
-
PUSH_SERVER_URL = "http://someappname@localhost:8675/"
|
9
|
-
API_TOKEN = "my-rhoconnect-token"
|
10
|
-
|
11
18
|
class Execute < Thor
|
12
|
-
no_tasks
|
19
|
+
no_tasks {
|
13
20
|
def self.define_task(&block)
|
14
21
|
Execute.class_eval(&block)
|
15
22
|
end
|
16
|
-
|
23
|
+
|
24
|
+
# Disable dtach usage for rspec examples
|
17
25
|
def dtach_installed?
|
18
26
|
false
|
19
|
-
end
|
27
|
+
end
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
tasks = [ 'generators', 'rhoconnect', 'redis' ]
|
32
|
+
unless windows?
|
33
|
+
tasks << 'dtach'
|
34
|
+
tasks << 'rhoconnect_attach' unless jruby?
|
35
|
+
end
|
36
|
+
tasks << if jruby? then "rhoconnect_war" else "rhoconnect_console" end
|
37
|
+
tasks << 'rhoconnect_spec' if File.exists?(File.join(Dir.pwd,'Gemfile'))
|
38
|
+
tasks.each do |dir|
|
39
|
+
Dir.glob(File.join(File.dirname(__FILE__), "..", "..", "commands", "#{dir}", "*.rb")) do |file|
|
40
|
+
require file
|
20
41
|
end
|
21
|
-
|
22
|
-
require_relative '../../lib/rhoconnect'
|
23
|
-
require_relative "../../lib/rhoconnect/utilities"
|
24
|
-
|
25
|
-
require_relative "../../commands/utilities/utilities"
|
26
|
-
require_relative "../../commands/utilities/redis_runner"
|
27
|
-
require_relative "../../commands/rhoconnect/config"
|
28
|
-
require_relative "../../commands/rhoconnect/start"
|
29
|
-
require_relative "../../commands/rhoconnect/stop"
|
30
|
-
require_relative "../../commands/rhoconnect/version"
|
31
|
-
include Utilities
|
32
|
-
|
33
42
|
end
|
34
43
|
|
35
44
|
before(:all) do
|
@@ -39,18 +48,29 @@ describe "RhoconnectCommandLineInterface" do
|
|
39
48
|
end
|
40
49
|
|
41
50
|
after(:each) do
|
42
|
-
pid = `cat /tmp/rhoconnect.pid` if File.exist?("/tmp/rhoconnect.pid")
|
43
|
-
puts "\nExecuting 'rhoconnect stop' command ..." if pid
|
44
|
-
Execute.start ["stop"] # 'rhoconnect stop'
|
51
|
+
pid = `cat /tmp/rhoconnect.pid` if File.exist?("/tmp/rhoconnect.pid")
|
52
|
+
puts "\nExecuting 'rhoconnect stop' command ..." if pid
|
53
|
+
Execute.start ["stop"] # 'rhoconnect stop'
|
45
54
|
File.exist?("/tmp/rhoconnect.pid").should == false
|
46
|
-
`ps -p #{pid} -o pid=`.should be_empty if pid
|
55
|
+
`ps -p #{pid} -o pid=`.should be_empty if pid
|
47
56
|
end
|
48
|
-
|
57
|
+
|
49
58
|
after(:all) do
|
50
59
|
Dir.chdir @cur_dir
|
51
60
|
FileUtils.remove_entry @tmpdir
|
52
61
|
end
|
53
62
|
|
63
|
+
it "'rhoconnect help' cmd should display list of available commands" do
|
64
|
+
begin
|
65
|
+
out = StringIO.new
|
66
|
+
$stdout = out
|
67
|
+
Execute.start ["help"] # 'rhoconnect help'
|
68
|
+
ensure
|
69
|
+
$stdout = STDOUT
|
70
|
+
end
|
71
|
+
out.string.strip.should start_with "Commands:"
|
72
|
+
end
|
73
|
+
|
54
74
|
it "'rhoconnect version' cmd should display gem version" do
|
55
75
|
begin
|
56
76
|
out = StringIO.new
|
@@ -58,13 +78,31 @@ describe "RhoconnectCommandLineInterface" do
|
|
58
78
|
Execute.start ["version"] # 'rhoconnect version'
|
59
79
|
ensure
|
60
80
|
$stdout = STDOUT
|
61
|
-
end
|
81
|
+
end
|
62
82
|
out.string.strip.should == Rhoconnect::VERSION
|
63
83
|
end
|
64
|
-
|
84
|
+
|
85
|
+
it "'rhoconnect routes' cmd should display list of available routes" do
|
86
|
+
begin
|
87
|
+
@prev_dir = Dir.pwd
|
88
|
+
@appdir = File.join(File.dirname(__FILE__), "..", "apps", "rhotestapp")
|
89
|
+
puts " we have here #{@appdir}"
|
90
|
+
Dir.chdir @appdir
|
91
|
+
out = StringIO.new
|
92
|
+
$stdout = out
|
93
|
+
Execute.start ["routes"] # 'rhoconnect routes'
|
94
|
+
ensure
|
95
|
+
$stdout = STDOUT
|
96
|
+
Dir.chdir @prev_dir
|
97
|
+
end
|
98
|
+
out.string.strip.should include("SampleAdapterController: /app/v1/SampleAdapter")
|
99
|
+
out.string.strip.should include("FixedSchemaAdapterController: /app/v1/FixedSchemaAdapter")
|
100
|
+
out.string.strip.should_not include("FooAdapterController: /app/v1/FooAdapter")
|
101
|
+
end
|
102
|
+
|
65
103
|
it "'rhoconnect start' cmd should start blank app from any directory" do
|
66
104
|
thread = Thread.new do
|
67
|
-
puts "Executing 'rhoconnect start' command ..."
|
105
|
+
puts "Executing 'rhoconnect start' command ..."
|
68
106
|
# Array of params expected
|
69
107
|
Execute.start ["start"] # 'rhoconnect start'
|
70
108
|
end
|
@@ -73,11 +111,11 @@ describe "RhoconnectCommandLineInterface" do
|
|
73
111
|
raise "'rhoconnect start' failed to start with exception" if thread.status.nil?
|
74
112
|
break if File.exist?("/tmp/rhoconnect.pid")
|
75
113
|
end
|
76
|
-
|
114
|
+
|
77
115
|
File.exist?("/tmp/rhoconnect.pid").should == true
|
78
116
|
pid = `cat /tmp/rhoconnect.pid`
|
79
117
|
puts "Rhoconnect app is running with pid=#{pid}"
|
80
118
|
`ps -p #{pid} -o pid=`.should_not be_empty
|
81
119
|
end
|
82
|
-
|
120
|
+
|
83
121
|
end
|
data/spec/client_sync_spec.rb
CHANGED
@@ -7,7 +7,6 @@ describe "ClientSync" do
|
|
7
7
|
params = {'create'=>{'1'=>@product1}}
|
8
8
|
@c.source_name = 'Product2'
|
9
9
|
# create handler
|
10
|
-
params = {:p_size => 2}
|
11
10
|
lv = lambda { @model.create(@params[:create_object]) }
|
12
11
|
@model = Rhoconnect::Model::Base.create(@s2)
|
13
12
|
@cs1 = Rhoconnect::Handler::Changes::Runner.new(['create'],@model,@c,lv,params)
|
@@ -44,7 +43,7 @@ describe "ClientSync" do
|
|
44
43
|
end
|
45
44
|
|
46
45
|
it "should handle receive cud that triggers processing of the previously queued data" do
|
47
|
-
queued_create_data =
|
46
|
+
queued_create_data = [[@s.name, [['1', @product1]]]]
|
48
47
|
set_source_queue_state(@s, {:create => queued_create_data}, @c.id)
|
49
48
|
verify_source_queue_data(@s, {:create => [queued_create_data],
|
50
49
|
:update => [],
|
@@ -54,6 +53,21 @@ describe "ClientSync" do
|
|
54
53
|
:update => [],
|
55
54
|
:delete => []})
|
56
55
|
end
|
56
|
+
|
57
|
+
it "should handle receive cud from the custom queue_key that triggers processing of the previously queued data" do
|
58
|
+
queue_key = "post:/my_custom_create_route"
|
59
|
+
queue_name = "create:#{queue_key}"
|
60
|
+
Source.define_valid_queues([queue_name])
|
61
|
+
queued_create_data = [[@s.name, [['1', @product1]]]]
|
62
|
+
set_source_queue_state(@s, {queue_name => queued_create_data}, @c.id)
|
63
|
+
verify_source_queue_data(@s, {queue_name => [queued_create_data]})
|
64
|
+
@cud_handler.params[:queue_key] = queue_key
|
65
|
+
@cud_handler.engine.params[:queue_key] = queue_key
|
66
|
+
@cud_handler.operations = ["create"]
|
67
|
+
@cud_handler.engine.operations = ["create"]
|
68
|
+
@cud_handler.run
|
69
|
+
verify_source_queue_data(@s, {queue_name => []})
|
70
|
+
end
|
57
71
|
|
58
72
|
it "should handle receive cud with pass through" do
|
59
73
|
params = {'create'=>{'1'=>@product1},'update'=>{'2'=>@product2},'delete'=>{'3'=>@product3}}
|
@@ -61,10 +75,7 @@ describe "ClientSync" do
|
|
61
75
|
|
62
76
|
rhcud = lambda { @model.send params[:operation].to_sym, params["#{params[:operation]}_object".to_sym] }
|
63
77
|
@cud_handler = Rhoconnect::Handler::Changes::PassThroughRunner.new(['create','update','delete'],@model,@c,rhcud,params)
|
64
|
-
@cud_handler.run
|
65
|
-
verify_source_queue_data(@s, {:create => [],
|
66
|
-
:update => [],
|
67
|
-
:delete => []})
|
78
|
+
JSON.parse(@cud_handler.run).should == {"processed" => ['1', '2', '3']}
|
68
79
|
end
|
69
80
|
|
70
81
|
it "should handle exeptions in receive cud with pass through" do
|
@@ -72,10 +83,7 @@ describe "ClientSync" do
|
|
72
83
|
@s.pass_through = 'true'
|
73
84
|
rhcud = lambda { @model.send params[:operation].to_sym, params["#{params[:operation]}_object".to_sym] }
|
74
85
|
@cud_handler = Rhoconnect::Handler::Changes::PassThroughRunner.new(['create','update','delete'],@model,@c,rhcud,params)
|
75
|
-
@cud_handler.run
|
76
|
-
verify_source_queue_data(@s, {:create => [],
|
77
|
-
:update => [],
|
78
|
-
:delete => []})
|
86
|
+
JSON.parse(@cud_handler.run).should == {"error" => {"message" => "undefined method `[]' for nil:NilClass" }, "processed" => []}
|
79
87
|
end
|
80
88
|
|
81
89
|
it "should handle send cud" do
|
@@ -237,9 +245,11 @@ describe "ClientSync" do
|
|
237
245
|
error_objs = add_error_object({},"Error delete record")
|
238
246
|
op_data = {'delete'=>error_objs}
|
239
247
|
@cud_handler.params = op_data
|
248
|
+
@cud_handler.operations = ["delete"]
|
249
|
+
@cud_handler.engine.operations = ["delete"]
|
240
250
|
@cud_handler.run
|
241
251
|
@sync_handler.run.should == [{'version'=>Rhoconnect::SYNC_VERSION},{"token"=>""}, {"count"=>0}, {"progress_count"=>0}, {"total_count"=>0},
|
242
|
-
{"delete-error"=>{"#{ERROR}-error"=>{"message"=>msg},ERROR=>error_objs[ERROR]}}]
|
252
|
+
{"delete-error"=>{"#{ERROR}-error"=>{"message"=>msg},ERROR=>error_objs[ERROR]}}]
|
243
253
|
end
|
244
254
|
|
245
255
|
it "should send cud errors only once" do
|
@@ -247,17 +257,19 @@ describe "ClientSync" do
|
|
247
257
|
error_objs = add_error_object({},"Error delete record")
|
248
258
|
op_data = {'delete'=>error_objs}
|
249
259
|
@cud_handler.params = op_data
|
260
|
+
@cud_handler.operations = ["delete"]
|
261
|
+
@cud_handler.engine.operations = ["delete"]
|
250
262
|
@cud_handler.run
|
251
263
|
@sync_handler.run.should == [{'version'=>Rhoconnect::SYNC_VERSION},{"token"=>""}, {"count"=>0}, {"progress_count"=>0}, {"total_count"=>0},
|
252
264
|
{"delete-error"=>{"#{ERROR}-error"=>{"message"=>msg},ERROR=>error_objs[ERROR]}}]
|
253
265
|
verify_result(@c.docname(:delete_errors) => {})
|
254
|
-
@sync_handler.run.should == [{'version'=>Rhoconnect::SYNC_VERSION},{"token"=>""}, {"count"=>0}, {"progress_count"=>0}, {"total_count"=>0},{}]
|
266
|
+
@sync_handler.run.should == [{'version'=>Rhoconnect::SYNC_VERSION},{"token"=>""}, {"count"=>0}, {"progress_count"=>0}, {"total_count"=>0},{}]
|
255
267
|
end
|
256
268
|
|
257
269
|
|
258
270
|
end
|
259
271
|
|
260
|
-
it "should handle receive_cud" do
|
272
|
+
it "should handle receive_cud and perform proper operation on the md and cd" do
|
261
273
|
set_doc_state(@s, :md => {'3'=>@product3})
|
262
274
|
set_doc_state(@c, :cd => {'3'=>@product3})
|
263
275
|
params = {'create'=>{'1'=>@product1},
|
@@ -269,6 +281,9 @@ describe "ClientSync" do
|
|
269
281
|
:delete => []})
|
270
282
|
verify_doc_result(@s, :md => {})
|
271
283
|
verify_doc_result(@c, :cd => {})
|
284
|
+
verify_source_queue_data(@s2, {:create => [],
|
285
|
+
:update => [],
|
286
|
+
:delete => []})
|
272
287
|
end
|
273
288
|
|
274
289
|
it "should handle send_cud with query_params" do
|
@@ -598,6 +613,8 @@ describe "ClientSync" do
|
|
598
613
|
def receive_and_send_cud(operation)
|
599
614
|
msg = "Error #{operation} record"
|
600
615
|
op_data = {operation=>{ERROR=>{'an_attribute'=>msg,'name'=>'wrongname'}}}
|
616
|
+
@cud_handler.operations = [operation]
|
617
|
+
@cud_handler.engine.operations = [operation]
|
601
618
|
@cud_handler.params = op_data
|
602
619
|
@cud_handler.run
|
603
620
|
if operation == 'update'
|
@@ -7,6 +7,10 @@ describe "Rhoconnect::Controller::JsBase" do
|
|
7
7
|
include Rhoconnect
|
8
8
|
|
9
9
|
it_behaves_like "SharedRhoconnectHelper", :rhoconnect_data => true do
|
10
|
+
def app
|
11
|
+
@app ||= Rack::URLMap.new Rhoconnect.url_map
|
12
|
+
end
|
13
|
+
|
10
14
|
before(:each) do
|
11
15
|
Rhoconnect::Server.set :environment, :test
|
12
16
|
Rhoconnect::Server.set :secret, "secure!"
|
@@ -15,10 +19,6 @@ describe "Rhoconnect::Controller::JsBase" do
|
|
15
19
|
do_post "/rc/#{Rhoconnect::API_VERSION}/app/login", "login" => @u.login, "password" => 'testpass'
|
16
20
|
end
|
17
21
|
|
18
|
-
def app
|
19
|
-
@app ||= Rack::URLMap.new Rhoconnect.url_map
|
20
|
-
end
|
21
|
-
|
22
22
|
after(:each) do
|
23
23
|
Rhoconnect::Node.kill_process
|
24
24
|
end
|
@@ -72,6 +72,12 @@ describe "Rhoconnect::Controller::JsBase" do
|
|
72
72
|
last_response.should be_ok
|
73
73
|
end
|
74
74
|
|
75
|
+
it "should call route that overrides default option" do
|
76
|
+
get '/app/v1/JsSample/no_client_route', {}
|
77
|
+
last_response.should be_ok
|
78
|
+
last_response.body.should == 'no client required!'
|
79
|
+
end
|
80
|
+
|
75
81
|
it "should upload blob in multipart post" do
|
76
82
|
file1,file2 = 'upload1.txt'
|
77
83
|
@product1['txtfile-rhoblob'] = file1
|
@@ -16,7 +16,7 @@ describe "SourceJob" do
|
|
16
16
|
it "should perform process_cud" do
|
17
17
|
expected = {'backend_id'=>@product1}
|
18
18
|
@product1['link'] = 'abc'
|
19
|
-
@s.push_queue(:create, @c.id,
|
19
|
+
@s.push_queue(:create, @c.id, [[@s.name, [['1', @product1]]]])
|
20
20
|
SourceJob.perform('cud',@s.id,@s.app_id,@s.user_id,nil)
|
21
21
|
verify_source_queue_data(@s, :create => [])
|
22
22
|
verify_doc_result(@s, {:md => expected,
|
@@ -21,18 +21,6 @@ describe "Rhoconnect::Model::JsBase" do
|
|
21
21
|
Source.valid_doctypes.delete('tmpdoc'.to_sym)
|
22
22
|
end
|
23
23
|
|
24
|
-
it "should call model's create method"
|
25
|
-
|
26
|
-
it "should call model's update method"
|
27
|
-
|
28
|
-
it "should call model's delete method"
|
29
|
-
|
30
|
-
it "should call model's query method"
|
31
|
-
|
32
|
-
it "should call model's login method"
|
33
|
-
|
34
|
-
it "should call model's logoff method"
|
35
|
-
|
36
24
|
it "should call js model method explicitly" do
|
37
25
|
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
38
26
|
res = js.login
|
@@ -60,13 +48,75 @@ describe "Rhoconnect::Model::JsBase" do
|
|
60
48
|
js.get_data('tmpdoc').should == data
|
61
49
|
end
|
62
50
|
|
51
|
+
it "should test non-nil result from query" do
|
52
|
+
data = {'1' => {'name' => 'iPhone'}}
|
53
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
54
|
+
js.do_query(test_non_hash: true)
|
55
|
+
js.get_data(:md).should == {}
|
56
|
+
end
|
57
|
+
|
63
58
|
it "should call getData for a model" do
|
64
59
|
data = {'1' => {'name' => 'iPhone'}}
|
65
60
|
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
66
|
-
|
61
|
+
js.do_query
|
67
62
|
js.testGetModelData.should == data
|
68
63
|
end
|
69
64
|
|
65
|
+
it "should call partitionName for a model" do
|
66
|
+
JsSample.partition_name('testuser').should == 'testuser_partition'
|
67
|
+
end
|
68
|
+
|
69
|
+
context "exceptions" do
|
70
|
+
it "should raise ruby Rhoconnect::Model::Exception" do
|
71
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
72
|
+
lambda {
|
73
|
+
js.testRaiseException
|
74
|
+
}.should raise_error(Rhoconnect::Model::Exception, /some custom message/)
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should raise ruby Rhoconnect::Model::LoginException" do
|
78
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
79
|
+
lambda {
|
80
|
+
js.testRaiseLoginException
|
81
|
+
}.should raise_error(Rhoconnect::Model::LoginException, /some login message/)
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should raise ruby Rhoconnect::Model::LogoffException" do
|
85
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
86
|
+
lambda {
|
87
|
+
js.testRaiseLogoffException
|
88
|
+
}.should raise_error(Rhoconnect::Model::LogoffException, /some logoff message/)
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should raise ruby Rhoconnect::Model::ServerTimeoutException" do
|
92
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
93
|
+
lambda {
|
94
|
+
js.testRaiseTimeoutException
|
95
|
+
}.should raise_error(Rhoconnect::Model::ServerTimeoutException, /some timeout message/)
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should raise ruby Rhoconnect::Model::ServerErrorException" do
|
99
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
100
|
+
lambda {
|
101
|
+
js.testRaiseErrorException
|
102
|
+
}.should raise_error(Rhoconnect::Model::ServerErrorException, /some error message/)
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should raise ruby Rhoconnect::Model::ObjectConflictErrorException" do
|
106
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
107
|
+
lambda {
|
108
|
+
js.testRaiseConflictException
|
109
|
+
}.should raise_error(Rhoconnect::Model::ObjectConflictErrorException, /some object conflict message/)
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should raise an exception during a regular adapter method" do
|
113
|
+
js = JsSample.new(Source.load('JsSample', {:app_id => @a.id, :user_id => @u.id}))
|
114
|
+
lambda {
|
115
|
+
js.do_query(raise_an_error: true)
|
116
|
+
}.should raise_error(Rhoconnect::Model::ServerErrorException, /query error occured/)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
70
120
|
context "Store" do
|
71
121
|
it "should call getValue" do
|
72
122
|
Store.put_value('foo', 'bar')
|