Browse Source

lk | moves notes, adds backup instructions, and shows asignees of bikes on bike page when they're present

master
Louis Knapp 7 years ago
parent
commit
fa2c2ede08
  1. 1
      app/controllers/bikes_controller.rb
  2. 6
      app/views/bikes/edit.html.haml
  3. 13
      docs/db_backups.md
  4. 3
      docs/notes.md
  5. 9
      spec/controllers/bikes_controller_spec.rb

1
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

6
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

13
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

3
notes.md → 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

9
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

Loading…
Cancel
Save