marty 1.0.47 → 1.0.48

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5c800ee99b1eb7023ea3a849088707a0200ba7a4
4
- data.tar.gz: cdc3f0083bb23d6f42e9c94cbb6b50f927cf11c5
3
+ metadata.gz: 376e0b397909c27475e6b4cdae94dee42567e903
4
+ data.tar.gz: b93e6460252eb76a0391732a33ed14304d422b90
5
5
  SHA512:
6
- metadata.gz: 1f0f1912b8bcb74509857d1291c1a578960fe061625bc0e087b04eedc04aad4ae466008f6cf4d71a132392c8e3b1b0c88cce1a6bd4665d7e8aec421074f63e50
7
- data.tar.gz: 66e079cb3b5034ab20cda7f3e4752d437ce92caa16b617e8362a5e28e7b0dbe1fb883526762d962198fdd07e1005b46e05ce4f833e1762781c615f8d0b140386
6
+ metadata.gz: 5d573ea332aea15f9eb89406a0158c00c359ab2761ddbc53f07804e7bb2044862ca02a31ab1308588c6a2a5d1901797e18367ec80a81738dce87dd2278585fdc
7
+ data.tar.gz: 6d1523146cc9ed32261d66676c54d673c4221b23cc915b9005a244da666a1c864a9ec451750138773b0a342715f05a8b90fc242fb7a99f7896fddf606ca82705
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- marty (1.0.46)
4
+ marty (1.0.48)
5
5
  axlsx (= 2.1.0pre)
6
6
  coderay
7
7
  delorean_lang (~> 0.1)
@@ -3,28 +3,34 @@ class Marty::ApiLogView < Marty::Grid
3
3
  has_marty_permissions read: :admin,
4
4
  update: :admin
5
5
 
6
+ DATE_OP_MAP = {
7
+ 'eq' => '=',
8
+ 'gt' => '>',
9
+ 'lt' => '<'
10
+ }
11
+
12
+ @@attrs = [
13
+ :script,
14
+ :node,
15
+ :attrs,
16
+ :input,
17
+ :output,
18
+ :error,
19
+ :remote_ip,
20
+ :auth_name,
21
+ :start_time,
22
+ :end_time,
23
+ ]
24
+
6
25
  def configure(c)
7
26
  super
8
27
  c.editing = :in_form
9
28
  c.paging = :buffered
10
29
  c.title = 'Api Log View'
11
- c.model = Marty::ApiLog
12
- c.attributes = [
13
- :script,
14
- :node,
15
- :attrs,
16
- :start_time,
17
- :end_time,
18
- :input,
19
- :output,
20
- :error,
21
- :remote_ip,
22
- :auth_name,
23
- ]
24
-
25
- c.store_config.merge!(
26
- {sorters: [{ property: :start_time, direction: :desc }]},
27
- )
30
+ c.model = Marty::Log
31
+ c.attributes = @@attrs
32
+ c.scope = {message_type: 'api'}
33
+ c.store_config.merge!(sorters: [{property: :timestamp, direction: 'DESC'}])
28
34
  end
29
35
 
30
36
  component :edit_window do |c|
@@ -32,13 +38,6 @@ class Marty::ApiLogView < Marty::Grid
32
38
  c.width = 1200
33
39
  end
34
40
 
35
- [:script, :node, :attrs, :remote_ip, :auth_name, :start_time,
36
- :end_time].each do |a|
37
- attribute a do |c|
38
- c.read_only = true
39
- end
40
- end
41
-
42
41
  def default_form_items
43
42
  [
44
43
  :script,
@@ -54,20 +53,42 @@ class Marty::ApiLogView < Marty::Grid
54
53
  ]
55
54
  end
56
55
 
57
- [:input, :output].each do |a|
56
+ @@attrs.each do |a|
58
57
  attribute a do |c|
