rhoconnect 4.0.4 → 5.1.1
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/spec/server/stats_spec.rb
CHANGED
@@ -8,18 +8,18 @@ STATS_RECORD_SIZE = 8 unless defined? STATS_RECORD_SIZE
|
|
8
8
|
include Rhoconnect
|
9
9
|
|
10
10
|
describe "Middleware" do
|
11
|
-
|
11
|
+
|
12
12
|
before(:each) do
|
13
13
|
@now = 10.0
|
14
14
|
Store.flush_all
|
15
|
-
app =
|
16
|
-
app.stub
|
15
|
+
app = double('app')
|
16
|
+
app.stub(:call)
|
17
17
|
Rhoconnect.stats = true
|
18
18
|
Rhoconnect::Server.enable :stats
|
19
19
|
@middleware_new_routes = Rhoconnect::Middleware::Stats.new(app)
|
20
|
-
Store.stub
|
20
|
+
Store.stub(:lock).and_yield
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
after(:each) do
|
24
24
|
Rhoconnect.stats = false
|
25
25
|
Rhoconnect::Server.disable :stats
|
@@ -27,7 +27,7 @@ describe "Middleware" do
|
|
27
27
|
|
28
28
|
it "should compute http average" do
|
29
29
|
@incr = 0
|
30
|
-
Time.stub
|
30
|
+
Time.stub(:now).and_return do
|
31
31
|
if @incr > 0
|
32
32
|
@now += 0.3
|
33
33
|
@incr -= 1
|
@@ -45,13 +45,13 @@ describe "Middleware" do
|
|
45
45
|
metric = 'http:GET:/api/application/query:SampleAdapter'
|
46
46
|
Rhoconnect::Stats::Record.key(metric).should == "stat:#{metric}"
|
47
47
|
|
48
|
-
# The conversion algorithm (float to string) currently checks two precisions.
|
49
|
-
# it tries 16 digits and if that's not enough it then uses 17.
|
48
|
+
# The conversion algorithm (float to string) currently checks two precisions.
|
49
|
+
# it tries 16 digits and if that's not enough it then uses 17.
|
50
50
|
Rhoconnect::Stats::Record.range(metric, 0, -1).should == [
|
51
|
-
"2.0,0.6000000000000014:12",
|
52
|
-
"2.0,0.6000000000000014:14",
|
53
|
-
"2.0,0.6000000000000014:16",
|
51
|
+
"2.0,0.6000000000000014:12",
|
52
|
+
"2.0,0.6000000000000014:14",
|
53
|
+
"2.0,0.6000000000000014:16",
|
54
54
|
"2.0,0.6000000000000014:18"
|
55
55
|
]
|
56
|
-
end
|
56
|
+
end
|
57
57
|
end
|
data/spec/source_adapter_spec.rb
CHANGED
@@ -1,154 +1,153 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'spec_helper')
|
2
2
|
|
3
3
|
describe "loading Model" do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => true
|
5
|
+
|
6
|
+
it "should load Model instance from user name" do
|
7
|
+
username = 'testuser'
|
8
|
+
model_instance = SimpleAdapter.load(username)
|
9
|
+
model_instance.class.name.should == 'SimpleAdapter'
|
10
|
+
model_instance.source.name.should == 'SimpleAdapter'
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "Model" do
|
15
|
-
|
16
|
-
before(:each) do
|
17
|
-
@s = Source.load('SimpleAdapter',@s_params)
|
18
|
-
@sa = Rhoconnect::Model::Base.create(@s)
|
19
|
-
end
|
15
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => true
|
20
16
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
:login => 'testuser',
|
26
|
-
:password => 'testpass',
|
27
|
-
}
|
28
|
-
Source.create(fields,@s_params)
|
29
|
-
end
|
17
|
+
before(:each) do
|
18
|
+
@s = Source.load('SimpleAdapter',@s_params)
|
19
|
+
@sa = Rhoconnect::Model::Base.create(@s)
|
20
|
+
end
|
30
21
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
pa = Rhoconnect::Model::Base.create(pas)
|
41
|
-
pa.class.name.should == "Rhoconnect::#{adapter_name}"
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
it "should create DynamicAdapterModel" do
|
46
|
-
@sa1 = Rhoconnect::Model::Base.create(@s2)
|
47
|
-
@sa1.class.name.should == 'Rhoconnect::Model::DynamicAdapterModel'
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should capture exception in create" do
|
51
|
-
Rhoconnect::Model::DynamicAdapterModel.should_receive(:new).once.and_raise(Exception)
|
52
|
-
lambda { @sa1 = Rhoconnect::Model::Base.create(@s2) }.should raise_error(Exception)
|
53
|
-
end
|
22
|
+
def setup_adapter(name)
|
23
|
+
fields = {
|
24
|
+
:name => name,
|
25
|
+
:url => 'http://example.com',
|
26
|
+
:login => 'testuser',
|
27
|
+
:password => 'testpass',
|
28
|
+
}
|
29
|
+
Source.create(fields,@s_params)
|
30
|
+
end
|
54
31
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
broken_source.delete
|
59
|
-
end
|
32
|
+
it "should create model with source" do
|
33
|
+
@sa.class.name.should == @s.name
|
34
|
+
end
|
60
35
|
|
61
|
-
|
62
|
-
|
63
|
-
|
36
|
+
it "should create all existing pre-defined models" do
|
37
|
+
Rhoconnect.predefined_sources.keys.sort.should == ['RhoInternalBenchmarkAdapter'].sort
|
38
|
+
Rhoconnect.predefined_sources.each do |adapter_name, filename|
|
39
|
+
pas = Source.load(adapter_name, @s_params)
|
40
|
+
pas.should_not == nil
|
41
|
+
pa = Rhoconnect::Model::Base.create(pas)
|
42
|
+
pa.class.name.should == "Rhoconnect::#{adapter_name}"
|
64
43
|
end
|
44
|
+
end
|
65
45
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
46
|
+
it "should create DynamicAdapterModel" do
|
47
|
+
@sa1 = Rhoconnect::Model::Base.create(@s2)
|
48
|
+
@sa1.class.name.should == 'Rhoconnect::Model::DynamicAdapterModel'
|
49
|
+
end
|
70
50
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
end
|
51
|
+
it "should capture exception in create" do
|
52
|
+
Rhoconnect::Model::DynamicAdapterModel.should_receive(:new).once.and_raise(Exception)
|
53
|
+
lambda { @sa1 = Rhoconnect::Model::Base.create(@s2) }.should raise_error(Exception)
|
54
|
+
end
|
76
55
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
Source.valid_doctypes.delete(:md_custom)
|
83
|
-
end
|
56
|
+
it "should fail to create Bro-ken model" do
|
57
|
+
broken_source = setup_adapter('Bro-ken')
|
58
|
+
lambda { Rhoconnect::Model::Base.create(broken_source) }.should raise_error(Exception)
|
59
|
+
broken_source.delete
|
60
|
+
end
|
84
61
|
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
end
|
62
|
+
it "should create model with trailing spaces" do
|
63
|
+
s = setup_adapter('SimpleAdapter ')
|
64
|
+
Rhoconnect::Model::Base.create(s).is_a?(SimpleAdapter).should be_true
|
65
|
+
end
|
90
66
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
@sa.search(params).should == expected
|
96
|
-
params.should == {:hello => 'world', :foo => 'bar'}
|
97
|
-
end
|
67
|
+
describe "model methods" do
|
68
|
+
it "should execute Model login method with source vars" do
|
69
|
+
@sa.login.should == true
|
70
|
+
end
|
98
71
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
72
|
+
it "should get Model data (:md)" do
|
73
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
74
|
+
@s.put_data(:md, expected)
|
75
|
+
@sa.get_data.should == expected
|
76
|
+
end
|
103
77
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
78
|
+
it "should get Model data from specific document" do
|
79
|
+
expected = {'4'=>@product1,'5'=>@product2}
|
80
|
+
Source.define_valid_doctypes([:md_custom])
|
81
|
+
@s.put_data(:md_custom, expected)
|
82
|
+
@sa.get_data(:md_custom).should == expected
|
83
|
+
Source.valid_doctypes.delete(:md_custom)
|
84
|
+
end
|
111
85
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
86
|
+
it "should execute Model query method" do
|
87
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
88
|
+
@sa.inject_result expected
|
89
|
+
@sa.query.should == expected
|
90
|
+
end
|
117
91
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
92
|
+
it "should execute Model search method and modify params" do
|
93
|
+
params = {:hello => 'world'}
|
94
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
95
|
+
@sa.inject_result expected
|
96
|
+
@sa.search(params).should == expected
|
97
|
+
params.should == {:hello => 'world', :foo => 'bar'}
|
98
|
+
end
|
122
99
|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
@sa.inject_result({})
|
128
|
-
@sa.do_query
|
129
|
-
Store.get_value(@s.docname(:md_size)).to_i.should == 0
|
130
|
-
end
|
100
|
+
it "should execute Model login with current_user" do
|
101
|
+
@sa.should_receive(:current_user).with(no_args()).and_return(@u)
|
102
|
+
@sa.login
|
103
|
+
end
|
131
104
|
|
132
|
-
|
133
|
-
|
134
|
-
|
105
|
+
it "should execute Model sync method" do
|
106
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
107
|
+
@sa.inject_result expected
|
108
|
+
@sa.do_query
|
109
|
+
Store.get_data(@s.docname(:md)).should == expected
|
110
|
+
Store.get_value(@s.docname(:md_size)).to_i.should == 2
|
111
|
+
end
|
135
112
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
113
|
+
it "should execute Model sync method with nil result" do
|
114
|
+
@sa.inject_result nil
|
115
|
+
@sa.do_query
|
116
|
+
Store.get_data(@s.docname(:md)).should == {}
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should fail gracefully if @result is missing" do
|
120
|
+
@sa.inject_result nil
|
121
|
+
lambda { @sa.query }.should_not raise_error
|
122
|
+
end
|
145
123
|
|
146
|
-
|
124
|
+
it "should reset count if @result is empty" do
|
125
|
+
@sa.inject_result({'1'=>@product1,'2'=>@product2})
|
126
|
+
@sa.do_query
|
127
|
+
Store.get_value(@s.docname(:md_size)).to_i.should == 2
|
128
|
+
@sa.inject_result({})
|
129
|
+
@sa.do_query
|
130
|
+
Store.get_value(@s.docname(:md_size)).to_i.should == 0
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should execute Model create method" do
|
134
|
+
@sa.create(@product4).should == 'obj4'
|
135
|
+
end
|
136
|
+
|
137
|
+
it "should stash @result in store and set it to nil" do
|
138
|
+
expected = {'1'=>@product1,'2'=>@product2}
|
139
|
+
Source.define_valid_doctypes(['tmpdoc'.to_sym])
|
140
|
+
@sa.inject_result(expected)
|
141
|
+
@sa.inject_tmpdoc('tmpdoc')
|
142
|
+
@sa.stash_result
|
143
|
+
@s.get_data('tmpdoc').should == expected
|
144
|
+
Source.valid_doctypes.delete('tmpdoc'.to_sym)
|
145
|
+
end
|
147
146
|
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
147
|
+
describe "Model metadata method" do
|
148
|
+
it "should execute Model metadata method" do
|
149
|
+
mock_metadata_method([SimpleAdapter]) do
|
150
|
+
@sa.metadata.should == "{\"foo\":\"bar\"}"
|
152
151
|
end
|
153
152
|
end
|
154
153
|
end
|
data/spec/source_spec.rb
CHANGED
@@ -1,157 +1,156 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__),'spec_helper')
|
2
2
|
|
3
3
|
describe "Source" do
|
4
|
-
|
5
|
-
|
6
|
-
before(:each) do
|
7
|
-
@s = Source.load(@s_fields[:name],@s_params)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should create and load source with @s_fields and @s_params" do
|
11
|
-
@s.name.should == @s_fields[:name]
|
12
|
-
@s.url.should == @s_fields[:url]
|
13
|
-
@s.login.should == @s_fields[:login]
|
14
|
-
@s.app.name.should == @a_fields[:name]
|
15
|
-
@s.priority.should == 1
|
16
|
-
@s.callback_url.should be_nil
|
17
|
-
@s.queue.should be_nil
|
18
|
-
@s.query_queue.should be_nil
|
19
|
-
@s.cud_queue.should be_nil
|
20
|
-
@s.app_id.should == @s_params[:app_id]
|
21
|
-
@s.user_id.should == @s_params[:user_id]
|
22
|
-
@s.sync_type.should == :incremental
|
23
|
-
@s.partition_type.should == :user
|
24
|
-
@s.poll_interval.should == 300
|
25
|
-
|
26
|
-
@s1 = Source.load(@s.id,@s_params)
|
27
|
-
@s1.name.should == @s_fields[:name]
|
28
|
-
@s1.url.should == @s_fields[:url]
|
29
|
-
@s1.login.should == @s_fields[:login]
|
30
|
-
@s1.app.name.should == @a_fields[:name]
|
31
|
-
@s1.priority.should == 1
|
32
|
-
@s1.callback_url.should be_nil
|
33
|
-
@s1.poll_interval.should == 300
|
34
|
-
@s1.app_id.should == @s_params[:app_id]
|
35
|
-
@s1.user_id.should == @s_params[:user_id]
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should create source with user" do
|
39
|
-
@s.user.login.should == @u_fields[:login]
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should create source with app and document" do
|
43
|
-
@s.app.name.should == @a_fields[:name]
|
44
|
-
@s.docname(:md).should == "source:#{@s.app.id}:#{@u.id}:#{@s_fields[:name]}:md"
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should return values that set by setter method' do
|
48
|
-
@s.login = "shurab"
|
49
|
-
@s.login.should == "shurab"
|
50
|
-
@s.poll_interval = 350
|
51
|
-
@s.poll_interval.should == 350
|
52
|
-
@s.poll_interval = nil
|
53
|
-
@s.poll_interval.should == nil
|
54
|
-
@s.url = nil
|
55
|
-
@s.url.should be_nil
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should delete source" do
|
59
|
-
@s.delete
|
60
|
-
Source.is_exist?(@s_fields[:name]).should == false
|
61
|
-
@s = Source.create(@s_fields,@s_params)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "should delete master and all documents associated with source" do
|
65
|
-
key = @s.docname('*')
|
66
|
-
Source.define_valid_doctypes([:md_source])
|
67
|
-
set_doc_state(@s, {:md_source => @data})
|
68
|
-
@s.delete
|
69
|
-
i = 0
|
70
|
-
while i < Store.num_stores do
|
71
|
-
Store.get_store(i).keys(key).should == []
|
72
|
-
i += 1
|
73
|
-
end
|
74
|
-
Source.valid_doctypes.delete(:md_source)
|
75
|
-
@s = Source.create(@s_fields,@s_params)
|
76
|
-
end
|
77
|
-
|
78
|
-
it "should create source with default partition user" do
|
79
|
-
@s1 = Source.load(@s_fields[:name],{:app_id => @a.id,:user_id => '*'})
|
80
|
-
@s1.partition.should == :user
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should create correct docname based on partition scheme" do
|
84
|
-
@s.partition = :app
|
85
|
-
@s.docname(:md).should == "source:#{@s.app.id}:__shared__:#{@s_fields[:name]}:md"
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should create source with default read/write queue" do
|
89
|
-
@s.delete
|
90
|
-
@s_fields[:queue] = :default
|
91
|
-
@s_fields[:query_queue] = :query
|
92
|
-
@s_fields[:cud_queue] = :cud
|
93
|
-
@s = Source.create(@s_fields,@s_params)
|
94
|
-
s = Source.load(@s_fields[:name],@s_params)
|
95
|
-
s.queue.should == :default
|
96
|
-
s.query_queue.should == :query
|
97
|
-
s.cud_queue.should == :cud
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should add associations based on belongs_to field for a source" do
|
101
|
-
@s2 = Source.create({:name => 'SimpleAdapter'}, @s_params)
|
102
|
-
@s2.belongs_to = [{'product_id' => 'SampleAdapter'}].to_json
|
103
|
-
sf = Source.load(@s1.name,{:app_id => @a.id,:user_id => '*'})
|
104
|
-
Source.update_associations([@s.name,@s1.name, @s2.name])
|
105
|
-
s = Source.load(@s.name,{:app_id => @a.id,:user_id => '*'})
|
106
|
-
s.has_many.should == "#{@s1.name},brand,#{@s2.name},product_id"
|
107
|
-
end
|
108
|
-
|
109
|
-
it "should log warning about incorrect belongs_to format for a source" do
|
110
|
-
@s2 = Source.create({:name => 'SimpleAdapter'}, @s_params)
|
111
|
-
@s2.belongs_to = {'product_id' => 'SampleAdapter'}.to_json
|
112
|
-
Source.should_receive(:log).once.with(
|
113
|
-
"WARNING: Incorrect belongs_to format for SimpleAdapter, belongs_to should be an array."
|
114
|
-
)
|
115
|
-
Source.update_associations([@s.name,@s1.name, @s2.name])
|
116
|
-
end
|
4
|
+
include_examples "SharedRhoconnectHelper", :rhoconnect_data => false
|
117
5
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
6
|
+
before(:each) do
|
7
|
+
@s = Source.load(@s_fields[:name],@s_params)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should create and load source with @s_fields and @s_params" do
|
11
|
+
@s.name.should == @s_fields[:name]
|
12
|
+
@s.url.should == @s_fields[:url]
|
13
|
+
@s.login.should == @s_fields[:login]
|
14
|
+
@s.app.name.should == @a_fields[:name]
|
15
|
+
@s.priority.should == 1
|
16
|
+
@s.callback_url.should be_nil
|
17
|
+
@s.queue.should be_nil
|
18
|
+
@s.query_queue.should be_nil
|
19
|
+
@s.cud_queue.should be_nil
|
20
|
+
@s.app_id.should == @s_params[:app_id]
|
21
|
+
@s.user_id.should == @s_params[:user_id]
|
22
|
+
@s.sync_type.should == :incremental
|
23
|
+
@s.partition_type.should == :user
|
24
|
+
@s.poll_interval.should == 300
|
25
|
+
|
26
|
+
@s1 = Source.load(@s.id,@s_params)
|
27
|
+
@s1.name.should == @s_fields[:name]
|
28
|
+
@s1.url.should == @s_fields[:url]
|
29
|
+
@s1.login.should == @s_fields[:login]
|
30
|
+
@s1.app.name.should == @a_fields[:name]
|
31
|
+
@s1.priority.should == 1
|
32
|
+
@s1.callback_url.should be_nil
|
33
|
+
@s1.poll_interval.should == 300
|
34
|
+
@s1.app_id.should == @s_params[:app_id]
|
35
|
+
@s1.user_id.should == @s_params[:user_id]
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should create source with user" do
|
39
|
+
@s.user.login.should == @u_fields[:login]
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should create source with app and document" do
|
43
|
+
@s.app.name.should == @a_fields[:name]
|
44
|
+
@s.docname(:md).should == "source:#{@s.app.id}:#{@u.id}:#{@s_fields[:name]}:md"
|
45
|
+
end
|
137
46
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
47
|
+
it 'should return values that set by setter method' do
|
48
|
+
@s.login = "shurab"
|
49
|
+
@s.login.should == "shurab"
|
50
|
+
@s.poll_interval = 350
|
51
|
+
@s.poll_interval.should == 350
|
52
|
+
@s.poll_interval = nil
|
53
|
+
@s.poll_interval.should == nil
|
54
|
+
@s.url = nil
|
55
|
+
@s.url.should be_nil
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should delete source" do
|
59
|
+
@s.delete
|
60
|
+
Source.is_exist?(@s_fields[:name]).should == false
|
61
|
+
@s = Source.create(@s_fields,@s_params)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should delete master and all documents associated with source" do
|
65
|
+
key = @s.docname('*')
|
66
|
+
Source.define_valid_doctypes([:md_source])
|
67
|
+
set_doc_state(@s, {:md_source => @data})
|
68
|
+
@s.delete
|
69
|
+
i = 0
|
70
|
+
while i < Store.num_stores do
|
71
|
+
Store.get_store(i).keys(key).should == []
|
72
|
+
i += 1
|
155
73
|
end
|
74
|
+
Source.valid_doctypes.delete(:md_source)
|
75
|
+
@s = Source.create(@s_fields,@s_params)
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should create source with default partition user" do
|
79
|
+
@s1 = Source.load(@s_fields[:name],{:app_id => @a.id,:user_id => '*'})
|
80
|
+
@s1.partition.should == :user
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should create correct docname based on partition scheme" do
|
84
|
+
@s.partition = :app
|
85
|
+
@s.docname(:md).should == "source:#{@s.app.id}:__shared__:#{@s_fields[:name]}:md"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should create source with default read/write queue" do
|
89
|
+
@s.delete
|
90
|
+
@s_fields[:queue] = :default
|
91
|
+
@s_fields[:query_queue] = :query
|
92
|
+
@s_fields[:cud_queue] = :cud
|
93
|
+
@s = Source.create(@s_fields,@s_params)
|
94
|
+
s = Source.load(@s_fields[:name],@s_params)
|
95
|
+
s.queue.should == :default
|
96
|
+
s.query_queue.should == :query
|
97
|
+
s.cud_queue.should == :cud
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should add associations based on belongs_to field for a source" do
|
101
|
+
@s2 = Source.create({:name => 'SimpleAdapter'}, @s_params)
|
102
|
+
@s2.belongs_to = [{'product_id' => 'SampleAdapter'}].to_json
|
103
|
+
sf = Source.load(@s1.name,{:app_id => @a.id,:user_id => '*'})
|
104
|
+
Source.update_associations([@s.name,@s1.name, @s2.name])
|
105
|
+
s = Source.load(@s.name,{:app_id => @a.id,:user_id => '*'})
|
106
|
+
s.has_many.should == "#{@s1.name},brand,#{@s2.name},product_id"
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should log warning about incorrect belongs_to format for a source" do
|
110
|
+
@s2 = Source.create({:name => 'SimpleAdapter'}, @s_params)
|
111
|
+
@s2.belongs_to = {'product_id' => 'SampleAdapter'}.to_json
|
112
|
+
Source.should_receive(:log).once.with(
|
113
|
+
"WARNING: Incorrect belongs_to format for SimpleAdapter, belongs_to should be an array."
|
114
|
+
)
|
115
|
+
Source.update_associations([@s.name,@s1.name, @s2.name])
|
116
|
+
end
|
117
|
+
|
118
|
+
# check custom partitions
|
119
|
+
it "should return custom partition for users if defined in the model" do
|
120
|
+
u1_fields = {:login => 'cus_user1'}
|
121
|
+
u1 = User.create(u1_fields)
|
122
|
+
u2_fields = {:login => 'cus_user2'}
|
123
|
+
u2 = User.create(u2_fields)
|
124
|
+
u3_fields = {:login => 'other_user'}
|
125
|
+
u3 = User.create(u3_fields)
|
126
|
+
|
127
|
+
s = Source.load('SampleAdapter', {:user_id => u1.login, :app_id => APP_NAME})
|
128
|
+
s.user_by_partition.should == 'custom_partition'
|
129
|
+
s.docname(:md).should == "source:#{s.app.id}:custom_partition:SampleAdapter:md"
|
130
|
+
s = Source.load('FixedSchemaAdapter', {:user_id => u1.login, :app_id => APP_NAME})
|
131
|
+
s.user_by_partition.should == 'cus_user1'
|
132
|
+
s = Source.load('SampleAdapter', {:user_id => u2.login, :app_id => APP_NAME})
|
133
|
+
s.user_by_partition.should == 'custom_partition'
|
134
|
+
s = Source.load('SampleAdapter', {:user_id => u3.login, :app_id => APP_NAME})
|
135
|
+
s.user_by_partition.should == 'other_user'
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should delete data from custom partition" do
|
139
|
+
u1_fields = {:login => 'cus_user1'}
|
140
|
+
u1 = User.create(u1_fields)
|
141
|
+
data = {'1' => {'Name' => 'Value'}}
|
142
|
+
|
143
|
+
s = Source.load('SampleAdapter', {:user_id => u1.login, :app_id => APP_NAME})
|
144
|
+
s.user_by_partition.should == 'custom_partition'
|
145
|
+
Source.define_valid_doctypes([:md_source])
|
146
|
+
set_doc_state(s, {:md_source => data})
|
147
|
+
Store.get_data("source:#{s.app.id}:custom_partition:SampleAdapter:md_source").should == data
|
148
|
+
Store.get_data("source:#{s.app.id}:cus_user1:SampleAdapter:md_source").should == {}
|
149
|
+
Store.put_data("source:#{s.app.id}:cus_user1:SampleAdapter:md_source", data)
|
150
|
+
|
151
|
+
s.delete
|
152
|
+
Store.get_data("source:#{s.app.id}:custom_partition:SampleAdapter:md_source").should == {}
|
153
|
+
Store.get_data("source:#{s.app.id}:cus_user1:SampleAdapter:md_source").should == data
|
154
|
+
Source.valid_doctypes.delete(:md_source)
|
156
155
|
end
|
157
156
|
end
|