diff --git a/.DS_Store b/.DS_Store index ca5d0e6e7..c3ac046f6 100644 Binary files a/.DS_Store and b/.DS_Store differ 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/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..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 @@ -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 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) }