Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ gem 'foundation-rails', '~> 6.3.1'
gem 'omniauth'
gem 'omniauth-github'


gem 'simplecov'
gem 'minitest-rails'
gem 'minitest-reporters'

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
Expand Down Expand Up @@ -68,6 +73,5 @@ group :development do
end

group :test do
gem 'minitest-rails'
gem 'minitest-reporters'

end
10 changes: 9 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ GEM
concurrent-ruby (1.0.5)
crass (1.0.2)
debug_inspector (0.0.3)
docile (1.1.5)
dotenv (2.2.1)
dotenv-rails (2.2.1)
dotenv (= 2.2.1)
Expand All @@ -93,6 +94,7 @@ GEM
jquery-turbolinks (2.1.0)
railties (>= 3.1.0)
turbolinks
json (2.0.2)
jwt (1.5.6)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
Expand Down Expand Up @@ -193,6 +195,11 @@ GEM
selenium-webdriver (3.6.0)
childprocess (~> 0.5)
rubyzip (~> 1.0)
simplecov (0.15.1)
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
Expand Down Expand Up @@ -256,6 +263,7 @@ DEPENDENCIES
rails (~> 5.1.4)
sass-rails (~> 5.0)
selenium-webdriver
simplecov
spring
spring-watcher-listen (~> 2.0.0)
turbolinks (~> 5)
Expand All @@ -264,4 +272,4 @@ DEPENDENCIES
web-console (>= 3.3.0)

BUNDLED WITH
1.15.4
1.16.0.pre.3
12 changes: 1 addition & 11 deletions app/controllers/order_items_controller.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class OrderItemsController < ApplicationController

def index
#maybe just for that merchant
@order_items = OrderItem.where(order_id: session[:order_id])
end

Expand All @@ -10,8 +9,6 @@ def new
end

def create
#if there is already an open order, set the order_item order_id to that order.
#otherwise make a new order
if session[:order_id] == nil
@order = Order.create(status: "pending")
session[:order_id] = @order.id
Expand All @@ -20,13 +17,6 @@ def create

@order_item.save!
redirect_to order_items_path
# else
# #
# # render :new
# flash[:status] = :failure
# flash[:result_text] = "Could not create order item"
# flash[:details] = @order_item.errors.messages
# end
end

def update
Expand All @@ -35,7 +25,7 @@ def update
if @order_item.save
redirect_to root_path
else
# render :edit

end

@order_item.update_attributes(order_item_params)
Expand Down
24 changes: 10 additions & 14 deletions app/controllers/orders_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class OrdersController < ApplicationController
def index

@orders = Order.all
end

Expand All @@ -9,23 +8,13 @@ def new
end

def create
@order = Order.new(order_params)
if params[:order][:status] == " "
flash[:failure] = 'Please enter the required fields.'
redirect_to new_order_path
else
@order = Order.new(
status: 'pending',
customer_name: params[:order][:customer_name],
customer_email: params[:order][:customer_email],
customer_address: params[:order][:customer_address],
cc_number: params[:order][:cc_number],
cc_expiration: params[:order][:cc_expiration],
cc_ccv: params[:order][:cc_ccv],
zip_code: params[:order][:zip_code],
)
result = @order.save

if result
@order = Order.new(order_params)
if @order.save
flash[:success] = 'Your order has been placed'
redirect_to orders_path
else
Expand Down Expand Up @@ -69,4 +58,11 @@ def show
@order = Order.find(params[:id])
end

private

def order_params
params.require(:order).permit(:customer_email, :customer_name,
:zip_code, :cc_expiration, :status, :cc_ccv, :cc_number, :customer_address)
end

end
6 changes: 3 additions & 3 deletions app/models/merchant.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
class Merchant < ApplicationRecord
has_many :products

validates :provider, presence: true
validates :uid, presence: true, uniqueness: true

def self.from_auth_hash(provider, auth_hash)
merchant = new
merchant.provider = provider
merchant.uid = auth_hash['uid']
merchant.email = auth_hash['info']['email']
merchant.username = auth_hash['info']['nickname']

return merchant
end


end
5 changes: 5 additions & 0 deletions coverage/.last_run.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"result": {
"covered_percent": 85.95
}
}
Loading