item groups now have order - start page is now item group 1 (configurable in globals)
This commit is contained in:
4
back-office/app/controllers/item_in_groups_controller.rb
Normal file
4
back-office/app/controllers/item_in_groups_controller.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class ItemInGroupsController < ApplicationController
|
||||
active_scaffold :"item_in_group" do |conf|
|
||||
end
|
||||
end
|
||||
2
back-office/app/helpers/item_in_groups_helper.rb
Normal file
2
back-office/app/helpers/item_in_groups_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module ItemInGroupsHelper
|
||||
end
|
||||
@@ -5,7 +5,7 @@ class Item < ActiveRecord::Base
|
||||
belongs_to :supplier
|
||||
belongs_to :brand
|
||||
belongs_to :delivery_time_estimation
|
||||
has_and_belongs_to_many :item_groups, :join_table => 'item_item_groups'
|
||||
|
||||
|
||||
validates_presence_of :name, :description, :list_price, :current_input_price, :tags, :unit_id, :code, :sub_category_id, :weight, :supplier_id
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class ItemGroup < ActiveRecord::Base
|
||||
has_and_belongs_to_many :items, :join_table => 'item_item_groups'
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
8
back-office/app/models/item_in_group.rb
Normal file
8
back-office/app/models/item_in_group.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
class ItemInGroup < ActiveRecord::Base
|
||||
belongs_to :item_group
|
||||
belongs_to :item
|
||||
|
||||
validates_presence_of :item_group_id
|
||||
validates_presence_of :item_id
|
||||
validates_presence_of :position
|
||||
end
|
||||
@@ -1,5 +1,6 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
resources :item_in_groups do as_routes end
|
||||
resources :item_groups do as_routes end
|
||||
resources :link_banners do as_routes end
|
||||
resources :delivery_time_estimations do as_routes end
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemInGroupsControllerTest < ActionController::TestCase
|
||||
setup do
|
||||
@item_in_group = item_in_groups(:one)
|
||||
end
|
||||
|
||||
test "should get index" do
|
||||
get :index
|
||||
assert_response :success
|
||||
assert_not_nil assigns(:item_in_groups)
|
||||
end
|
||||
|
||||
test "should get new" do
|
||||
get :new
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should create item_in_group" do
|
||||
assert_difference('ItemInGroup.count') do
|
||||
post :create, item_in_group: { item_group_id: @item_in_group.item_group_id, item_id: @item_in_group.item_id, position: @item_in_group.position }
|
||||
end
|
||||
|
||||
assert_redirected_to item_in_group_path(assigns(:item_in_group))
|
||||
end
|
||||
|
||||
test "should show item_in_group" do
|
||||
get :show, id: @item_in_group
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should get edit" do
|
||||
get :edit, id: @item_in_group
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "should update item_in_group" do
|
||||
patch :update, id: @item_in_group, item_in_group: { item_group_id: @item_in_group.item_group_id, item_id: @item_in_group.item_id, position: @item_in_group.position }
|
||||
assert_redirected_to item_in_group_path(assigns(:item_in_group))
|
||||
end
|
||||
|
||||
test "should destroy item_in_group" do
|
||||
assert_difference('ItemInGroup.count', -1) do
|
||||
delete :destroy, id: @item_in_group
|
||||
end
|
||||
|
||||
assert_redirected_to item_in_groups_path
|
||||
end
|
||||
end
|
||||
11
back-office/test/fixtures/item_in_groups.yml
vendored
Normal file
11
back-office/test/fixtures/item_in_groups.yml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
item_id: 1
|
||||
item_group_id: 1
|
||||
position: 1
|
||||
|
||||
two:
|
||||
item_id: 1
|
||||
item_group_id: 1
|
||||
position: 1
|
||||
7
back-office/test/models/item_in_group_test.rb
Normal file
7
back-office/test/models/item_in_group_test.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ItemInGroupTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user