Browse Source

lk | user can log multiple bikes in a row

master
Louis Knapp 9 years ago
parent
commit
f2badbd484
  1. 7
      app/controllers/bikes_controller.rb
  2. 2
      app/views/bikes/_form.html.haml
  3. 10
      db/schema.rb
  4. 10
      notes.txt
  5. 12
      spec/controllers/bikes_controller_spec.rb

7
app/controllers/bikes_controller.rb

@ -4,10 +4,7 @@ class BikesController < ApplicationController
def index def index
@bikes = Bike.all.order(:log_number).reverse_order.paginate(:page => params[:page], :per_page => 30) @bikes = Bike.all.order(:log_number).reverse_order.paginate(:page => params[:page], :per_page => 30)
@unsold_bikes = @bikes.select{ |bike| @unsold_bikes = @bikes.select{|bike| bike.date_sold.nil? && bike.purpose == "Sale"}
!bike.date_sold &&
(bike.purpose == "Sale")
}
end end
def show; end def show; end
@ -31,7 +28,7 @@ class BikesController < ApplicationController
def create def create
@bike = Bike.new(bike_params) @bike = Bike.new(bike_params)
if @bike.save if @bike.save
redirect_to @bike, notice: 'Bike was successfully created.' redirect_to new_bike_path, notice: 'Bike was successfully created.'
else else
render action: 'new' render action: 'new'
end end

2
app/views/bikes/_form.html.haml

@ -9,4 +9,4 @@
.row .row
.actions.col-sm-offset-2 .actions.col-sm-offset-2
= f.submit class: "btn btn-default" = f.submit value: "Log another bike", class: "btn btn-default"

10
db/schema.rb

@ -16,7 +16,7 @@ ActiveRecord::Schema.define(version: 20150918221119) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
create_table "agencies", force: true do |t| create_table "agencies", force: :cascade do |t|
t.string "agency_name" t.string "agency_name"
t.string "contact_name" t.string "contact_name"
t.string "street_address" t.string "street_address"
@ -27,7 +27,7 @@ ActiveRecord::Schema.define(version: 20150918221119) do
t.string "email" t.string "email"
end end
create_table "bikes", force: true do |t| create_table "bikes", force: :cascade do |t|
t.string "entry_date" t.string "entry_date"
t.string "brand" t.string "brand"
t.string "model" t.string "model"
@ -49,7 +49,7 @@ ActiveRecord::Schema.define(version: 20150918221119) do
t.integer "bike_index_id" t.integer "bike_index_id"
end end
create_table "clients", force: true do |t| create_table "clients", force: :cascade do |t|
t.string "first_name" t.string "first_name"
t.string "last_name" t.string "last_name"
t.date "application_date" t.date "application_date"
@ -75,7 +75,7 @@ ActiveRecord::Schema.define(version: 20150918221119) do
add_index "clients", ["agency_id"], name: "index_clients_on_agency_id", using: :btree add_index "clients", ["agency_id"], name: "index_clients_on_agency_id", using: :btree
add_index "clients", ["bike_id"], name: "index_clients_on_bike_id", using: :btree add_index "clients", ["bike_id"], name: "index_clients_on_bike_id", using: :btree
create_table "users", force: true do |t| create_table "users", force: :cascade do |t|
t.string "email", default: "", null: false t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false t.string "encrypted_password", default: "", null: false
t.string "reset_password_token" t.string "reset_password_token"
@ -93,7 +93,7 @@ ActiveRecord::Schema.define(version: 20150918221119) do
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
create_table "volunteers", force: true do |t| create_table "volunteers", force: :cascade do |t|
t.string "name" t.string "name"
t.string "email" t.string "email"
t.string "phone" t.string "phone"

10
notes.txt

@ -1,9 +1,8 @@
Integrate with autocomplete to get manufacturers & models integrate with autocomplete to get manufacturers & models
enable posting to bike index when a bike is created
Freecyclery Receipts Freecyclery Receipts
enable posting to bike index when a bike is created
Reports Reports
General Reports General Reports
bikes donated per year bikes donated per year
@ -17,16 +16,13 @@ style client receipts
assign a bike from the available freecyclery bikes page assign a bike from the available freecyclery bikes page
validations around parameters that break site if incomplete
mark as sold should be disabled after bike is sold mark as sold should be disabled after bike is sold
there should be nice feedback indicating that the bike was sold there should be nice feedback indicating that the bike was sold
Improve form layouts Improve form layouts
make navigation always on the left side of the page make navigation always on the left side of the page
Make customer facing bike index with pitchers Make customer facing bike index with pitchers
make skizzers marks on the labels page
Improve great dummy data
refactor index - move unsold bikes to model refactor index - move unsold bikes to model
add a request-a-feature feature
add pics of bikes for sale add pics of bikes for sale
add recyclery logos & bike memorabilia pics all over app add recyclery logos & bike memorabilia pics all over app

12
spec/controllers/bikes_controller_spec.rb

@ -9,12 +9,23 @@ describe BikesController do
sign_in user sign_in user
end end
describe "GET #index" do
it "assignes unsold bikes" do
bike = FactoryGirl.create(:bike, date_sold: nil, purpose: "Sale")
get :index
expect(assigns(:unsold_bikes)).to eq([bike])
end
end
describe "POST #create" do describe "POST #create" do
it "creates a new bike with valid credentials" do it "creates a new bike with valid credentials" do
expect{ expect{
post :create, bike: FactoryGirl.attributes_for(:bike) post :create, bike: FactoryGirl.attributes_for(:bike)
}.to change(Bike, :count).by(1) }.to change(Bike, :count).by(1)
end end
it "redirects to new bike path" do
expect(post :create, bike: FactoryGirl.attributes_for(:bike)).to redirect_to(new_bike_path)
end
end end
describe "GET #new" do describe "GET #new" do
@ -25,4 +36,5 @@ describe BikesController do
end end
end end
end end

Loading…
Cancel
Save