59
- c.text = a.to_s
60
- c.width = 900
61
- c.read_only = true
62
- c.type = :string
63
- c.getter = lambda { |r| r.send(a).pretty_inspect }
58
+ c.filterable = true
59
+ c.read_only = true
60
+ c.getter = lambda {|r| r.details[a.to_s] }
61
+ c.sorting_scope = lambda {
62
+ |r, dir|
63
+ r.order("details->>'#{a.to_s}'" + dir.to_s)
64
+ }
65
+ c.filter_with = lambda {
66
+ |r, v, op|
67
+ r.where("details->>'#{a.to_s}' #{op} '#{v}%'")
68
+ } unless [:start_time, :endtime].include?(a)
69
+
70
+ case a
71
+ when :start_time, :end_time
72
+ c.type = :datetime
73
+ c.format = 'Y-m-d h:i:s'
74
+ c.getter = lambda {|r| Time.zone.parse(r.details[a.to_s])}
75
+ c.filter_with = lambda {
76
+ |r, v, op|
77
+ r.where("(details->>'#{a.to_s}')::date #{DATE_OP_MAP[op]} '#{v}%'")
78
+ }
79
+ when :input, :output
80
+ c.getter = lambda { |r| r.details[a.to_s].pretty_inspect }
81
+ c.width = 900
82
+ c.read_only = true
83
+ end
64
84
  end
85
+ end
86
+
87
+ [:input, :output].each do |a|
65
88
  column a do |c|
66
- c.width = 250
67
- c.type = :string
68
- c.getter = lambda { |r| r.send(a).to_json }
89
+ c.width = 250
90
+ c.getter = lambda { |r| r.details[a.to_s].to_json }
69
91
  end
70
92
  end
71
-
72
93
  end
73
94
  ApiLogView = Marty::ApiLogView
@@ -14,11 +14,17 @@ class Marty::ReportForm < Marty::Form
14
14
  a.disabled = false
15
15
  end
16
16
 
17
+ action :link do |a|
18
+ a.text = a.tooltip = I18n.t("reporting.link")
19
+ a.icon = :link_go
20
+ a.disabled = false
21
+ end
22
+
17
23
  ######################################################################
18
24
 
19
25
  def default_bbar
20
26
  [
21
- '->', :apply, :foreground
27
+ '->', :apply, :foreground, :link
22
28
  ]
23
29
  end
24
30
 
@@ -134,6 +140,37 @@ class Marty::ReportForm < Marty::Form
134
140
  document.body.removeChild(form);
135
141
  }
136
142
  JS
143
+
144
+ c.netzke_on_link = l(<<-JS)
145
+ function() {
146
+ var values = this.getForm().getValues();
147
+
148
+ // check for early url generation and exit with error message
149
+ if (values['selected_script_name'] == null) {
150
+ alert("Please select a report before generating url.");
151
+ return;
152
+ }
153
+
154
+ params = {
155
+ "format": this.repformat,
156
+ "reptitle": this.reptitle
157
+ }
158
+
159
+ for (var key in values) {if (values[key] == "") {delete values[key]}}
160
+ data = Ext.encode(values)
161
+
162
+ // construct url
163
+ var proto_host = location.protocol + '//' + location.host
164
+ var url = proto_host + '/report?data=' + data
165
+ for (var key in params) {
166
+ if (params[key] == "") continue;
167
+ url += '&' + key + '=' + params[key];
168
+ }
169
+ url = encodeURI(url)
170
+ var win = window.open('');
171
+ win.document.write(url.link(url));
172
+ }
173
+ JS
137
174
  end
138
175
 
139
176
  endpoint :netzke_load do |params|
@@ -231,7 +268,7 @@ class Marty::ReportForm < Marty::Form
231
268
  c.reptitle = title
232
269
  c.authenticity_token = controller.send(:form_authenticity_token)
233
270
 
234
- actions[:foreground].disabled = !!background_only
271
+ [:foreground, :link].each{|a| actions[a].disabled = !!background_only}
235
272
  end
236
273
  end
237
274
 
@@ -83,7 +83,7 @@ module Marty
83
83
  display = <<-ERB
84
84
  <% inconsistent = diff(data) %>
85
85
  <h3><%=name.demodulize%></h3>
86
- <%='<h3 class="error">&#x26a0; Issues Detected</h3>' if
86
+ <%='<h3 class="error">Issues Detected</h3>' if
87
87
  inconsistent%>
