mirror of
https://github.com/fspc/bike-database.git
synced 2026-09-16 08:31:39 -04:00
lk - add devise for session management; user must log in to update bikes & volunteers
This commit is contained in:
@@ -1,35 +1,6 @@
|
||||
require 'spec_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
describe BikesController do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Bike. As you add validations to Bike, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) { { } }
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# BikesController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET index" do
|
||||
it "assigns all bikes as @bikes" do
|
||||
bike = Bike.create! valid_attributes
|
||||
@@ -83,14 +54,12 @@ describe BikesController do
|
||||
|
||||
describe "with invalid params" do
|
||||
it "assigns a newly created but unsaved bike as @bike" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Bike.any_instance.stub(:save).and_return(false)
|
||||
post :create, {:bike => { }}, valid_session
|
||||
assigns(:bike).should be_a_new(Bike)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Bike.any_instance.stub(:save).and_return(false)
|
||||
post :create, {:bike => { }}, valid_session
|
||||
response.should render_template("new")
|
||||
@@ -102,10 +71,6 @@ describe BikesController do
|
||||
describe "with valid params" do
|
||||
it "updates the requested bike" do
|
||||
bike = Bike.create! valid_attributes
|
||||
# Assuming there are no other bikes in the database, this
|
||||
# specifies that the Bike created on the previous line
|
||||
# receives the :update_attributes message with whatever params are
|
||||
# submitted in the request.
|
||||
Bike.any_instance.should_receive(:update).with({ "these" => "params" })
|
||||
put :update, {:id => bike.to_param, :bike => { "these" => "params" }}, valid_session
|
||||
end
|
||||
@@ -126,7 +91,6 @@ describe BikesController do
|
||||
describe "with invalid params" do
|
||||
it "assigns the bike as @bike" do
|
||||
bike = Bike.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Bike.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => bike.to_param, :bike => { }}, valid_session
|
||||
assigns(:bike).should eq(bike)
|
||||
@@ -134,7 +98,6 @@ describe BikesController do
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
bike = Bike.create! valid_attributes
|
||||
# Trigger the behavior that occurs when invalid params are submitted
|
||||
Bike.any_instance.stub(:save).and_return(false)
|
||||
put :update, {:id => bike.to_param, :bike => { }}, valid_session
|
||||
response.should render_template("edit")
|
||||
|
||||
Reference in New Issue
Block a user