search for: assert_response

Displaying 20 results from an estimated 84 matches for "assert_response".

2009 May 18
0
[PATCH server] fixed functional tests after recent controller refactoring and managed node controller fixes.
...00644 --- a/src/test/functional/host_controller_test.rb +++ b/src/test/functional/host_controller_test.rb @@ -59,47 +59,6 @@ class HostControllerTest < Test::Unit::TestCase assert assigns(:host).valid? end - def test_new - get :new, :hardware_pool_id => pools(:default).id - - assert_response :redirect - assert_redirected_to :controller => 'hardware', :action => 'show', :id => pools(:default).id - end - - def test_create - num_hosts = Host.count - - post :create, :host => {} - - assert_response :redirect - assert_redirected_to :controller =&g...
2006 Jul 05
2
How to write get functional test when there is no action by that name
...;'event_info'' It causes a URL like http://localhost:3000/event/_jewels_exhibition_ to be sent to the home controller with action as ''event_info''. I am trying to test this action. My first gut was to write something like def test_event_info get :event_info assert_response :success end But this doesn''t work. Does anyone have any idea how to creat a get request whicn transaltes into " http://localhost:3000/event/_jewels_exhibition_ ". I am stuck because of this and can''t proceed with my testing. I even tried def test_event_info...
2006 Oct 21
6
test_create gets 200 instead of :success
...''Borrower could not be added.'' render :action => ''new'' end end Setting breakpoints at different places in the above code indicates that my test is going through the rescue section. Here''s the test code: def test_new get :new assert_response :success assert_template ''new'' end def test_create num_borrowers = Borrower.count post :create, :borrower => {:SSN => ''000'', :LastName => ''Anyone''} assert_response :redirect # gets 200 (OK) instead of 302 (Fo...
2009 Apr 21
2
validates_uniqueness_of
...num_bins = Bin.count post :create, {:bin => { :carrier => carriers(:A), :cycle => cycles(:one), :name => "701", :start => "1:00", :end => "1:01" }}, { :user => @user_id, :division => @division_id } validates_uniqueness_of :cycles assert_response :redirect assert_redirected_to :action => ''list'' assert_equal num_bins + 1, Bin.count rescue exception: NoMethodError assert_response :error flash[:notice]="Cycle name not unique." end end 1) Error: test_create_failure_cycle_unique(BinsCo...
2006 Apr 04
1
integration tests - 1.1
...controller redirects to the correct place and preserves the query string. Here?s the code: class LoginRedirectTest < ActionController::IntegrationTest def test_non_admin_auth request_uri = "/datafeed/event/report?blah=blah" get(request_uri) follow_redirect! assert_response :success status = post("/login/authenticate", :login_info => {:user_name => "blah", :password => "blah"}) follow_redirect! assert_response :success user = session[:user] assert !user.nil? # puts response["REQUEST_URI"]...
2006 Aug 15
7
Trying to Overide Class Object Methdos For Testing
Hi, I thought I had a handle on the whole singleton class thing but now I''m not too sure. I have a class definition: class ValidationMaster def validate(params) # complex and time consuming validation # returns true on success, raises Exception # on failure end end Okay, so when I''m running my functional tests within rails, I want to be able to control how
2007 Jul 30
6
Object.stubs doesn''t seem to work.
Hi I''m using Mocha 0.5.3 and I want to stub out a call to Time.now, just like the example in the post http://blog.floehopper.org/articles/2007/06/08/mocha-0-5-released However, trying it in irb gets me the following error: >> require ''mocha'' => true >> Time.stubs(:now).returns(Time.parse(''Thu Feb 01 00:00:00 UTC 2007'')) NoMethodError:
2008 Jan 12
0
Can't test application controller methods in functional tests?
...res :messages, :message_threads, :message_boards, :forums def setup @controller = ForumController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end ... # test logout (all cases) def test_logout get :logout, nil, nil assert_response :success assert_nil session[:username] assert_nil session[:admin] get :logout, nil, {:username => ''bogus''} assert_response :success assert_nil session[:username] assert_nil session[:admin] get :logout, nil, {:username => ''Admin''...
2006 Oct 13
6
If I stub do I have to mock as well?
...m new to mocha and stubba but eager to learn. I have a rails functional test in which I would like to stub an instance method of particular class to always return true. I tried the following: def test_post_checkout Order.any_instance.stubs(:successful?).returns(true) post :checkout assert_response :redirect assert_equal "Checkout was successful.", flash[:notice] end I expected that the stub would help my test pass but instead it failed and the failure included the following: test/functional/store_controller_test.rb:103:in `test_post_checkout'']: #<Mocha::Mock...
2006 Jun 17
3
What is this failure trying to tell me?
Here is my unit test code. post :login, :user=>{ :login => "bob", :password => "test"} assert_response :redirect assert_session_has :user assert_redirected_to :action => ''welcome'' Here is the failure I''m getting when I run my tests. 2) Failure: test_login_required(UserControllerTest) [test/functional/user_controller_test.rb:122]: response is not a redirecti...
2010 Aug 09
0
Exceptions in functional tests (rescue_action_in_public! broken?)
In 2.3, exceptions raised by controllers under functional tests were by default propagated to the test, but by using rescue_action_in_public! a test could trigger the production, public behavior and then use assert_response or similar to test the expected result. This was implemented via coordination between ActionController::Rescue and ActionController::TestCase::RaiseActionExceptions. This coordination is no longer present in 3.0.0.rc1; rescue_action_in_public! has no effect on whether or not exceptions propagate t...
2006 Sep 26
0
some help with functional testing of nested routes
...ories def setup @controller = ProductsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @first_id = products(:first).id @category_id = categories(:first).id end def test_index # HTTP GET get :index assert_response :success assert assigns(:products) assert_template ''index'' end def test_new # HTTP GET get :new assert_response :success assert_template ''new'' assert_not_nil assigns(:product) end def test_create num_records = Product.cou...
2007 Dec 01
5
specifying an HTTP status code
...ecifically I want to test for the usage of 301 as opposed to 302, for a permanent redirection. response.should be_redirect looks like it calls ActionController::TestRequest#redirect?, which is only testing for a status code from 300..399. In an old-fashioned Test::Unit Rails test I could do assert_response, but I can''t see anything matching that in RSpec. Is there a less-documented feature I''m missing? Thanks, Francis Hwang http://fhwang.net/
2006 May 05
3
posting xml in functional test
...ml in a REST- like fashion. However the following code won''t work for me - an exception is generated def test_create post :create, ''<person><name>john</name></person>'', {''Content-Type''=>''application/xml''} assert_response 200 end Anyone give me a hint where I''m going wrong ? thanks in advance -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060505/3660b628/attachment.html
2008 Apr 01
2
Functional Testing - page actions
...imple question, I''ve tried to ajaxify some actions and the first one I did was a delete - def delete_job ..... render :update do |page| page.remove "job_#{id}" end .... end and in my functional test I call this function via post def test.... post :delete_job, :id => 1 assert_response :success ...... end after the assert_response, how do I test that the page is deleting the job / div? I created some entries and ran this manually and it worked, but I don''t know what the assert is for the test. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~--------...
2007 Jan 26
0
Problems with assert_select in integration tests
...''me-hcDgGtZH8xPR7s880joybQ@public.gmane.org''} click_button "Create Account", "/account/new_account_step_two", {:first_name=>''Test'', :last_name=>''User''} end private def goto_home_page get "/" assert_response :success assert_template "register/list" end def click_link(link_text, destination) assert_select "a[href*=#{destination}]", link_text get destination assert_response :success end def click_button(button_text, destination, params={}) assert_select &...
2006 Oct 12
2
Test should fail !
...n(e) raise e end; end class AlertsControllerTest < Test::Unit::TestCase fixtures :clients def setup @controller = AlertsController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new end def test_get_index get :index assert_response :success end end -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TL...
2008 Nov 17
2
Can't seem to test http error codes
...mat| format.html { render :template => "shared/status_# {status.to_s}", :status => status } format.any { head status } end end in a controller project = Project.find(params[:id]) in my test def test_bad_project put :update, :id => KNOWN_BAD_ID assert_response(:missing) end The result is that I get a 500 every time. Any clues as to whats'' going on? There''s nothing in the log to explain the 500 I get during tests; the application controller seems to be detecting the exception and setting the status to 404, but my tests get 500. Dav...
2007 Jul 25
3
autotest + integration testing (follow_redirect!) error
I''ve got an interesting (possibly) problem right now between autotest and rails integration tests. There are a few things to preface this with. Works fine: rake test rake test:integration Blows up: autotest Autotest is correctly determining rails and runs tests just fine. One part of the behavior is that if I save a change in just the integration test (even hitting cmd+s to trigger a
2006 Jan 12
2
Engines issue: rake test_plugins failing when it shouldn''t
...FredController < ApplicationController def hello render :text => ''Hello, world!'' end end and I create a simple functional test within the engine: class FredControllerTest < Test::Unit::TestCase ... def test_hello get :hello assert_response :success end end Running ''rake test_plugins'' succeeds, and firing up the server and requesting /fred/hello gives the expected page. Now, in the project that includes the engine, I override FredController: class FredController < ApplicationController def goo...