88
88
  <div class="wrapper">
89
89
  <% data.each do |node, result| %>
@@ -155,10 +155,13 @@ class Marty::RpcController < ActionController::Base
155
155
  rescue => e
156
156
  return {error: e.message}
157
157
  end
158
+ shash = Hash[schemas]
158
159
  pairs = attrs.zip(res)
159
- pairs.zip(schemas).each do |(attr, res), (_, sch)|
160
+ pairs.each do |attr, result|
161
+ next unless sch = shash[attr+"_"]
162
+ next if result.is_a?(Hash) && result["error"]
160
163
  begin
161
- er = JSON::Validator.fully_validate(sch.merge(to_append), res, opt)
164
+ er = JSON::Validator.fully_validate(sch.merge(to_append), result, opt)
162
165
  rescue NameError
163
166
  return {error: "Unrecognized PgEnum for attribute #{attr}"}
164
167
  rescue => ex
@@ -168,20 +171,19 @@ class Marty::RpcController < ActionController::Base
168
171
  err_count += er.size
169
172
  end
170
173
  if err_count > 0
171
- res = pairs.map do |attr, res|
172
- is_strict = strict_validate.include?(attr)
173
- the_error = validation_error[attr]
174
+ res = pairs.map do |attr, result|
175
+ next result unless shash[attr+"_"]
176
+ next result unless the_error = validation_error[attr]
174
177
 
175
178
  Marty::Logger.error("API #{sname}:#{node}.#{attr}",
176
179
  {error: the_error,
177
- data: res}) if the_error
178
- is_strict && the_error ?
180
+ data: result})
181
+ strict_validate.include?(attr) ?
179
182
  {error: "Error(s) validating: #{the_error}",
180
- data: res} : res
183
+ data: result} : result
181
184
  end
182
185
  end
183
186
  end
184
-
185
187
  return retval = (attrs_atom ? res.first : res)
186
188
  rescue => exc
187
189
  err_msg = Delorean::Engine.grok_runtime_exception(exc).symbolize_keys
@@ -189,9 +191,9 @@ class Marty::RpcController < ActionController::Base
189
191
  return retval = err_msg
190
192
  ensure
191
193
  error = Hash === retval ? retval[:error] : nil
192
-
193
- # FIXME: how do we know this isn't going to fail??
194
- Marty::ApiLog.create!(script: sname,
194
+ Marty::Log.write_log('api',
195
+ "#{sname} - #{node}",
196
+ {script: sname,
195
197
  node: node,
196
198
  attrs: (attrs_atom ? attrs.first : attrs),
197
199
  input: orig_params,
@@ -200,8 +202,8 @@ class Marty::RpcController < ActionController::Base
200
202
  end_time: Time.zone.now,
201
203
  error: error,
202
204
  remote_ip: request.remote_ip,
203
- auth_name: auth,
204
- ) if need_log.present?
205
+ auth_name: auth
206
+ }) if need_log.present?
205
207
  end
206
208
  end
207
209
  end
@@ -152,11 +152,13 @@ class Marty::DataGrid < Marty::Base
152
152
  PLV_DT_FMT = "%Y-%m-%d %H:%M:%S.%N6"
153
153
 
154
154
  def plv_lookup_grid_distinct(h_passed, ret_grid_data=false, distinct=true)
155
- row_info = {"id" => id,
156
- "group_id" => group_id,
157
- "created_dt" =>
158
- (@@dtcache ||= {})[created_dt] ||= created_dt.strftime(PLV_DT_FMT)
159
- }
155
+ row_info = {
156
+ "id" => id,
157
+ "group_id" => group_id,
158
+ "created_dt" => (
159
+ @@dtcache ||= {})[created_dt] ||= created_dt.strftime(PLV_DT_FMT)
160
+ }
161
+
160
162
  h = metadata.each_with_object({}) do |m, h|
161
163
  attr = m["attr"]
162
164
  inc = h_passed.fetch(attr, :__nf__)
@@ -164,19 +166,19 @@ class Marty::DataGrid < Marty::Base
164
166
  h[attr] = (defined? inc.name) ? inc.name : inc
