From 3983f5d03c8f980c41484bab83e828e5ae64182d Mon Sep 17 00:00:00 2001 From: RileyManda Date: Thu, 19 Oct 2023 21:27:02 +0200 Subject: [PATCH 1/5] Navigation:recipes --- app/views/food/index.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/food/index.html.erb b/app/views/food/index.html.erb index 9ac5c80..5758f8e 100644 --- a/app/views/food/index.html.erb +++ b/app/views/food/index.html.erb @@ -1,4 +1,5 @@ <%= "Welcome, #{current_user.email}" %> +<%= link_to 'Recipes', recipe_index_path, class: 'btn small btn-primary' %>

Foods

From 40a9cc80c7a8287bbcaf33e03d78a6ce6082365a Mon Sep 17 00:00:00 2001 From: RileyManda Date: Thu, 19 Oct 2023 21:34:02 +0200 Subject: [PATCH 2/5] Navigation:food --- app/views/food/index.html.erb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/views/food/index.html.erb b/app/views/food/index.html.erb index 5758f8e..42405fe 100644 --- a/app/views/food/index.html.erb +++ b/app/views/food/index.html.erb @@ -1,5 +1,8 @@ <%= "Welcome, #{current_user.email}" %> <%= link_to 'Recipes', recipe_index_path, class: 'btn small btn-primary' %> +<%= link_to 'Public Recipes', public_recipes_path, class: 'btn small btn-primary' %> +<%= link_to 'Food', food_index_path, class: 'btn small btn-primary' %> +

Foods

From 0a0d945f8b82715d5342c67a9982f7b75f87c0e2 Mon Sep 17 00:00:00 2001 From: RileyManda Date: Thu, 19 Oct 2023 21:43:49 +0200 Subject: [PATCH 3/5] Generated boilerplate code for shopping view --- app/controllers/shopping_controller.rb | 4 +++ app/helpers/shopping_helper.rb | 2 ++ app/views/food/index.html.erb | 1 + app/views/shopping/index.html.erb | 38 ++++++++++++++++++++++ config/routes.rb | 2 ++ spec/helpers/shopping_helper_spec.rb | 15 +++++++++ spec/requests/shopping_spec.rb | 11 +++++++ spec/views/shopping/index.html.erb_spec.rb | 5 +++ 8 files changed, 78 insertions(+) create mode 100644 app/controllers/shopping_controller.rb create mode 100644 app/helpers/shopping_helper.rb create mode 100644 app/views/shopping/index.html.erb create mode 100644 spec/helpers/shopping_helper_spec.rb create mode 100644 spec/requests/shopping_spec.rb create mode 100644 spec/views/shopping/index.html.erb_spec.rb diff --git a/app/controllers/shopping_controller.rb b/app/controllers/shopping_controller.rb new file mode 100644 index 0000000..e5ec84d --- /dev/null +++ b/app/controllers/shopping_controller.rb @@ -0,0 +1,4 @@ +class ShoppingController < ApplicationController + def index + end +end diff --git a/app/helpers/shopping_helper.rb b/app/helpers/shopping_helper.rb new file mode 100644 index 0000000..ad4884f --- /dev/null +++ b/app/helpers/shopping_helper.rb @@ -0,0 +1,2 @@ +module ShoppingHelper +end diff --git a/app/views/food/index.html.erb b/app/views/food/index.html.erb index 42405fe..ace4912 100644 --- a/app/views/food/index.html.erb +++ b/app/views/food/index.html.erb @@ -2,6 +2,7 @@ <%= link_to 'Recipes', recipe_index_path, class: 'btn small btn-primary' %> <%= link_to 'Public Recipes', public_recipes_path, class: 'btn small btn-primary' %> <%= link_to 'Food', food_index_path, class: 'btn small btn-primary' %> +<%= link_to "Shopping", shopping_index_path, class: 'btn btn-primary' %>

Foods

diff --git a/app/views/shopping/index.html.erb b/app/views/shopping/index.html.erb new file mode 100644 index 0000000..a735150 --- /dev/null +++ b/app/views/shopping/index.html.erb @@ -0,0 +1,38 @@ +
+ <%= link_to '< Back To All Recipes', recipe_index_path, class: 'btn small btn-primary' %> +
+
+ + + + + + + + + + <% if @recipe_foods.present? %> + <% @recipe_foods.each do |recipe_food| %> + + + + + + + <% end %> + <% else %> + + + + <% end %> + +
FoodQuantityPrice
<%= recipe_food.food.name %><%= recipe_food.quantity %>g$<%= recipe_food.quantity * recipe_food.food.price %> +
+ + <%= form_for([@recipe, recipe_food], method: :delete, html: { data: { confirm: 'Are you sure you want to delete this ingredient?' } }) do |f| %> + <%= f.submit 'Remove', class: "btn btn-danger btn-sm" %> + <% end %> +
+
No Shopping List generated
+
+
diff --git a/config/routes.rb b/config/routes.rb index b76ef7f..ae587c1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,5 @@ Rails.application.routes.draw do + get 'shopping/index' root 'food#index' devise_for :users @@ -12,6 +13,7 @@ resources :recipe_foods, only: [:new, :create, :destroy] post '', to: 'recipe#create', on: :new, as: 'create_recipe' get 'new_recipe', to: 'recipe#new', on: :new, as: 'new_recipe' + get 'shopping', to: 'shopping#index', as: 'shopping_index' end delete 'recipe/:id', to: 'recipe#destroy', as: 'remove_recipe' diff --git a/spec/helpers/shopping_helper_spec.rb b/spec/helpers/shopping_helper_spec.rb new file mode 100644 index 0000000..172d30c --- /dev/null +++ b/spec/helpers/shopping_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the ShoppingHelper. For example: +# +# describe ShoppingHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe ShoppingHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/shopping_spec.rb b/spec/requests/shopping_spec.rb new file mode 100644 index 0000000..69c5c52 --- /dev/null +++ b/spec/requests/shopping_spec.rb @@ -0,0 +1,11 @@ +require 'rails_helper' + +RSpec.describe "Shoppings", type: :request do + describe "GET /index" do + it "returns http success" do + get "/shopping/index" + expect(response).to have_http_status(:success) + end + end + +end diff --git a/spec/views/shopping/index.html.erb_spec.rb b/spec/views/shopping/index.html.erb_spec.rb new file mode 100644 index 0000000..8cfe0b3 --- /dev/null +++ b/spec/views/shopping/index.html.erb_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe "shopping/index.html.erb", type: :view do + pending "add some examples to (or delete) #{__FILE__}" +end From 02503d251e7fc92ed60fdf925b01ce6b77973019 Mon Sep 17 00:00:00 2001 From: RileyManda Date: Thu, 19 Oct 2023 21:50:04 +0200 Subject: [PATCH 4/5] Shopping List ui design:skeleton view --- app/views/recipe/show.html.erb | 2 +- app/views/shopping/index.html.erb | 24 ++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/views/recipe/show.html.erb b/app/views/recipe/show.html.erb index e6ba481..9e213aa 100644 --- a/app/views/recipe/show.html.erb +++ b/app/views/recipe/show.html.erb @@ -1,7 +1,7 @@

<%= @recipe.name %>

-

Preparation Time: <%= @recipe.preparation_time %> minutes

+

Preparation Time: <%= @recipe.preparation_time %> hours

<%= form_for @recipe, url: recipe_path(@recipe), method: :patch do |f| %> <%= hidden_field_tag :authenticity_token, form_authenticity_token %> diff --git a/app/views/shopping/index.html.erb b/app/views/shopping/index.html.erb index a735150..9ae67d7 100644 --- a/app/views/shopping/index.html.erb +++ b/app/views/shopping/index.html.erb @@ -1,6 +1,19 @@
- <%= link_to '< Back To All Recipes', recipe_index_path, class: 'btn small btn-primary' %> +

Shopping List

+

Amount of food to buy:

+ +
+ Recipe: Recipe2Link +
+ +
+

Total value of of food needed:

+
+ Inventory: Inventory1 +
+ +
@@ -18,21 +31,16 @@ <% end %> <% else %> - + <% end %>
<%= recipe_food.quantity %>g $<%= recipe_food.quantity * recipe_food.food.price %> -
- - <%= form_for([@recipe, recipe_food], method: :delete, html: { data: { confirm: 'Are you sure you want to delete this ingredient?' } }) do |f| %> - <%= f.submit 'Remove', class: "btn btn-danger btn-sm" %> - <% end %> -
No Shopping List generatedNo shopping list available.
+ <%= link_to '< Back To All Recipes', recipe_index_path, class: 'btn small btn-primary' %>
From 8d36dcb5040dbe4b9be99a39bd8c539d8777382d Mon Sep 17 00:00:00 2001 From: RileyManda Date: Thu, 19 Oct 2023 21:52:06 +0200 Subject: [PATCH 5/5] Linter fixes:Updated navigation and generated shopping controller --- app/controllers/shopping_controller.rb | 3 +-- app/views/shopping/index.html.erb | 2 -- spec/requests/shopping_spec.rb | 9 ++++----- spec/views/shopping/index.html.erb_spec.rb | 2 +- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/app/controllers/shopping_controller.rb b/app/controllers/shopping_controller.rb index e5ec84d..10cc613 100644 --- a/app/controllers/shopping_controller.rb +++ b/app/controllers/shopping_controller.rb @@ -1,4 +1,3 @@ class ShoppingController < ApplicationController - def index - end + def index; end end diff --git a/app/views/shopping/index.html.erb b/app/views/shopping/index.html.erb index 9ae67d7..c3e66fb 100644 --- a/app/views/shopping/index.html.erb +++ b/app/views/shopping/index.html.erb @@ -12,8 +12,6 @@
Inventory: Inventory1
- -
diff --git a/spec/requests/shopping_spec.rb b/spec/requests/shopping_spec.rb index 69c5c52..3e64d2e 100644 --- a/spec/requests/shopping_spec.rb +++ b/spec/requests/shopping_spec.rb @@ -1,11 +1,10 @@ require 'rails_helper' -RSpec.describe "Shoppings", type: :request do - describe "GET /index" do - it "returns http success" do - get "/shopping/index" +RSpec.describe 'Shoppings', type: :request do + describe 'GET /index' do + it 'returns http success' do + get '/shopping/index' expect(response).to have_http_status(:success) end end - end diff --git a/spec/views/shopping/index.html.erb_spec.rb b/spec/views/shopping/index.html.erb_spec.rb index 8cfe0b3..7323afd 100644 --- a/spec/views/shopping/index.html.erb_spec.rb +++ b/spec/views/shopping/index.html.erb_spec.rb @@ -1,5 +1,5 @@ require 'rails_helper' -RSpec.describe "shopping/index.html.erb", type: :view do +RSpec.describe 'shopping/index.html.erb', type: :view do pending "add some examples to (or delete) #{__FILE__}" end