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

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

@ -9,4 +9,4 @@
.row
.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
enable_extension "plpgsql"
create_table "agencies", force: true do |t|
create_table "agencies", force: :cascade do |t|
t.string "agency_name"
t.string "contact_name"
t.string "street_address"
@ -27,7 +27,7 @@ ActiveRecord::Schema.define(version: 20150918221119) do
t.string "email"
end
create_table "bikes", force: true do |t|
create_table "bikes", force: :cascade do |t|
t.string "entry_date"
t.string "brand"
t.string "model"
@ -49,7 +49,7 @@ ActiveRecord::Schema.define(version: 20150918221119) do
t.integer "bike_index_id"
end
create_table "clients", force: true do |t|
create_table "clients", force: :cascade do |t|
t.string "first_name"
t.string "last_name"
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", ["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 "encrypted_password", default: "", null: false
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", ["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 "email"
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
enable posting to bike index when a bike is created
Reports
General Reports
bikes donated per year
@ -17,16 +16,13 @@ style client receipts
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
there should be nice feedback indicating that the bike was sold
Improve form layouts
make navigation always on the left side of the page
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
add a request-a-feature feature
add pics of bikes for sale
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
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
it "creates a new bike with valid credentials" do
expect{
post :create, bike: FactoryGirl.attributes_for(:bike)
}.to change(Bike, :count).by(1)
end
it "redirects to new bike path" do
expect(post :create, bike: FactoryGirl.attributes_for(:bike)).to redirect_to(new_bike_path)
end
end
describe "GET #new" do
@ -25,4 +36,5 @@ describe BikesController do
end
end
end

Loading…
Cancel
Save