165
167
  end
166
168
 
167
- fn = "lookup_grid_distinct"
168
- hjson = "'#{h.to_json}'::JSONB"
169
+ fn = "lookup_grid_distinct"
170
+ hjson = "'#{h.to_json}'::JSONB"
169
171
  rijson = "'#{row_info.to_json}'::JSONB"
170
172
  params = "#{hjson}, #{rijson}, #{ret_grid_data}, #{distinct}"
171
- sql = "SELECT #{fn}(#{params})"
172
- raw = ActiveRecord::Base.connection.execute(sql)[0][fn]
173
- res = JSON.parse(raw)
173
+ sql = "SELECT #{fn}(#{params})"
174
+ raw = ActiveRecord::Base.connection.execute(sql)[0][fn]
175
+ res = JSON.parse(raw)
174
176
 
175
177
  if res["error"]
176
178
  msg = res["error"]
177
179
  parms, sqls, ress, dg = res["error_extra"].values_at(
178
- "params", "sql",
179
- "results", "dg")
180
+ "params", "sql", "results", "dg")
181
+
180
182
  raise "DG #{name}: Error in PLV8 call: #{msg}\n"\
181
183
  "params: #{parms}\n"\
182
184
  "sqls: #{sqls}\n"\
@@ -6,9 +6,9 @@ class Marty::Log < Marty::Base
6
6
  def self.write_log(type, message, details)
7
7
  begin
8
8
  create!(message_type: type,
9
- message: message,
10
- details: details,
11
- timestamp: Time.zone.now)
9
+ message: message,
10
+ details: details,
11
+ timestamp: Time.zone.now)
12
12
  rescue => e
13
13
  Marty::Util.logger.error("Marty::Logger failure: #{e.message}")
14
14
  end
@@ -51,7 +51,7 @@
51
51
  </head>
52
52
  <body>
53
53
  <div style="text-align:center">
54
- <h1><%=Rails.application.class.parent_name%> Diagnostic &#x26E8</h1>
54
+ <h1><%=Rails.application.class.parent_name%> Diagnostic</h1>
55
55
  <%== @result %>
56
56
  </div>
57
57
  </body>
@@ -119,6 +119,7 @@ en:
119
119
  select_script: Select Script
120
120
  generate: Generate Report
121
121
  background: Background Report
122
+ link: Generate URL
122
123
 
123
124
  jobs:
124
125
  promise_view: Jobs Dashboard
@@ -1,3 +1,7 @@
1
+ Rails.application.routes.draw do
2
+ get 'report', to: 'marty/report#index'
3
+ end
4
+
1
5
  Marty::Engine.routes.draw do
2
6
  match via: [:get, :post], "rpc/:action(.:format)" => "rpc", as: :rpc
3
7
  get "job/:action" => "job", as: :job
@@ -0,0 +1,9 @@
1
+ class DropMartyApiLogs < ActiveRecord::Migration
2
+ def self.up
3
+ drop_table :marty_api_logs
4
+ end
5
+
6
+ def self.down
7
+ announce("No-op on DropMartyApiLogs.down")
8
+ end
9
+ end
@@ -50,6 +50,9 @@ class Marty::DataExporter
50
50
  # FIXME: very hacky to default row_sep to CRLF
51
51
  conf[:row_sep] ||= "\r\n"
52
52
 
53
+ # remove non CSV.generate options before entering generate blocks
54
+ readable = conf.delete(:readable)
55
+
53
56
  # FIXME: the following is ridiculously complex. We have different
54
57
  # data paths for hashes and arrays. Also, arrays can turn into
55
58
  # hashes is all their items are hashes! We map to complex objects
