diff --git a/app/controllers/bikes_controller.rb b/app/controllers/bikes_controller.rb index c05bd91..338c0cd 100644 --- a/app/controllers/bikes_controller.rb +++ b/app/controllers/bikes_controller.rb @@ -16,6 +16,7 @@ class BikesController < ApplicationController def edit @next_bike = Bike.where(log_number: @bike.log_number + 1).first @previous_bike = Bike.where(log_number: @bike.log_number - 1).first + @client = @bike.client end def print_select diff --git a/app/views/bikes/edit.html.haml b/app/views/bikes/edit.html.haml index e748045..0f8eace 100644 --- a/app/views/bikes/edit.html.haml +++ b/app/views/bikes/edit.html.haml @@ -4,6 +4,12 @@ %h1 Edit bike .col-sm-3.col-sm-offset-3 =button_to "Mark as sold", {action: "mark_as_sold", id: @bike.id}, method: :patch, class: "btn btn-default", disabled: @bike.sold? + - if @client + .row + .col-sm-12 + %h4 + %span Assigned To + = link_to @client.name, edit_client_path(@client) = render 'edit_form' .bottom-nav-links - if @previous_bike diff --git a/docs/db_backups.md b/docs/db_backups.md new file mode 100644 index 0000000..050a6a6 --- /dev/null +++ b/docs/db_backups.md @@ -0,0 +1,13 @@ +To get the dump from a deployed environment: + +First, create a backup: + heroku pg:backups:capture --app [app name] + +Then, download the backup: + heroku pg:backups:download [backup id] --app [app name] + +Then, reset the local database: + rake db:drop db:create db:migrate + +Then, load the backup into the database: + pg_restore --verbose --clean --no-acl --no-owner -h localhost -U [username] -d [database name] latest.dump diff --git a/notes.md b/docs/notes.md similarity index 93% rename from notes.md rename to docs/notes.md index 961d4eb..c0630f3 100644 --- a/notes.md +++ b/docs/notes.md @@ -6,6 +6,9 @@ - reports are broken - bike receipts dont fit well - margins are too big and explanatory text too small +- flash message after a bike is logged should include the bike log + number +- unique index on log number for bikes - Use hyphens for dates instead of backslashes - Autopopulate fields like model, brand, color based on what exists in db diff --git a/spec/controllers/bikes_controller_spec.rb b/spec/controllers/bikes_controller_spec.rb index 160f3c7..529a472 100644 --- a/spec/controllers/bikes_controller_spec.rb +++ b/spec/controllers/bikes_controller_spec.rb @@ -54,6 +54,15 @@ describe BikesController do expect(assigns(:bike)).to eq(@current_bike) expect(assigns(:next_bike)).to eq(@next_bike) end + it "assigns a client if there is one" do + @client = create :client, bike: @current_bike + get :edit, id: @current_bike.id + expect(assigns(:client)).to eq(@client) + end + it "does not assign a client if there is none" do + get :edit, id: @current_bike.id + expect(assigns(:client)).to be_nil + end end describe "#update" do