marty 2.5.2 → 2.5.4

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.
Files changed (181) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +4 -0
  3. data/.rubocop.yml +7 -0
  4. data/.rubocop_todo.yml +11 -589
  5. data/Gemfile +9 -9
  6. data/Gemfile.lock +1 -1
  7. data/Rakefile +1 -3
  8. data/app/components/marty/api_auth_view.rb +3 -3
  9. data/app/components/marty/api_config_view.rb +8 -8
  10. data/app/components/marty/api_log_view.rb +16 -20
  11. data/app/components/marty/auth_app.rb +6 -6
  12. data/app/components/marty/base_rule_view.rb +27 -19
  13. data/app/components/marty/config_view.rb +12 -9
  14. data/app/components/marty/data_grid_view.rb +26 -26
  15. data/app/components/marty/delorean_rule_view.rb +0 -1
  16. data/app/components/marty/event_view.rb +27 -27
  17. data/app/components/marty/extras/layout.rb +26 -26
  18. data/app/components/marty/extras/misc.rb +2 -2
  19. data/app/components/marty/grid.rb +13 -13
  20. data/app/components/marty/grid_append_only.rb +0 -1
  21. data/app/components/marty/import_type_view.rb +13 -13
  22. data/app/components/marty/import_view.rb +17 -16
  23. data/app/components/marty/log_view.rb +16 -14
  24. data/app/components/marty/main_auth_app.rb +59 -59
  25. data/app/components/marty/main_auth_app/client/main_auth_app.js +3 -3
  26. data/app/components/marty/mcfly_grid_panel.rb +10 -10
  27. data/app/components/marty/new_posting_form.rb +11 -11
  28. data/app/components/marty/new_posting_window.rb +0 -1
  29. data/app/components/marty/posting_grid.rb +12 -13
  30. data/app/components/marty/promise_view.rb +6 -6
  31. data/app/components/marty/report_form.rb +50 -53
  32. data/app/components/marty/report_select.rb +27 -27
  33. data/app/components/marty/reporting.rb +4 -4
  34. data/app/components/marty/script_form.rb +40 -42
  35. data/app/components/marty/script_grid.rb +24 -24
  36. data/app/components/marty/script_tester.rb +40 -42
  37. data/app/components/marty/scripting.rb +25 -27
  38. data/app/components/marty/simple_app.rb +24 -9
  39. data/app/components/marty/tag_grid.rb +12 -13
  40. data/app/components/marty/user_view.rb +35 -35
  41. data/app/controllers/marty/application_controller.rb +3 -4
  42. data/app/controllers/marty/components_controller.rb +1 -1
  43. data/app/controllers/marty/delayed_job_controller.rb +1 -0
  44. data/app/controllers/marty/diagnostic/controller.rb +4 -6
  45. data/app/controllers/marty/job_controller.rb +6 -6
  46. data/app/controllers/marty/report_controller.rb +11 -11
  47. data/app/controllers/marty/rpc_controller.rb +15 -16
  48. data/app/helpers/marty/script_set.rb +4 -4
  49. data/app/models/marty/api_auth.rb +4 -5
  50. data/app/models/marty/api_config.rb +1 -1
  51. data/app/models/marty/base.rb +9 -8
  52. data/app/models/marty/base_rule.rb +18 -13
  53. data/app/models/marty/config.rb +4 -5
  54. data/app/models/marty/data_grid.rb +157 -181
  55. data/app/models/marty/delorean_rule.rb +63 -62
  56. data/app/models/marty/enum.rb +1 -1
  57. data/app/models/marty/event.rb +56 -59
  58. data/app/models/marty/helper.rb +38 -6
  59. data/app/models/marty/import_type.rb +6 -6
  60. data/app/models/marty/log.rb +3 -2
  61. data/app/models/marty/name_validator.rb +3 -2
  62. data/app/models/marty/pg_enum.rb +3 -4
  63. data/app/models/marty/posting.rb +20 -24
  64. data/app/models/marty/promise.rb +28 -30
  65. data/app/models/marty/script.rb +30 -28
  66. data/app/models/marty/tag.rb +8 -8
  67. data/app/models/marty/token.rb +2 -2
  68. data/app/models/marty/user.rb +24 -23
  69. data/app/models/marty/vw_promise.rb +10 -11
  70. data/config/routes.rb +2 -2
  71. data/delorean/blame_report.dl +268 -0
  72. data/{spec/dummy/delorean/fields.dl → delorean/marty_fields.dl} +8 -0
  73. data/delorean/table_report.dl +34 -0
  74. data/docker-compose.dummy.yml +2 -3
  75. data/lib/marty/aws/base.rb +8 -8
  76. data/lib/marty/aws/request.rb +4 -4
  77. data/lib/marty/cache_adapters/mcfly_ruby_cache.rb +1 -0
  78. data/lib/marty/content_handler.rb +25 -25
  79. data/lib/marty/data_change.rb +49 -71
  80. data/lib/marty/data_conversion.rb +20 -28
  81. data/lib/marty/data_exporter.rb +25 -28
  82. data/lib/marty/data_importer.rb +25 -27
  83. data/lib/marty/engine.rb +1 -2
  84. data/lib/marty/json_schema.rb +22 -24
  85. data/lib/marty/logger.rb +6 -9
  86. data/lib/marty/mcfly_model.rb +20 -24
  87. data/lib/marty/migrations.rb +37 -35
  88. data/lib/marty/monkey.rb +33 -33
  89. data/lib/marty/permissions.rb +18 -18
  90. data/lib/marty/promise_job.rb +17 -17
  91. data/lib/marty/promise_proxy.rb +6 -6
  92. data/lib/marty/relation.rb +6 -7
  93. data/lib/marty/rpc_call.rb +13 -12
  94. data/lib/marty/rule_script_set.rb +32 -28
  95. data/lib/marty/schema_helper.rb +37 -51
  96. data/lib/marty/util.rb +25 -24
  97. data/lib/marty/version.rb +1 -1
  98. data/lib/marty/xl.rb +121 -115
  99. data/make-dummy.mk +3 -0
  100. data/marty.gemspec +21 -21
  101. data/other/marty/api/base.rb +34 -35
  102. data/other/marty/diagnostic/aws/ec2_instance.rb +8 -8
  103. data/other/marty/diagnostic/base.rb +13 -14
  104. data/other/marty/diagnostic/collection.rb +2 -1
  105. data/other/marty/diagnostic/connections.rb +8 -6
  106. data/other/marty/diagnostic/database.rb +1 -0
  107. data/other/marty/diagnostic/delayed_job_version.rb +7 -9
  108. data/other/marty/diagnostic/delayed_job_worker_total_count.rb +1 -1
  109. data/other/marty/diagnostic/delayed_job_workers.rb +1 -1
  110. data/other/marty/diagnostic/environment_variables.rb +17 -15
  111. data/other/marty/diagnostic/fatal.rb +1 -1
  112. data/other/marty/diagnostic/node.rb +5 -9
  113. data/other/marty/diagnostic/nodes.rb +7 -5
  114. data/other/marty/diagnostic/packer.rb +7 -7
  115. data/other/marty/diagnostic/reporter.rb +24 -27
  116. data/other/marty/diagnostic/version.rb +3 -5
  117. data/script/rails +2 -1
  118. data/spec/controllers/application_controller_spec.rb +6 -6
  119. data/spec/controllers/delayed_job_controller_spec.rb +4 -4
  120. data/spec/controllers/diagnostic/controller_spec.rb +59 -60
  121. data/spec/controllers/job_controller_spec.rb +68 -69
  122. data/spec/controllers/rpc_controller_spec.rb +353 -359
  123. data/spec/controllers/rpc_import_spec.rb +15 -16
  124. data/spec/dummy/delorean/blame_report.dl +110 -15
  125. data/spec/dummy/delorean/data_report.dl +4 -4
  126. data/spec/dummy/delorean/marty_fields.dl +63 -0
  127. data/spec/dummy/delorean/table_report.dl +34 -0
  128. data/spec/features/auth_app_spec.rb +1 -2
  129. data/spec/features/data_import_spec.rb +2 -3
  130. data/spec/features/enum_spec.rb +42 -46
  131. data/spec/features/jobs_dashboard_spec.rb +14 -8
  132. data/spec/features/log_view_spec.rb +40 -43
  133. data/spec/features/reporting_spec.rb +15 -15
  134. data/spec/features/rule_spec.rb +195 -190
  135. data/spec/features/scripting_spec.rb +17 -20
  136. data/spec/features/scripting_test_spec.rb +32 -33
  137. data/spec/features/user_view_spec.rb +15 -17
  138. data/spec/job_helper.rb +11 -11
  139. data/spec/lib/data_blame_spec.rb +82 -0
  140. data/spec/lib/data_exporter_spec.rb +31 -32
  141. data/spec/lib/data_importer_spec.rb +382 -395
  142. data/spec/lib/delorean_query_spec.rb +117 -119
  143. data/spec/lib/json_schema_spec.rb +382 -392
  144. data/spec/lib/logger_spec.rb +23 -24
  145. data/spec/lib/mcfly_model_spec.rb +112 -109
  146. data/spec/lib/migrations_spec.rb +10 -10
  147. data/spec/lib/struct_compare_spec.rb +6 -6
  148. data/spec/lib/table_report_spec.rb +90 -0
  149. data/spec/lib/xl_spec.rb +63 -65
  150. data/spec/lib/xl_styles_spec.rb +16 -19
  151. data/spec/models/api_auth_spec.rb +30 -30
  152. data/spec/models/config_spec.rb +32 -32
  153. data/spec/models/data_grid_spec.rb +642 -655
  154. data/spec/models/event_spec.rb +96 -88
  155. data/spec/models/import_type_spec.rb +20 -20
  156. data/spec/models/posting_spec.rb +35 -35
  157. data/spec/models/promise_spec.rb +5 -5
  158. data/spec/models/rule_spec.rb +280 -269
  159. data/spec/models/script_spec.rb +27 -18
  160. data/spec/models/user_spec.rb +9 -9
  161. data/spec/other/diagnostic/base_spec.rb +20 -19
  162. data/spec/other/diagnostic/collection_spec.rb +6 -5
  163. data/spec/other/diagnostic/delayed_job_version_spec.rb +1 -1
  164. data/spec/other/diagnostic/delayed_job_workers_spec.rb +8 -8
  165. data/spec/other/diagnostic/reporter_spec.rb +31 -33
  166. data/spec/spec_helper.rb +5 -5
  167. data/spec/support/chromedriver.rb +3 -5
  168. data/spec/support/components/netzke_combobox.rb +1 -1
  169. data/spec/support/components/netzke_grid.rb +17 -17
  170. data/spec/support/custom_matchers.rb +2 -2
  171. data/spec/support/download_helper.rb +1 -1
  172. data/spec/support/helper.rb +1 -2
  173. data/spec/support/netzke.rb +31 -31
  174. data/spec/support/performance_helper.rb +8 -8
  175. data/spec/support/post_run_logger.rb +1 -2
  176. data/spec/support/setup.rb +1 -4
  177. data/spec/support/shared_connection.rb +2 -2
  178. data/spec/support/structure_compare.rb +21 -22
  179. data/spec/support/suite.rb +1 -2
  180. data/spec/support/users.rb +5 -6
  181. metadata +32 -26