@@ -69,7 +72,7 @@ class Marty::DataExporter
69
72
  csv << x.map { |v|
70
73
  case v
71
74
  when Array, Hash
72
- encode_json(v.to_json)
75
+ readable ? v.to_s : encode_json(v.to_json)
73
76
  when nil
74
77
  nil
75
78
  else
@@ -1,3 +1,3 @@
1
1
  module Marty
2
- VERSION = "1.0.47"
2
+ VERSION = "1.0.48"
3
3
  end
@@ -56,7 +56,7 @@ module Marty
56
56
  def version_display_fail val
57
57
  <<-ERB
58
58
  <h3>Version</h3>
59
- <h3 class="error"> &#x26a0; Issues Detected </h3>
59
+ <h3 class="error">Issues Detected </h3>
60
60
  <div class="wrapper">
61
61
  <table>
62
62
  <th class="error">node1</th>
@@ -46,7 +46,9 @@ A: M3::A
46
46
  f =?
47
47
  g = e * 5 + f
48
48
  h = f + 1
49
+ i =?
49
50
  ptest = p * 10
51
+ ii = i
50
52
  result = [{"a": p, "b": 456}, {"a": 789, "b": p}]
51
53
  eof
52
54
 
@@ -134,6 +136,10 @@ A:
134
136
  }
135
137
  d_ = { "type" : "integer" }
136
138
 
139
+ ii = {}
140
+
141
+ ii_ = { "type" : "integer" }
142
+
137
143
  g = { "properties" : {
138
144
  "e" : { "type" : "integer" },
139
145
  "f" : { "type" : "integer" },
@@ -740,6 +746,35 @@ describe Marty::RpcController do
740
746
  attr: nil,
741
747
  logged: false,
742
748
  input_validated: true,
749
+ output_validated: true,
750
+ strict_validate: true)
751
+ attrs = ["d", "g", "ii", "result"].to_json
752
+ params = {"p" => 132, "e" => 55, "f"=>16, "i"=>"string"}.to_json
753
+ get 'evaluate', {
754
+ format: :json,
755
+ script: "M4",
756
+ node: "A",
757
+ attrs: attrs,
758
+ params: params
759
+ }
760
+ res_hash = JSON.parse(response.body)
761
+ errpart = "of type string did not match the following type: integer"
762
+ expect(res_hash[0]).to eq(135)
763
+ expect(res_hash[1]).to eq(291)
764
+ expect(res_hash[2]["error"]).to include(errpart)
765
+ expect(res_hash[3]).to eq([{"a"=>132,"b"=>456},
766
+ {"a"=>789,"b"=>132}])
767
+ logs = Marty::Log.all
768
+ expect(logs.count).to eq(1)
769
+ expect(logs[0].details["error"][0]).to include(errpart)
770
+ end
771
+ it "validates output 2" do
772
+ # not all attrs being validated
773
+ Marty::ApiConfig.create!(script: "M4",
774
+ node: "A",
775
+ attr: "result",
776
+ logged: false,
777
+ input_validated: true,
743
778
  output_validated: true)
744
779
  attrs = ["d", "g", "result"].to_json
745
780
  params = {"p" => 132, "e" => 55, "f"=>16}.to_json
@@ -968,25 +1003,25 @@ describe Marty::RpcController do
968
1003
  node: "A",
969
1004
  attr: nil,
970
1005
  logged: true)
971
- attrs = ["lc"].to_json
1006
+ attrs = ["lc"]
972
1007
  params = {"p" => 5}
973
1008
  get 'evaluate', {
974
1009
  format: :csv,
975
1010
  script: "M3",
976
1011
  node: "A",
977
- attrs: attrs,
1012
+ attrs: attrs.to_json,
978
1013
  params: params.to_json
979
1014
  }
980
1015
  expect(response.body).to eq("9\r\n9\r\n")
981
- log = Marty::ApiLog.order(id: :desc).first
1016
+ log = Marty::Log.order(id: :desc).first
982
1017
 
983
- expect(log.script).to eq("M3")
984
- expect(log.node).to eq("A")
985
- expect(log.attrs).to eq(attrs)
986
- expect(log.input).to eq(params)
987
- expect(log.output).to eq([[9, 9]])
988
- expect(log.remote_ip).to eq("0.0.0.0")
989
- expect(log.error).to eq(nil)
1018
+ expect(log.details['script']).to eq("M3")
1019
+ expect(log.details['node']).to eq("A")
1020
+ expect(log.details['attrs']).to eq(attrs)
1021
+ expect(log.details['input']).to eq(params)
1022
+ expect(log.details['output']).to eq([[9,9]])
1023
+ expect(log.details['remote_ip']).to eq("0.0.0.0")
1024
+ expect(log.details['error']).to eq(nil)
990
1025
 
