From 53fc9f0b994323ea459bc80469c4d56651c8ff91 Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Fri, 20 Feb 2015 07:33:26 +0100 Subject: [PATCH] created delivery destination model --- .../delivery_destinations_controller.rb | 4 ++ .../helpers/delivery_destinations_helper.rb | 2 + .../app/models/delivery_destination.rb | 2 + back-office/config/routes.rb | 1 + .../delivery_destinations_controller_test.rb | 49 +++++++++++++++++++ .../test/fixtures/delivery_destinations.yml | 19 +++++++ .../test/models/delivery_destination_test.rb | 7 +++ ...0220062314_create_delivery_destinations.rb | 19 +++++++ front-api/db/schema.rb | 19 ++++++- front-ui/app/components/cart/checkoutPage.js | 4 +- 10 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 back-office/app/controllers/delivery_destinations_controller.rb create mode 100644 back-office/app/helpers/delivery_destinations_helper.rb create mode 100644 back-office/app/models/delivery_destination.rb create mode 100644 back-office/test/controllers/delivery_destinations_controller_test.rb create mode 100644 back-office/test/fixtures/delivery_destinations.yml create mode 100644 back-office/test/models/delivery_destination_test.rb create mode 100644 front-api/db/migrate/20150220062314_create_delivery_destinations.rb diff --git a/back-office/app/controllers/delivery_destinations_controller.rb b/back-office/app/controllers/delivery_destinations_controller.rb new file mode 100644 index 0000000..0973ead --- /dev/null +++ b/back-office/app/controllers/delivery_destinations_controller.rb @@ -0,0 +1,4 @@ +class DeliveryDestinationsController < ApplicationController + active_scaffold :"delivery_destination" do |conf| + end +end diff --git a/back-office/app/helpers/delivery_destinations_helper.rb b/back-office/app/helpers/delivery_destinations_helper.rb new file mode 100644 index 0000000..b8f78e1 --- /dev/null +++ b/back-office/app/helpers/delivery_destinations_helper.rb @@ -0,0 +1,2 @@ +module DeliveryDestinationsHelper +end \ No newline at end of file diff --git a/back-office/app/models/delivery_destination.rb b/back-office/app/models/delivery_destination.rb new file mode 100644 index 0000000..01ebde4 --- /dev/null +++ b/back-office/app/models/delivery_destination.rb @@ -0,0 +1,2 @@ +class DeliveryDestination < ActiveRecord::Base +end diff --git a/back-office/config/routes.rb b/back-office/config/routes.rb index 361a159..e8d76e3 100644 --- a/back-office/config/routes.rb +++ b/back-office/config/routes.rb @@ -1,5 +1,6 @@ Rails.application.routes.draw do + resources :delivery_destinations do as_routes end mount RailsAdmin::Engine => '/admin', as: 'rails_admin' resources :filter_criteria_values do as_routes end resources :filter_criteria do as_routes end diff --git a/back-office/test/controllers/delivery_destinations_controller_test.rb b/back-office/test/controllers/delivery_destinations_controller_test.rb new file mode 100644 index 0000000..853776f --- /dev/null +++ b/back-office/test/controllers/delivery_destinations_controller_test.rb @@ -0,0 +1,49 @@ +require 'test_helper' + +class DeliveryDestinationsControllerTest < ActionController::TestCase + setup do + @delivery_destination = delivery_destinations(:one) + end + + test "should get index" do + get :index + assert_response :success + assert_not_nil assigns(:delivery_destinations) + end + + test "should get new" do + get :new + assert_response :success + end + + test "should create delivery_destination" do + assert_difference('DeliveryDestination.count') do + post :create, delivery_destination: { address: @delivery_destination.address, email: @delivery_destination.email, name: @delivery_destination.name, note: @delivery_destination.note, phone: @delivery_destination.phone, place: @delivery_destination.place, postal_code: @delivery_destination.postal_code } + end + + assert_redirected_to delivery_destination_path(assigns(:delivery_destination)) + end + + test "should show delivery_destination" do + get :show, id: @delivery_destination + assert_response :success + end + + test "should get edit" do + get :edit, id: @delivery_destination + assert_response :success + end + + test "should update delivery_destination" do + patch :update, id: @delivery_destination, delivery_destination: { address: @delivery_destination.address, email: @delivery_destination.email, name: @delivery_destination.name, note: @delivery_destination.note, phone: @delivery_destination.phone, place: @delivery_destination.place, postal_code: @delivery_destination.postal_code } + assert_redirected_to delivery_destination_path(assigns(:delivery_destination)) + end + + test "should destroy delivery_destination" do + assert_difference('DeliveryDestination.count', -1) do + delete :destroy, id: @delivery_destination + end + + assert_redirected_to delivery_destinations_path + end +end diff --git a/back-office/test/fixtures/delivery_destinations.yml b/back-office/test/fixtures/delivery_destinations.yml new file mode 100644 index 0000000..97c69d2 --- /dev/null +++ b/back-office/test/fixtures/delivery_destinations.yml @@ -0,0 +1,19 @@ +# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html + +one: + name: MyString + address: MyString + place: MyString + postal_code: MyString + phone: MyString + email: MyString + note: MyText + +two: + name: MyString + address: MyString + place: MyString + postal_code: MyString + phone: MyString + email: MyString + note: MyText diff --git a/back-office/test/models/delivery_destination_test.rb b/back-office/test/models/delivery_destination_test.rb new file mode 100644 index 0000000..a3daff7 --- /dev/null +++ b/back-office/test/models/delivery_destination_test.rb @@ -0,0 +1,7 @@ +require 'test_helper' + +class DeliveryDestinationTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/front-api/db/migrate/20150220062314_create_delivery_destinations.rb b/front-api/db/migrate/20150220062314_create_delivery_destinations.rb new file mode 100644 index 0000000..6f6b533 --- /dev/null +++ b/front-api/db/migrate/20150220062314_create_delivery_destinations.rb @@ -0,0 +1,19 @@ +class CreateDeliveryDestinations < ActiveRecord::Migration + def change + create_table :delivery_destinations do |t| + t.string :name + t.string :address + t.string :place + t.string :postal_code + t.string :phone + t.string :email + t.text :note + t.boolean :email_verified + t.boolean :phone_verified + t.string :phone_verification_code + t.string :email_verification_code + + t.timestamps null: false + end + end +end diff --git a/front-api/db/schema.rb b/front-api/db/schema.rb index e839303..29c6457 100644 --- a/front-api/db/schema.rb +++ b/front-api/db/schema.rb @@ -11,7 +11,8 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20150218053655) do +ActiveRecord::Schema.define(version: 20150220062314) do + # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -30,6 +31,22 @@ ActiveRecord::Schema.define(version: 20150218053655) do t.string "image_url" end + create_table "delivery_destinations", force: :cascade do |t| + t.string "name" + t.string "address" + t.string "place" + t.string "postal_code" + t.string "phone" + t.string "email" + t.text "note" + t.boolean "email_verified" + t.boolean "phone_verified" + t.string "phone_verification_code" + t.string "email_verification_code" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "filter_criteria", force: :cascade do |t| t.string "title" t.string "field_name" diff --git a/front-ui/app/components/cart/checkoutPage.js b/front-ui/app/components/cart/checkoutPage.js index ededa18..6d08232 100644 --- a/front-ui/app/components/cart/checkoutPage.js +++ b/front-ui/app/components/cart/checkoutPage.js @@ -66,7 +66,7 @@ var CheckoutPage = React.createClass({

broj mobitela - mora biti sa jedne od mreža u BiH

- + @@ -83,7 +83,7 @@ var CheckoutPage = React.createClass({
-
+