Skip to content

Commit

Permalink
Make @results less magic-y
Browse files Browse the repository at this point in the history
  • Loading branch information
pgengler committed Jan 26, 2020
1 parent 6e962eb commit d3f919b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions app/controllers/test_results_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def create
return
end

if succeeded? && !verify_test_results(params[:results])
if succeeded? && !verify_test_results
head :unprocessable_entity
return
end
Expand All @@ -42,7 +42,7 @@ def create
addon_version_id: build.addon_version.id,
build_server: build.build_server,
canary: build.canary?,
ember_try_results: @results,
ember_try_results: results,
output: output,
output_format: output_format,
semver_string: semver_string,
Expand Down Expand Up @@ -93,15 +93,17 @@ def succeeded?
params[:status] == 'succeeded'
end

def verify_test_results(results_str)
return false unless results_str
begin
@results = JSON.parse(results_str)
def results
@results ||= begin
JSON.parse(params[:results] || '')
rescue JSON::ParserError
return false
return nil
end
end

return false if @results['scenarios'].empty?
def verify_test_results
return false if results.nil?
return false if results['scenarios'].empty?
true
end

Expand Down

0 comments on commit d3f919b

Please sign in to comment.