Skip to content

Commit

Permalink
commented out unneeded categories controller + test
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Ellis committed Jul 29, 2011
1 parent 23733a0 commit e0df724
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 126 deletions.
164 changes: 83 additions & 81 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,83 +1,85 @@
class CategoriesController < ApplicationController
# GET /categories
# GET /categories.xml
def index
@categories = Category.all

respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @categories }
end
end

# GET /categories/1
# GET /categories/1.xml
def show
@category = Category.find(params[:id])

respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @category }
end
end

# GET /categories/new
# GET /categories/new.xml
def new
@category = Category.new

respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @category }
end
end

# GET /categories/1/edit
def edit
@category = Category.find(params[:id])
end

# POST /categories
# POST /categories.xml
def create
@category = Category.new(params[:category])

respond_to do |format|
if @category.save
format.html { redirect_to(@category, :notice => 'Category was successfully created.') }
format.xml { render :xml => @category, :status => :created, :location => @category }
else
format.html { render :action => "new" }
format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
end
end
end

# PUT /categories/1
# PUT /categories/1.xml
def update
@category = Category.find(params[:id])

respond_to do |format|
if @category.update_attributes(params[:category])
format.html { redirect_to(@category, :notice => 'Category was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
end
end
end

# DELETE /categories/1
# DELETE /categories/1.xml
def destroy
@category = Category.find(params[:id])
@category.destroy

respond_to do |format|
format.html { redirect_to(categories_url) }
format.xml { head :ok }
end
end
# TODO delete this controller if no longer used - 2011-07-28 - Joe Ellis

# # GET /categories
# # GET /categories.xml
# def index
# @categories = Category.all
#
# respond_to do |format|
# format.html # index.html.erb
# format.xml { render :xml => @categories }
# end
# end
#
# # GET /categories/1
# # GET /categories/1.xml
# def show
# @category = Category.find(params[:id])
#
# respond_to do |format|
# format.html # show.html.erb
# format.xml { render :xml => @category }
# end
# end
#
# # GET /categories/new
# # GET /categories/new.xml
# def new
# @category = Category.new
#
# respond_to do |format|
# format.html # new.html.erb
# format.xml { render :xml => @category }
# end
# end
#
# # GET /categories/1/edit
# def edit
# @category = Category.find(params[:id])
# end
#
# # POST /categories
# # POST /categories.xml
# def create
# @category = Category.new(params[:category])
#
# respond_to do |format|
# if @category.save
# format.html { redirect_to(@category, :notice => 'Category was successfully created.') }
# format.xml { render :xml => @category, :status => :created, :location => @category }
# else
# format.html { render :action => "new" }
# format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # PUT /categories/1
# # PUT /categories/1.xml
# def update
# @category = Category.find(params[:id])
#
# respond_to do |format|
# if @category.update_attributes(params[:category])
# format.html { redirect_to(@category, :notice => 'Category was successfully updated.') }
# format.xml { head :ok }
# else
# format.html { render :action => "edit" }
# format.xml { render :xml => @category.errors, :status => :unprocessable_entity }
# end
# end
# end
#
# # DELETE /categories/1
# # DELETE /categories/1.xml
# def destroy
# @category = Category.find(params[:id])
# @category.destroy
#
# respond_to do |format|
# format.html { redirect_to(categories_url) }
# format.xml { head :ok }
# end
# end
end
90 changes: 45 additions & 45 deletions test/functional/categories_controller_test.rb
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
require 'test_helper'

class CategoriesControllerTest < ActionController::TestCase
setup do
@category = categories(:create)
end

test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:categories)
end

test "should get new" do
get :new
assert_response :success
end

test "should create category" do
assert_difference('Category.count') do
post :create, :category => {:name => 'New Category'}
end

assert_redirected_to category_path(assigns(:category))
end

test "should show category" do
get :show, :id => @category.to_param
assert_response :success
end

test "should get edit" do
get :edit, :id => @category.to_param
assert_response :success
end

test "should update category" do
put :update, :id => @category.to_param, :category => @category.attributes
assert_redirected_to category_path(assigns(:category))
end

test "should destroy category" do
assert_difference('Category.count', -1) do
delete :destroy, :id => @category.to_param
end

assert_redirected_to categories_path
end
# setup do
# @category = categories(:create)
# end
#
# test "should get index" do
# get :index
# assert_response :success
# assert_not_nil assigns(:categories)
# end
#
# test "should get new" do
# get :new
# assert_response :success
# end
#
# test "should create category" do
# assert_difference('Category.count') do
# post :create, :category => {:name => 'New Category'}
# end
#
# assert_redirected_to category_path(assigns(:category))
# end
#
# test "should show category" do
# get :show, :id => @category.to_param
# assert_response :success
# end
#
# test "should get edit" do
# get :edit, :id => @category.to_param
# assert_response :success
# end
#
# test "should update category" do
# put :update, :id => @category.to_param, :category => @category.attributes
# assert_redirected_to category_path(assigns(:category))
# end
#
# test "should destroy category" do
# assert_difference('Category.count', -1) do
# delete :destroy, :id => @category.to_param
# end
#
# assert_redirected_to categories_path
# end
end

0 comments on commit e0df724

Please sign in to comment.