Skip to content

Commit

Permalink
fixes specs around the cookbook show actions for the 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 11, 2016
1 parent 884de90 commit 5b84834
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Api::V1::CookbookVersionsController < Api::V1Controller
def show
@cookbook = Cookbook.with_name(params[:cookbook]).first!
@cookbook_version = @cookbook.get_version!(params[:version])
@cookbook_version_metrics = @cookbook_version.metric_results
@cookbook_version_metrics = @cookbook_version.metric_results.includes(:quality_metric)
end

#
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ json.version cookbook_version.version
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?
json.quality do
@cookbook_version_metrics.each do |metric|
json.name metric.quality_metric.name
json.failed metric.failure
json.feedback metric.feedback
end
end
json.quality_metrics @cookbook_version_metrics do |metric|
json.name metric.quality_metric.name
json.failed metric.failure
json.feedback metric.feedback
end
json.set! :dependencies do
cookbook_version.cookbook_dependencies.each do |dependency|
end

json.set! :dependencies do
cookbook_version.cookbook_dependencies.each do |dependency|
json.set! dependency.name, dependency.version_constraint
end
end
12 changes: 6 additions & 6 deletions src/supermarket/spec/api/cookbook_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,18 @@

let(:quality_metrics) do
{
'quality' => {
'foodcritic' => {
'quality_metrics' => [
{
'name' => quality_metric_foodcritic.name,
'failed' => foodcritic_result.failure,
'feedback' => foodcritic_result.feedback
},
'collaborator' => {
{
'name' => quality_metric_collab_num.name,
'failed' => collab_result.failure,
'feedback' => collab_result.feedback
}
}
]
}
end

Expand All @@ -101,7 +103,6 @@

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

Expand All @@ -114,7 +115,6 @@
it 'returns a 200' do
get "/api/v1/cookbooks/#{cookbook.name}/versions/#{cookbook_version.version}"

puts response.body.inspect
expect(response.status.to_i).to eql(200)
end

Expand Down

0 comments on commit 5b84834

Please sign in to comment.