Skip to content
Browse files

Done with layout and routes tutorial.

  • Loading branch information...
1 parent 2e6c72b commit 83e5bb6c3500d6b0c88b605a53ae32e6ef8dbcdf @davidpeoples committed Jan 30, 2011
View
1 app/controllers/categories_controller.rb
@@ -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 }
View
2 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
View
16 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"
View
6 old.autotest
@@ -0,0 +1,6 @@
+#Autotest.add_hook :initialize do |autotest|
+ #autotest.add_mapping(%r%^spec/(requests)/.*rb$%) do |filename, _|
+ #filename
+ #end
+#end
+
View
67 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.
Something went wrong with that request. Please try again.