rails-profiler 0.44.28 → 0.44.30
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/CHANGELOG.md +23 -0
- data/app/assets/builds/profiler.js +5 -5
- data/app/controllers/profiler/api/env_vars_controller.rb +8 -0
- data/app/controllers/profiler/api/test_runner_controller.rb +7 -0
- data/app/controllers/profiler/profiles_controller.rb +7 -2
- data/lib/profiler/test_runner/discovery.rb +6 -0
- data/lib/profiler/test_runner/runner.rb +6 -0
- data/lib/profiler/version.rb +1 -1
- metadata +1 -1
|
@@ -32,6 +32,14 @@ module Profiler
|
|
|
32
32
|
|
|
33
33
|
value = params[:value]
|
|
34
34
|
|
|
35
|
+
# A structured value (JSON array or object) has no ENV representation. Scalars (numbers,
|
|
36
|
+
# booleans) are still coerced with to_s, as before.
|
|
37
|
+
if value.is_a?(Array) || value.is_a?(Hash) || value.respond_to?(:to_unsafe_h)
|
|
38
|
+
render json: { error: "Value must be a scalar, not an array or an object; #{key} was left unchanged" },
|
|
39
|
+
status: :unprocessable_entity
|
|
40
|
+
return
|
|
41
|
+
end
|
|
42
|
+
|
|
35
43
|
# A value ENV cannot hold is refused before the store is written, like a refused key.
|
|
36
44
|
if (reason = Profiler::EnvKeyPolicy.value_rejection(key, value))
|
|
37
45
|
render json: { error: "#{reason}; #{key} was left unchanged" }, status: :unprocessable_entity
|
|
@@ -16,6 +16,8 @@ module Profiler
|
|
|
16
16
|
|
|
17
17
|
def files
|
|
18
18
|
framework = params[:framework]
|
|
19
|
+
return render_invalid_framework unless framework.nil? || framework.is_a?(String)
|
|
20
|
+
|
|
19
21
|
tree = Profiler::TestRunner::Discovery.files(framework: framework)
|
|
20
22
|
frameworks = Profiler::TestRunner::Discovery.frameworks
|
|
21
23
|
|
|
@@ -28,6 +30,7 @@ module Profiler
|
|
|
28
30
|
def create
|
|
29
31
|
files = Array(params[:files])
|
|
30
32
|
framework = params[:framework] || detect_framework
|
|
33
|
+
return render_invalid_framework unless framework.is_a?(String)
|
|
31
34
|
|
|
32
35
|
if files.empty?
|
|
33
36
|
return render json: { error: "No files selected" }, status: :unprocessable_entity
|
|
@@ -88,6 +91,10 @@ module Profiler
|
|
|
88
91
|
|
|
89
92
|
private
|
|
90
93
|
|
|
94
|
+
def render_invalid_framework
|
|
95
|
+
render json: { error: "framework must be a String" }, status: :unprocessable_entity
|
|
96
|
+
end
|
|
97
|
+
|
|
91
98
|
def detect_framework
|
|
92
99
|
if Profiler::TestRunner::Discovery.rspec_available?
|
|
93
100
|
"rspec"
|
|
@@ -5,8 +5,13 @@ require_relative "../../../lib/profiler/cluster/slave_proxy"
|
|
|
5
5
|
module Profiler
|
|
6
6
|
class ProfilesController < ApplicationController
|
|
7
7
|
def index
|
|
8
|
-
limit =
|
|
9
|
-
|
|
8
|
+
limit, offset = page_params
|
|
9
|
+
|
|
10
|
+
# Validate filter parameter is a Hash if present
|
|
11
|
+
if params[:filter].present? && !params[:filter].respond_to?(:to_unsafe_h) && !params[:filter].is_a?(Hash)
|
|
12
|
+
render json: { error: "filter must be a hash" }, status: :unprocessable_entity
|
|
13
|
+
return
|
|
14
|
+
end
|
|
10
15
|
|
|
11
16
|
@profiles = Profiler.storage.list(limit: limit, offset: offset)
|
|
12
17
|
@profiles = filter_profiles(@profiles) if params[:filter].present?
|
|
@@ -15,6 +15,12 @@ module Profiler
|
|
|
15
15
|
|
|
16
16
|
def self.files(framework: nil)
|
|
17
17
|
root = defined?(Rails) ? Rails.root.to_s : Dir.pwd
|
|
18
|
+
|
|
19
|
+
# Validate framework is a String or Symbol if provided
|
|
20
|
+
if !framework.nil? && !framework.is_a?(String) && !framework.is_a?(Symbol)
|
|
21
|
+
raise ArgumentError, "framework must be a String or Symbol"
|
|
22
|
+
end
|
|
23
|
+
|
|
18
24
|
result = {}
|
|
19
25
|
|
|
20
26
|
globs = case framework&.to_sym
|
|
@@ -24,6 +24,12 @@ module Profiler
|
|
|
24
24
|
# Raises TooManyRunsError when config.test_runner_max_active_runs runs still have their
|
|
25
25
|
# test process.
|
|
26
26
|
def self.start(files:, framework:)
|
|
27
|
+
unless framework.is_a?(String) || framework.is_a?(Symbol)
|
|
28
|
+
raise ArgumentError, "framework must be a String or Symbol"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
framework = framework.to_s
|
|
32
|
+
|
|
27
33
|
validate_files!(files, framework)
|
|
28
34
|
config = Profiler.configuration
|
|
29
35
|
run = Profiler::TestRunner.run_store.create(
|
data/lib/profiler/version.rb
CHANGED