Modifying the mash tournament schema a touch and adding a slew of scaffold-y stuff

This commit is contained in:
Dan Buch
2012-03-09 08:11:54 -05:00
parent d4dda1e9d8
commit 1fa4ffbe65
19 changed files with 399 additions and 245 deletions

View File

@@ -0,0 +1,131 @@
require 'spec_helper'
describe MashTournamentsController do
def mock_mash_tournament(stubs={})
@mock_mash_tournament ||= mock_model(MashTournament, stubs)
end
describe "GET index" do
it "assigns all mash_tournaments as @mash_tournaments" do
MashTournament.stub(:find).with(:all).and_return([mock_mash_tournament])
get :index
assigns[:mash_tournaments].should == [mock_mash_tournament]
end
end
describe "GET show" do
it "assigns the requested mash_tournament as @mash_tournament" do
MashTournament.stub(:find).with("37").and_return(mock_mash_tournament)
get :show, :id => "37"
assigns[:mash_tournament].should equal(mock_mash_tournament)
end
end
describe "GET new" do
it "assigns a new mash_tournament as @mash_tournament" do
MashTournament.stub(:new).and_return(mock_mash_tournament)
get :new
assigns[:mash_tournament].should equal(mock_mash_tournament)
end
end
describe "GET edit" do
it "assigns the requested mash_tournament as @mash_tournament" do
MashTournament.stub(:find).with("37").and_return(mock_mash_tournament)
get :edit, :id => "37"
assigns[:mash_tournament].should equal(mock_mash_tournament)
end
end
describe "POST create" do
describe "with valid params" do
it "assigns a newly created mash_tournament as @mash_tournament" do
MashTournament.stub(:new).with({'these' => 'params'}).and_return(mock_mash_tournament(:save => true))
post :create, :mash_tournament => {:these => 'params'}
assigns[:mash_tournament].should equal(mock_mash_tournament)
end
it "redirects to the created mash_tournament" do
MashTournament.stub(:new).and_return(mock_mash_tournament(:save => true))
post :create, :mash_tournament => {}
response.should redirect_to(mash_tournament_url(mock_mash_tournament))
end
end
describe "with invalid params" do
it "assigns a newly created but unsaved mash_tournament as @mash_tournament" do
MashTournament.stub(:new).with({'these' => 'params'}).and_return(mock_mash_tournament(:save => false))
post :create, :mash_tournament => {:these => 'params'}
assigns[:mash_tournament].should equal(mock_mash_tournament)
end
it "re-renders the 'new' template" do
MashTournament.stub(:new).and_return(mock_mash_tournament(:save => false))
post :create, :mash_tournament => {}
response.should render_template('new')
end
end
end
describe "PUT update" do
describe "with valid params" do
it "updates the requested mash_tournament" do
MashTournament.should_receive(:find).with("37").and_return(mock_mash_tournament)
mock_mash_tournament.should_receive(:update_attributes).with({'these' => 'params'})
put :update, :id => "37", :mash_tournament => {:these => 'params'}
end
it "assigns the requested mash_tournament as @mash_tournament" do
MashTournament.stub(:find).and_return(mock_mash_tournament(:update_attributes => true))
put :update, :id => "1"
assigns[:mash_tournament].should equal(mock_mash_tournament)
end
it "redirects to the mash_tournament" do
MashTournament.stub(:find).and_return(mock_mash_tournament(:update_attributes => true))
put :update, :id => "1"
response.should redirect_to(mash_tournament_url(mock_mash_tournament))
end
end
describe "with invalid params" do
it "updates the requested mash_tournament" do
MashTournament.should_receive(:find).with("37").and_return(mock_mash_tournament)
mock_mash_tournament.should_receive(:update_attributes).with({'these' => 'params'})
put :update, :id => "37", :mash_tournament => {:these => 'params'}
end
it "assigns the mash_tournament as @mash_tournament" do
MashTournament.stub(:find).and_return(mock_mash_tournament(:update_attributes => false))
put :update, :id => "1"
assigns[:mash_tournament].should equal(mock_mash_tournament)
end
it "re-renders the 'edit' template" do
MashTournament.stub(:find).and_return(mock_mash_tournament(:update_attributes => false))
put :update, :id => "1"
response.should render_template('edit')
end
end
end
describe "DELETE destroy" do
it "destroys the requested mash_tournament" do
MashTournament.should_receive(:find).with("37").and_return(mock_mash_tournament)
mock_mash_tournament.should_receive(:destroy)
delete :destroy, :id => "37"
end
it "redirects to the mash_tournaments list" do
MashTournament.stub(:find).and_return(mock_mash_tournament(:destroy => true))
delete :destroy, :id => "1"
response.should redirect_to(mash_tournaments_url)
end
end
end

