Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:37:49+00:00 2026-05-24T18:37:49+00:00

I recently changed my controller code from: def create @checklist_item = @checklist.items.build(params[:checklist_item]) if @checklist_item.save

  • 0

I recently changed my controller code from:

  def create
    @checklist_item = @checklist.items.build(params[:checklist_item])
    if @checklist_item.save
      flash[:notice] = "Successfully created checklist item."
      redirect_to checklist_item_url(@checklist, @checklist_item)
    else
      render :action => 'new'
    end
  end

to

  respond_to :html, :json
  def create
    @checklist_item = @checklist.items.build(params[:checklist_item])
    if @checklist_item.save
      flash[:notice] = "Successfully created checklist item."
    end
    respond_with @checklist_item
  end

But my spec that worked fine with my previous controller code is failing:

  it "create action should render new template when model is invalid" do
    checklist_item.stub(:valid? => false)
    checklist.stub_chain(:items, :build => checklist_item)
    post :create, :checklist_id => checklist.id
    response.should render_template(:new)
  end

With the error:

1) Checklists::ItemsController create action should render new template when model is invalid
     Failure/Error: response.should render_template(:new)
     MiniTest::Assertion:
       Expected block to return true value.

I’m not sure how to change the spec. Everything still functions the same when I test it in the browser (its renders new).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:37:50+00:00Added an answer on May 24, 2026 at 6:37 pm

    Pretty funny, just tried and indeed the response doesn’t contain much.

    It’s a mere status 302. Test: response.status.should eq 302

    With a body like:

    "<html><body>You are being <a href=\"new_url">redirected</a>.</body></html>"

    which is easily testable too.

    I’ll dig a little further.


    Edit:

    Even with render_views, response remains a mere redirect.

    You could also check response.header which looks like:

    {"Location"=>"http://test.host/users", "Content-Type"=>"text/html; charset=utf-8"}
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've recently run into interesting problem passing parameters to my controller action from my
I recently changed the type of one of my properties from @property (readonly) NSImage
I recently changed from using the C interface to the C++ interface in OpenCV.
I've recently changed to Mate as a framework for flex. However am running into
I just recently changed out all my hard drives and in the process of
HI people I recently changed to VIM for coding in C. I'd like to
I have Apache 2 running on a VPS server (running Debian). I recently changed
Recently our Subversion (SVN) server was changed and we did a svn switch .
just simple question, recently i have setup a web server to build project using
I recently changed URLs of my site. Old URL: mysite.com/top/1 New URL: mysite.com/top/page=1 When

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.