diff --git a/back-office/app/controllers/item_groups_controller.rb b/back-office/app/controllers/item_groups_controller.rb new file mode 100644 index 0000000..337376a --- /dev/null +++ b/back-office/app/controllers/item_groups_controller.rb @@ -0,0 +1,4 @@ +class ItemGroupsController < ApplicationController + active_scaffold :"item_group" do |conf| + end +end diff --git a/back-office/app/controllers/link_banners_controller.rb b/back-office/app/controllers/link_banners_controller.rb new file mode 100644 index 0000000..264ac3e --- /dev/null +++ b/back-office/app/controllers/link_banners_controller.rb @@ -0,0 +1,4 @@ +class LinkBannersController < ApplicationController + active_scaffold :"link_banner" do |conf| + end +end diff --git a/back-office/app/controllers/special_offers_controller.rb b/back-office/app/controllers/special_offers_controller.rb deleted file mode 100644 index 1f4d14f..0000000 --- a/back-office/app/controllers/special_offers_controller.rb +++ /dev/null @@ -1,4 +0,0 @@ -class SpecialOffersController < ApplicationController - active_scaffold :"special_offer" do |conf| - end -end diff --git a/back-office/app/helpers/item_groups_helper.rb b/back-office/app/helpers/item_groups_helper.rb new file mode 100644 index 0000000..cdf3914 --- /dev/null +++ b/back-office/app/helpers/item_groups_helper.rb @@ -0,0 +1,2 @@ +module ItemGroupsHelper +end \ No newline at end of file diff --git a/back-office/app/helpers/link_banners_helper.rb b/back-office/app/helpers/link_banners_helper.rb new file mode 100644 index 0000000..c9ca3c0 --- /dev/null +++ b/back-office/app/helpers/link_banners_helper.rb @@ -0,0 +1,2 @@ +module LinkBannersHelper +end \ No newline at end of file diff --git a/back-office/app/helpers/special_offers_helper.rb b/back-office/app/helpers/special_offers_helper.rb deleted file mode 100644 index 03257ac..0000000 --- a/back-office/app/helpers/special_offers_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module SpecialOffersHelper -end \ No newline at end of file diff --git a/back-office/app/models/item.rb b/back-office/app/models/item.rb index 004e94a..14649b1 100644 --- a/back-office/app/models/item.rb +++ b/back-office/app/models/item.rb @@ -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 diff --git a/back-office/app/models/item_group.rb b/back-office/app/models/item_group.rb new file mode 100644 index 0000000..1df6aa7 --- /dev/null +++ b/back-office/app/models/item_group.rb @@ -0,0 +1,4 @@ +class ItemGroup < ActiveRecord::Base + has_and_belongs_to_many :items, :join_table => 'item_item_groups' + +end diff --git a/back-office/app/models/special_offer.rb b/back-office/app/models/link_banner.rb similarity index 86% rename from back-office/app/models/special_offer.rb rename to back-office/app/models/link_banner.rb index 5f227a4..dc95b74 100644 --- a/back-office/app/models/special_offer.rb +++ b/back-office/app/models/link_banner.rb @@ -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 diff --git a/back-office/config/routes.rb b/back-office/config/routes.rb index 42e4898..75027dd 100644 --- a/back-office/config/routes.rb +++ b/back-office/config/routes.rb @@ -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 diff --git a/back-office/test/controllers/item_groups_controller_test.rb b/back-office/test/controllers/item_groups_controller_test.rb new file mode 100644 index 0000000..4204683 --- /dev/null +++ b/back-office/test/controllers/item_groups_controller_test.rb @@ -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 diff --git a/back-office/test/controllers/link_banners_controller_test.rb b/back-office/test/controllers/link_banners_controller_test.rb new file mode 100644 index 0000000..b0f8466 --- /dev/null +++ b/back-office/test/controllers/link_banners_controller_test.rb @@ -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 diff --git a/back-office/test/controllers/special_offers_controller_test.rb b/back-office/test/controllers/special_offers_controller_test.rb deleted file mode 100644 index aa94ad2..0000000 --- a/back-office/test/controllers/special_offers_controller_test.rb +++ /dev/null @@ -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 diff --git a/back-office/test/fixtures/item_groups.yml b/back-office/test/fixtures/item_groups.yml new file mode 100644 index 0000000..7cf5295 --- /dev/null +++ b/back-office/test/fixtures/item_groups.yml @@ -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 diff --git a/back-office/test/fixtures/special_offers.yml b/back-office/test/fixtures/link_banners.yml similarity index 70% rename from back-office/test/fixtures/special_offers.yml rename to back-office/test/fixtures/link_banners.yml index fbdb62a..5392feb 100644 --- a/back-office/test/fixtures/special_offers.yml +++ b/back-office/test/fixtures/link_banners.yml @@ -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 diff --git a/back-office/test/models/special_offer_test.rb b/back-office/test/models/item_group_test.rb similarity index 61% rename from back-office/test/models/special_offer_test.rb rename to back-office/test/models/item_group_test.rb index d0392e8..a622298 100644 --- a/back-office/test/models/special_offer_test.rb +++ b/back-office/test/models/item_group_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class SpecialOfferTest < ActiveSupport::TestCase +class ItemGroupTest < ActiveSupport::TestCase # test "the truth" do # assert true # end diff --git a/back-office/test/models/link_banner_test.rb b/back-office/test/models/link_banner_test.rb new file mode 100644 index 0000000..c10b3f8 --- /dev/null +++ b/back-office/test/models/link_banner_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class LinkBannerTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/front-api/db/migrate/20150322043737_create_link_banners.rb b/front-api/db/migrate/20150322043737_create_link_banners.rb new file mode 100644 index 0000000..fd741ea --- /dev/null +++ b/front-api/db/migrate/20150322043737_create_link_banners.rb @@ -0,0 +1,25 @@ +class CreateLinkBanners < ActiveRecord::Migration + def change + create_table :link_banners do |t| + t.string :image_url + t.boolean :start_page + t.integer :section_id + t.integer :category_id + t.integer :sub_category_id + t.integer :item_id + t.boolean :thank_you_page + t.boolean :search_result_page + t.boolean :checkout_page + t.date :beginning + t.date :ending + t.boolean :footer + t.boolean :header + t.string :link_url + + t.timestamps null: false + end + + drop_table :special_offers + + end +end diff --git a/front-api/db/migrate/20150322044941_create_item_groups.rb b/front-api/db/migrate/20150322044941_create_item_groups.rb new file mode 100644 index 0000000..62d70c1 --- /dev/null +++ b/front-api/db/migrate/20150322044941_create_item_groups.rb @@ -0,0 +1,13 @@ +class CreateItemGroups < ActiveRecord::Migration + def change + create_table :item_groups do |t| + t.string :name + t.text :description + t.boolean :visible + + t.timestamps null: false + end + end + + create_join_table :item, :item_groups +end diff --git a/front-api/db/schema.rb b/front-api/db/schema.rb index e0eac76..e7fa267 100644 --- a/front-api/db/schema.rb +++ b/front-api/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150321052740) do +ActiveRecord::Schema.define(version: 20150322044941) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -85,6 +85,14 @@ ActiveRecord::Schema.define(version: 20150321052740) do t.integer "filter_criteria_id" end + create_table "item_groups", force: :cascade do |t| + t.string "name" + t.text "description" + t.boolean "visible" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "item_in_carts", force: :cascade do |t| t.integer "cart_id" t.integer "item_id" @@ -94,6 +102,11 @@ ActiveRecord::Schema.define(version: 20150321052740) do t.decimal "price" end + create_table "item_item_groups", id: false, force: :cascade do |t| + t.integer "item_id", null: false + t.integer "item_group_id", null: false + end + create_table "items", force: :cascade do |t| t.string "name" t.string "code", limit: 10 @@ -114,6 +127,25 @@ ActiveRecord::Schema.define(version: 20150321052740) do t.integer "delivery_time_estimation_id" end + create_table "link_banners", force: :cascade do |t| + t.string "image_url" + t.boolean "start_page" + t.integer "section_id" + t.integer "category_id" + t.integer "sub_category_id" + t.integer "item_id" + t.boolean "thank_you_page" + t.boolean "search_result_page" + t.boolean "checkout_page" + t.date "beginning" + t.date "ending" + t.boolean "footer" + t.boolean "header" + t.string "link_url" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "media_types", force: :cascade do |t| t.string "name" end @@ -139,22 +171,6 @@ ActiveRecord::Schema.define(version: 20150321052740) do t.integer "order" end - create_table "special_offers", force: :cascade do |t| - t.string "image_url" - t.boolean "start_page" - t.integer "section_id" - t.integer "category_id" - t.integer "sub_category_id" - t.integer "item_id" - t.boolean "thank_you_page" - t.boolean "search_result_page" - t.boolean "checkout_page" - t.date "beginning" - t.date "ending" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - end - create_table "sub_categories", force: :cascade do |t| t.string "name" t.integer "category_id"