Displaying 20 results from an estimated 54 matches for "assert_redirected_to".
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 redirection to all of the options supplied
(redirection is <"htt...
2010 Feb 19
2
Problem with assert_redirected_to
I have taken over some old Rails code and am trying to get the tests to run.
In the functional test every time the assertion ''assert_redirected_to'' is
called I get the following error:
test_should_update_venue(VenuesControllerTest):
NoMethodError: undefined method `[]'' for
#<Enumerable::Enumerator:0x102f747e0>
/blah/blah/blah/project/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/core_ext/strin...
2006 Jul 11
0
assert_redirected_to not recognizing routes
I''m getting a weird error in a call to assert_redirected_to in one of
my functional tests. Here is the test:
def test_signin
admin = users(:adminuser)
post :signin, {:login => admin.email, :realpass => @password}
assert_redirected_to :action => ''list'' # failure happens on this line
assert_equal admin.id, sessi...
2006 Mar 22
0
assert_redirected_to behaviour
...just
def bar
redirect_to :action => ''baz''
end
and have all those x, y and z parameters inherited from bar action.
So far, rails has that feature available.
Then you write a functional test something like this:
def test_bar
get :bar, :x => 1, :y => 5, :z => 2
assert_redirected_to :action => :baz, :x => 1, :y => 5, :z => 2
end
As far as I see, now assert_redirected_to only matches parameters
supplied to it with parameters supplied to redirect_to method. I think,
that assert should work something like this:
1. construct url with parameters supplied for redirec...
2006 Dec 11
1
assert_redirected_to error
I''m new to TDD in rails, I''m getting this weird error with
assert_redirected_to.
Here''s my test:
def test_friendship_request_accept
@request.session[:user] = users(:nathan).id
get :accept, { :id => 1 }
assert_redirected_to :controller => "/users/profile", :action =>
"index", :id => users(:nathan).id
end
When I run this I...
2006 Jun 30
4
Strange behaviour from assert_redirected_to
I have this assertion in my tests:
assert_redirected_to :controller => ''user'', :action => ''change_password''
It fails with:
response is not a redirection to all of the options supplied
(redirection is <"http://test.host/user/change_password">),
difference: <{:controller=>"user"}&...
2010 Aug 16
0
assert_redirected_to partial assertion does not work?
Hi,
From the docs I see:
http://api.rubyonrails.org/classes/ActionController/Assertions/ResponseAssertions.html
This match can be partial, such that assert_redirected_to(:controller =>
"weblog") will also match the redirection of redirect_to(:controller =>
"weblog", :action => "show") and so on
But it my case it does not work. As assert_redirected_to(:controller =>
''articles'') expects the index action of...
2006 Aug 03
2
Failing test with assert_redirected_to
I''m having a strange problem with an assert_redirected_to in my
controller test which hopefully someone can point out my failings with!
;)
Controller method -
def new
if request.post?
#Not important here.
else
flash[:notice] = ''Please join a tree from this page.''
redirect_to :controller => ''trees'',...
2005 Mar 06
3
question about testing
...actions that require a log
in. But, for security''s sake, I''d like to test that actions while
logged out, do in fact redirect to the login screen.
I originally wrote the test method like this:
def test_loggedout
@request.session["user"] = nil
process :new
assert_redirected_to :controller => ''account'', :action => ''login''
process :edit
assert_redirected_to :controller => ''account'', :action => ''login''
...
end
And so on for all my protected actions. Hopefully it''s obvi...
2007 Jan 09
1
assert_redirected_to not working as expected
...gns_up_successfully
end
...
private
module BrowsingTestDSL
include ERB::Util
attr_writer :name
...
def signs_up_successfully
post_signup("gooddog", "gooddog-plI9Zfxs2xb6V6G2DxALlg@public.gmane.org", "gooddog",
"gooddog")
assert_redirected_to :controller => "home", :action => "welcome"
end
...
private
def post_signup(login, email, password, confirm_password)
post "/account/signup", :login => login, :email => email,
:password => password, :confirm_password => confirm_p...
2007 Dec 24
1
Uninitialized constant in integration test
I am seeing weird issues when trying to create integration tests. Here
is a very simple example of something that is failing. The
assert_redirected_to, and other methods, fail with this or similar
exceptions.
I have tried requiring both ''application'' and ''listings_controller'', but
neither solves this problem, although the exception changes.
Anybody know what''s going on here?
Thanks.
----
require &q...
2007 Jan 21
0
Functional Test Fails with before filter in application.rb
Hi There,
I am trying to write my first tests for a role bassed authentication
taken from Rails Recipies. Whenever I add:
assert_redirected_to :action => ''login''
I get the following error:
NoMethodError: undefined method `first'' for :user:Symbol
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.1/lib/action_controller/assertions/response_assertions.rb:72:in
`assert_redirected_to''
/usr/local/...
2009 Jan 19
1
in functional test, assert_redirected_to w prefix
I had to use sub-URI deployment (could not use subdomains..), and when
running my functional tests, I the redirected_to assertion embed the
prefix.. quite normal ;-))
is there a way to stipulate this prefix in the test setup to avoid
hard-coding in all the tests ?
Expected response to be a redirect to <http://test.host/my/page>
but was a redirect to
2006 Jul 02
5
"the number of parameters does not match the number of substitutions" error
All of a sudden, I''m getting this error:
1) Error:
test_index(AccountControllerTest):
RuntimeError: The number of parameters does not match the number of
substitutions.
/home/joe/projects/tanga/trunk/config/../vendor/rails/actionpack/lib/action_controller/assertions.rb:92:in
`assert_redirected_to''
/home/joe/projects/tanga/trunk/config/../vendor/rails/actionpack/lib/action_controller/assertions.rb:313:in
`clean_backtrace''
/home/joe/projects/tanga/trunk/config/../vendor/rails/actionpack/lib/action_controller/assertions.rb:74:in
`assert_redirected_to''
./t...
2009 May 18
0
[PATCH server] fixed functional tests after recent controller refactoring and managed node controller fixes.
.../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 => 'dashboard'
-
- assert...
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:
2006 Jan 03
1
must write '':controller => "/foo"'' because of "admin/bar"
Hi all,
Because I place admin controllers in an "admin" subdirectory, I''m forced
to use absolute controller names/paths whole over my app.
=>
I can no longer write:
.. :controller => "foo"
.. :controller => :foo
or
.. :controller => "admin/bar
I have to use instead :
.. :controller => "/foo"
.. :controller
2011 Aug 04
3
#create tests fail when I add FriendlyId to my model
...`test_create_valid''
Here''s the relevant line in brand.rb:
has_friendly_id :name, :use_slug => true, :approximate_ascii => true
Here''s the test (using mocha):
def test_create_valid
Brand.any_instance.stubs(:valid?).returns(true)
post :create
assert_redirected_to brand_url(assigns(:brand))
end
Here''s the fixture:
one:
name: MyString
image_file_name: MyString
image_content_type: MyString
image_file_size: 1
image_updated_at: 2011-08-03 10:49:03
tease: MyText
description: MyText
All other tests pass, and if I comment out has...
2005 Dec 23
6
Agile book - test error
...I get an error when testing the "store_controller_test.rb"
The troublesome line is in the test below:
def test_add_to_cart
get :add_to_cart, :id => @version_control_book.id <<<
cart = session[:cart]
assert_equal @version_control_book.price, cart.total_price
assert_redirected_to :action => ''display_cart''
follow_redirect
assert_equal 1, assigns(:items).size
assert_template "store/display_cart"
end
And the error n question is:
1) Error:
test_add_to_cart(StoreControllerTest):
RuntimeError: Called id for nil, which would mistaken...
2006 Oct 21
6
test_create gets 200 instead of :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
(Found)
assert_redirected_to :action => ''list''
assert_equal ''Borrower Anyone was added.'', flash[:notice]
assert_equal num_borrowers + 1, Borrower.count
end
What am I leaving out of my test to keep me from :success? Or should it
be rearranged somehow? As I said, the app itself...