I have an action in my controller that I'm having problems with. This is my first application for rails, so I'm not sure about the best methods related to rails.
I have a model called Group and a few actions that go into it. I wrote a test that should make the controller display an error in JSON due to an invalid group id. Instead of rendering and exiting, it looks like the controller is rendering and continuing to execute.
Test
test 'should not remove group because of invalid group id' do post(:remove, {'group_id' => '3333'}) response = JSON.parse(@response.body) assert_response :success assert_equal 'Success', response['message'] end
Controller action
The controller executes the first if statement: render :json => { :message => "group_id not found" } but @group.destroy is still executing. This seems intriguing to me, I think the render method should exit the controller.
Why doesn't the controller exit after calling render ?
The purpose of this block of code is to gracefully recover when an entry with an identifier is not transferred. Is this the right way to do something like this?
codysehl
source share