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.
- 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/lib/xl_spec.rb
CHANGED
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
require 'marty'
|
|
3
3
|
require 'delorean_lang'
|
|
4
4
|
|
|
5
|
-
CODE
|
|
5
|
+
CODE = <<EOS
|
|
6
6
|
M:
|
|
7
7
|
cfmt = {
|
|
8
8
|
"type": ":cellIs",
|
|
@@ -83,26 +83,24 @@ M:
|
|
|
83
83
|
format = "xlsx"
|
|
84
84
|
EOS
|
|
85
85
|
|
|
86
|
-
|
|
87
86
|
describe Marty::Xl do
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
87
|
+
let(:engine) do
|
|
88
|
+
Delorean::Engine.new 'YYY'
|
|
89
|
+
end
|
|
92
90
|
|
|
93
91
|
def worksheet(ind, c)
|
|
94
92
|
code = CODE.clone
|
|
95
|
-
map = {'C1' => c[0].to_s, 'C2' => c[1].to_s}
|
|
96
|
-
map.each { |k,v| code.sub!(k,v) }
|
|
93
|
+
map = { 'C1' => c[0].to_s, 'C2' => c[1].to_s }
|
|
94
|
+
map.each { |k, v| code.sub!(k, v) }
|
|
97
95
|
engine.parse(code)
|
|
98
|
-
engine.evaluate(
|
|
96
|
+
engine.evaluate('M', ['result']).flatten(1)
|
|
99
97
|
end
|
|
100
98
|
|
|
101
99
|
before(:all) do
|
|
102
100
|
@coords = [
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
101
|
+
[[9, 5], [2, 5]], # coords for non-overlaping datasets
|
|
102
|
+
[[5, 8], [2, 5]], # coords for overlaping datasets
|
|
103
|
+
]
|
|
106
104
|
end
|
|
107
105
|
|
|
108
106
|
it "should be able to create a spreadsheet that includes multiple datasets that don't overlap " do
|
|
@@ -111,91 +109,91 @@ describe Marty::Xl do
|
|
|
111
109
|
file = Tempfile.new('file.xlsx')
|
|
112
110
|
lambda { sp.serialize(file) }.should_not raise_error()
|
|
113
111
|
|
|
114
|
-
sp.workbook.worksheets[0].rows[0].cells[0..1].map
|
|
115
|
-
[
|
|
116
|
-
|
|
117
|
-
sp.workbook.worksheets[0].rows[1].cells[0..1].map { |c| c.value }.should ==
|
|
118
|
-
["", ""]
|
|
112
|
+
sp.workbook.worksheets[0].rows[0].cells[0..1].map(&:value).should ==
|
|
113
|
+
['Threshold', 5]
|
|
119
114
|
|
|
120
|
-
sp.workbook.worksheets[0].rows[
|
|
121
|
-
[
|
|
115
|
+
sp.workbook.worksheets[0].rows[1].cells[0..1].map(&:value).should ==
|
|
116
|
+
['', '']
|
|
122
117
|
|
|
123
|
-
sp.workbook.worksheets[0].rows[
|
|
124
|
-
[
|
|
118
|
+
sp.workbook.worksheets[0].rows[5].cells[0..15].map(&:value).should ==
|
|
119
|
+
['', '', 'Sec Inst Name', 'Market Change Sec Inst', '', '', '', '',
|
|
120
|
+
'', 'Sec Inst Name', 'Market Change Sec Inst', '', '', '', '']
|
|
125
121
|
|
|
126
|
-
sp.workbook.worksheets[0].rows[
|
|
127
|
-
[
|
|
122
|
+
sp.workbook.worksheets[0].rows[6].cells[0..15].map(&:value).should ==
|
|
123
|
+
['', '', 'title', 2, 4, 5, 6, 8, '', 'title', 2, 4, 5, 6, 8]
|
|
128
124
|
|
|
129
|
-
sp.workbook.worksheets[0].rows[
|
|
130
|
-
[
|
|
125
|
+
sp.workbook.worksheets[0].rows[7].cells[0..15].map(&:value).should ==
|
|
126
|
+
['', '', 'text', 12, 4, 15, 6, 18, '', 'text', 12, 4, 15, 6, 18]
|
|
131
127
|
|
|
132
|
-
sp.workbook.worksheets[0].rows[
|
|
133
|
-
[
|
|
128
|
+
sp.workbook.worksheets[0].rows[8].cells[0..15].map(&:value).should ==
|
|
129
|
+
['', '', 'text', 22, 4, 25, 6, 28, '', 'text', 22, 4, 25, 6, 28]
|
|
134
130
|
|
|
135
|
-
sp.workbook.worksheets[0].rows[
|
|
136
|
-
[
|
|
131
|
+
sp.workbook.worksheets[0].rows[9].cells[0..15].map(&:value).should ==
|
|
132
|
+
['', '', 'text', 32, 4, 35, 6, 38, '', 'text', 32, 4, 35, 6, 38]
|
|
137
133
|
|
|
138
|
-
sp.workbook.worksheets[0].rows[
|
|
139
|
-
[
|
|
134
|
+
sp.workbook.worksheets[0].rows[10].cells[0..15].map(&:value).should ==
|
|
135
|
+
['', '', 'text', 42, 4, 45, 6, 48, '', 'text', 42, 4, 45, 6, 48]
|
|
140
136
|
|
|
141
|
-
sp.workbook.worksheets[0].rows[
|
|
142
|
-
[
|
|
137
|
+
sp.workbook.worksheets[0].rows[11].cells[0..15].map(&:value).should ==
|
|
138
|
+
['', '', 'text', 52, 4, 55, 6, 58, '', 'text', 52, 4, 55, 6, 58]
|
|
143
139
|
|
|
144
|
-
sp.workbook.worksheets[0].rows[
|
|
145
|
-
[
|
|
140
|
+
sp.workbook.worksheets[0].rows[12].cells[0..15].map(&:value).should ==
|
|
141
|
+
['', '', 'text', 62, 4, 65, 6, 68, '', 'text', 62, 4, 65, 6, 68]
|
|
146
142
|
|
|
143
|
+
sp.workbook.worksheets[0].rows[13].cells[0..15].map(&:value).should ==
|
|
144
|
+
['', '', 'text', 72, 4, 75, 6, 78, '', 'text', 72, 4, 75, 6, 78]
|
|
147
145
|
end
|
|
148
146
|
|
|
149
|
-
it
|
|
147
|
+
it 'should be able to create a spreadsheet that includes multiple datasets that overlap ' do
|
|
150
148
|
ws = worksheet(1, @coords[1])
|
|
151
149
|
sp = Marty::Xl.spreadsheet(ws)
|
|
152
150
|
file = Tempfile.new('file.xlsx')
|
|
153
151
|
lambda { sp.serialize(file) }.should_not raise_error()
|
|
154
152
|
|
|
155
|
-
sp.workbook.worksheets[0].rows[0].cells[0..1].map
|
|
156
|
-
[
|
|
153
|
+
sp.workbook.worksheets[0].rows[0].cells[0..1].map(&:value).should ==
|
|
154
|
+
['Threshold', 5]
|
|
157
155
|
|
|
158
|
-
sp.workbook.worksheets[0].rows[1].cells[0..1].map
|
|
159
|
-
[
|
|
156
|
+
sp.workbook.worksheets[0].rows[1].cells[0..1].map(&:value).should ==
|
|
157
|
+
['', '']
|
|
160
158
|
|
|
161
|
-
sp.workbook.worksheets[0].rows[5].cells[0..11].map
|
|
162
|
-
[
|
|
159
|
+
sp.workbook.worksheets[0].rows[5].cells[0..11].map(&:value).should ==
|
|
160
|
+
['', '', 'Sec Inst Name', 'Market Change Sec Inst', '', '', '', '', '', '', '']
|
|
163
161
|
|
|
164
|
-
sp.workbook.worksheets[0].rows[6].cells[0..11].map
|
|
165
|
-
[
|
|
162
|
+
sp.workbook.worksheets[0].rows[6].cells[0..11].map(&:value).should ==
|
|
163
|
+
['', '', 'title', 2, 4, 5, 6, 8, '', '', '']
|
|
166
164
|
|
|
167
|
-
sp.workbook.worksheets[0].rows[7].cells[0..11].map
|
|
168
|
-
[
|
|
165
|
+
sp.workbook.worksheets[0].rows[7].cells[0..11].map(&:value).should ==
|
|
166
|
+
['', '', 'text', 12, 4, 15, 6, 18, '', '', '']
|
|
169
167
|
|
|
170
|
-
sp.workbook.worksheets[0].rows[8].cells[0..11].map
|
|
171
|
-
[
|
|
168
|
+
sp.workbook.worksheets[0].rows[8].cells[0..11].map(&:value).should ==
|
|
169
|
+
['', '', 'text', 22, 4, 'Sec Inst Name', 'Market Change Sec Inst', 28, '', '', '']
|
|
172
170
|
|
|
173
|
-
sp.workbook.worksheets[0].rows[9].cells[0..11].map
|
|
174
|
-
[
|
|
171
|
+
sp.workbook.worksheets[0].rows[9].cells[0..11].map(&:value).should ==
|
|
172
|
+
['', '', 'text', 32, 4, 'title', 2, 4, 5, 6, 8]
|
|
175
173
|
|
|
176
|
-
sp.workbook.worksheets[0].rows[10].cells[0..11].map
|
|
177
|
-
[
|
|
174
|
+
sp.workbook.worksheets[0].rows[10].cells[0..11].map(&:value).should ==
|
|
175
|
+
['', '', 'text', 42, 4, 'text', 12, 4, 15, 6, 18]
|
|
178
176
|
|
|
179
|
-
sp.workbook.worksheets[0].rows[11].cells[0..11].map
|
|
180
|
-
[
|
|
177
|
+
sp.workbook.worksheets[0].rows[11].cells[0..11].map(&:value).should ==
|
|
178
|
+
['', '', 'text', 52, 4, 'text', 22, 4, 25, 6, 28]
|
|
181
179
|
|
|
182
|
-
sp.workbook.worksheets[0].rows[12].cells[0..11].map
|
|
183
|
-
[
|
|
180
|
+
sp.workbook.worksheets[0].rows[12].cells[0..11].map(&:value).should ==
|
|
181
|
+
['', '', 'text', 62, 4, 'text', 32, 4, 35, 6, 38]
|
|
184
182
|
|
|
185
|
-
sp.workbook.worksheets[0].rows[13].cells[0..11].map
|
|
186
|
-
[
|
|
183
|
+
sp.workbook.worksheets[0].rows[13].cells[0..11].map(&:value).should ==
|
|
184
|
+
['', '', 'text', 72, 4, 'text', 42, 4, 45, 6, 48]
|
|
187
185
|
|
|
188
|
-
sp.workbook.worksheets[0].rows[14].cells[0..11].map
|
|
189
|
-
[
|
|
186
|
+
sp.workbook.worksheets[0].rows[14].cells[0..11].map(&:value).should ==
|
|
187
|
+
['', '', '', '', '', 'text', 52, 4, 55, 6, 58]
|
|
190
188
|
|
|
191
|
-
sp.workbook.worksheets[0].rows[15].cells[0..11].map
|
|
192
|
-
[
|
|
189
|
+
sp.workbook.worksheets[0].rows[15].cells[0..11].map(&:value).should ==
|
|
190
|
+
['', '', '', '', '', 'text', 62, 4, 65, 6, 68]
|
|
193
191
|
|
|
194
|
-
sp.workbook.worksheets[0].rows[16].cells[0..11].map
|
|
195
|
-
[
|
|
192
|
+
sp.workbook.worksheets[0].rows[16].cells[0..11].map(&:value).should ==
|
|
193
|
+
['', '', '', '', '', 'text', 72, 4, 75, 6, 78]
|
|
196
194
|
end
|
|
197
195
|
|
|
198
|
-
it
|
|
196
|
+
it 'should not raise an exception when given an empty, frozen arg' do
|
|
199
197
|
data = [].freeze
|
|
200
198
|
expect { Marty::Xl.spreadsheet(data).to_stream.read }.to_not raise_error
|
|
201
199
|
end
|
data/spec/lib/xl_styles_spec.rb
CHANGED
|
@@ -2,8 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
require 'marty'
|
|
3
3
|
require 'delorean_lang'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
STYLE_CODE =<<EOS
|
|
5
|
+
STYLE_CODE = <<EOS
|
|
7
6
|
S:
|
|
8
7
|
data =
|
|
9
8
|
[
|
|
@@ -35,18 +34,17 @@ S:
|
|
|
35
34
|
EOS
|
|
36
35
|
|
|
37
36
|
describe Marty::Xl do
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
37
|
+
let(:engine) do
|
|
38
|
+
Delorean::Engine.new 'YYY'
|
|
39
|
+
end
|
|
42
40
|
|
|
43
41
|
before(:each) do
|
|
44
42
|
code = STYLE_CODE.clone
|
|
45
43
|
engine.parse(code)
|
|
46
|
-
@ws =
|
|
44
|
+
@ws = engine.evaluate('S', ['result']).flatten(1)
|
|
47
45
|
end
|
|
48
46
|
|
|
49
|
-
it
|
|
47
|
+
it 'should be able to create a spreadsheet with overlapping border styles' do
|
|
50
48
|
sp = Marty::Xl.spreadsheet(@ws)
|
|
51
49
|
wb = sp.workbook
|
|
52
50
|
|
|
@@ -58,17 +56,17 @@ describe Marty::Xl do
|
|
|
58
56
|
b.prs.each do |pr|
|
|
59
57
|
edges << [pr.name, pr.style, pr.color.rgb]
|
|
60
58
|
end
|
|
61
|
-
edges.sort_by{ |k| k[0] }
|
|
59
|
+
edges.sort_by { |k| k[0] }
|
|
62
60
|
end
|
|
63
61
|
|
|
64
|
-
sp.workbook.worksheets[0].rows[0].cells[0..1].map
|
|
65
|
-
[
|
|
62
|
+
sp.workbook.worksheets[0].rows[0].cells[0..1].map(&:value).should ==
|
|
63
|
+
['', '']
|
|
66
64
|
|
|
67
|
-
sp.workbook.worksheets[0].rows[1].cells[0..2].map
|
|
68
|
-
[
|
|
65
|
+
sp.workbook.worksheets[0].rows[1].cells[0..2].map(&:value).should ==
|
|
66
|
+
['', 1, 2]
|
|
69
67
|
|
|
70
|
-
sp.workbook.worksheets[0].rows[2].cells[0..2].map
|
|
71
|
-
[
|
|
68
|
+
sp.workbook.worksheets[0].rows[2].cells[0..2].map(&:value).should ==
|
|
69
|
+
['', 3, 4]
|
|
72
70
|
|
|
73
71
|
wb.worksheets[0].styles.borders.count.should >= 4
|
|
74
72
|
|
|
@@ -79,11 +77,11 @@ describe Marty::Xl do
|
|
|
79
77
|
when 0
|
|
80
78
|
b.should == []
|
|
81
79
|
when 2
|
|
82
|
-
b.should == [[:left, :thin,
|
|
80
|
+
b.should == [[:left, :thin, 'FF000000']]
|
|
83
81
|
when 3
|
|
84
|
-
b.should == [[:top, :thick,
|
|
82
|
+
b.should == [[:top, :thick, 'FFFF0000']]
|
|
85
83
|
when 4
|
|
86
|
-
b.should == [[:left, :thin,
|
|
84
|
+
b.should == [[:left, :thin, 'FF000000'], [:top, :thick, 'FFFF0000']]
|
|
87
85
|
else
|
|
88
86
|
next
|
|
89
87
|
end
|
|
@@ -110,6 +108,5 @@ describe Marty::Xl do
|
|
|
110
108
|
next
|
|
111
109
|
end
|
|
112
110
|
end
|
|
113
|
-
|
|
114
111
|
end
|
|
115
112
|
end
|
|
@@ -4,8 +4,8 @@ module Marty
|
|
|
4
4
|
describe ApiAuth do
|
|
5
5
|
before(:each) do
|
|
6
6
|
Marty::Script.load_script_bodies({
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
'Script1' => "A:\n a = 1\n",
|
|
8
|
+
'NewScript1' => "B:\n b = 0\n",
|
|
9
9
|
}, Date.today)
|
|
10
10
|
|
|
11
11
|
@api = ApiAuth.new
|
|
@@ -16,11 +16,11 @@ module Marty
|
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def create_params script, key
|
|
19
|
-
{script: script, api_key: key}
|
|
19
|
+
{ script: script, api_key: key }
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
describe
|
|
23
|
-
it
|
|
22
|
+
describe 'validations' do
|
|
23
|
+
it 'should require app name, api key and script name' do
|
|
24
24
|
api = ApiAuth.new
|
|
25
25
|
expect(api).to_not be_valid
|
|
26
26
|
expect(api.errors[:app_name].any?).to be_truthy
|
|
@@ -28,7 +28,7 @@ module Marty
|
|
|
28
28
|
expect(api.errors[:script_name].any?).to be_truthy
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
it
|
|
31
|
+
it 'should require unique app name/script name' do
|
|
32
32
|
api = @api.dup
|
|
33
33
|
expect(api).to_not be_valid
|
|
34
34
|
expect(api.errors[:app_name].to_s).to include('already been taken')
|
|
@@ -36,7 +36,7 @@ module Marty
|
|
|
36
36
|
expect(api).to be_valid
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
-
it
|
|
39
|
+
it 'should require unique api key/script name' do
|
|
40
40
|
api = @api.dup
|
|
41
41
|
expect(api).to_not be_valid
|
|
42
42
|
expect(api.errors[:api_key].to_s).to include('must be unique')
|
|
@@ -44,7 +44,7 @@ module Marty
|
|
|
44
44
|
expect(api).to be_valid
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
it
|
|
47
|
+
it 'should require a valid associated script name' do
|
|
48
48
|
api = ApiAuth.new
|
|
49
49
|
api.app_name = 'NewApp'
|
|
50
50
|
api.script_name = @api.script_name + 'Bad'
|
|
@@ -52,8 +52,8 @@ module Marty
|
|
|
52
52
|
expect(api.errors[:base].to_s).to include('reference a valid script')
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
it
|
|
56
|
-
|
|
55
|
+
it 'should allow a tagged script version to be associated when a DEV ' +
|
|
56
|
+
'version of that script also exists' do
|
|
57
57
|
s = Marty::Script.find_by(obsoleted_dt: 'infinity', name: 'Script1')
|
|
58
58
|
s.body = "A:\n a = 3\n"
|
|
59
59
|
s.save!
|
|
@@ -64,8 +64,8 @@ module Marty
|
|
|
64
64
|
expect(api).to be_valid
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
it
|
|
68
|
-
|
|
67
|
+
it 'should not allow a DEV script to be associated if there is no ' +
|
|
68
|
+
'tagged version of that script' do
|
|
69
69
|
s = Marty::Script.new
|
|
70
70
|
s.name = 'TestScript'
|
|
71
71
|
s.body = '-- Test3'
|
|
@@ -81,16 +81,16 @@ module Marty
|
|
|
81
81
|
end
|
|
82
82
|
end
|
|
83
83
|
|
|
84
|
-
describe
|
|
85
|
-
it
|
|
84
|
+
describe 'key management' do
|
|
85
|
+
it 'should require a 38 character key' do
|
|
86
86
|
expect(@api.api_key.length).to eq(38)
|
|
87
87
|
|
|
88
|
-
@api.api_key =
|
|
88
|
+
@api.api_key = '123456789'
|
|
89
89
|
expect(@api).to_not be_valid
|
|
90
90
|
expect(@api.errors[:base].to_s).to include('length must be 38')
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
it
|
|
93
|
+
it 'should create the api key if necessary when the record is created' do
|
|
94
94
|
a = ApiAuth.new
|
|
95
95
|
a.app_name = 'MyApp'
|
|
96
96
|
a.script_name = 'NewScript1'
|
|
@@ -99,7 +99,7 @@ module Marty
|
|
|
99
99
|
expect(a.api_key).to_not be_nil
|
|
100
100
|
end
|
|
101
101
|
|
|
102
|
-
it
|
|
102
|
+
it 'should allow api key to be updated for an existing record' do
|
|
103
103
|
old = @api.api_key
|
|
104
104
|
@api.api_key = ApiAuth.generate_key
|
|
105
105
|
new = @api.api_key
|
|
@@ -110,7 +110,7 @@ module Marty
|
|
|
110
110
|
expect(@api.api_key).to eq(new)
|
|
111
111
|
end
|
|
112
112
|
|
|
113
|
-
it
|
|
113
|
+
it 'should generate new api key if old one is cleared' do
|
|
114
114
|
old = @api.api_key
|
|
115
115
|
@api.api_key = ''
|
|
116
116
|
@api.app_name += 'x'
|
|
@@ -118,7 +118,7 @@ module Marty
|
|
|
118
118
|
expect(@api.api_key).to_not eq(old)
|
|
119
119
|
end
|
|
120
120
|
|
|
121
|
-
it
|
|
121
|
+
it 'should generate new api key if old one is cleared (2)' do
|
|
122
122
|
old = @api.api_key
|
|
123
123
|
@api.api_key = nil
|
|
124
124
|
@api.app_name += 'x'
|
|
@@ -127,21 +127,21 @@ module Marty
|
|
|
127
127
|
end
|
|
128
128
|
end
|
|
129
129
|
|
|
130
|
-
describe
|
|
131
|
-
it
|
|
130
|
+
describe 'authorization' do
|
|
131
|
+
it 'should pass when script is not secured' do
|
|
132
132
|
# Script is not secured by any entries
|
|
133
|
-
params = create_params('SomeScript','SomeKey')
|
|
133
|
+
params = create_params('SomeScript', 'SomeKey')
|
|
134
134
|
expect(Marty::Api::Base.is_authorized?(params)).to be_truthy
|
|
135
135
|
end
|
|
136
136
|
|
|
137
|
-
it
|
|
137
|
+
it 'should pass when script is secured and key is valid' do
|
|
138
138
|
expect(@api.script_name).to include('Script1')
|
|
139
139
|
|
|
140
140
|
params = create_params(@api.script_name, @api.api_key)
|
|
141
141
|
expect(Marty::Api::Base.is_authorized?(params)).to be_truthy
|
|
142
142
|
end
|
|
143
143
|
|
|
144
|
-
it
|
|
144
|
+
it 'should pass when script is secured and key is valid 2' do
|
|
145
145
|
a = ApiAuth.new
|
|
146
146
|
a.app_name = @api.app_name + 'x'
|
|
147
147
|
a.script_name = 'NewScript1'
|
|
@@ -151,7 +151,7 @@ module Marty
|
|
|
151
151
|
expect(Marty::Api::Base.is_authorized?(params)).to be_truthy
|
|
152
152
|
end
|
|
153
153
|
|
|
154
|
-
it
|
|
154
|
+
it 'should match on exact script name' do
|
|
155
155
|
a = ApiAuth.new
|
|
156
156
|
a.app_name = @api.app_name + 'x'
|
|
157
157
|
a.script_name = 'NewScript1'
|
|
@@ -161,12 +161,12 @@ module Marty
|
|
|
161
161
|
expect(Marty::Api::Base.is_authorized?(params)).to be_falsey
|
|
162
162
|
end
|
|
163
163
|
|
|
164
|
-
it
|
|
164
|
+
it 'should fail when script is secured and key is invalid' do
|
|
165
165
|
params = create_params('Script1', 'SomeKey')
|
|
166
166
|
expect(Marty::Api::Base.is_authorized?(params)).to be_falsey
|
|
167
167
|
end
|
|
168
168
|
|
|
169
|
-
it
|
|
169
|
+
it 'should fail when script is secured and key is invalid (2)' do
|
|
170
170
|
a = ApiAuth.new
|
|
171
171
|
a.app_name = @api.app_name + 'x'
|
|
172
172
|
a.script_name = 'NewScript1'
|
|
@@ -176,7 +176,7 @@ module Marty
|
|
|
176
176
|
expect(Marty::Api::Base.is_authorized?(params)).to be_falsey
|
|
177
177
|
end
|
|
178
178
|
|
|
179
|
-
it
|
|
179
|
+
it 'should fail when script is secured and key is not specified' do
|
|
180
180
|
params = create_params('Script1', nil)
|
|
181
181
|
expect(Marty::Api::Base.is_authorized?(params)).to be_falsey
|
|
182
182
|
|
|
@@ -184,7 +184,7 @@ module Marty
|
|
|
184
184
|
expect(Marty::Api::Base.is_authorized?(params)).to be_falsey
|
|
185
185
|
end
|
|
186
186
|
|
|
187
|
-
it
|
|
187
|
+
it 'should pass when api_auth is deleted and no other auths exist' do
|
|
188
188
|
params = create_params(@api.script_name, @api.api_key)
|
|
189
189
|
expect(Marty::Api::Base.is_authorized?(params)).to be_truthy
|
|
190
190
|
@api.delete
|
|
@@ -192,7 +192,7 @@ module Marty
|
|
|
192
192
|
expect(Marty::Api::Base.is_authorized?(params)).to be_truthy
|
|
193
193
|
end
|
|
194
194
|
|
|
195
|
-
it
|
|
195
|
+
it 'should fail when api_auth is deleted and another auth exists' do
|
|
196
196
|
api = @api.dup
|
|
197
197
|
api.app_name += 'x'
|
|
198
198
|
api.api_key = nil
|