cart creation backend logic is at place / adding items in progress
This commit is contained in:
4
back-office/app/controllers/carts_controller.rb
Normal file
4
back-office/app/controllers/carts_controller.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class CartsController < ApplicationController
|
||||
active_scaffold :"cart" do |conf|
|
||||
end
|
||||
end
|
||||
4
back-office/app/controllers/item_in_carts_controller.rb
Normal file
4
back-office/app/controllers/item_in_carts_controller.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class ItemInCartsController < ApplicationController
|
||||
active_scaffold :"item_in_cart" do |conf|
|
||||
end
|
||||
end
|
||||
2
back-office/app/helpers/carts_helper.rb
Normal file
2
back-office/app/helpers/carts_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module CartsHelper
|
||||
end
|
||||
2
back-office/app/helpers/item_in_carts_helper.rb
Normal file
2
back-office/app/helpers/item_in_carts_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module ItemInCartsHelper
|
||||
end
|
||||
2
back-office/app/models/cart.rb
Normal file
2
back-office/app/models/cart.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Cart < ActiveRecord::Base
|
||||
end
|
||||
2
back-office/app/models/item_in_cart.rb
Normal file
2
back-office/app/models/item_in_cart.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class ItemInCart < ActiveRecord::Base
|
||||
end
|
||||
@@ -1,5 +1,7 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
resources :item_in_carts do as_routes end
|
||||
resources :carts do as_routes end
|
||||
resources :multi_media_descriptions do as_routes end
|
||||
resources :sections do as_routes end
|
||||
resources :media_types do as_routes end
|
||||
|
||||
49
back-office/test/controllers/carts_controller_test.rb
Normal file
49
back-office/test/controllers/carts_controller_test.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class CartsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@cart = carts(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:carts)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create cart" do
|
||||
assert_difference('Cart.count') do
|
||||
post :create, cart: { ordered: @cart.ordered, user_id: @cart.user_id }
|
||||
end
|
||||
|
||||
assert_redirected_to cart_path(assigns(:cart))
|
||||
end
|
||||
|
||||
test "should show cart" do
|
||||
get :show, id: @cart
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @cart
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update cart" do
|
||||
patch :update, id: @cart, cart: { ordered: @cart.ordered, user_id: @cart.user_id }
|
||||
assert_redirected_to cart_path(assigns(:cart))
|
||||
end
|
||||
|
||||
test "should destroy cart" do
|
||||
assert_difference('Cart.count', -1) do
|
||||
delete :destroy, id: @cart
|
||||
end
|
||||
|
||||
assert_redirected_to carts_path
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemInCartsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@item_in_cart = item_in_carts(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:item_in_carts)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create item_in_cart" do
|
||||
assert_difference('ItemInCart.count') do
|
||||
post :create, item_in_cart: { cart_id: @item_in_cart.cart_id, item_id: @item_in_cart.item_id }
|
||||
end
|
||||
|
||||
assert_redirected_to item_in_cart_path(assigns(:item_in_cart))
|
||||
end
|
||||
|
||||
test "should show item_in_cart" do
|
||||
get :show, id: @item_in_cart
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @item_in_cart
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update item_in_cart" do
|
||||
patch :update, id: @item_in_cart, item_in_cart: { cart_id: @item_in_cart.cart_id, item_id: @item_in_cart.item_id }
|
||||
assert_redirected_to item_in_cart_path(assigns(:item_in_cart))
|
||||
end
|
||||
|
||||
test "should destroy item_in_cart" do
|
||||
assert_difference('ItemInCart.count', -1) do
|
||||
delete :destroy, id: @item_in_cart
|
||||
end
|
||||
|
||||
assert_redirected_to item_in_carts_path
|
||||
end
|
||||
end
|
||||
9
back-office/test/fixtures/carts.yml
vendored
Normal file
9
back-office/test/fixtures/carts.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
user_id: 1
|
||||
ordered:
|
||||
|
||||
two:
|
||||
user_id: 1
|
||||
ordered:
|
||||
9
back-office/test/fixtures/item_in_carts.yml
vendored
Normal file
9
back-office/test/fixtures/item_in_carts.yml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
cart_id: 1
|
||||
item_id: 1
|
||||
|
||||
two:
|
||||
cart_id: 1
|
||||
item_id: 1
|
||||
7
back-office/test/models/cart_test.rb
Normal file
7
back-office/test/models/cart_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class CartTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
back-office/test/models/item_in_cart_test.rb
Normal file
7
back-office/test/models/item_in_cart_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemInCartTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user