@@ -16,27 +16,27 @@ describe Marty::Event do
16
16
 
17
17
  Marty::Script.load_script_bodies(promise_bodies, Date.today)
18
18
  start_delayed_job
19
- Marty::Config["MARTY_EVENT_POLL_SECS"] = 1
19
+ Marty::Config['MARTY_EVENT_POLL_SECS'] = 1
20
20
 
21
21
  @time = Time.zone.now
22
22
  @date_string = @time.strftime('%Y-%m-%d')
23
23
  @old_start = '1970-01-01 08:00:00'
24
24
  @old_end = '1970-01-01 09:00:00'
25
25
  # add events
26
- [['testcl1', 123, @time, nil, nil, 'AVM', 'a comment',
27
- nil],
28
- ['testcl1', 123, @time + 2.second, nil,nil, 'CRA', 'b comment',
29
- nil],
30
- ['testcl1', 123, @time + 4.seconds, nil,10000, 'PRICING', 'c comment',
31
- nil],
32
- ['testcl1', 234, @time - 5.seconds, @time, nil, 'PRICING', 'c comment',
33
- false],
34
- ['testcl2', 123, @time, nil, 2, 'AVM', 'e comment', nil],
35
- ['testcl2', 123, @time + 1.second, nil, 4, 'CRA', 'f comment', nil],
36
- ['testcl2', 123, Time.zone.parse(@old_start),
37
- Time.zone.parse(@old_end), nil, 'PRICING', 'old event', 0],
38
- ].each do
39
- |klass, subjid, startdt, enddt, expire, op, comment, error|
26
+ [
27
+ ['testcl1', 123, @time, nil, nil, 'AVM', 'a comment',
28
+ nil],
29
+ ['testcl1', 123, @time + 2.second, nil, nil, 'CRA', 'b comment',
30
+ nil],
31
+ ['testcl1', 123, @time + 4.seconds, nil, 10000, 'PRICING', 'c comment',
32
+ nil],
33
+ ['testcl1', 234, @time - 5.seconds, @time, nil, 'PRICING', 'c comment',
34
+ false],
35
+ ['testcl2', 123, @time, nil, 2, 'AVM', 'e comment', nil],
36
+ ['testcl2', 123, @time + 1.second, nil, 4, 'CRA', 'f comment', nil],
37
+ ['testcl2', 123, Time.zone.parse(@old_start),
38
+ Time.zone.parse(@old_end), nil, 'PRICING', 'old event', 0]
39
+ ].each do |klass, subjid, startdt, enddt, expire, op, comment, error|
40
40
  Marty::Event.create!(klass: klass,
41
41
  subject_id: subjid,
42
42
  start_dt: startdt,
@@ -47,18 +47,17 @@ describe Marty::Event do
47
47
  error: error)
