Skip to content

Commit

Permalink
Remove XML stuff from Books controller.
Browse files Browse the repository at this point in the history
Not gonna use it in a foreseeable future
  • Loading branch information
be9 committed Oct 18, 2008
1 parent 694ea4b commit ab2a4fc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 67 deletions.
54 changes: 11 additions & 43 deletions app/controllers/books_controller.rb
@@ -1,35 +1,17 @@
class BooksController < ApplicationController
# GET /books
# GET /books.xml
def index
@books = Book.find(:all)

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

# GET /books/1
# GET /books/1.xml
def show
@book = Book.find(params[:id])

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

# GET /books/new
# GET /books/new.xml
def new
@book = Book.new

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

# GET /books/1/edit
Expand All @@ -38,48 +20,34 @@ def edit
end

# POST /books
# POST /books.xml
def create
@book = Book.new(params[:book])

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

# PUT /books/1
# PUT /books/1.xml
def update
@book = Book.find(params[:id])

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

# DELETE /books/1
# DELETE /books/1.xml
def destroy
@book = Book.find(params[:id])
@book.destroy

respond_to do |format|
format.html { redirect_to(books_url) }
format.xml { head :ok }
end
redirect_to(books_url)
end
end
24 changes: 0 additions & 24 deletions spec/controllers/books_controller_spec.rb
Expand Up @@ -14,18 +14,6 @@ def mock_book(stubs={})
assigns[:books].should == [mock_book]
end

describe "with mime type of xml" do

it "should render all books as xml" do
request.env["HTTP_ACCEPT"] = "application/xml"
Book.should_receive(:find).with(:all).and_return(books = mock("Array of Books"))
books.should_receive(:to_xml).and_return("generated XML")
get :index
response.body.should == "generated XML"
end

end

end

describe "responding to GET show" do
Expand All @@ -36,18 +24,6 @@ def mock_book(stubs={})
assigns[:book].should equal(mock_book)
end

describe "with mime type of xml" do

it "should render the requested book as xml" do
request.env["HTTP_ACCEPT"] = "application/xml"
Book.should_receive(:find).with("37").and_return(mock_book)
mock_book.should_receive(:to_xml).and_return("generated XML")
get :show, :id => "37"
response.body.should == "generated XML"
end

end

end

describe "responding to GET new" do
Expand Down

0 comments on commit ab2a4fc

Please sign in to comment.