Open
Conversation
added 23 commits
November 2, 2018 13:12
API MuncherWhat We're Looking For
|
CheezItMan
reviewed
Nov 6, 2018
| end | ||
| end | ||
|
|
||
| describe "show" do |
There was a problem hiding this comment.
This describe should be inside the describe RecipesController do block
| it 'shows a list of recipes' do | ||
| VCR.use_cassette('recipes') do | ||
|
|
||
| get recipes_path, params: search |
There was a problem hiding this comment.
search is undefined, maybe this should be something like:
get recipes_path, params: { search: 'pasta' }|
|
||
|
|
||
| it "can get the index path" do | ||
| ingredients = {ingredients: "chocolate"} |
| must_respond_with :ok | ||
| end | ||
| end | ||
| it "will redirect with invalid search terms" do |
There was a problem hiding this comment.
This test crashes because of a bug in your index.html.erb view
| if @search_term | ||
| @recipes = EdamamApiWrapper.search_recipes(params[:search]) | ||
| else | ||
| @recipes = nil |
There was a problem hiding this comment.
maybe if @search_term is nil you should make @recipes be an empty array.
Otherwise your view gives an error when it tries to do .each on nil.
| <section class="text-center"> | ||
| <p class = "btn btn-outline-dark"><%= link_to "View Original Recipe ", "#{recipe.url}", target: :_blank %></p> | ||
| </section> | ||
| <div class="card-body"> |
| end | ||
| return @recipe_list | ||
| else | ||
| return nil |
There was a problem hiding this comment.
I suggest returning an empty array if there are no results.
| @@ -0,0 +1,53 @@ | |||
| require 'httparty' | |||
| def self.find_recipe(id) | ||
| url = BASE_URL + "search?" + "r=http%3A%2F%2Fwww.edamam.com%2Fontologies%2Fedamam.owl%23recipe_#{id}" + "&app_id=#{ID}&app_key=#{KEY}" | ||
| data = HTTParty.get(url) | ||
| if data.length |
There was a problem hiding this comment.
I would make this if data.length > 0
| end | ||
|
|
||
| def show | ||
| @recipe = EdamamApiWrapper.find_recipe(recipe.id) |
There was a problem hiding this comment.
Shouldn't this be
@recipe = EdamamApiWrapper.find_recipe(params[:id])
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions
lib? How would your project change if you needed to interact with more than one API (aka more than just the Edamam API)?