48
48
  end
49
49
 
50
-
51
50
  engine = Marty::ScriptSet.new.get_engine(NAME_I)
52
- res = engine.background_eval("SLEEPER", {"secs" => 5}, ["a"],
53
- {klass: "testcl3",
54
- id: 987,
55
- operation: 'PRICING'})
51
+ res = engine.background_eval('SLEEPER', { 'secs' => 5 }, ['a'],
52
+ klass: 'testcl3',
53
+ id: 987,
54
+ operation: 'PRICING')
56
55
  res.force
57
56
  engine = Marty::ScriptSet.new.get_engine(NAME_J)
58
- res = engine.background_eval("FAILER", {"dummy" => "dummy"}, ["a"],
59
- {klass: "testcl3",
60
- id: 654,
61
- operation: 'PRICING'})
57
+ res = engine.background_eval('FAILER', { 'dummy' => 'dummy' }, ['a'],
58
+ klass: 'testcl3',
59
+ id: 654,
60
+ operation: 'PRICING')
62
61
  res.force rescue nil
63
62
  sleep 5
64
63
  save_clean_db(@save_file)
@@ -75,53 +74,51 @@ describe Marty::Event do
75
74
  Marty::Event.clear_cache
76
75
  end
77
76
 
78
-
79
- it "reports currently running" do
77
+ it 'reports currently running' do
80
78
  expect(Marty::Event.currently_running('testcl1', 123)).
