Created
January 7, 2009 21:18
-
-
Save mytrile/44441 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| def index | |
| @category = Category.find(:all) | |
| @cat = Category.new | |
| respond_to do |format| | |
| format.html | |
| format.xml { render :xml => @category } | |
| format.json { render :json => @category } | |
| end | |
| end | |
| def create | |
| @category = Category.new(params[:category]) | |
| if @category.save(params) | |
| flash[:notice] = 'Category successfully added !' | |
| redirect_to '/categories' | |
| else | |
| flash[:notice] = 'There was an error processing your request' | |
| render :action => "index" | |
| end | |
| end |
This file contains hidden or 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
| context "on POST to :create " do | |
| setup { post :create, :category => { :name => 'Flowers', :description => 'I Like flowers' } } | |
| should_assign_to :category | |
| should_set_the_flash_to "Category successfully added !" | |
| end | |
| context "on POST to :create without values" do | |
| setup { post :create, | |
| :category => { :name => nil, :description => nil } } | |
| should_assign_to :category | |
| should_set_the_flash_to "There was an error processing your request" | |
| should_render_template :index | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment