marty 2.5.2 → 2.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +4 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +11 -589
- data/Gemfile +9 -9
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -3
- data/app/components/marty/api_auth_view.rb +3 -3
- data/app/components/marty/api_config_view.rb +8 -8
- data/app/components/marty/api_log_view.rb +16 -20
- data/app/components/marty/auth_app.rb +6 -6
- data/app/components/marty/base_rule_view.rb +27 -19
- data/app/components/marty/config_view.rb +12 -9
- data/app/components/marty/data_grid_view.rb +26 -26
- data/app/components/marty/delorean_rule_view.rb +0 -1
- data/app/components/marty/event_view.rb +27 -27
- data/app/components/marty/extras/layout.rb +26 -26
- data/app/components/marty/extras/misc.rb +2 -2
- data/app/components/marty/grid.rb +13 -13
- data/app/components/marty/grid_append_only.rb +0 -1
- data/app/components/marty/import_type_view.rb +13 -13
- data/app/components/marty/import_view.rb +17 -16
- data/app/components/marty/log_view.rb +16 -14
- data/app/components/marty/main_auth_app.rb +59 -59
- data/app/components/marty/main_auth_app/client/main_auth_app.js +3 -3
- data/app/components/marty/mcfly_grid_panel.rb +10 -10
- data/app/components/marty/new_posting_form.rb +11 -11
- data/app/components/marty/new_posting_window.rb +0 -1
- data/app/components/marty/posting_grid.rb +12 -13
- data/app/components/marty/promise_view.rb +6 -6
- data/app/components/marty/report_form.rb +50 -53
- data/app/components/marty/report_select.rb +27 -27
- data/app/components/marty/reporting.rb +4 -4
- data/app/components/marty/script_form.rb +40 -42
- data/app/components/marty/script_grid.rb +24 -24
- data/app/components/marty/script_tester.rb +40 -42
- data/app/components/marty/scripting.rb +25 -27
- data/app/components/marty/simple_app.rb +24 -9
- data/app/components/marty/tag_grid.rb +12 -13
- data/app/components/marty/user_view.rb +35 -35
- data/app/controllers/marty/application_controller.rb +3 -4
- data/app/controllers/marty/components_controller.rb +1 -1
- data/app/controllers/marty/delayed_job_controller.rb +1 -0
- data/app/controllers/marty/diagnostic/controller.rb +4 -6
- data/app/controllers/marty/job_controller.rb +6 -6
- data/app/controllers/marty/report_controller.rb +11 -11
- data/app/controllers/marty/rpc_controller.rb +15 -16
- data/app/helpers/marty/script_set.rb +4 -4
- data/app/models/marty/api_auth.rb +4 -5
- data/app/models/marty/api_config.rb +1 -1
- data/app/models/marty/base.rb +9 -8
- data/app/models/marty/base_rule.rb +18 -13
- data/app/models/marty/config.rb +4 -5
- data/app/models/marty/data_grid.rb +157 -181
- data/app/models/marty/delorean_rule.rb +63 -62
- data/app/models/marty/enum.rb +1 -1
- data/app/models/marty/event.rb +56 -59
- data/app/models/marty/helper.rb +38 -6
- data/app/models/marty/import_type.rb +6 -6
- data/app/models/marty/log.rb +3 -2
- data/app/models/marty/name_validator.rb +3 -2
- data/app/models/marty/pg_enum.rb +3 -4
- data/app/models/marty/posting.rb +20 -24
- data/app/models/marty/promise.rb +28 -30
- data/app/models/marty/script.rb +30 -28
- data/app/models/marty/tag.rb +8 -8
- data/app/models/marty/token.rb +2 -2
- data/app/models/marty/user.rb +24 -23
- data/app/models/marty/vw_promise.rb +10 -11
- data/config/routes.rb +2 -2
- data/delorean/blame_report.dl +268 -0
- data/{spec/dummy/delorean/fields.dl → delorean/marty_fields.dl} +8 -0
- data/delorean/table_report.dl +34 -0
- data/docker-compose.dummy.yml +2 -3
- data/lib/marty/aws/base.rb +8 -8
- data/lib/marty/aws/request.rb +4 -4
- data/lib/marty/cache_adapters/mcfly_ruby_cache.rb +1 -0
- data/lib/marty/content_handler.rb +25 -25
- data/lib/marty/data_change.rb +49 -71
- data/lib/marty/data_conversion.rb +20 -28
- data/lib/marty/data_exporter.rb +25 -28
- data/lib/marty/data_importer.rb +25 -27
- data/lib/marty/engine.rb +1 -2
- data/lib/marty/json_schema.rb +22 -24
- data/lib/marty/logger.rb +6 -9
- data/lib/marty/mcfly_model.rb +20 -24
- data/lib/marty/migrations.rb +37 -35
- data/lib/marty/monkey.rb +33 -33
- data/lib/marty/permissions.rb +18 -18
- data/lib/marty/promise_job.rb +17 -17
- data/lib/marty/promise_proxy.rb +6 -6
- data/lib/marty/relation.rb +6 -7
- data/lib/marty/rpc_call.rb +13 -12
- data/lib/marty/rule_script_set.rb +32 -28
- data/lib/marty/schema_helper.rb +37 -51
- data/lib/marty/util.rb +25 -24
- data/lib/marty/version.rb +1 -1
- data/lib/marty/xl.rb +121 -115
- data/make-dummy.mk +3 -0
- data/marty.gemspec +21 -21
- data/other/marty/api/base.rb +34 -35
- data/other/marty/diagnostic/aws/ec2_instance.rb +8 -8
- data/other/marty/diagnostic/base.rb +13 -14
- data/other/marty/diagnostic/collection.rb +2 -1
- data/other/marty/diagnostic/connections.rb +8 -6
- data/other/marty/diagnostic/database.rb +1 -0
- data/other/marty/diagnostic/delayed_job_version.rb +7 -9
- data/other/marty/diagnostic/delayed_job_worker_total_count.rb +1 -1
- data/other/marty/diagnostic/delayed_job_workers.rb +1 -1
- data/other/marty/diagnostic/environment_variables.rb +17 -15
- data/other/marty/diagnostic/fatal.rb +1 -1
- data/other/marty/diagnostic/node.rb +5 -9
- data/other/marty/diagnostic/nodes.rb +7 -5
- data/other/marty/diagnostic/packer.rb +7 -7
- data/other/marty/diagnostic/reporter.rb +24 -27
- data/other/marty/diagnostic/version.rb +3 -5
- data/script/rails +2 -1
- data/spec/controllers/application_controller_spec.rb +6 -6
- data/spec/controllers/delayed_job_controller_spec.rb +4 -4
- data/spec/controllers/diagnostic/controller_spec.rb +59 -60
- data/spec/controllers/job_controller_spec.rb +68 -69
- data/spec/controllers/rpc_controller_spec.rb +353 -359
- data/spec/controllers/rpc_import_spec.rb +15 -16
- data/spec/dummy/delorean/blame_report.dl +110 -15
- data/spec/dummy/delorean/data_report.dl +4 -4
- data/spec/dummy/delorean/marty_fields.dl +63 -0
- data/spec/dummy/delorean/table_report.dl +34 -0
- data/spec/features/auth_app_spec.rb +1 -2
- data/spec/features/data_import_spec.rb +2 -3
- data/spec/features/enum_spec.rb +42 -46
- data/spec/features/jobs_dashboard_spec.rb +14 -8
- data/spec/features/log_view_spec.rb +40 -43
- data/spec/features/reporting_spec.rb +15 -15
- data/spec/features/rule_spec.rb +195 -190
- data/spec/features/scripting_spec.rb +17 -20
- data/spec/features/scripting_test_spec.rb +32 -33
- data/spec/features/user_view_spec.rb +15 -17
- data/spec/job_helper.rb +11 -11
- data/spec/lib/data_blame_spec.rb +82 -0
- data/spec/lib/data_exporter_spec.rb +31 -32
- data/spec/lib/data_importer_spec.rb +382 -395
- data/spec/lib/delorean_query_spec.rb +117 -119
- data/spec/lib/json_schema_spec.rb +382 -392
- data/spec/lib/logger_spec.rb +23 -24
- data/spec/lib/mcfly_model_spec.rb +112 -109
- data/spec/lib/migrations_spec.rb +10 -10
- data/spec/lib/struct_compare_spec.rb +6 -6
- data/spec/lib/table_report_spec.rb +90 -0
- data/spec/lib/xl_spec.rb +63 -65
- data/spec/lib/xl_styles_spec.rb +16 -19
- data/spec/models/api_auth_spec.rb +30 -30
- data/spec/models/config_spec.rb +32 -32
- data/spec/models/data_grid_spec.rb +642 -655
- data/spec/models/event_spec.rb +96 -88
- data/spec/models/import_type_spec.rb +20 -20
- data/spec/models/posting_spec.rb +35 -35
- data/spec/models/promise_spec.rb +5 -5
- data/spec/models/rule_spec.rb +280 -269
- data/spec/models/script_spec.rb +27 -18
- data/spec/models/user_spec.rb +9 -9
- data/spec/other/diagnostic/base_spec.rb +20 -19
- data/spec/other/diagnostic/collection_spec.rb +6 -5
- data/spec/other/diagnostic/delayed_job_version_spec.rb +1 -1
- data/spec/other/diagnostic/delayed_job_workers_spec.rb +8 -8
- data/spec/other/diagnostic/reporter_spec.rb +31 -33
- data/spec/spec_helper.rb +5 -5
- data/spec/support/chromedriver.rb +3 -5
- data/spec/support/components/netzke_combobox.rb +1 -1
- data/spec/support/components/netzke_grid.rb +17 -17
- data/spec/support/custom_matchers.rb +2 -2
- data/spec/support/download_helper.rb +1 -1
- data/spec/support/helper.rb +1 -2
- data/spec/support/netzke.rb +31 -31
- data/spec/support/performance_helper.rb +8 -8
- data/spec/support/post_run_logger.rb +1 -2
- data/spec/support/setup.rb +1 -4
- data/spec/support/shared_connection.rb +2 -2
- data/spec/support/structure_compare.rb +21 -22
- data/spec/support/suite.rb +1 -2
- data/spec/support/users.rb +5 -6
- metadata +32 -26
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
ENV[
|
2
|
-
ENV[
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
2
|
+
ENV['TZ'] ||= 'America/Los_Angeles'
|
3
3
|
|
4
4
|
require 'dummy/config/application'
|
5
5
|
require 'rspec/rails'
|
@@ -11,15 +11,15 @@ require "#{support}/shared_connection"
|
|
11
11
|
|
12
12
|
Dummy::Application.initialize! unless Dummy::Application.initialized?
|
13
13
|
|
14
|
-
ActiveRecord::Migrator.migrate File.expand_path(
|
15
|
-
ActiveRecord::Migrator.migrate File.expand_path(
|
14
|
+
ActiveRecord::Migrator.migrate File.expand_path('../../db/migrate/', __FILE__)
|
15
|
+
ActiveRecord::Migrator.migrate File.expand_path('../dummy/db/migrate/', __FILE__)
|
16
16
|
|
17
17
|
RSpec.configure do |config|
|
18
18
|
config.include Marty::RSpec::Suite
|
19
19
|
config.include Marty::RSpec::SharedConnection
|
20
20
|
config.include Marty::RSpec::SharedConnectionDbHelpers
|
21
21
|
|
22
|
-
#RspecMarty::SharedConnection.classes_to_exclude_shared = ['Marty::Log']
|
22
|
+
# RspecMarty::SharedConnection.classes_to_exclude_shared = ['Marty::Log']
|
23
23
|
Capybara.default_max_wait_time = 3
|
24
24
|
|
25
25
|
# TODO: Continue to remove should syntax from specs - remove this line to see
|
@@ -2,12 +2,12 @@ require 'selenium-webdriver'
|
|
2
2
|
require Pathname.new(__FILE__).parent.to_s + '/download_helper'
|
3
3
|
|
4
4
|
module Marty; module RSpec; module Chromedriver
|
5
|
-
def self.register_chrome_driver driver= :chrome, opts={}
|
5
|
+
def self.register_chrome_driver driver = :chrome, opts = {}
|
6
6
|
Capybara.register_driver driver do |app|
|
7
7
|
copts = {
|
8
8
|
chromeOptions: opts.deep_merge(
|
9
|
-
prefs: {'download.default_directory' =>
|
10
|
-
Marty::RSpec::DownloadHelper::PATH.to_s}),
|
9
|
+
prefs: { 'download.default_directory' =>
|
10
|
+
Marty::RSpec::DownloadHelper::PATH.to_s }),
|
11
11
|
pageLoadStrategy: 'none',
|
12
12
|
}
|
13
13
|
|
@@ -26,7 +26,6 @@ module Marty; module RSpec; module Chromedriver
|
|
26
26
|
headless_args = ['no-sandbox', 'headless', 'disable-gpu', "window-size=#{window_size}"]
|
27
27
|
|
28
28
|
register_chrome_driver(:headless_chrome, args: headless_args) do |driver|
|
29
|
-
|
30
29
|
# workaround to enable downloading with headless chrome
|
31
30
|
bridge = driver.browser.send(:bridge)
|
32
31
|
bridge.http.call(:post,
|
@@ -41,5 +40,4 @@ module Marty; module RSpec; module Chromedriver
|
|
41
40
|
Capybara.default_driver = :chrome
|
42
41
|
Capybara.javascript_driver = ENV['HEADLESS'] == 'true' ?
|
43
42
|
:headless_chrome : :chrome
|
44
|
-
|
45
43
|
end end end
|
@@ -6,7 +6,7 @@ module Marty; module RSpec; module Components
|
|
6
6
|
class NetzkeGrid
|
7
7
|
include Netzke
|
8
8
|
include Capybara::DSL
|
9
|
-
#include RSpec::Matchers
|
9
|
+
# include RSpec::Matchers
|
10
10
|
|
11
11
|
attr_reader :name, :grid
|
12
12
|
|
@@ -53,7 +53,7 @@ module Marty; module RSpec; module Components
|
|
53
53
|
|
54
54
|
def data_desc row
|
55
55
|
res = run_js <<-JS
|
56
|
-
var r = #{grid}.getStore().getAt(#{row.to_i-1});
|
56
|
+
var r = #{grid}.getStore().getAt(#{row.to_i - 1});
|
57
57
|
return r.data.desc
|
58
58
|
JS
|
59
59
|
res.gsub(/<.*?>/, '')
|
@@ -65,10 +65,10 @@ module Marty; module RSpec; module Components
|
|
65
65
|
return #{ext_find(ext_arg('gridcolumn', text: col), 'grid')}.id
|
66
66
|
JS
|
67
67
|
|
68
|
-
find(
|
68
|
+
find('#' + el).click
|
69
69
|
end
|
70
70
|
|
71
|
-
def get_col_vals(col, cnt=row_count, init=0)
|
71
|
+
def get_col_vals(col, cnt = row_count, init = 0)
|
72
72
|
# NOTE: does not validate the # of rows
|
73
73
|
run_js <<-JS
|
74
74
|
var result = [];
|
@@ -84,7 +84,7 @@ module Marty; module RSpec; module Components
|
|
84
84
|
JS
|
85
85
|
end
|
86
86
|
|
87
|
-
def validate_col_vals(col, val, cnt, init=0)
|
87
|
+
def validate_col_vals(col, val, cnt, init = 0)
|
88
88
|
run_js <<-JS
|
89
89
|
for (var i = #{init}; i < #{init.to_i + cnt.to_i}; i++) {
|
90
90
|
#{ext_cell_val('i', col, grid)}
|
@@ -101,20 +101,20 @@ module Marty; module RSpec; module Components
|
|
101
101
|
JS
|
102
102
|
end
|
103
103
|
|
104
|
-
def select_row(row, click_after=true)
|
104
|
+
def select_row(row, click_after = true)
|
105
105
|
resid = run_js(<<-JS, 10.0)
|
106
106
|
#{ext_var(grid, 'grid')}
|
107
|
-
grid.getSelectionModel().select(#{row.to_i-1});
|
108
|
-
return grid.getView().getNode(#{row.to_i-1}).id;
|
107
|
+
grid.getSelectionModel().select(#{row.to_i - 1});
|
108
|
+
return grid.getView().getNode(#{row.to_i - 1}).id;
|
109
109
|
JS
|
110
110
|
el = find_by_id(resid)
|
111
111
|
el.click if click_after
|
112
112
|
wait_for_ajax
|
113
|
-
|
113
|
+
el
|
114
114
|
end
|
115
115
|
|
116
116
|
def set_row_vals row, fields
|
117
|
-
js_set_fields = fields.each_pair.map do |k,v|
|
117
|
+
js_set_fields = fields.each_pair.map do |k, v|
|
118
118
|
"r.set('#{k}', '#{v}');"
|
119
119
|
end.join
|
120
120
|
|
@@ -124,14 +124,14 @@ module Marty; module RSpec; module Components
|
|
124
124
|
JS
|
125
125
|
end
|
126
126
|
|
127
|
-
def get_row_vals row, fields=nil
|
127
|
+
def get_row_vals row, fields = nil
|
128
128
|
res = run_js <<-JS
|
129
129
|
#{ext_var(grid, 'grid')}
|
130
130
|
return Ext.encode(#{ext_row(row.to_i - 1, 'grid')}.data);
|
131
131
|
JS
|
132
132
|
temp = JSON.parse(res)
|
133
133
|
parsed = temp.merge(temp.delete('association_values') || {})
|
134
|
-
fields ? fields.each_with_object({}).each{|k,h| h[k] = parsed[k]} :
|
134
|
+
fields ? fields.each_with_object({}).each { |k, h| h[k] = parsed[k] } :
|
135
135
|
parsed
|
136
136
|
end
|
137
137
|
|
@@ -201,7 +201,7 @@ module Marty; module RSpec; module Components
|
|
201
201
|
#{ext_var(ext_netzkecombo(field), 'combo')}
|
202
202
|
#{ext_var(ext_celleditor, 'editor')}
|
203
203
|
|
204
|
-
editor.startEditByPosition({ row:#{row.to_i-1},
|
204
|
+
editor.startEditByPosition({ row:#{row.to_i - 1},
|
205
205
|
column:grid.headerCt.items.findIndex('name', '#{field}') });
|
206
206
|
|
207
207
|
var now = new Date().getTime();
|
@@ -216,7 +216,7 @@ module Marty; module RSpec; module Components
|
|
216
216
|
#{ext_var(grid, 'grid')}
|
217
217
|
#{ext_var(ext_celleditor, 'editor')}
|
218
218
|
|
219
|
-
editor.startEditByPosition({ row:#{row.to_i-1},
|
219
|
+
editor.startEditByPosition({ row:#{row.to_i - 1},
|
220
220
|
column:grid.headerCt.items.findIndex('name', '#{field}') });
|
221
221
|
return editor.activeEditor.field.inputId;
|
222
222
|
JS
|
@@ -237,7 +237,7 @@ module Marty; module RSpec; module Components
|
|
237
237
|
#{ext_var(grid, 'grid')}
|
238
238
|
#{ext_var(ext_celleditor, 'editor')}
|
239
239
|
|
240
|
-
editor.startEditByPosition({ row:#{row.to_i-1},
|
240
|
+
editor.startEditByPosition({ row:#{row.to_i - 1},
|
241
241
|
column:grid.headerCt.items.findIndex('name', '#{field}') });
|
242
242
|
return editor.activeEditor.field.getItemId();
|
243
243
|
JS
|
@@ -323,7 +323,7 @@ module Marty; module RSpec; module Components
|
|
323
323
|
#{ext_var(ext_netzkecombo(field), 'combo')}
|
324
324
|
#{ext_var(ext_celleditor, 'editor')}
|
325
325
|
|
326
|
-
editor.startEditByPosition({ row:#{row.to_i-1},
|
326
|
+
editor.startEditByPosition({ row:#{row.to_i - 1},
|
327
327
|
column:grid.headerCt.items.findIndex('name', '#{field}') });
|
328
328
|
|
329
329
|
var now = new Date().getTime();
|
@@ -339,7 +339,7 @@ module Marty; module RSpec; module Components
|
|
339
339
|
#{ext_combo(field, 'combo')}
|
340
340
|
#{ext_var(ext_celleditor, 'editor')}
|
341
341
|
|
342
|
-
editor.startEditByPosition({ row:#{row.to_i-1},
|
342
|
+
editor.startEditByPosition({ row:#{row.to_i - 1},
|
343
343
|
column:grid.headerCt.items.findIndex('name', '#{field}') });
|
344
344
|
JS
|
345
345
|
end
|
@@ -2,8 +2,8 @@ require 'rspec'
|
|
2
2
|
|
3
3
|
RSpec::Matchers.define :netzke_include do |expected|
|
4
4
|
match do |actual|
|
5
|
-
parsed_values = actual.each_with_object({}) do |
|
6
|
-
h[k] = v ==
|
5
|
+
parsed_values = actual.each_with_object({}) do |(k, v), h|
|
6
|
+
h[k] = v == 'False' ? false : v
|
7
7
|
end
|
8
8
|
expect(parsed_values).to include(expected.stringify_keys)
|
9
9
|
end
|
data/spec/support/helper.rb
CHANGED
@@ -6,8 +6,7 @@ module Marty; module RSpec;
|
|
6
6
|
# Helper function which increments a global counter. Can be used by
|
7
7
|
# tests which run Delorean code to see how many times some code is
|
8
8
|
# being called. Works for rule scripts as well.
|
9
|
-
delorean_fn :global_inc, sig: 1 do
|
10
|
-
|inc|
|
9
|
+
delorean_fn :global_inc, sig: 1 do |inc|
|
11
10
|
@@global_inc ||= 0
|
12
11
|
|
13
12
|
if inc
|
data/spec/support/netzke.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Marty; module RSpec; module Netzke
|
2
2
|
MAX_WAIT_TIME = 5.0
|
3
3
|
|
4
|
-
def by message, level=0
|
4
|
+
def by message, level = 0
|
5
5
|
wait_for_ready(10)
|
6
6
|
pending(message) unless block_given?
|
7
7
|
yield
|
@@ -25,39 +25,39 @@ module Marty; module RSpec; module Netzke
|
|
25
25
|
log_out
|
26
26
|
wait_for_ajax
|
27
27
|
end
|
28
|
-
rescue
|
28
|
+
rescue StandardError
|
29
29
|
# ignore error
|
30
30
|
end
|
31
31
|
|
32
|
-
find(:xpath,
|
33
|
-
fill_in(
|
34
|
-
fill_in(
|
35
|
-
press(
|
32
|
+
find(:xpath, '//span', text: 'Sign in', match: :first, wait: 5).click
|
33
|
+
fill_in('login', :with => username)
|
34
|
+
fill_in('password', :with => password)
|
35
|
+
press('OK')
|
36
36
|
wait_for_ajax
|
37
37
|
end
|
38
38
|
|
39
39
|
def log_in_as(username)
|
40
40
|
Rails.configuration.marty.auth_source = 'local'
|
41
41
|
|
42
|
-
ensure_on(
|
42
|
+
ensure_on('/')
|
43
43
|
log_in(username, Rails.configuration.marty.local_password)
|
44
|
-
ensure_on(
|
44
|
+
ensure_on('/')
|
45
45
|
end
|
46
46
|
|
47
47
|
def log_out
|
48
|
-
press(
|
49
|
-
press(
|
48
|
+
press('Current user')
|
49
|
+
press('Sign out')
|
50
50
|
end
|
51
51
|
|
52
52
|
def press button_name, index_of = 0
|
53
53
|
wait_for_element do
|
54
54
|
begin
|
55
55
|
cmp = first("a[data-qtip='#{button_name}']")
|
56
|
-
cmp ||= first(:xpath,
|
56
|
+
cmp ||= first(:xpath, './/a', text: button_name.to_s)
|
57
57
|
cmp ||= find(:btn, button_name, match: :first)
|
58
58
|
cmp.click
|
59
59
|
true
|
60
|
-
rescue
|
60
|
+
rescue StandardError
|
61
61
|
find_by_id(ext_button_id(button_name, index_of), visible: :all).click
|
62
62
|
true
|
63
63
|
end
|
@@ -104,7 +104,7 @@ module Marty; module RSpec; module Netzke
|
|
104
104
|
while !res && current_time - start_time < seconds_to_wait
|
105
105
|
begin
|
106
106
|
res = yield
|
107
|
-
rescue
|
107
|
+
rescue StandardError
|
108
108
|
ensure
|
109
109
|
sleep sleeptime
|
110
110
|
current_time = Time.now
|
@@ -152,9 +152,9 @@ module Marty; module RSpec; module Netzke
|
|
152
152
|
JS
|
153
153
|
end
|
154
154
|
|
155
|
-
def set_field_value value, field_type='textfield', name=''
|
156
|
-
args1 = name.empty? ?
|
157
|
-
args2 = name.empty? ?
|
155
|
+
def set_field_value value, field_type = 'textfield', name = ''
|
156
|
+
args1 = name.empty? ? '' : "[fieldLabel='#{name}']"
|
157
|
+
args2 = name.empty? ? '' : "[name='#{name}']"
|
158
158
|
run_js <<-JS
|
159
159
|
var field = Ext.ComponentQuery.query("#{field_type}#{args1}")[0];
|
160
160
|
field = field || Ext.ComponentQuery.query("#{field_type}#{args2}")[0];
|
@@ -209,31 +209,31 @@ module Marty; module RSpec; module Netzke
|
|
209
209
|
def press_key_in(key, el_id)
|
210
210
|
kd = key.downcase
|
211
211
|
use_key = ['enter', 'return'].include?(kd) ? kd.to_sym : key
|
212
|
-
el = find_by_id(
|
212
|
+
el = find_by_id(el_id.to_s)
|
213
213
|
el.native.send_keys(use_key)
|
214
214
|
end
|
215
215
|
|
216
216
|
def simple_escape! text
|
217
|
-
text.gsub!(/(\r\n|\n)/,
|
218
|
-
text.gsub!(/\t/,
|
217
|
+
text.gsub!(/(\r\n|\n)/, '\\n')
|
218
|
+
text.gsub!(/\t/, '\\t')
|
219
219
|
end
|
220
220
|
|
221
221
|
def simple_escape text
|
222
|
-
text.gsub(/(\r\n|\n)/,
|
223
|
-
|
224
|
-
|
222
|
+
text.gsub(/(\r\n|\n)/, '\\n').
|
223
|
+
gsub(/\t/, '\\t').
|
224
|
+
gsub(/"/, '\"')
|
225
225
|
end
|
226
226
|
|
227
|
-
def type_in(type_s, el_id)
|
228
|
-
el = find_by_id(
|
229
|
-
el.native.clear()
|
227
|
+
def type_in(type_s, el_id, enter: false)
|
228
|
+
el = find_by_id(el_id.to_s)
|
230
229
|
type_s.each_char do |key|
|
231
230
|
el.native.send_keys(key)
|
232
231
|
end
|
233
|
-
el.send_keys(:enter)
|
232
|
+
el.send_keys(:enter) if enter
|
234
233
|
end
|
235
234
|
|
236
235
|
private
|
236
|
+
|
237
237
|
############################################################################
|
238
238
|
# ExtJS/Netzke helper javascripts:
|
239
239
|
# Netzke component lookups, arguments for helper methods
|
@@ -255,7 +255,7 @@ module Marty; module RSpec; module Netzke
|
|
255
255
|
JS
|
256
256
|
end
|
257
257
|
|
258
|
-
def ext_var(ext_find_str, var_name='ext_c')
|
258
|
+
def ext_var(ext_find_str, var_name = 'ext_c')
|
259
259
|
<<-JS
|
260
260
|
var #{var_name} = #{ext_find_str};
|
261
261
|
JS
|
@@ -267,7 +267,7 @@ module Marty; module RSpec; module Netzke
|
|
267
267
|
JS
|
268
268
|
end
|
269
269
|
|
270
|
-
def ext_combo combo_label, c_name='combo'
|
270
|
+
def ext_combo combo_label, c_name = 'combo'
|
271
271
|
<<-JS
|
272
272
|
#{ext_var(ext_find(ext_arg('combobox', fieldLabel: combo_label)), c_name)}
|
273
273
|
#{c_name} = #{c_name} ||
|
@@ -275,19 +275,19 @@ module Marty; module RSpec; module Netzke
|
|
275
275
|
JS
|
276
276
|
end
|
277
277
|
|
278
|
-
def ext_celleditor(grid_name='grid')
|
278
|
+
def ext_celleditor(grid_name = 'grid')
|
279
279
|
<<-JS
|
280
280
|
#{grid_name}.getPlugin('celleditor')
|
281
281
|
JS
|
282
282
|
end
|
283
283
|
|
284
|
-
def ext_row(row, grid_name='grid')
|
284
|
+
def ext_row(row, grid_name = 'grid')
|
285
285
|
<<-JS
|
286
286
|
#{grid_name}.getStore().getAt(#{row})
|
287
287
|
JS
|
288
288
|
end
|
289
289
|
|
290
|
-
def ext_col(col, grid_name='grid')
|
290
|
+
def ext_col(col, grid_name = 'grid')
|
291
291
|
<<-JS
|
292
292
|
#{ext_find(ext_arg('gridcolumn', name: "\"#{col}\""), grid_name)}
|
293
293
|
JS
|
@@ -4,22 +4,22 @@ module Marty; module RSpec; module PerformanceHelper
|
|
4
4
|
include Marty::RSpec::PostRunLogger
|
5
5
|
|
6
6
|
def calculate_baseline iterations
|
7
|
-
Benchmark.measure
|
8
|
-
ActiveRecord::Base.uncached {(0...iterations).each { yield }}
|
9
|
-
|
7
|
+
Benchmark.measure do
|
8
|
+
ActiveRecord::Base.uncached { (0...iterations).each { yield } }
|
9
|
+
end
|
10
10
|
end
|
11
11
|
|
12
|
-
def compare_baseline baseline, timings, opts={}
|
13
|
-
result_time = timings.map
|
12
|
+
def compare_baseline baseline, timings, opts = {}
|
13
|
+
result_time = timings.map(&:total).sum
|
14
14
|
factor = result_time / baseline.total
|
15
15
|
|
16
16
|
lb = opts.delete(:lower_bound) || 1.5
|
17
17
|
ub = opts.delete(:upper_bound) || 5.0
|
18
18
|
|
19
|
-
post_run_log ' '+'-'*45,
|
20
|
-
|
19
|
+
post_run_log ' ' + '-' * 45,
|
20
|
+
' baseline: %.2f, result: %.2f, factor: %.2f' %
|
21
21
|
[baseline.total, result_time, factor],
|
22
|
-
' '+'-'*45
|
22
|
+
' ' + '-' * 45
|
23
23
|
|
24
24
|
expect(result_time).to be_between(baseline.total * lb, baseline.total * ub)
|
25
25
|
end
|
@@ -12,7 +12,7 @@ module Marty; module RSpec; module PostRunLogger
|
|
12
12
|
def self.store_data(name, line)
|
13
13
|
data << " #{test_number}) #{name}"
|
14
14
|
data << Array(line).map { |string| " #{string}" }
|
15
|
-
data <<
|
15
|
+
data << ''
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.dump_data
|
@@ -21,7 +21,6 @@ module Marty; module RSpec; module PostRunLogger
|
|
21
21
|
puts data
|
22
22
|
end
|
23
23
|
end
|
24
|
-
|
25
24
|
end
|
26
25
|
|
27
26
|
def post_run_log(*log_string)
|
data/spec/support/setup.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
module Marty; module RSpec; module Setup
|
2
|
-
|
3
2
|
def marty_whodunnit
|
4
3
|
Mcfly.whodunnit = Marty::User.find_by_login('marty')
|
5
4
|
end
|
@@ -23,14 +22,12 @@ module Marty; module RSpec; module Setup
|
|
23
22
|
end
|
24
23
|
|
25
24
|
def disable_triggers(table_name, &block)
|
26
|
-
begin
|
27
25
|
ActiveRecord::Base.connection.
|
28
26
|
execute("ALTER TABLE #{table_name} DISABLE TRIGGER USER;")
|
29
27
|
|
30
28
|
block.call
|
31
|
-
|
29
|
+
ensure
|
32
30
|
ActiveRecord::Base.connection.
|
33
31
|
execute("ALTER TABLE #{table_name} ENABLE TRIGGER USER;")
|
34
|
-
end
|
35
32
|
end
|
36
33
|
end end end
|