i am new to rails testing and i am using unit:test. I have an action in my controller
def save_campaign unless params[:app_id].blank? @app = TestApp.find(params[:app_id]) if params[:test_app] @app.update_attributes(params[:test_app]) end flash[:notice] = "Your Registration Process is completed" redirect_to "/dashboard" else redirect_to root_path end end and my test case is as following
test "should save campagin " do assert_difference('TestApp.count', 0) do post :save_campaign, test_app: @test_app.attributes end assert_redirected_to "/dashboard" end end This method is a post method. While running this test, it is failing and showing me a message
"should save campagin (0.07s) Expected response to be a redirect to http://test.host/dashboard but was a redirect to http://test.host/ /home/nouman/.rvm/gems/ruby-1.9.2-p290@global/gems/actionpack-3.1.3/lib/action_dispatch/testing/assertions/response.rb:67:in `assert_redirected_to'
My guess is that i am not giving it right assertion to check params
params[:app_id] and @app = TestApp.find(params[:app_id]).
How can i write such an assertion to check these attributes, check wether a parameter is blank. How can 1 find an object with a given id.