81
79
  to eq(['AVM', 'CRA', 'PRICING'])
82
80
  expect(Marty::Event.currently_running('testcl2', 123)).to eq([])
83
81
  expect(Marty::Event.currently_running('testcl3', 987)).to eq([])
84
82
  expect(Marty::Event.last_event('testcl1', 123)).
85
83
  to include(
86
- {"klass"=>"testcl1",
87
- "subject_id"=>123,
88
- "enum_event_operation"=>"PRICING",
89
- "comment"=>"c comment", "expire_secs"=>10000})
84
+ 'klass' => 'testcl1',
85
+ 'subject_id' => 123,
86
+ 'enum_event_operation' => 'PRICING',
87
+ 'comment' => 'c comment', 'expire_secs' => 10000)
90
88
  expect(Marty::Event.last_event('testcl2', 123)).
91
89
  to include(
92
- {"klass"=>"testcl2",
93
- "subject_id"=>123,
94
- "enum_event_operation"=>"PRICING",
95
- "comment"=>"old event"})
90
+ 'klass' => 'testcl2',
91
+ 'subject_id' => 123,
92
+ 'enum_event_operation' => 'PRICING',
93
+ 'comment' => 'old event')
96
94
  expect(Marty::Event.last_event('testcl3', 987)).
97
95
  to include(
98
- {"klass"=>"testcl3",
99
- "subject_id"=>987,
100
- "enum_event_operation"=>"PRICING",
101
- "comment"=>nil,
102
- "expire_secs"=>nil})
96
+ 'klass' => 'testcl3',
97
+ 'subject_id' => 987,
98
+ 'enum_event_operation' => 'PRICING',
99
+ 'comment' => nil,
100
+ 'expire_secs' => nil)
103
101
 
104
- Timecop.freeze(@time+1.second)
102
+ Timecop.freeze(@time + 1.second)
105
103
  Marty::Event.clear_cache
106
104
  expect(Marty::Event.currently_running('testcl1', 123)).
107
105
  to eq(['AVM', 'CRA', 'PRICING'])
108
106
  expect(Marty::Event.currently_running('testcl2', 123)).to eq(['AVM', 'CRA'])
109
107
 
110
- Timecop.freeze(@time+3.seconds)
108
+ Timecop.freeze(@time + 3.seconds)
111
109
  Marty::Event.clear_cache
112
110
  expect(Marty::Event.currently_running('testcl1', 123)).
113
111
  to eq(['AVM', 'CRA', 'PRICING'])
114
112
  expect(Marty::Event.currently_running('testcl2', 123)).to eq(['CRA'])
115
113
 
116
- Timecop.freeze(@time+6.seconds)
114
+ Timecop.freeze(@time + 6.seconds)
117
115
  expect(Marty::Event.currently_running('testcl1', 123)).
118
116
  to eq(['AVM', 'CRA', 'PRICING'])
119
117
  expect(Marty::Event.currently_running('testcl2', 123)).to eq([])
120
118
  Timecop.return
121
-
122
119
  end
123
120
 
124
- it "misc API tests" do
121
+ it 'misc API tests' do
125
122
  ev1 = Marty::Event.where(klass: 'testcl3', subject_id: 987).first
