Skip to content

Commit

Permalink
Merge branch 'master' of github.com:eliseworthy/store_engine
Browse files Browse the repository at this point in the history
  • Loading branch information
Elise Worthy committed Apr 18, 2012
2 parents dcbe5dd + 6a31e4c commit fb8fc74
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 161 deletions.
20 changes: 5 additions & 15 deletions app/controllers/order_items_controller.rb
Expand Up @@ -23,17 +23,10 @@ def edit

def update
@order_item = OrderItem.find(params[:id])
respond_to do |format|
if @order_item.update_attributes(params[:order_item])
format.html { redirect_to order_path(@order_item.order),
notice: 'Order was successfully updated.' }
format.json { head :no_content }
else
format.html { redirect_to order_path(@order_item.order),
notice: 'Quantity must be greater than 0' }
format.json { render json: @order_item.order,
status: :unprocessable_entity }
end
if @order_item.update_attributes(params[:order_item])
redirect_to order_path(@order_item.order), notice: 'Order was successfully updated.'
else
redirect_to order_path(@order_item.order), notice: 'Quantity must be greater than 0'
end
end

Expand All @@ -44,9 +37,6 @@ def lookup_order_item
def destroy
@order_item = OrderItem.find(params[:id])
@order_item.destroy
respond_to do |format|
format.html { redirect_to order_path(@order_item.order) }
format.json { head :no_content }
end
redirect_to order_path(@order_item.order)
end
end
2 changes: 1 addition & 1 deletion spec/models/order_item_spec.rb
Expand Up @@ -9,7 +9,7 @@
li.save
li
end
let!(:order_item) { OrderItem.create(line_item: line_item) }
let!(:order_item) { FactoryGirl.create(:order_item) }

describe "#set_price" do
it "sets the order item's price from the line_item price" do
Expand Down
22 changes: 19 additions & 3 deletions spec/requests/category_assignments_spec.rb
Expand Up @@ -4,10 +4,11 @@

let!(:user) { FactoryGirl.create(:user, password: "123") }
let!(:admin_user) { FactoryGirl.create(:user, password: "123", admin: true) }
let!(:product) { Product.create(title: "title", price: 2, description: "desc") }
let!(:product_2) { Product.create(title: "title2", price: 4, description: "new desc") }
let!(:product) { Product.create(title: "title", price: 2, description: "desc", upc: "072140002282") }
let!(:product_2) { Product.create(title: "title2", price: 4, description: "new desc", upc: "072140002282") }
let!(:category) { Category.create(name: "category_sample") }
let!(:category_2) { Category.create(name: "category_no_assignments") }
let!(:category_3) { Category.create(name: "other_sample_category") }
let!(:category_assignment) { CategoryAssignment.create(product_id: product.id, category_id: category.id) }
let!(:category_assignment2) { CategoryAssignment.create(product_id: product_2.id, category_id: category.id) }

Expand All @@ -23,7 +24,22 @@

it "allows an admin to add a category assignment to a product" do
visit edit_product_path(product)
save_and_open_page
within ("#product_category_ids") do
select "category_sample"
select "category_no_assignments"
end
click_button "Update Product"
page.should have_content("category_sample")
page.should have_content("category_no_assignments")
end

it "allows an admin to remove a category assignment from a product" do
visit edit_product_path(product)
within ("#product_category_ids") do
select "other_sample_category"
end
click_button "Update Product"
page.should have_content("other_sample_category")
end
end
end
Expand Down
131 changes: 0 additions & 131 deletions spec/requests/order_spec.rb

This file was deleted.

24 changes: 13 additions & 11 deletions spec/requests/orders_spec.rb
Expand Up @@ -27,17 +27,19 @@
page.should have_content("Cart is empty")
end

# it "enables you to checkout if cart has contents" do
# visit products_path
# click_on "Add to Cart"
# click_on "Checkout"
# fill_in "order_name", with: "Testing1234"
# fill_in "order_address", with: "1234 fake st"
# fill_in "order_email", with: "testemail@fake.com"
# page.select("Check", :from => "order_pay_type")
# click_button "Place Order"
# page.should have_content("Thank you for your order")
# end
it "enables you to checkout if cart has contents" do
visit products_path
click_on "Add to Cart"
click_on "Checkout"
save_and_open_page
fill_in "order_name", with: "Testing1234"
fill_in "order_address", with: "1234 fake st"
fill_in "order_email", with: "testemail@fake.com"
fill_in "order_cc_number", with: "1234567890"
fill_in "order_cc_expiry", with: "12/12"
click_button "Place Order"
page.should have_content("Thank you for your order")
end

it "enables one-click checkout if there is a previous order" do
visit products_path
Expand Down

0 comments on commit fb8fc74

Please sign in to comment.