991
1026
  end
992
1027
 
@@ -995,26 +1030,18 @@ describe Marty::RpcController do
995
1030
  node: "A",
996
1031
  attr: nil,
997
1032
  logged: true)
998
- attrs = ["lc"].to_json
1033
+ attrs = ["lc"]
999
1034
  params = {"p" => 5}
1000
1035
  get 'evaluate', {
1001
1036
  format: :csv,
1002
1037
  script: "M3",
1003
1038
  node: "A",
1004
- attrs: attrs,
1039
+ attrs: attrs.to_json,
1005
1040
  params: params.to_json,
1006
1041
  background: true
1007
1042
  }
1008
1043
  expect(response.body).to match(/job_id,/)
1009
- log = Marty::ApiLog.order(id: :desc).first
1010
-
1011
- expect(log.script).to eq("M3")
1012
- expect(log.node).to eq("A")
1013
- expect(log.attrs).to eq(attrs)
1014
- expect(log.input).to eq(params)
1015
- expect(log.output).to include("job_id")
1016
- expect(log.remote_ip).to eq("0.0.0.0")
1017
- expect(log.error).to eq(nil)
1044
+ log = Marty::Log.order(id: :desc).first
1018
1045
 
1019
1046
  end
1020
1047
 
@@ -1026,7 +1053,7 @@ describe Marty::RpcController do
1026
1053
  attrs: ["a", "b"].to_json,
1027
1054
  tag: t1.name,
1028
1055
  }
1029
- expect(Marty::ApiLog.count).to eq(0)
1056
+ expect(Marty::Log.count).to eq(0)
1030
1057
  end
1031
1058
 
1032
1059
  it "should handle atom attribute" do
@@ -1043,14 +1070,16 @@ describe Marty::RpcController do
1043
1070
  params: params.to_json
1044
1071
  }
1045
1072
  expect(response.body).to eq("9\r\n9\r\n")
1046
- log = Marty::ApiLog.order(id: :desc).first
1047
- expect(log.script).to eq("M3")
1048
- expect(log.node).to eq("A")
1049
- expect(log.attrs).to eq("lc")
1050
- expect(log.input).to eq(params)
1051
- expect(log.output).to eq([9, 9])
1052
- expect(log.remote_ip).to eq("0.0.0.0")
1053
- expect(log.error).to eq(nil)
1073
+ log = Marty::Log.order(id: :desc).first
1074
+
1075
+ expect(log.details['script']).to eq("M3")
1076
+ expect(log.details['node']).to eq("A")
1077
+ expect(log.details['attrs']).to eq("lc")
1078
+ expect(log.details['input']).to eq(params)
1079
+ expect(log.details['output']).to eq([9, 9])
1080
+ expect(log.details['remote_ip']).to eq("0.0.0.0")
1081
+ expect(log.details['error']).to eq(nil)
1082
+
1054
1083
  end
1055
1084
 
1056
1085
  it "should support api authorization - api_key not required" do
@@ -1092,21 +1121,23 @@ describe Marty::RpcController do
1092
1121
  apic = Marty::ApiConfig.create!(script: 'M3',
1093
1122
  logged: true)
1094
1123
 
1124
+ attrs = ["pc"]
1095
1125
  get 'evaluate', {
1096
1126
  format: :json,
1097
1127
  script: "M3",
1098
1128
  node: "C",
1099
- attrs: ["pc"].to_json,
1129
+ attrs: attrs.to_json,
1100
1130
  api_key: api.api_key,
1101
1131
  }
1102
1132
  expect(response.body).to eq([7].to_json)