126
123
  ev2 = Marty::Event.where(klass: 'testcl3', subject_id: 654).first
127
124
  af = Marty::Event.all_finished
@@ -160,39 +157,39 @@ describe Marty::Event do
160
157
  expect(Marty::Event.currently_running('testcl1', 123)).
161
158
  to eq(['CRA', 'PRICING'])
162
159
  expect(Marty::Event.currently_running_multi('testcl1', [123])).
163
- to eq({123 => ['CRA', 'PRICING']})
160
+ to eq(123 => ['CRA', 'PRICING'])
164
161
 
165
162
  expect(Marty::Event.op_is_running?('testcl1', 123, 'AVM')).to be_falsey
166
163
  expect(Marty::Event.op_is_running?('testcl1', 123, 'CRA')).to be_truthy
167
164
 
168
165
  ev = Marty::Event.lookup_event('testcl1', 123, 'AVM')
169
166
  expect(ev.length).to eq(1)
170
- expect(ev.first).to include({"klass"=>"testcl1",
171
- "subject_id"=>123,
172
- "enum_event_operation"=>"AVM",
173
- "comment"=>"wassup",
174
- "expire_secs"=>nil,
175
- "error"=> false})
176
- Marty::Event.update_comment(ev.first, "updated")
167
+ expect(ev.first).to include('klass' => 'testcl1',
168
+ 'subject_id' => 123,
169
+ 'enum_event_operation' => 'AVM',
170
+ 'comment' => 'wassup',
171
+ 'expire_secs' => nil,
172
+ 'error' => false)
173
+ Marty::Event.update_comment(ev.first, 'updated')
177
174
  ev = Marty::Event.lookup_event('testcl1', 123, 'AVM')
178
- expect(ev.first).to include({"comment"=>"updated"})
175
+ expect(ev.first).to include('comment' => 'updated')
179
176
  expect(Marty::Event.compact_end_dt(ev.first)).to match(/\d\d:\d\d/)
180
177
  expect(Marty::Event.pretty_op(ev.first)).to eq('Avm')
181
178
  ev = Marty::Event.lookup_event('testcl1', 123, 'PRICING').first
182
179
  expect(Marty::Event.pretty_op(ev)).to eq('Pricing')
183
180
  evs = Marty::Event.last_event_multi('testcl1', [123, 234])
184
- expect(evs[123]).to include({"klass"=>"testcl1",
185
- "subject_id"=>123,
186
- "enum_event_operation"=>"CRA",
187
- "comment"=>"b comment",
188
- "expire_secs"=>nil,
189
- "error"=>nil})
190
- expect(evs[234]).to include({"klass"=>"testcl1",
191
- "subject_id"=>234,
192
- "enum_event_operation"=>"PRICING",
193
- "comment"=>"c comment",
194
- "expire_secs"=>nil,
195
- "error"=>false})
181
+ expect(evs[123]).to include('klass' => 'testcl1',
182
+ 'subject_id' => 123,
183
+ 'enum_event_operation' => 'CRA',
184
+ 'comment' => 'b comment',
185
+ 'expire_secs' => nil,
186
+ 'error' => nil)
187
+ expect(evs[234]).to include('klass' => 'testcl1',
188
+ 'subject_id' => 234,
189
+ 'enum_event_operation' => 'PRICING',
190
+ 'comment' => 'c comment',
191
+ 'expire_secs' => nil,
192
+ 'error' => false)
196
193
 
197
194
  af = Marty::Event.all_finished
198
195
  expect(af.count).to eq(4)
@@ -201,29 +198,41 @@ describe Marty::Event do
201
198
  expect(af[['testcl1', 123]]['AVM']).to start_with(@date_string)
202
199
  end
203
200
 
204
- it "raises on error" do
205
- expect {Marty::Event.create_event('testcl', 1234, 'AVM', Time.zone.now, 600,
206
- "the comment") }.not_to raise_error
201
+ it 'raises on error' do
202
+ expect do
203
+ Marty::Event.create_event('testcl', 1234, 'AVM', Time.zone.now, 600,
204
+ 'the comment')
205
+ end .not_to raise_error
207
206
 
208
- expect {Marty::Event.create_event('testcl', 1234, 'AVM', Time.zone.now, 600,
209
- "the comment") }.
207
+ expect do
208
+ Marty::Event.create_event('testcl', 1234, 'AVM', Time.zone.now, 600,
209
+ 'the comment')
210
+ end.
210
211
  to raise_error(%r!AVM is already running for testcl/1234!)
