Skip to content

Commit

Permalink
adds check for fieri feature when displaying quality metrics through api
Browse files Browse the repository at this point in the history
Signed-off-by: Nell Shamrell <[email protected]>
  • Loading branch information
nellshamrell committed Oct 12, 2016
1 parent 5b84834 commit a2f40ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ json.average_rating nil
json.cookbook api_v1_cookbook_url(cookbook)
json.file api_v1_cookbook_version_download_url(cookbook_version.cookbook, cookbook_version)

if !@cookbook_version_metrics.nil? && @cookbook_version_metrics.any?
if ROLLOUT.active?(:fieri)
json.quality_metrics @cookbook_version_metrics do |metric|
json.name metric.quality_metric.name
json.failed metric.failure
Expand Down
36 changes: 26 additions & 10 deletions src/supermarket/spec/api/cookbook_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,23 +101,39 @@
expect(signature(json_body)).to include(cookbook_version_signature)
end

it 'returns quality metrics for the cookbook version' do
get json_body['versions'].find { |v| v =~ /0.1.0/ }
expect(signature(json_body)).to include(quality_metrics)
end

context 'when the cookbook has only the foodcritic metric' do
context 'when the fieri feature is active' do
before do
collab_result.destroy
expect(cookbook_version.metric_results.count).to eq(1)
allow(ROLLOUT).to receive(:active?).with(:fieri).and_return(true)
end

it 'returns a 200' do
it 'returns quality metrics for the cookbook version' do
get "/api/v1/cookbooks/#{cookbook.name}/versions/#{cookbook_version.version}"
expect(JSON.parse(response.body)).to include(quality_metrics)
end

context 'when the cookbook has only the foodcritic metric' do
before do
collab_result.destroy
expect(cookbook_version.metric_results.count).to eq(1)
end

it 'returns a 200' do
get "/api/v1/cookbooks/#{cookbook.name}/versions/#{cookbook_version.version}"

expect(response.status.to_i).to eql(200)
expect(response.status.to_i).to eql(200)
end
end
end

context 'when the fieri feature is not active' do
before do
allow(ROLLOUT).to receive(:active?).with(:fieri).and_return(false)
end

it 'does not return quality metrics for the cookbook version' do
get "/api/v1/cookbooks/#{cookbook.name}/versions/#{cookbook_version.version}"
expect(JSON.parse(response.body)).to_not include(quality_metrics)
end
end
end

Expand Down

0 comments on commit a2f40ab

Please sign in to comment.