created item groups and link banners and their associations and fixed bugs with join tables

This commit is contained in:
Senad Uka
2015-03-22 06:17:05 +01:00
parent 38548e3e33
commit bbedb4a877
20 changed files with 219 additions and 81 deletions

View File

@@ -0,0 +1,4 @@
class ItemGroupsController < ApplicationController
active_scaffold :"item_group" do |conf|
end
end

View File

@@ -0,0 +1,4 @@
class LinkBannersController < ApplicationController
active_scaffold :"link_banner" do |conf|
end
end

View File

@@ -1,4 +0,0 @@
class SpecialOffersController < ApplicationController
active_scaffold :"special_offer" do |conf|
end
end

View File

@@ -0,0 +1,2 @@
module ItemGroupsHelper
end

View File

@@ -0,0 +1,2 @@
module LinkBannersHelper
end

View File

@@ -1,2 +0,0 @@
module SpecialOffersHelper
end

View File

@@ -3,7 +3,7 @@ class Item < ActiveRecord::Base
has_many :multi_media_descriptions
belongs_to :sub_category
belongs_to :supplier
belongs_to :special_offer
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

View File

@@ -0,0 +1,4 @@
class ItemGroup < ActiveRecord::Base
has_and_belongs_to_many :items, :join_table => 'item_item_groups'
end

View File

@@ -1,5 +1,5 @@
class SpecialOffer < ActiveRecord::Base
belongs_to :item
class LinkBanner < ActiveRecord::Base
belongs_to :category
belongs_to :section
belongs_to :sub_category

View File

@@ -1,7 +1,8 @@
Rails.application.routes.draw do
resources :item_groups do as_routes end
resources :link_banners do as_routes end
resources :delivery_time_estimations do as_routes end
resources :special_offers do as_routes end
resources :suppliers do as_routes end
resources :places do as_routes end
resources :delivery_destinations do as_routes end

View File

@@ -0,0 +1,49 @@
require 'test_helper'
class ItemGroupsControllerTest < ActionController::TestCase
setup do
@item_group = item_groups(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:item_groups)
end
test "should get new" do
get :new
assert_response :success
end
test "should create item_group" do
assert_difference('ItemGroup.count') do
post :create, item_group: { description: @item_group.description, name: @item_group.name, visible: @item_group.visible }
end
assert_redirected_to item_group_path(assigns(:item_group))
end
test "should show item_group" do
get :show, id: @item_group
assert_response :success
end
test "should get edit" do
get :edit, id: @item_group
assert_response :success
end
test "should update item_group" do
patch :update, id: @item_group, item_group: { description: @item_group.description, name: @item_group.name, visible: @item_group.visible }
assert_redirected_to item_group_path(assigns(:item_group))
end
test "should destroy item_group" do
assert_difference('ItemGroup.count', -1) do
delete :destroy, id: @item_group
end
assert_redirected_to item_groups_path
end
end

View File

@@ -0,0 +1,49 @@
require 'test_helper'
class LinkBannersControllerTest < ActionController::TestCase
setup do
@link_banner = link_banners(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:link_banners)
end
test "should get new" do
get :new
assert_response :success
end
test "should create link_banner" do
assert_difference('LinkBanner.count') do
post :create, link_banner: { beginning: @link_banner.beginning, category_id: @link_banner.category_id, checkout_page: @link_banner.checkout_page, ending: @link_banner.ending, footer: @link_banner.footer, header: @link_banner.header, image_url: @link_banner.image_url, item_id: @link_banner.item_id, link_url: @link_banner.link_url, search_result_page: @link_banner.search_result_page, section_id: @link_banner.section_id, start_page: @link_banner.start_page, sub_category_id: @link_banner.sub_category_id, thank_you_page: @link_banner.thank_you_page }
end
assert_redirected_to link_banner_path(assigns(:link_banner))
end
test "should show link_banner" do
get :show, id: @link_banner
assert_response :success
end
test "should get edit" do
get :edit, id: @link_banner
assert_response :success
end
test "should update link_banner" do
patch :update, id: @link_banner, link_banner: { beginning: @link_banner.beginning, category_id: @link_banner.category_id, checkout_page: @link_banner.checkout_page, ending: @link_banner.ending, footer: @link_banner.footer, header: @link_banner.header, image_url: @link_banner.image_url, item_id: @link_banner.item_id, link_url: @link_banner.link_url, search_result_page: @link_banner.search_result_page, section_id: @link_banner.section_id, start_page: @link_banner.start_page, sub_category_id: @link_banner.sub_category_id, thank_you_page: @link_banner.thank_you_page }
assert_redirected_to link_banner_path(assigns(:link_banner))
end
test "should destroy link_banner" do
assert_difference('LinkBanner.count', -1) do
delete :destroy, id: @link_banner
end
assert_redirected_to link_banners_path
end
end

View File

@@ -1,49 +0,0 @@
require 'test_helper'
class SpecialOffersControllerTest < ActionController::TestCase
setup do
@special_offer = special_offers(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:special_offers)
end
test "should get new" do
get :new
assert_response :success
end
test "should create special_offer" do
assert_difference('SpecialOffer.count') do
post :create, special_offer: { beginning: @special_offer.beginning, category_id: @special_offer.category_id, checkout_page: @special_offer.checkout_page, ending: @special_offer.ending, image_url: @special_offer.image_url, item_id: @special_offer.item_id, search_result_page: @special_offer.search_result_page, section_id: @special_offer.section_id, start_page: @special_offer.start_page, sub_category_id: @special_offer.sub_category_id, thank_you_page: @special_offer.thank_you_page }
end
assert_redirected_to special_offer_path(assigns(:special_offer))
end
test "should show special_offer" do
get :show, id: @special_offer
assert_response :success
end
test "should get edit" do
get :edit, id: @special_offer
assert_response :success
end
test "should update special_offer" do
patch :update, id: @special_offer, special_offer: { beginning: @special_offer.beginning, category_id: @special_offer.category_id, checkout_page: @special_offer.checkout_page, ending: @special_offer.ending, image_url: @special_offer.image_url, item_id: @special_offer.item_id, search_result_page: @special_offer.search_result_page, section_id: @special_offer.section_id, start_page: @special_offer.start_page, sub_category_id: @special_offer.sub_category_id, thank_you_page: @special_offer.thank_you_page }
assert_redirected_to special_offer_path(assigns(:special_offer))
end
test "should destroy special_offer" do
assert_difference('SpecialOffer.count', -1) do
delete :destroy, id: @special_offer
end
assert_redirected_to special_offers_path
end
end

View File

@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
one:
name: MyString
description: MyText
visible: false
two:
name: MyString
description: MyText
visible: false

View File

@@ -10,8 +10,11 @@ one:
thank_you_page: false
search_result_page: false
checkout_page: false
beginning: 2015-03-18
ending: 2015-03-18
beginning: 2015-03-22
ending: 2015-03-22
footer: false
header: false
link_url: MyString
two:
image_url: MyString
@@ -23,5 +26,8 @@ two:
thank_you_page: false
search_result_page: false
checkout_page: false
beginning: 2015-03-18
ending: 2015-03-18
beginning: 2015-03-22
ending: 2015-03-22
footer: false
header: false
link_url: MyString

View File

@@ -1,6 +1,6 @@
require 'test_helper'
class SpecialOfferTest < ActiveSupport::TestCase
class ItemGroupTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end

View File

@@ -0,0 +1,7 @@
require 'test_helper'
class LinkBannerTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end