211
- expect {Marty::Event.create_event('testcl', 2345, 'AVM', Time.zone.now, 600,
212
- "the comment") }.not_to raise_error
213
- expect {Marty::Event.finish_event('testcl', 1234, 'AVM', false,
214
- "new comment") }.
212
+ expect do
213
+ Marty::Event.create_event('testcl', 2345, 'AVM', Time.zone.now, 600,
214
+ 'the comment')
215
+ end .not_to raise_error
216
+ expect do
217
+ Marty::Event.finish_event('testcl', 1234, 'AVM', false,
218
+ 'new comment')
219
+ end.
215
220
  not_to raise_error
216
- expect {Marty::Event.finish_event('testcl', 1234, 'AVM', false,
217
- "new comment") }.
221
+ expect do
222
+ Marty::Event.finish_event('testcl', 1234, 'AVM', false,
223
+ 'new comment')
224
+ end.
218
225
  to raise_error(%r!event testcl/1234/AVM not found!)
219
- expect {Marty::Event.finish_event('testcl', 2345, 'AVM', false, 'foobar') }.
226
+ expect { Marty::Event.finish_event('testcl', 2345, 'AVM', false, 'foobar') }.
220
227
  not_to raise_error
221
- expect {Marty::Event.finish_event('testcl', 2345, 'AVM', false, 'foobar') }.
228
+ expect { Marty::Event.finish_event('testcl', 2345, 'AVM', false, 'foobar') }.
222
229
  to raise_error(%r!event testcl/2345/AVM not found!)
223
- expect {Marty::Event.finish_event('testcl', 2345, 'AVM', nil, 'foobar') }.
230
+ expect { Marty::Event.finish_event('testcl', 2345, 'AVM', nil, 'foobar') }.
224
231
  to raise_error(/error must be true or false/)
225
- expect {Marty::Event.create_event('testcl', 1234, 'AMV', Time.zone.now, 600,
226
- "the comment") }.
232
+ expect do
233
+ Marty::Event.create_event('testcl', 1234, 'AMV', Time.zone.now, 600,
234
+ 'the comment')
235
+ end.
227
236
  to raise_error(%r!PG::.*invalid input value for enum.*"AMV"!)
228
237
  Marty::Event.clear_cache
229
238
  af = Marty::Event.all_finished
@@ -236,8 +245,8 @@ describe Marty::Event do
236
245
  expect(af[['testcl', 2345]]['AVM']).to start_with(@date_string)
237
246
  end
238
247
 
239
- it "truncates long comment" do
240
- long_comment = "comment string abcdefg"*100
248
+ it 'truncates long comment' do
249
+ long_comment = 'comment string abcdefg' * 100
241
250
  long_comment_truncated = long_comment.truncate(255)
242
251
  Marty::Event.create_event('testcl', 123, 'PRICING', Time.zone.now, 600,
243
252
  long_comment)
@@ -249,16 +258,15 @@ describe Marty::Event do
249
258
  comment: long_comment)
250
259
 
251
260
  Marty::Event.create_event('testcl', 789, 'AVM', Time.zone.now, 600,
252
- "comment")
261
+ 'comment')
253
262
  Marty::Event.finish_event('testcl', 789, 'AVM', false, long_comment)
254
263
 
255
264
  e1 = Marty::Event.lookup_event('testcl', 123, 'PRICING').first
256
265
  e2 = Marty::Event.lookup_event('testcl', 456, 'CRA').first
257
266
  e3 = Marty::Event.lookup_event('testcl', 789, 'AVM').first
258
267
 
259
- expect(e1["comment"]).to eq(long_comment_truncated)
260
- expect(e2["comment"]).to eq(long_comment_truncated)
261
- expect(e3["comment"]).to eq(long_comment_truncated)
262
-
268
+ expect(e1['comment']).to eq(long_comment_truncated)
269
+ expect(e2['comment']).to eq(long_comment_truncated)
270
+ expect(e3['comment']).to eq(long_comment_truncated)
263
271
  end
264
272
  end
@@ -17,14 +17,14 @@ module Marty
17
17
 
18
18
  before(:each) do
19
19
  @import = ImportType.new
20
- @import.name = "Test1"
21
- @import.db_model_name = "Marty::ARTestModel"
20
+ @import.name = 'Test1'
21
+ @import.db_model_name = 'Marty::ARTestModel'
22
22
  @import.role_id = role_id
23
23
  @import.save!
24
24
  end
25
25
 
26
- describe "validations" do
27
- it "require name, db_model and role" do
26
+ describe 'validations' do
27
+ it 'require name, db_model and role' do
28
28
  it = ImportType.new
29
29
  expect(it).to_not be_valid
30
30
  expect(it.errors[:name].any?).to be true
@@ -32,28 +32,28 @@ module Marty
32
32
  expect(it.errors[:role_id].any?).to be true
