Skip to content

Commit

Permalink
Done with layout and routes tutorial.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpeoples committed Jan 30, 2011
1 parent 2e6c72b commit 83e5bb6
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 39 deletions.
1 change: 0 additions & 1 deletion app/controllers/categories_controller.rb
Expand Up @@ -3,7 +3,6 @@ class CategoriesController < ApplicationController
# GET /categories.xml
def index
@categories = Category.all(:order => "lft")

respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @categories }
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/products_controller.rb
@@ -1,11 +1,13 @@
class ProductsController < ApplicationController
def index
@title = "Products"
end

def show
end

def new
@title = "New Product"
end

def edit
Expand Down
16 changes: 2 additions & 14 deletions config/routes.rb
@@ -1,25 +1,13 @@
SalamanderServer::Application.routes.draw do

get "products/index"

get "products/show"

get "products/new"

get "products/edit"

get "products/create"

get "products/update"

get "products/destroy"

match '/contact', :to => 'pages#contact'
match '/about', :to => 'pages#about'
match '/help', :to => 'pages#help'

resources :categories

resources :products

root :to => "pages#home"

#get "home/index"
Expand Down
6 changes: 6 additions & 0 deletions old.autotest
@@ -0,0 +1,6 @@
#Autotest.add_hook :initialize do |autotest|
#autotest.add_mapping(%r%^spec/(requests)/.*rb$%) do |filename, _|
#filename
#end
#end

67 changes: 43 additions & 24 deletions spec/controllers/products_controller_spec.rb
@@ -1,54 +1,73 @@
require 'spec_helper'

describe ProductsController do
render_views

before(:each) do
@base_title = "Salamander Server | "
end

describe "GET 'index'" do
it "should be successful" do
get 'index'
response.should be_success
end
end

describe "GET 'show'" do
it "should be successful" do
get 'show'
response.should be_success
end
it "should have the right title" do
get 'index'
response.should have_selector("title",
:content => @base_title + "Products")
end

end

# describe "GET 'show'" do
# it "should be successful" do
# get 'show'
# response.should be_success
# end
# end

describe "GET 'new'" do
it "should be successful" do
get 'new'
response.should be_success
end
end

describe "GET 'edit'" do
it "should be successful" do
get 'edit'
response.should be_success
end
it "should have the right title" do
get 'new'
response.should have_selector("title",
:content => @base_title + "New Product")
end

end

# describe "GET 'edit'" do
# it "should be successful" do
# get 'edit'
# response.should be_success
# end
# end

describe "GET 'create'" do
it "should be successful" do
get 'create'
response.should be_success
end
end

describe "GET 'update'" do
it "should be successful" do
get 'update'
response.should be_success
end
end
# describe "GET 'update'" do
# it "should be successful" do
# get 'update'
# response.should be_success
# end
# end

describe "GET 'destroy'" do
it "should be successful" do
get 'destroy'
response.should be_success
end
end
# describe "GET 'destroy'" do
# it "should be successful" do
# get 'destroy'
# response.should be_success
# end
# end

end

0 comments on commit 83e5bb6

Please sign in to comment.