mirror of
https://github.com/fspc/bike-database.git
synced 2025-02-23 09:33:23 -05:00
lk | user can log multiple bikes in a row
This commit is contained in:
parent
db0945ce81
commit
f2badbd484
@ -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
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
= form_for @bike, html: {class: 'form-horizontal'} do |f|
|
= form_for @bike, html: {class: 'form-horizontal'} do |f|
|
||||||
- if @bike.errors.any?
|
- if @bike.errors.any?
|
||||||
#error_explanation
|
#error_explanation
|
||||||
%h2= pluralize(@bike.errors.count, "error") + " prohibited this bike from being saved:"
|
%h2= pluralize(@bike.errors.count, "error") + " prohibited this bike from being saved:"
|
||||||
%ul
|
%ul
|
||||||
- @bike.errors.full_messages.each do |msg|
|
- @bike.errors.full_messages.each do |msg|
|
||||||
%li= msg
|
%li= msg
|
||||||
= render 'fields', f: f
|
= render 'fields', f: f
|
||||||
|
|
||||||
.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
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
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
|
||||||
|
@ -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…
x
Reference in New Issue
Block a user