summaryrefslogtreecommitdiff
path: root/app/serializers/test_case_entity.rb
blob: 299160cd1bfd225ca56c69f395472ba9361a7ba4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# frozen_string_literal: true

class TestCaseEntity < Grape::Entity
  include API::Helpers::RelatedResourcesHelpers

  expose :status
  expose :name
  expose :classname
  expose :file
  expose :execution_time
  expose :system_output
  expose :stack_trace
  expose :recent_failures
  expose :attachment_url, if: -> (*) { can_read_screenshots? } do |test_case|
    expose_url(test_case.attachment_url)
  end

  private

  alias_method :test_case, :object

  def can_read_screenshots?
    Feature.enabled?(:junit_pipeline_screenshots_view, options[:project]) && test_case.has_attachment?
  end
end