From 5c95ff835e05343b0d133e270caa20637b4200db Mon Sep 17 00:00:00 2001 From: Iuliia Chikulaeva Date: Tue, 7 Nov 2017 10:08:30 -0800 Subject: [PATCH 1/3] Remove comments --- .DS_Store | Bin 0 -> 6148 bytes app/models/movie.rb | 2 +- test/models/customer_test.rb | 8 -------- 3 files changed, 1 insertion(+), 9 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..c3ac046f6c51a2cd4bc2df32c603e493458c382e GIT binary patch literal 6148 zcmeH~F^{dt=u>Bl;zddfqZjB=JE!l7EiIwCR znHYd=e=Zwf1hAw#vGy=AV?N-4FWm9?zTD5J+wJN_+D8XGrH`2G=e8gPq<|EV0#ZN< z%t(Pe#+RQndL})J6p#Y*P{6+rh3>4$))}7;h8O|Jf#oo+W0oL`7s#4yovhF-rw7Yc zi!sFO(N31Ut|nV&Z-?dZVR>isDTZdf9afmotOgXMfE1W0u;}^d=l`Dm-~2ymQ7Q$b zz?&&x!|t%#@}=@@{quTWKW5d}jZVhp3{O7+O#CQb(Zjf3d_mS^>tuzdAAyiTK?=N7 FfnTX=61e~X literal 0 HcmV?d00001 diff --git a/app/models/movie.rb b/app/models/movie.rb index 074012735..866cedd89 100644 --- a/app/models/movie.rb +++ b/app/models/movie.rb @@ -1,3 +1,3 @@ class Movie < ApplicationRecord - # belongs_to :customer + belongs_to :customer end diff --git a/test/models/customer_test.rb b/test/models/customer_test.rb index e171f1324..dbe89b053 100644 --- a/test/models/customer_test.rb +++ b/test/models/customer_test.rb @@ -1,13 +1,5 @@ require "test_helper" -# validates :name, presence: true -# validates :registered_at, presence: true -# validates :address, presence: true -# validates :city, presence: true -# validates :state, presence: true -# validates :postal_code, presence: true -# validates :phone, presence: true - describe Customer do let(:customer) { customers(:one) } From 18c3df13397997b05978e54e91e080ea8bcd5ff5 Mon Sep 17 00:00:00 2001 From: Iuliia Chikulaeva Date: Tue, 7 Nov 2017 10:19:14 -0800 Subject: [PATCH 2/3] Add moveis count to customer --- .../20171107181635_add_checked_out_count_to_customer.rb | 5 +++++ db/schema.rb | 3 ++- test/controllers/customers_controller_test.rb | 3 ++- test/controllers/movies_controller_test.rb | 1 - 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20171107181635_add_checked_out_count_to_customer.rb diff --git a/db/migrate/20171107181635_add_checked_out_count_to_customer.rb b/db/migrate/20171107181635_add_checked_out_count_to_customer.rb new file mode 100644 index 000000000..4c9a7846c --- /dev/null +++ b/db/migrate/20171107181635_add_checked_out_count_to_customer.rb @@ -0,0 +1,5 @@ +class AddCheckedOutCountToCustomer < ActiveRecord::Migration[5.1] + def change + add_column :customers, :movies_checked_out_count, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 028a5f1b8..f88589461 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20171106215930) do +ActiveRecord::Schema.define(version: 20171107181635) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -26,6 +26,7 @@ t.datetime "created_at", null: false t.datetime "updated_at", null: false t.float "account_credit" + t.integer "movies_checked_out_count" end create_table "movies", force: :cascade do |t| diff --git a/test/controllers/customers_controller_test.rb b/test/controllers/customers_controller_test.rb index 2b5339a13..add671278 100644 --- a/test/controllers/customers_controller_test.rb +++ b/test/controllers/customers_controller_test.rb @@ -111,7 +111,8 @@ patch customer_path(customer.id), params: customer_data must_respond_with :success - # customer.name.must_equal customer_data[:name] + customer.reload + customer.name.must_equal customer_data[:name] end it "won't update customer information if data is missing" do diff --git a/test/controllers/movies_controller_test.rb b/test/controllers/movies_controller_test.rb index d3b21fb95..1ca0995cb 100644 --- a/test/controllers/movies_controller_test.rb +++ b/test/controllers/movies_controller_test.rb @@ -16,7 +16,6 @@ it "returns an array" do get movies_path - # This returns the body of all pets! body = JSON.parse(response.body) body.must_be_kind_of Array end From 3f49495431ebc0a129dec74e0b48085c963c2a9e Mon Sep 17 00:00:00 2001 From: Iuliia Chikulaeva Date: Tue, 7 Nov 2017 10:22:04 -0800 Subject: [PATCH 3/3] Fix test to match new column --- app/controllers/customers_controller.rb | 2 +- test/controllers/customers_controller_test.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/customers_controller.rb b/app/controllers/customers_controller.rb index cf493ce5e..76f311958 100644 --- a/app/controllers/customers_controller.rb +++ b/app/controllers/customers_controller.rb @@ -62,6 +62,6 @@ def update private def customer_params - params.permit(:name, :registered_at, :address, :city, :state, :postal_code, :phone, :account_credit) + params.permit(:name, :registered_at, :address, :city, :state, :postal_code, :phone, :account_credit, :movies_checked_out_count) end end diff --git a/test/controllers/customers_controller_test.rb b/test/controllers/customers_controller_test.rb index add671278..7440fb1e0 100644 --- a/test/controllers/customers_controller_test.rb +++ b/test/controllers/customers_controller_test.rb @@ -28,7 +28,7 @@ get customers_path body = JSON.parse(response.body) body.each do |customer| - customer.keys.sort.must_equal ["account_credit", "address", "city", "id", "name", "phone", "postal_code", "registered_at", "state"] + customer.keys.sort.must_equal ["account_credit", "address", "city", "id", "movies_checked_out_count", "name", "phone", "postal_code", "registered_at", "state"] end end