Commit db4e8fdf authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '345386-fix-non-string-coverage' into 'master'

Fix regression in pipeline coverage API response

See merge request gitlab-org/gitlab!76299
parents 3eef59f3 0582b70a
......@@ -10,7 +10,9 @@ module API
expose :created_at, :updated_at, :started_at, :finished_at, :committed_at
expose :duration
expose :queued_duration
expose :coverage
expose :coverage do |pipeline|
pipeline.present.coverage
end
expose :detailed_status, using: DetailedStatusEntity do |pipeline, options|
pipeline.detailed_status(options[:current_user])
end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe API::Entities::Ci::Pipeline do
let_it_be(:pipeline) { create(:ci_empty_pipeline) }
let_it_be(:job) { create(:ci_build, name: "rspec", coverage: 30.212, pipeline: pipeline) }
let(:entity) { described_class.new(pipeline) }
subject { entity.as_json }
it 'returns the coverage as a string' do
expect(subject[:coverage]).to eq '30.21'
end
end
......@@ -840,7 +840,7 @@ RSpec.describe API::Ci::Pipelines do
it 'exposes the coverage' do
get api("/projects/#{project.id}/pipelines/#{pipeline.id}", user)
expect(json_response["coverage"].to_i).to eq(30)
expect(json_response["coverage"]).to eq('30.00')
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment