Skip to content
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

feedback commit #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

feedback commit #118

wants to merge 1 commit into from

Conversation

case-eee
Copy link
Collaborator

feedback only - do NOT merge!


expect(page).to have_current_path(cart_path)
expect(page).to have_content("#{item_1.description}")
expect(page).to have_content("#{item_2.description}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.


expect(page).to have_current_path(cart_path)
expect(page).to have_content("#{item_1.description}")
expect(page).to have_content("#{item_2.description}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.

create_valid_account

expect(page).to have_current_path(cart_path)
expect(page).to have_content("#{item_1.description}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.

create_valid_account

expect(page).to have_current_path(cart_path)
expect(page).to have_content("#{item_1.description}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.


scenario "the user has two items in their cart" do
expect(page).to have_content("#{item_1.description}")
expect(page).to have_content("#{item_2.description}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.


scenario "the user has two items in their cart" do
expect(page).to have_content("#{item_1.description}")
expect(page).to have_content("#{item_2.description}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.

end

scenario "the user has two items in their cart" do
expect(page).to have_content("#{item_1.description}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.

end

scenario "the user has two items in their cart" do
expect(page).to have_content("#{item_1.description}")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.

require 'rails_helper'

feature 'When a visitor has items in their cart' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

require 'rails_helper'

feature 'When a visitor has items in their cart' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

require 'rails_helper'

feature "A visitor does not successfully create an account" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

require 'rails_helper'

feature "A visitor does not successfully create an account" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

require 'rails_helper'

feature 'A visitor can create an account' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

require 'rails_helper'

feature 'A visitor can create an account' do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

feature "When a site visitor is unauthenticated" do
before do
customer = create(:customer)
@order_1, order_2, order_3 = create_list(:all_new_order, 3, customer: customer)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless assignment to variable - order_2. Use _ or _order_2 as a variable name to indicate that it won't be used.
Useless assignment to variable - order_3. Use _ or _order_3 as a variable name to indicate that it won't be used.

feature "When a site visitor is unauthenticated" do
before do
customer = create(:customer)
@order_1, order_2, order_3 = create_list(:all_new_order, 3, customer: customer)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Useless assignment to variable - order_2. Use _ or _order_2 as a variable name to indicate that it won't be used.
Useless assignment to variable - order_3. Use _ or _order_3 as a variable name to indicate that it won't be used.


feature "When a visitor is logged in" do
before do
Customer.create!( first_name: "Jane",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside parentheses detected.


feature "When a visitor is logged in" do
before do
Customer.create!( first_name: "Jane",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside parentheses detected.

end

feature "When a customer visits the items detail page and adds that item to their cart" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

end

feature "When a customer visits the items detail page and adds that item to their cart" do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

scenario "the admin updates the item description" do
new_description = "Genuine lumberjack pants. Look like you do work, without actually doing it."
click_on_edit
fill_in "item[description]", with: "#{new_description}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.

scenario "the admin updates the item description" do
new_description = "Genuine lumberjack pants. Look like you do work, without actually doing it."
click_on_edit
fill_in "item[description]", with: "#{new_description}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer to_s over string interpolation.

@@ -0,0 +1,81 @@
FactoryGirl.define do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

@@ -0,0 +1,81 @@
FactoryGirl.define do

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body beginning.

end

def items_and_quantities
items.reduce(Hash.new(0)) do |hash, item|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use each_with_object instead of reduce.

end

def items_and_quantities
items.reduce(Hash.new(0)) do |hash, item|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use each_with_object instead of reduce.


def clean_cart
contents.delete_if do |item_id, quantity|
quantity == 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use quantity.zero? instead of quantity == 0.


def clean_cart
contents.delete_if do |item_id, quantity|
quantity == 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use quantity.zero? instead of quantity == 0.

private

def clean_cart
contents.delete_if do |item_id, quantity|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused block argument - item_id. If it's necessary, use _ or _item_id as an argument name to indicate that it won't be used.

end

def items_with_quantities
contents.reduce({}) do |memo, (id, quantity)|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use each_with_object instead of reduce.

private

def clean_cart
contents.delete_if do |item_id, quantity|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused block argument - item_id. If it's necessary, use _ or _item_id as an argument name to indicate that it won't be used.

end

def items_with_quantities
contents.reduce({}) do |memo, (id, quantity)|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use each_with_object instead of reduce.

Copy link
Collaborator Author

@case-eee case-eee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CPowell23 @robbie-smith @ski-climb @lucyconklin great work on this. here's some feedback 😄 sorry for the delay!

@@ -1,24 +1,11 @@
# README
# Little Shop
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suggest adding an overview of what this application does here and perhaps how to pull it down and get it working locally 👍

});
});

function stripeResponseHandler(status, response) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wooo stripe checkout 🎉


def filter_orders
if status_filter.nil?
Order.all.most_recent
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if most_recent is a class method, we don't need to call all here

@@ -1,3 +1,38 @@
class ApplicationController < ActionController::Base
include ApplicationHelper
include MessageHelper
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we talked about this in your eval a bit, helper modules are conventionally used for your views - their responsibility is formatting output for viewing purposes. i like how you refactored your controllers - could we make a PORO though to handle some of this logic?

def create
customer = current_customer.stripe_customer

begin
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's a lot of stuff going on here (i know this is all stripe logic) - i suggest pulling this out to a PORO in order to keep your controller more single responsibility 👍

<p><%= @item.description %></p>
<div>
<h4><%= number_to_currency(@item.price_in_dollars) %></h4>
<% if @item.retired == false %>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is too much logic in your view. i suggest creating a method on Item called retired? that does this for you 😄

<%= yield %>
<%= render partial: 'layouts/nav' %>
<section class="main">
<%= render partial: 'shared/errors' %>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woooo shared partials 👍

</div>
<% end %>
<p><%= number_to_currency(item.price_in_dollars) %></p>
<% if item.retired == false %>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could reuse that retired? method here!

<% end %>
</td>
<td>
<% if order.status.paid? || order.status.ordered? %>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is also a lot of logic in your view. can we create a method in Order that does this for us? maybe something called paid_or_ordered??

@@ -58,6 +58,9 @@ development:
test:
<<: *default
database: little_shop_test

adapter: postgresql
database: travis_ci_test
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 🎉 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants