lk | adds links to previous and next bikes on bike edit page and removes

bike#show route
This commit is contained in:
Louis Knapp
2016-07-24 07:53:54 -05:00
parent a517eefd73
commit 692f12d47d
5 changed files with 45 additions and 24 deletions
+27 -10
View File
@@ -2,40 +2,57 @@ require 'spec_helper'
describe BikesController do
let(:user){FactoryGirl.create(:user)}
let(:bike){FactoryGirl.create(:bike)}
let(:user){ create :user }
let(:bike){ create :bike }
before :each do
sign_in user
end
describe "GET #index" do
describe "#index" do
it "assignes unsold bikes" do
bike = FactoryGirl.create(:bike, date_sold: nil, purpose: "Sale")
bike = create :bike, date_sold: nil, purpose: "Sale"
get :index
expect(assigns(:unsold_bikes)).to eq([bike])
end
end
describe "POST #create" do
describe "#create" do
it "creates a new bike with valid credentials" do
expect{
post :create, bike: FactoryGirl.attributes_for(:bike)
post :create, bike: 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)
expect(post :create, bike: attributes_for(:bike)).to redirect_to(new_bike_path)
end
end
describe "GET #new" do
describe "#new" do
it "assigns a log number" do
FactoryGirl.create(:bike, log_number: 3)
create :bike, log_number: 3
get :new
expect(assigns(:log_number)).to eq(4)
end
it "assigns the previous bike" do
previous_bike = create :bike, log_number: 3
get :new
expect(assigns(:previous_bike)).to eq(previous_bike)
end
end
describe "#edit" do
before do
@previous_bike = create :bike, log_number: 2
@current_bike = create :bike, log_number: 3
@next_bike = create :bike, log_number: 4
end
it "assigns the current, previous, and next bikes" do
get :edit, id: @current_bike.id
expect(assigns(:previous_bike)).to eq(@previous_bike)
expect(assigns(:bike)).to eq(@current_bike)
expect(assigns(:next_bike)).to eq(@next_bike)
end
end
end