1103
- log = Marty::ApiLog.order(id: :desc).first
1104
- expect(log.script).to eq('M3')
1105
- expect(log.node).to eq('C')
1106
- expect(log.attrs).to eq(%Q!["pc"]!)
1107
- expect(log.output).to eq([7])
1108
- expect(log.remote_ip).to eq("0.0.0.0")
1109
- expect(log.auth_name).to eq("TestApp")
1133
+ log = Marty::Log.order(id: :desc).first
1134
+
1135
+ expect(log.details['script']).to eq("M3")
1136
+ expect(log.details['node']).to eq("C")
1137
+ expect(log.details['attrs']).to eq(attrs)
1138
+ expect(log.details['output']).to eq([7])
1139
+ expect(log.details['remote_ip']).to eq("0.0.0.0")
1140
+ expect(log.details['auth_name']).to eq("TestApp")
1110
1141
  end
1111
1142
 
1112
1143
  it "should support api authorization - api_key required but incorrect" do
@@ -100,6 +100,16 @@ DELOREAN
100
100
  end
101
101
  end
102
102
 
103
+ def generate_rep_url format: 'csv'
104
+ URI.encode("http://#{Capybara.current_session.server.host}"\
105
+ ":#{Capybara.current_session.server.port}"\
106
+ '/report?data='\
107
+ '{"pt_name":"XYZ",'\
108
+ '"selected_script_name":"SomeReport",'\
109
+ '"selected_node":"AA",'\
110
+ "\"selected_testing\":\"true\"}&format=#{format}&reptitle=AA")
111
+ end
112
+
103
113
  it 'run_script displays proper data' do
104
114
  log_in_as('dev1')
105
115
  go_to_reporting
@@ -249,4 +259,38 @@ DELOREAN
249
259
  '---')
250
260
  end
251
261
  end
262
+
263
+ it 'can generate an url that can be used to access report' do
264
+ log_in_as('dev1')
265
+ go_to_reporting
266
+
267
+ tag_grid = netzke_find('tag_grid')
268
+ script_grid = netzke_find('script_grid')
269
+
270
+ and_by 'select SomeReport script & AA node' do
271
+ script_grid.select_row(1)
272
+ select_node('AA (csv)')
273
+ end
274
+
275
+ and_by 'fill form and navigate to generated link' do
276
+ wait_for_ajax
277
+ set_field_value('XYZ', '', 'pt_name')
278
+ set_field_value('true', 'textfield', 'selected_testing')
279
+ new_window = window_opened_by {press("Generate URL")}
280
+ within_window new_window do
281
+ url = generate_rep_url
282
+ expect(page).to have_content(url)
283
+ end
284
+ new_window.close
285
+ end
286
+ end
287
+
288
+ it 'can generate report through generated url' do
289
+ url = generate_rep_url(format: 'txt') + URI.encode('&disposition=inline')
290
+ visit url
291
+ wait_for_element do
292
+ expect(page).to have_content('XYZ1,XYZ2,XYZ3,XYZ4 1,2,3,4 2,4,6,8 ' +
293
+ '3,6,9,12 4,8,12,16')
294
+ end
295
+ end
252
296
  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: 1.0.47
4
+ version: 1.0.48
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: 2017-11-02 00:00:00.000000000 Z
17
+ date: 2017-11-06 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: pg
@@ -413,7 +413,6 @@ files:
413
413
  - app/helpers/marty/script_set.rb
414
414
  - app/models/marty/api_auth.rb
415
415
  - app/models/marty/api_config.rb
416
- - app/models/marty/api_log.rb
417
416
  - app/models/marty/base.rb
418
417
  - app/models/marty/config.rb
419
418
  - app/models/marty/data_grid.rb
@@ -481,6 +480,7 @@ files:
481
480
  - db/migrate/301_create_marty_api_log.rb
482
481
  - db/migrate/302_add_api_configs_validate_result.rb
483
482
  - db/migrate/303_create_marty_logs.rb
483
+ - db/migrate/304_drop_marty_api_logs.rb
484
484
  - db/migrate/400_create_dg_plv8_v1_fns.rb
485
485
  - db/seeds.rb
486
486
  - delorean/script_report.dl
@@ -1,5 +0,0 @@
1
- class Marty::ApiLog < Marty::Base
2
- validates_presence_of :script, :node, :attrs, :start_time, :end_time,
3
- :remote_ip
4
-
5
- end