33
33
  end
34
34
 
35
- it "require a unique name" do
35
+ it 'require a unique name' do
36
36
  it = ImportType.new
37
- it.name = "Test1"
38
- it.db_model_name = "Marty::ARTestModel"
37
+ it.name = 'Test1'
38
+ it.db_model_name = 'Marty::ARTestModel'
39
39
  it.role_id = role_id
40
40
  expect(it).to_not be_valid
41
41
  expect(it.errors[:name].any?).to be true
42
42
  end
43
43
 
44
- it "require an ActiveRecord model for the db_model_name" do
44
+ it 'require an ActiveRecord model for the db_model_name' do
45
45
  it = ImportType.new
46
- it.name = "Test1"
47
- it.db_model_name = "Marty::TestModel"
46
+ it.name = 'Test1'
47
+ it.db_model_name = 'Marty::TestModel'
48
48
  it.role_id = role_id
49
49
  expect(it).to_not be_valid
50
- expect(it.errors[:base][0]).to eq "bad model name"
50
+ expect(it.errors[:base][0]).to eq 'bad model name'
51
51
  end
52
52
 
53
- it "do not fail on blank strings for functions" do
54
- @import.cleaner_function = ""
55
- @import.validation_function = " "
56
- @import.preprocess_function = " "
53
+ it 'do not fail on blank strings for functions' do
54
+ @import.cleaner_function = ''
55
+ @import.validation_function = ' '
56
+ @import.preprocess_function = ' '
57
57
 
58
58
  expect(@import).to be_valid
59
59
  @import.save!
@@ -62,15 +62,15 @@ module Marty
62
62
  expect(@import.preprocess_function).to be nil
63
63
  end
64
64
 
65
- it "require valid functions for cleaner/validation/preprocess" do
66
- @import.cleaner_function = "import_cleaner"
67
- @import.validation_function = "import_validator"
65
+ it 'require valid functions for cleaner/validation/preprocess' do
66
+ @import.cleaner_function = 'import_cleaner'
67
+ @import.validation_function = 'import_validator'
68
68
  expect(@import).to be_valid
69
69
 
70
- @import.preprocess_function = "missing_func"
70
+ @import.preprocess_function = 'missing_func'
71
71
  expect(@import).to_not be_valid
72
72
  expect(@import.errors[:base][0]).
73
- to eq "unknown class method missing_func"
73
+ to eq 'unknown class method missing_func'
74
74
  end
75
75
  end
76
76
  end
@@ -2,36 +2,36 @@ require 'spec_helper'
2
2
 
3
3
  module Marty
4
4
  describe Posting do
5
- describe "validations" do
6
- it "requires unique names" do
7
- dt = "20130215 0800"
5
+ describe 'validations' do
6
+ it 'requires unique names' do
7
+ dt = '20130215 0800'
8
8
  c = Posting.count
9
- Posting.do_create("BASE", dt, 'a comment')
9
+ Posting.do_create('BASE', dt, 'a comment')
10
10
  Posting.count.should == c + 1
11
- expect { s = Posting.do_create("BASE", dt, 'a comment') }.
11
+ expect { s = Posting.do_create('BASE', dt, 'a comment') }.
12
12
  to raise_error(ActiveRecord::RecordInvalid)
13
13
  end
14
14
 
15
- it "creates name based on PDT" do
16
- d, t, tz = "20130215", "0900", "PST8PDT"
15
+ it 'creates name based on PDT' do
16
+ d, t, tz = '20130215', '0900', 'PST8PDT'
17
17
  dt_tz = [d, t, tz].join(' ')
18
- p = Posting.do_create("BASE", dt_tz, 'a comment')
18
+ p = Posting.do_create('BASE', dt_tz, 'a comment')
19
19
  expect(p.name).to match /BASE-#{d}-#{t}/
20
20
  p.reload
21
21
  expect(p.created_dt).to eq Time.zone.parse(dt_tz)
22
22
  end
23
23
  end
24
24
 
25
- describe "lookups" do
26
- it "are seeded with a NOW posting" do
27
- expect(Posting.lookup_dt("NOW")).to eq Float::INFINITY
25
+ describe 'lookups' do
26
+ it 'are seeded with a NOW posting' do
27
+ expect(Posting.lookup_dt('NOW')).to eq Float::INFINITY
28
28
  end
29
29
 
30
- describe ".get_latest" do
31
- it "provide a list of latest of postings in descending order" do
32
- 4.times { |d|
33
- Posting.do_create("BASE", d.day.from_now, 'a comment')
34
- }
30
+ describe '.get_latest' do
31
+ it 'provide a list of latest of postings in descending order' do
32
+ 4.times do |d|
33
+ Posting.do_create('BASE', d.day.from_now, 'a comment')
34
+ end
35
35
  dt3 = 3.day.from_now
