forked from gnocode/noladex.org
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commented out unneeded categories controller + test
- Loading branch information
Joe Ellis
committed
Jul 29, 2011
1 parent
23733a0
commit e0df724
Showing
2 changed files
with
128 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |