-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selam Ainalem Amperes #24
base: master
Are you sure you want to change the base?
Conversation
…tion, and added test file for recipe_api_wrapper class.
…e able to sign in with their github (attempted with google but the process kept rejecting clientID).
…onsive to size changes.
…s to show page of a recipe. Added flash messages (and some styling) for reminder to log-in and successful search.
…ted small aspects to flash message.
…ccounted for properly in conditions in wrapper class, and made update to css styling.
API MuncherWhat We're Looking For
|
<%= javascript_include_tag "application", 'data-turbolinks-track' => true %> | ||
<%= csrf_meta_tags %> | ||
</head> | ||
<nav> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This nav
element should be in the body
<%end%> | ||
</nav> | ||
|
||
<%if params[:query].nil?%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe simply put main
elements with these ids in the views for homepage and search etc.
@@ -0,0 +1,40 @@ | |||
|
|||
<h2 class="item-header"><%[email protected]%></h2> | |||
<h3 class="item-header">By <%[email protected]%></h3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be an excellent point for a link back to the source of the recipe.
end | ||
|
||
def show | ||
@recipe = RecipeApiWrapper.a_recipe(params[:uri]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should have some error handling for if a recipe isn't found.
return [] | ||
end | ||
a_recipe = recipe.uri_encode | ||
response = HTTParty.get("https://api.edamam.com/search?app_id=#{APP_ID}&app_key=#{APP_KEY}&r=#{a_recipe}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should do some error handling for if the API request doesn't work. What if the URI is incorrect? How do you handle it?
end | ||
end | ||
it 'will return [] for a recipe search that is not of string type' do | ||
VCR.use_cassette("recipe-is-a-string") do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a call with a URI that's not valid?
return recipe | ||
end | ||
|
||
def self.limited_query(query,from,to) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like a great candidate for combining with the list_of_queried_recipes
method using default parameters for the from and to fields.
it 'will display index for query within a specific range' do | ||
session[:user_id].must_equal @jay.id | ||
VCR.use_cassette("Recipe-controller:recipe-query-range") do | ||
get query_results_path, params: {from:"1", to: "5", query: "corn"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should also test with invalid from
and to
fields
end | ||
end | ||
describe 'Show' do | ||
it 'will show details of a recipe' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about invalid uri
s
end | ||
describe 'Logged-in User' do | ||
before do | ||
login(@jay) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very good that you're doing this testing.
API Muncher
Congratulations! You're submitting your assignment!
Comprehension Questions