36
36
 
37
37
  latest = Posting.get_latest(1)
@@ -40,32 +40,32 @@ module Marty
40
40
  end
41
41
  end
42
42
 
43
- describe ".get_latest_by_type" do
44
- context "when invalid parameters are supplied" do
43
+ describe '.get_latest_by_type' do
44
+ context 'when invalid parameters are supplied' do
45
45
  it "raises 'posting type list missing' error" do
46
46
  expect { Posting.get_latest_by_type(10, nil) }.
47
- to raise_error "missing posting types list"
47
+ to raise_error 'missing posting types list'
48
48
  end
49
49
 
50
50
  it "raises 'bad posting types list' error" do
51
51
  expect { Posting.get_latest_by_type(10, 'BASE') }.
52
- to raise_error "bad posting types list"
52
+ to raise_error 'bad posting types list'
53
53
  end
54
54
  end
55
55
 
56
- context "when valid parameters are supplied" do
56
+ context 'when valid parameters are supplied' do
57
57
  before do
58
- PostingType.create({name: 'SNAPSHOT'})
59
- PostingType.create({name: 'OTHER'})
60
- Posting.do_create("BASE", 0.day.from_now, 'base posting')
61
- Posting.do_create("SNAPSHOT", 1.day.from_now, 'snapshot1 posting')
62
- Posting.do_create("SNAPSHOT", 2.day.from_now, 'snapshot2 posting')
63
- Posting.do_create("OTHER" , 3.day.from_now, 'other1 posting')
64
- Posting.do_create("SNAPSHOT", 4.day.from_now, 'snapshot3 posting')
65
- Posting.do_create("OTHER" , 5.day.from_now, 'other2 posting')
58
+ PostingType.create(name: 'SNAPSHOT')
59
+ PostingType.create(name: 'OTHER')
60
+ Posting.do_create('BASE', 0.day.from_now, 'base posting')
61
+ Posting.do_create('SNAPSHOT', 1.day.from_now, 'snapshot1 posting')
62
+ Posting.do_create('SNAPSHOT', 2.day.from_now, 'snapshot2 posting')
63
+ Posting.do_create('OTHER', 3.day.from_now, 'other1 posting')
64
+ Posting.do_create('SNAPSHOT', 4.day.from_now, 'snapshot3 posting')
65
+ Posting.do_create('OTHER', 5.day.from_now, 'other2 posting')
66
66
  end
67
67
 
68
- it "filters on a single posting type" do
68
+ it 'filters on a single posting type' do
69
69
  # First param is just the limit (max) to return
70
70
  res = Posting.get_latest_by_type(10, ['BASE'])
71
71
  expect(res.count).to eq 1
@@ -73,7 +73,7 @@ module Marty
73
73
  expect(r0.comment).to eq 'base posting'
74
74
  end
75
75
 
76
- it "filters on multiple posting types" do
76
+ it 'filters on multiple posting types' do
77
77
  res = Posting.get_latest_by_type(10, ['BASE', 'SNAPSHOT'])
78
78
  expect(res.count).to eq 4
79
79
  # snapshot3 is most recent with this filter
@@ -83,8 +83,8 @@ module Marty
83
83
  expect(r3.comment).to eq 'base posting'
84
84
  end
85
85
 
86
- it "filters on posting types that are single or double quoted" do
87
- res = Posting.get_latest_by_type(10, ['SNAPSHOT', "OTHER"])
86
+ it 'filters on posting types that are single or double quoted' do
87
+ res = Posting.get_latest_by_type(10, ['SNAPSHOT', 'OTHER'])
88
88
  expect(res.count).to eq 5
89
89
  # other2 is most recent with this filter
90
90
  r0 = Posting.find_by_name(res[0]['name'])
@@ -93,7 +93,7 @@ module Marty
93
93
  expect(r4.comment).to eq 'snapshot1 posting'
94
94
  end
95
95
 
96
- it "filters and limits on multiple posting types" do
96
+ it 'filters and limits on multiple posting types' do
97
97
  res = Posting.get_latest_by_type(3, ['SNAPSHOT', 'OTHER'])
98
98
  expect(res.count).to eq 3
99
99
  # other2 is most recent with this filter
@@ -103,7 +103,7 @@ module Marty
103
103
  expect(r2.comment).to eq 'other1 posting'
104
104
  end
105
105
 
106
- it "returns nothing with an empty posting type list" do
106
+ it 'returns nothing with an empty posting type list' do
107
107
  res = Posting.get_latest_by_type(10, [])
108
108
  expect(res.count).to eq 0
109
109
  end