marty 2.6.8 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +1 -5
- data/Gemfile +1 -1
- data/Gemfile.lock +10 -12
- data/app/models/marty/pg_enum.rb +17 -10
- data/lib/marty/mcfly_model.rb +10 -0
- data/lib/marty/monkey.rb +17 -25
- data/lib/marty/version.rb +1 -1
- data/marty.gemspec +1 -1
- data/spec/dummy/app/components/gemini/my_rule_view.rb +19 -0
- data/spec/dummy/app/components/gemini/xyz_rule_view.rb +19 -0
- data/spec/dummy/delorean/delorean_fn.dl +33 -0
- data/spec/features/enum_spec.rb +2 -0
- data/spec/features/rule_spec.rb +15 -2
- data/spec/lib/mcfly_model_spec.rb +30 -9
- data/spec/models/script_spec.rb +79 -5
- data/spec/support/chromedriver.rb +3 -0
- metadata +5 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e0e03798f9be33a5ac6995f9a6bf568b4b9928c6548d85b3070e77d509d0265d
|
|
4
|
+
data.tar.gz: c6d25161882530320f08258601a6a4fc41550de79e50d061b130c29d76b9ecbe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24595f41c2364b5c8594d12031700b4a25698a1a77a06091f268b11762154dd78090a3cd3f8390b77e321eed5e34e87fb274ce92f0dff7bc78a7b3f88970c3d3
|
|
7
|
+
data.tar.gz: 61bd8abc08224bfbebaf55623f045b894c0fb098522cf682d8bb4aea88dec138f1eddb55e6b898855ac317a9d0aaa39f81a1ce626af56015960c464d9231156a
|
data/.gitlab-ci.yml
CHANGED
|
@@ -28,11 +28,7 @@ rspec-features:
|
|
|
28
28
|
extends: .base-test
|
|
29
29
|
script:
|
|
30
30
|
- ln -s /opt/support/extjs /cm_tech/marty/spec/dummy/public/extjs
|
|
31
|
-
-
|
|
32
|
-
# - bundle exec rspec --pattern "spec/features/**/*_spec.rb"
|
|
33
|
-
# FIXME: rule_spec is excluded, because chrome doesn't work with big window size in docker
|
|
34
|
-
# And test fails with 1400/1400 resolution
|
|
35
|
-
- bundle exec rspec --pattern "spec/features/**/*_spec.rb" --exclude-pattern "spec/features/rule_spec.rb"
|
|
31
|
+
- bundle exec rspec spec/features
|
|
36
32
|
|
|
37
33
|
cache:
|
|
38
34
|
key: 'marty_bundler_cache'
|
data/Gemfile
CHANGED
|
@@ -13,7 +13,6 @@ gem 'sqlite3'
|
|
|
13
13
|
|
|
14
14
|
group :development, :test do
|
|
15
15
|
gem 'capybara', '~> 2.18.0'
|
|
16
|
-
gem 'chromedriver-helper'
|
|
17
16
|
gem 'connection_pool'
|
|
18
17
|
gem 'database_cleaner'
|
|
19
18
|
gem 'pry-byebug'
|
|
@@ -24,6 +23,7 @@ group :development, :test do
|
|
|
24
23
|
gem 'rubocop', require: false
|
|
25
24
|
gem 'selenium-webdriver'
|
|
26
25
|
gem 'timecop'
|
|
26
|
+
gem 'webdrivers'
|
|
27
27
|
|
|
28
28
|
# gem 'mcfly', path: File.expand_path('../../mcfly', __FILE__)
|
|
29
29
|
gem 'mcfly'
|
data/Gemfile.lock
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
marty (2.
|
|
4
|
+
marty (2.7.0)
|
|
5
5
|
aws-sigv4 (~> 1.0, >= 1.0.2)
|
|
6
6
|
axlsx (= 3.0.0pre)
|
|
7
7
|
coderay
|
|
8
8
|
daemons (~> 1.3.1)
|
|
9
9
|
delayed_job_active_record
|
|
10
|
-
delorean_lang (~> 0.
|
|
10
|
+
delorean_lang (~> 0.6.0)
|
|
11
11
|
json-schema
|
|
12
12
|
mcfly (~> 0.0.20)
|
|
13
13
|
net-ldap (~> 0.16.1)
|
|
@@ -58,8 +58,6 @@ GEM
|
|
|
58
58
|
tzinfo (~> 1.1)
|
|
59
59
|
addressable (2.6.0)
|
|
60
60
|
public_suffix (>= 2.0.2, < 4.0)
|
|
61
|
-
archive-zip (0.11.0)
|
|
62
|
-
io-like (~> 0.3.0)
|
|
63
61
|
arel (8.0.0)
|
|
64
62
|
ast (2.4.0)
|
|
65
63
|
aws-eventstream (1.0.3)
|
|
@@ -81,15 +79,12 @@ GEM
|
|
|
81
79
|
xpath (>= 2.0, < 4.0)
|
|
82
80
|
childprocess (0.9.0)
|
|
83
81
|
ffi (~> 1.0, >= 1.0.11)
|
|
84
|
-
chromedriver-helper (2.1.0)
|
|
85
|
-
archive-zip (~> 0.10)
|
|
86
|
-
nokogiri (~> 1.8)
|
|
87
82
|
coderay (1.1.2)
|
|
88
83
|
coffee-script (2.4.1)
|
|
89
84
|
coffee-script-source
|
|
90
85
|
execjs
|
|
91
86
|
coffee-script-source (1.12.2)
|
|
92
|
-
concurrent-ruby (1.1.
|
|
87
|
+
concurrent-ruby (1.1.5)
|
|
93
88
|
connection_pool (2.2.2)
|
|
94
89
|
crass (1.0.4)
|
|
95
90
|
daemons (1.3.1)
|
|
@@ -99,7 +94,7 @@ GEM
|
|
|
99
94
|
delayed_job_active_record (4.1.3)
|
|
100
95
|
activerecord (>= 3.0, < 5.3)
|
|
101
96
|
delayed_job (>= 3.0, < 5)
|
|
102
|
-
delorean_lang (0.
|
|
97
|
+
delorean_lang (0.6.1)
|
|
103
98
|
activerecord (>= 3.2)
|
|
104
99
|
treetop (~> 1.5)
|
|
105
100
|
diff-lcs (1.3)
|
|
@@ -109,9 +104,8 @@ GEM
|
|
|
109
104
|
globalid (0.4.2)
|
|
110
105
|
activesupport (>= 4.2.0)
|
|
111
106
|
htmlentities (4.3.4)
|
|
112
|
-
i18n (1.
|
|
107
|
+
i18n (1.6.0)
|
|
113
108
|
concurrent-ruby (~> 1.0)
|
|
114
|
-
io-like (0.3.0)
|
|
115
109
|
jaro_winkler (1.5.2)
|
|
116
110
|
json-schema (2.8.1)
|
|
117
111
|
addressable (>= 2.4)
|
|
@@ -249,6 +243,10 @@ GEM
|
|
|
249
243
|
uglifier (4.1.20)
|
|
250
244
|
execjs (>= 0.3.0, < 3)
|
|
251
245
|
unicode-display_width (1.4.1)
|
|
246
|
+
webdrivers (3.9.4)
|
|
247
|
+
nokogiri (~> 1.6)
|
|
248
|
+
rubyzip (~> 1.0)
|
|
249
|
+
selenium-webdriver (~> 3.0)
|
|
252
250
|
websocket-driver (0.6.5)
|
|
253
251
|
websocket-extensions (>= 0.1.0)
|
|
254
252
|
websocket-extensions (0.1.3)
|
|
@@ -260,7 +258,6 @@ PLATFORMS
|
|
|
260
258
|
|
|
261
259
|
DEPENDENCIES
|
|
262
260
|
capybara (~> 2.18.0)
|
|
263
|
-
chromedriver-helper
|
|
264
261
|
connection_pool
|
|
265
262
|
daemons
|
|
266
263
|
database_cleaner
|
|
@@ -280,6 +277,7 @@ DEPENDENCIES
|
|
|
280
277
|
selenium-webdriver
|
|
281
278
|
sqlite3
|
|
282
279
|
timecop
|
|
280
|
+
webdrivers
|
|
283
281
|
|
|
284
282
|
BUNDLED WITH
|
|
285
283
|
2.0.1
|
data/app/models/marty/pg_enum.rb
CHANGED
|
@@ -9,15 +9,25 @@ module Marty::PgEnum
|
|
|
9
9
|
index
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def get_all(pt = nil)
|
|
13
|
-
self::VALUES.map(&:to_s)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
12
|
def self.extended(base)
|
|
17
13
|
base.class_eval do
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
extend ::Delorean::Functions unless respond_to?(:delorean_fn)
|
|
15
|
+
|
|
16
|
+
delorean_fn :get_all do |pt = nil|
|
|
17
|
+
self::VALUES.map(&:to_s)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
delorean_fn :[] do |i0, i1 = nil|
|
|
21
|
+
super(i0, i1)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
delorean_fn :lookup do |i0, i1 = nil|
|
|
25
|
+
send(:[], i0, i1)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
delorean_fn :find_by_name do |i0, i1 = nil|
|
|
29
|
+
send(:[], i0, i1)
|
|
30
|
+
end
|
|
21
31
|
end
|
|
22
32
|
end
|
|
23
33
|
|
|
@@ -27,7 +37,4 @@ module Marty::PgEnum
|
|
|
27
37
|
def _pg_enum?
|
|
28
38
|
true
|
|
29
39
|
end
|
|
30
|
-
|
|
31
|
-
alias_method :find_by_name, :[]
|
|
32
|
-
alias_method :lookup, :[]
|
|
33
40
|
end
|
data/lib/marty/mcfly_model.rb
CHANGED
|
@@ -16,6 +16,16 @@ module Mcfly::Model
|
|
|
16
16
|
send(meth, name, options) do |ts, *args|
|
|
17
17
|
raise 'time cannot be nil' if ts.nil?
|
|
18
18
|
|
|
19
|
+
# FIXME: sig is removed from delorean. We need to find a better way
|
|
20
|
+
# to control amount of arguments, instead of using *splat arguments.
|
|
21
|
+
max_args = Array(options[:sig]).max if options[:sig]
|
|
22
|
+
if max_args && (args.size + 1) > max_args
|
|
23
|
+
err = "Too many args to #{name}." \
|
|
24
|
+
"(given #{args.size + 1}, expected #{max_args})"
|
|
25
|
+
|
|
26
|
+
raise ArgumentError, err
|
|
27
|
+
end
|
|
28
|
+
|
|
19
29
|
ts = Mcfly.normalize_infinity(ts)
|
|
20
30
|
q = where("#{table_name}.obsoleted_dt >= ? AND " +
|
|
21
31
|
"#{table_name}.created_dt < ?", ts, ts).scoping do
|
data/lib/marty/monkey.rb
CHANGED
|
@@ -256,23 +256,6 @@ end
|
|
|
256
256
|
require 'marty/cache_adapters'
|
|
257
257
|
|
|
258
258
|
class ActiveRecord::Base
|
|
259
|
-
MCFLY_PT_SIG = [1, 1]
|
|
260
|
-
|
|
261
|
-
# FIXME: hacky signatures for AR queries on classes
|
|
262
|
-
COUNT_SIG = [0, 0]
|
|
263
|
-
DISTINCT_SIG = [0, 100]
|
|
264
|
-
FIND_BY_SIG = [0, 100]
|
|
265
|
-
FIRST_SIG = [0, 1]
|
|
266
|
-
GROUP_SIG = [1, 100]
|
|
267
|
-
JOINS_SIG = [1, 100]
|
|
268
|
-
LAST_SIG = [0, 1]
|
|
269
|
-
LIMIT_SIG = [1, 1]
|
|
270
|
-
NOT_SIG = [1, 100]
|
|
271
|
-
ORDER_SIG = [1, 100]
|
|
272
|
-
PLUCK_SIG = [1, 100]
|
|
273
|
-
SELECT_SIG = [1, 100]
|
|
274
|
-
WHERE_SIG = [0, 100]
|
|
275
|
-
|
|
276
259
|
class << self
|
|
277
260
|
alias_method :old_joins, :joins
|
|
278
261
|
|
|
@@ -290,19 +273,22 @@ end
|
|
|
290
273
|
|
|
291
274
|
ar_instances = [ActiveRecord::Relation, ActiveRecord::QueryMethods::WhereChain]
|
|
292
275
|
|
|
293
|
-
args_hack = [[Object, nil]] *
|
|
276
|
+
args_hack = [[Object, nil]] * 30
|
|
294
277
|
|
|
295
278
|
[
|
|
296
279
|
[:distinct, args_hack],
|
|
280
|
+
[:count, []],
|
|
297
281
|
[:find_by, args_hack],
|
|
282
|
+
[:first, args_hack],
|
|
298
283
|
[:group, args_hack],
|
|
299
284
|
[:joins, args_hack],
|
|
300
285
|
[:limit, [Integer]],
|
|
286
|
+
[:last, [[Integer, nil]]],
|
|
301
287
|
[:not, args_hack],
|
|
302
|
-
[:order,
|
|
303
|
-
[:pluck,
|
|
304
|
-
[:select,
|
|
305
|
-
[:where,
|
|
288
|
+
[:order, args_hack],
|
|
289
|
+
[:pluck, args_hack],
|
|
290
|
+
[:select, args_hack],
|
|
291
|
+
[:where, args_hack],
|
|
306
292
|
[:mcfly_pt, [[Date, Time, ActiveSupport::TimeWithZone, String], [nil, Class]]]
|
|
307
293
|
].each do |meth, args|
|
|
308
294
|
::Delorean::Ruby.whitelist.add_method meth do |method|
|
|
@@ -310,12 +296,18 @@ args_hack = [[Object, nil]] * 10
|
|
|
310
296
|
method.called_on ar, with: args
|
|
311
297
|
end
|
|
312
298
|
end
|
|
299
|
+
|
|
300
|
+
::Delorean::Ruby.whitelist.add_class_method meth do |method|
|
|
301
|
+
method.called_on ActiveRecord::Base, with: args
|
|
302
|
+
end
|
|
313
303
|
end
|
|
304
|
+
|
|
314
305
|
::Delorean::Ruby.whitelist.add_method :count do |method|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
306
|
+
ar_instances.each do |ar|
|
|
307
|
+
method.called_on ar
|
|
308
|
+
end
|
|
318
309
|
end
|
|
310
|
+
|
|
319
311
|
::Delorean::Ruby.whitelist.add_method :lookup_grid_distinct_entry do |method|
|
|
320
312
|
method.called_on OpenStruct, with: [[Date, Time,
|
|
321
313
|
ActiveSupport::TimeWithZone, String],
|
data/lib/marty/version.rb
CHANGED
data/marty.gemspec
CHANGED
|
@@ -66,4 +66,23 @@ class Gemini::MyRuleView < Marty::DeloreanRuleView
|
|
|
66
66
|
enum_column(c, Gemini::MyRuleType)
|
|
67
67
|
end
|
|
68
68
|
|
|
69
|
+
# Override width, so it would fit in chrome window in tests
|
|
70
|
+
component :add_window do |c|
|
|
71
|
+
super(c)
|
|
72
|
+
c.width = 1200
|
|
73
|
+
c.height = 740
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
component :edit_window do |c|
|
|
77
|
+
super(c)
|
|
78
|
+
c.width = 1200
|
|
79
|
+
c.height = 740
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
component :view_window do |c|
|
|
83
|
+
super(c)
|
|
84
|
+
c.width = 1200
|
|
85
|
+
c.height = 740
|
|
86
|
+
end
|
|
87
|
+
|
|
69
88
|
end
|
|
@@ -15,6 +15,7 @@ class Gemini::XyzRuleView < Marty::DeloreanRuleView
|
|
|
15
15
|
def default_form_items
|
|
16
16
|
super
|
|
17
17
|
end
|
|
18
|
+
|
|
18
19
|
self.init_fields
|
|
19
20
|
|
|
20
21
|
attribute :rule_type do |c|
|
|
@@ -22,4 +23,22 @@ class Gemini::XyzRuleView < Marty::DeloreanRuleView
|
|
|
22
23
|
enum_column(c, Gemini::XyzRuleType)
|
|
23
24
|
end
|
|
24
25
|
|
|
26
|
+
# Override width, so it would fit in chrome window in tests
|
|
27
|
+
component :add_window do |c|
|
|
28
|
+
super(c)
|
|
29
|
+
c.width = 1200
|
|
30
|
+
c.height = 740
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
component :edit_window do |c|
|
|
34
|
+
super(c)
|
|
35
|
+
c.width = 1200
|
|
36
|
+
c.height = 740
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
component :view_window do |c|
|
|
40
|
+
super(c)
|
|
41
|
+
c.width = 1200
|
|
42
|
+
c.height = 740
|
|
43
|
+
end
|
|
25
44
|
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
DeloreanFnTest:
|
|
2
|
+
get_all = Gemini::GuardOne.get_all
|
|
3
|
+
lookup = Gemini::GuardOne.lookup('G1V1')
|
|
4
|
+
find_by_name = Gemini::GuardOne.find_by_name('G1V1')
|
|
5
|
+
brackets = Gemini::GuardOne['G1V1']
|
|
6
|
+
result = Gemini::GuardOne.get_all()
|
|
7
|
+
|
|
8
|
+
ActiveRecord:
|
|
9
|
+
time =?
|
|
10
|
+
|
|
11
|
+
distinct = Marty::Script.distinct
|
|
12
|
+
distinct_select = Marty::Script.distinct().select('name')
|
|
13
|
+
count = Marty::Script.count
|
|
14
|
+
find_by = Marty::Script.find_by({ 'name' : 'DeloreanFn' })
|
|
15
|
+
first = Marty::Script.first
|
|
16
|
+
first2 = Marty::Script.first(2)
|
|
17
|
+
|
|
18
|
+
group_count = Marty::Script.group('created_dt').count
|
|
19
|
+
joins = Marty::Script.joins('user')
|
|
20
|
+
limit3 = Marty::Script.limit(3)
|
|
21
|
+
|
|
22
|
+
last = Marty::Script.last
|
|
23
|
+
last3 = Marty::Script.last(3)
|
|
24
|
+
|
|
25
|
+
order = Marty::Script.order('name')
|
|
26
|
+
|
|
27
|
+
pluck = Marty::Script.pluck('name')
|
|
28
|
+
pluck2 = Marty::Script.pluck('name', 'user_id')
|
|
29
|
+
|
|
30
|
+
select = Marty::Script.select('name')
|
|
31
|
+
select2 = Marty::Script.select('name', 'user_id')
|
|
32
|
+
where_not = Marty::Script.where.not({ 'user_id' : nil })
|
|
33
|
+
mcfly_pt = Marty::Script.mcfly_pt(time)
|
data/spec/features/enum_spec.rb
CHANGED
|
@@ -175,11 +175,13 @@ feature 'test netzke + pg_enum compatibility', js: true do
|
|
|
175
175
|
|
|
176
176
|
and_by 'filter form by state_enum ASCENDING' do
|
|
177
177
|
press('Enum state')
|
|
178
|
+
wait_for_ajax
|
|
178
179
|
expect(lp_grid.get_col_vals(:enum_state)).to eq(['AS', 'AZ', 'DC', 'WA'])
|
|
179
180
|
end
|
|
180
181
|
|
|
181
182
|
and_by 'filter form by state_enum DESCENDING' do
|
|
182
183
|
press('Enum state')
|
|
184
|
+
wait_for_ajax
|
|
183
185
|
expect(lp_grid.get_col_vals(:enum_state)).to eq(['WA', 'DC', 'AZ', 'AS'])
|
|
184
186
|
end
|
|
185
187
|
end
|
data/spec/features/rule_spec.rb
CHANGED
|
@@ -9,14 +9,17 @@ feature 'rule view', js: true do
|
|
|
9
9
|
Marty::Script.load_scripts
|
|
10
10
|
dt = DateTime.parse('2017-1-1')
|
|
11
11
|
p = File.expand_path('../../fixtures/csv/rule', __FILE__)
|
|
12
|
+
|
|
12
13
|
[Marty::DataGrid, Gemini::XyzRule, Gemini::MyRule].each do |klass|
|
|
13
14
|
f = '%s/%s.csv' % [p, klass.to_s.sub(/(Gemini|Marty)::/, '')]
|
|
14
15
|
Marty::DataImporter.do_import(klass, File.read(f), dt, nil, nil, ',')
|
|
15
16
|
end
|
|
16
17
|
end
|
|
18
|
+
|
|
17
19
|
after(:all) do
|
|
18
20
|
restore_clean_db(@save_file)
|
|
19
21
|
end
|
|
22
|
+
|
|
20
23
|
def go_to_my_rules
|
|
21
24
|
press('Pricing Config.')
|
|
22
25
|
press('My Rules')
|
|
@@ -57,8 +60,17 @@ feature 'rule view', js: true do
|
|
|
57
60
|
end
|
|
58
61
|
|
|
59
62
|
def column_filter(rv, name, value)
|
|
60
|
-
|
|
61
|
-
|
|
63
|
+
begin
|
|
64
|
+
cid = col_id(rv, name)
|
|
65
|
+
c = find('#' + cid)
|
|
66
|
+
rescue Capybara::ElementNotFound
|
|
67
|
+
# Scroll to the element
|
|
68
|
+
page.execute_script <<-JS
|
|
69
|
+
var element = document.getElementById('#{cid}')
|
|
70
|
+
element.scrollIntoView(true);
|
|
71
|
+
JS
|
|
72
|
+
c = find('#' + cid)
|
|
73
|
+
end
|
|
62
74
|
c.send_keys([:down, :down, :down, :down, :right, value, :return])
|
|
63
75
|
sleep 1.0
|
|
64
76
|
end
|
|
@@ -82,6 +94,7 @@ feature 'rule view', js: true do
|
|
|
82
94
|
tm.native.clear()
|
|
83
95
|
tm.native.send_keys(value)
|
|
84
96
|
end
|
|
97
|
+
|
|
85
98
|
it 'rule workflow' do
|
|
86
99
|
log_in_as('marty')
|
|
87
100
|
go_to_my_rules
|
|
@@ -156,27 +156,48 @@ describe 'McflyModel' do
|
|
|
156
156
|
expect(a1.to_a.count).to eq(4)
|
|
157
157
|
end
|
|
158
158
|
|
|
159
|
-
it
|
|
159
|
+
it 'raises exception when too many arguments passed' do
|
|
160
160
|
# generated methods
|
|
161
161
|
aggregate_failures 'errors' do
|
|
162
162
|
@errs.in_groups_of(2) do |name, fn|
|
|
163
163
|
err = /Too many args to #{fn}/
|
|
164
164
|
|
|
165
165
|
expect do
|
|
166
|
-
Marty::ScriptSet.new.get_engine(name)
|
|
167
|
-
|
|
166
|
+
Marty::ScriptSet.new.get_engine(name).evaluate(
|
|
167
|
+
'Err',
|
|
168
|
+
['result'],
|
|
169
|
+
'pt' => Time.zone.now, 'entity' => nil, 'note_rate' => nil
|
|
170
|
+
)
|
|
171
|
+
end.to raise_error(ArgumentError, err)
|
|
168
172
|
end
|
|
169
173
|
end
|
|
170
174
|
end
|
|
171
175
|
|
|
172
|
-
it
|
|
176
|
+
it 'raises exception when too many arguments passed (2)' do
|
|
173
177
|
# non-generated
|
|
174
178
|
aggregate_failures 'errors' do
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
expect do
|
|
180
|
+
Marty::ScriptSet.new.get_engine('E5').evaluate(
|
|
181
|
+
'Err',
|
|
182
|
+
['result'],
|
|
183
|
+
'pt' => Time.zone.now, 'e_id' => nil, 'bc_id' => nil
|
|
184
|
+
)
|
|
185
|
+
end.to raise_error(
|
|
186
|
+
ArgumentError,
|
|
187
|
+
/Too many args to a_func_p/
|
|
188
|
+
)
|
|
189
|
+
|
|
190
|
+
expect do
|
|
191
|
+
Marty::ScriptSet.new.get_engine('E6').evaluate(
|
|
192
|
+
'Err',
|
|
193
|
+
['result'],
|
|
194
|
+
'pt' => Time.zone.now, 'e_id' => nil,
|
|
195
|
+
'bc_id' => nil, 'mm' => nil
|
|
196
|
+
)
|
|
197
|
+
end.to raise_error(
|
|
198
|
+
ArgumentError,
|
|
199
|
+
/Too many args to b_func_p/
|
|
200
|
+
)
|
|
180
201
|
end
|
|
181
202
|
end
|
|
182
203
|
|
data/spec/models/script_spec.rb
CHANGED
|
@@ -11,9 +11,9 @@ NodeB:
|
|
|
11
11
|
eof
|
|
12
12
|
|
|
13
13
|
describe Marty::Script do
|
|
14
|
-
|
|
15
|
-
let(:now) { Time.zone.now - 1.minute }
|
|
14
|
+
let(:now) { Time.zone.now - 1.minute }
|
|
16
15
|
|
|
16
|
+
describe '.load_a_script' do
|
|
17
17
|
it "creates a new script if it doesn't already exist" do
|
|
18
18
|
expect { Marty::Script.load_a_script('TestNew', s1, now) }.
|
|
19
19
|
to change(Marty::Script, :count).by(1)
|
|
@@ -54,8 +54,6 @@ describe Marty::Script do
|
|
|
54
54
|
allow(Marty::Script).to receive(:load_a_script)
|
|
55
55
|
end
|
|
56
56
|
|
|
57
|
-
let(:now) { Time.zone.now - 1.minute }
|
|
58
|
-
|
|
59
57
|
it 'loads each script given a hash' do
|
|
60
58
|
Marty::Script.load_script_bodies({ 'Test1' => s1, 'Test2' => s2 }, now)
|
|
61
59
|
expect(Marty::Script).to have_received(:load_a_script).
|
|
@@ -119,7 +117,6 @@ describe Marty::Script do
|
|
|
119
117
|
let(:scripts_path) do
|
|
120
118
|
File.expand_path('../../fixtures/scripts/load_tests', __FILE__)
|
|
121
119
|
end
|
|
122
|
-
let(:now) { Time.zone.now - 1.minute }
|
|
123
120
|
let(:ls1) { File.read("#{scripts_path}/script1.dl") }
|
|
124
121
|
let(:ls2) { File.read("#{scripts_path}/script2.dl") }
|
|
125
122
|
let(:ls3) { File.read("#{scripts_path}/namespace/nested_namespace/script3.dl") }
|
|
@@ -208,4 +205,81 @@ describe Marty::Script do
|
|
|
208
205
|
expect(Marty::Script.count).to eq(0)
|
|
209
206
|
end
|
|
210
207
|
end
|
|
208
|
+
|
|
209
|
+
describe '.evaluate' do
|
|
210
|
+
let(:scripts_path) do
|
|
211
|
+
Rails.root.join('delorean')
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
def call_test(attr)
|
|
215
|
+
Marty::Script.evaluate(
|
|
216
|
+
Time.zone.now,
|
|
217
|
+
'DeloreanFn',
|
|
218
|
+
'DeloreanFnTest',
|
|
219
|
+
[attr],
|
|
220
|
+
{}
|
|
221
|
+
)
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
def call_ar(attr)
|
|
225
|
+
Marty::Script.evaluate(
|
|
226
|
+
Time.zone.now,
|
|
227
|
+
'DeloreanFn',
|
|
228
|
+
'ActiveRecord',
|
|
229
|
+
[attr],
|
|
230
|
+
'time' => Time.zone.now
|
|
231
|
+
)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
before do
|
|
235
|
+
Marty::Script.load_scripts(scripts_path, now)
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
it 'calls ruby code from delorean' do
|
|
239
|
+
res = call_test('result')
|
|
240
|
+
expect(res.first).to eq ['G1V1', 'G1V2', 'G1V3']
|
|
241
|
+
|
|
242
|
+
res = call_test('get_all')
|
|
243
|
+
expect(res.first).to eq ['G1V1', 'G1V2', 'G1V3']
|
|
244
|
+
|
|
245
|
+
res = call_test('lookup')
|
|
246
|
+
expect(res.first).to eq 'G1V1'
|
|
247
|
+
|
|
248
|
+
res = call_test('find_by_name')
|
|
249
|
+
expect(res.first).to eq 'G1V1'
|
|
250
|
+
|
|
251
|
+
res = call_test('brackets')
|
|
252
|
+
expect(res.first).to eq 'G1V1'
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
let(:ar_methods) do
|
|
256
|
+
[
|
|
257
|
+
:distinct,
|
|
258
|
+
:distinct_select,
|
|
259
|
+
:count,
|
|
260
|
+
:find_by,
|
|
261
|
+
:first,
|
|
262
|
+
:first2,
|
|
263
|
+
:group_count,
|
|
264
|
+
:joins,
|
|
265
|
+
:limit3,
|
|
266
|
+
:last,
|
|
267
|
+
:last3,
|
|
268
|
+
:order,
|
|
269
|
+
:pluck,
|
|
270
|
+
:pluck2,
|
|
271
|
+
:select,
|
|
272
|
+
:select2,
|
|
273
|
+
:where_not,
|
|
274
|
+
:mcfly_pt
|
|
275
|
+
]
|
|
276
|
+
end
|
|
277
|
+
|
|
278
|
+
it 'calls AR code from delorean' do
|
|
279
|
+
ar_methods.each do |method_name|
|
|
280
|
+
res = call_ar(method_name)
|
|
281
|
+
expect(res).to be_present
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
end
|
|
211
285
|
end
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require 'webdrivers/chromedriver'
|
|
1
2
|
require 'selenium-webdriver'
|
|
2
3
|
require Pathname.new(__FILE__).parent.to_s + '/download_helper'
|
|
3
4
|
|
|
@@ -40,4 +41,6 @@ module Marty; module RSpec; module Chromedriver
|
|
|
40
41
|
Capybara.default_driver = :chrome
|
|
41
42
|
Capybara.javascript_driver = ENV['HEADLESS'] == 'true' ?
|
|
42
43
|
:headless_chrome : :chrome
|
|
44
|
+
|
|
45
|
+
Webdrivers.cache_time = 86_400 # check new drivers once per day
|
|
43
46
|
end end end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: marty
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Arman Bostani
|
|
@@ -14,7 +14,7 @@ authors:
|
|
|
14
14
|
autorequire:
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
|
-
date: 2019-05-
|
|
17
|
+
date: 2019-05-31 00:00:00.000000000 Z
|
|
18
18
|
dependencies:
|
|
19
19
|
- !ruby/object:Gem::Dependency
|
|
20
20
|
name: pg
|
|
@@ -64,14 +64,14 @@ dependencies:
|
|
|
64
64
|
requirements:
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
|
-
version: 0.
|
|
67
|
+
version: 0.6.0
|
|
68
68
|
type: :runtime
|
|
69
69
|
prerelease: false
|
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
|
71
71
|
requirements:
|
|
72
72
|
- - "~>"
|
|
73
73
|
- !ruby/object:Gem::Version
|
|
74
|
-
version: 0.
|
|
74
|
+
version: 0.6.0
|
|
75
75
|
- !ruby/object:Gem::Dependency
|
|
76
76
|
name: mcfly
|
|
77
77
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -534,6 +534,7 @@ files:
|
|
|
534
534
|
- spec/dummy/delorean/base_code.dl
|
|
535
535
|
- spec/dummy/delorean/blame_report.dl
|
|
536
536
|
- spec/dummy/delorean/data_report.dl
|
|
537
|
+
- spec/dummy/delorean/delorean_fn.dl
|
|
537
538
|
- spec/dummy/delorean/marty_fields.dl
|
|
538
539
|
- spec/dummy/delorean/styles.dl
|
|
539
540
|
- spec/dummy/delorean/table_report.dl
|