View File

@@ -0,0 +1,11 @@
require 'spec_helper'
describe MashTournamentsHelper do
#Delete this example and add some real ones or delete this file
it "is included in the helper object" do
included_modules = (class << helper; self; end).send :included_modules
included_modules.should include(MashTournamentsHelper)
end
end

View File

@@ -0,0 +1,4 @@
require 'spec_helper'
describe "MashTournaments" do
end

View File

@@ -0,0 +1,33 @@
require 'spec_helper'
describe MashTournamentsController do
describe "routing" do
it "recognizes and generates #index" do
{ :get => "/mash_tournaments" }.should route_to(:controller => "mash_tournaments", :action => "index")
end
it "recognizes and generates #new" do
{ :get => "/mash_tournaments/new" }.should route_to(:controller => "mash_tournaments", :action => "new")
end
it "recognizes and generates #show" do
{ :get => "/mash_tournaments/1" }.should route_to(:controller => "mash_tournaments", :action => "show", :id => "1")
end
it "recognizes and generates #edit" do
{ :get => "/mash_tournaments/1/edit" }.should route_to(:controller => "mash_tournaments", :action => "edit", :id => "1")
end
it "recognizes and generates #create" do
{ :post => "/mash_tournaments" }.should route_to(:controller => "mash_tournaments", :action => "create")
end
it "recognizes and generates #update" do
{ :put => "/mash_tournaments/1" }.should route_to(:controller => "mash_tournaments", :action => "update", :id => "1")
end
it "recognizes and generates #destroy" do
{ :delete => "/mash_tournaments/1" }.should route_to(:controller => "mash_tournaments", :action => "destroy", :id => "1")
end
end
end

View File

@@ -0,0 +1,18 @@
require 'spec_helper'
describe "/mash_tournaments/edit.html.erb" do
include MashTournamentsHelper
before(:each) do
assigns[:mash_tournament] = @mash_tournament = stub_model(MashTournament,
:new_record? => false
)
end
it "renders the edit mash_tournament form" do
render
response.should have_tag("form[action=#{mash_tournament_path(@mash_tournament)}][method=post]") do
end
end
end

View File

@@ -0,0 +1,16 @@
require 'spec_helper'
describe "/mash_tournaments/index.html.erb" do
include MashTournamentsHelper
before(:each) do
assigns[:mash_tournaments] = [
stub_model(MashTournament),
stub_model(MashTournament)
]
end
it "renders a list of mash_tournaments" do
render
end
end

View File

@@ -0,0 +1,18 @@
require 'spec_helper'
describe "/mash_tournaments/new.html.erb" do
include MashTournamentsHelper
before(:each) do
assigns[:mash_tournament] = stub_model(MashTournament,
:new_record? => true
)
end
it "renders new mash_tournament form" do
render
response.should have_tag("form[action=?][method=post]", mash_tournaments_path) do
end
end
end

View File

@@ -0,0 +1,12 @@
require 'spec_helper'
describe "/mash_tournaments/show.html.erb" do
include MashTournamentsHelper
before(:each) do
assigns[:mash_tournament] = @mash_tournament = stub_model(MashTournament)
end
it "renders attributes in <p>" do
render
end
end