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")
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
||||
|
||||
FactoryGirl.define do
|
||||
factory :user do
|
||||
end
|
||||
end
|
||||
@@ -1,5 +1,4 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe Bike do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe User do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
@@ -0,0 +1,42 @@
|
||||
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
||||
ENV["RAILS_ENV"] ||= 'test'
|
||||
require File.expand_path("../../config/environment", __FILE__)
|
||||
require 'rspec/rails'
|
||||
require 'rspec/autorun'
|
||||
|
||||
# Requires supporting ruby files with custom matchers and macros, etc,
|
||||
# in spec/support/ and its subdirectories.
|
||||
Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
|
||||
|
||||
# Checks for pending migrations before tests are run.
|
||||
# If you are not using ActiveRecord, you can remove this line.
|
||||
ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
|
||||
|
||||
RSpec.configure do |config|
|
||||
# ## Mock Framework
|
||||
#
|
||||
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
||||
#
|
||||
# config.mock_with :mocha
|
||||
# config.mock_with :flexmock
|
||||
# config.mock_with :rr
|
||||
|
||||
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
||||
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
||||
|
||||
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
||||
# examples within a transaction, remove the following line or assign false
|
||||
# instead of true.
|
||||
config.use_transactional_fixtures = true
|
||||
|
||||
# If true, the base class of anonymous controllers will be inferred
|
||||
# automatically. This will be the default behavior in future versions of
|
||||
# rspec-rails.
|
||||
config.infer_base_class_for_anonymous_controllers = false
|
||||
|
||||
# Run specs in random order to surface order dependencies. If you find an
|
||||
# order dependency and want to debug it, you can fix the order by providing
|
||||
# the seed, which is printed after each run.
|
||||
# --seed 1234
|
||||
config.order = "random"
|
||||
end
|
||||
Reference in New Issue
Block a user