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 8663545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:00:44+00:00 2026-06-12T17:00:44+00:00

I have a controller action that should only respond to AJAX calls: def archive

  • 0

I have a controller action that should only respond to AJAX calls:

def archive
  @model = MyEngine::MyModel.find(params[:id])
  if @model.update_attributes(params[:model])
    @success = true
  else
    @success = false
  end
  respond_to do |format|
    format.js
  end
end

I want to test that with something like:

it "should respond with javascript" do
  xhr :post, :archive, {:id => @model.to_param, :use_route => :my_engine}, valid_session
  response.should render_template('asi/events/archive', :format => 'js')
end

and

it "should not respond with html" do
  xhr :post, :archive, {:id => @event1.to_param, :use_route => :asi}, valid_session
  response.should_not render_template('asi/events/archive', :format => 'html')
end

But it seems like the assertions are mainly concerned with rendering the ‘archive’ template and doesn’t care about it’s extension. Any ideas what I’m doing wrong if there’s a better way to spec this?

Thanks for looking!

  • 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-06-12T17:00:45+00:00Added an answer on June 12, 2026 at 5:00 pm

    try with

    response.should_not render_template 'asi/events/archive.html'
    

    also, you can refactor your model a little doing

    @success = @model.update_attributes(params[:model])
    

    or

    @success = @model.update_attributes(params[:model]) === true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a controller action that calls a model method which generates a serialized
I have a controller action that checks this.User.Identity.IsAuthenticated What do you suggest how to
I have a controller action that builds a pdf and than downloads it by
If i have a Controller Action that may recieve both HTTP GET and HTTP
If i have a controller action Create that returns a view with the following
I have a Rails controller action to test. In that action, a method User.can?
I have an ASP.NET MVC 3 controller action. That action is defined as follows:
I have a controller's action and view page that uses a master page. The
I have a spring action that I am rendering some json from the controller,
I'd like to have URLs that are even shorter than /{Controller}/{Action}/{Id}. For example, I'd

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.