Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion app/controllers/customers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCheckedOutCountToCustomer < ActiveRecord::Migration[5.1]
def change
add_column :customers, :movies_checked_out_count, :integer
end
end
3 changes: 2 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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|
Expand Down
5 changes: 3 additions & 2 deletions test/controllers/customers_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion test/controllers/movies_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 0 additions & 8 deletions test/models/customer_test.rb
Original file line number Diff line number Diff line change
@@ -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) }

Expand Down