debian-mirror-gitlab/app/serializers/test_case_entity.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
1.2 KiB
Ruby
Raw Normal View History

2018-11-20 20:47:30 +05:30
# frozen_string_literal: true
2018-11-18 11:00:15 +05:30
class TestCaseEntity < Grape::Entity
2020-04-22 19:07:51 +05:30
include API::Helpers::RelatedResourcesHelpers
2023-01-13 00:05:48 +05:30
expose :status, documentation: { type: 'string', example: 'success' }
expose :name, default: "(No name)",
documentation: { type: 'string', example: 'Security Reports can create an auto-remediation MR' }
expose :classname, documentation: { type: 'string', example: 'vulnerability_management_spec' }
expose :file, documentation: { type: 'string', example: './spec/test_spec.rb' }
expose :execution_time, documentation: { type: 'integer', example: 180 }
expose :system_output, documentation: { type: 'string', example: 'Failure/Error: is_expected.to eq(3)' }
expose :stack_trace, documentation: { type: 'string', example: 'Failure/Error: is_expected.to eq(3)' }
expose :recent_failures, documentation: { example: { count: 3, base_branch: 'develop' } }
expose(
:attachment_url,
if: -> (*) { can_read_screenshots? },
documentation: { type: 'string', example: 'http://localhost/namespace1/project1/-/jobs/1/artifacts/file/some/path.png' }
) do |test_case|
2020-04-22 19:07:51 +05:30
expose_url(test_case.attachment_url)
end
private
alias_method :test_case, :object
def can_read_screenshots?
2021-06-08 01:23:25 +05:30
test_case.has_attachment?
2020-04-22 19:07:51 +05:30
end
2018-11-18 11:00:15 +05:30
end