Displaying 20 results from an estimated 25 matches for "login_a".
Did you mean:
login_
2008 Jan 21
9
DRY act_as_authenticated functional testing
I''m using the acts_as_authenticated plug-in for my app. Now I need to
get my functional tests to work properly. I have not written functional
tests before so I''m unsure how to utilize setup so that all of my tests
can use the login. My tests pass if I put login_as :user inside of each
test, but that''s clearly not DRY. Can I add something to my
test_helper.rb file or create a def set in each functional test? Any
direction for this would be greatly appreciated.
Thanks.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~-----------...
2006 Dec 24
6
What do you think of this controller spec?
Here''s a controller spec I wrote, it''s for a very simple RESTful
controller (well, aren''t all RESTful controllers simple? :)
I''ve created a couple spec helper methods to refactor some of the
common code...for example, require_login_and_correct_user creates two
specifications: one for when the user isn''t logged in, and one when
the user is logged in but requests someone else''s book. do_request
automatically calls do_get/post/put/delete depending on what''s
implemented.
Here''s all the code:
b...
2007 Feb 28
4
acts_as_authenticated error with Object#id
...when I run my Rails controller specs.
<projectroot>/config/../lib/authenticated_system.rb:16: warning: Object#id
will be deprecated; use Object#object_id
I added "include AuthenticatedTestHelper" to /spec/spec_helper.rb so
that my controller tests^H^H^H^H^Hspecs can use the "login_as" helper
method. Anyone know how to fix this?
--
Cheers,
Kevin Williams
http://www.almostserio.us/
"Any sufficiently advanced technology is indistinguishable from
Magic." - Arthur C. Clarke
2007 Jun 25
1
Functional tests and active scaffold: unexpected assertion failure.
Hello,
I''m writing a functional test for a controller that uses active
scaffold.
def test_presence_of_field
login_as(:peter)
profile = Profile.find :first
get :edit, {:id => profile.id}
assert_response 200
assert_select "textarea#record_free_text_ec"
end
I was expecting the first ''assert 200'' to give me a green bar,
but added it for confirmation, and indeed it gives me te...
2007 Sep 13
5
Authenticating before tests
Hi all,
I''m using Goldberg, an engine that provides roles based access
control for my app. I need to login before I can do controller tests,
but I can''t find any examples of people doing this.
Could someone point me in the right direction?
I thought the simplest way would be to either call the login action
from my other tests before(:all), but I can''t seem to
2007 Oct 11
2
Login testing ideas
I''ve been going through Pat''s example story and noticed that there was
no checking for a bad login. I assume this is because that would have
made the article bigger and more complicated than it needed to be.
So the question that comes of of this is:
How do folks normally handle the negative case? My plan was to just
use another scenario, but as a new person to BDD/TDD,
2008 Mar 20
5
sharing story steps
...t all my stories share?
i.e. My stories often start out looking like this:
Given a user Joe
Given a user Jordan
then:
Given("a user $username") do |username|
@users ||= {}
@user_sessions ||= {}
@users[username] = create_user(:username => username)
@user_sessions[username] = login_as(@users[username])
end
I want to share that Given with all my stories. Or is there a better
way to do it?
Joe
2006 Nov 08
1
controller.session not same as session?
> context "A user logging out" do
> fixtures :users
> controller_name :account
>
> setup do
> login_as :quentin
> users(:quentin).remember_me
> request.cookies["auth_token"] = cookie_for(:quentin)
> end
>
> def logout
> get :logout
> end
>
> specify "should unset :user in session" do
> logout
> controller.sess...
2007 Oct 26
2
Examples of writing controller specs that use authentication
Hello,
I''m working on specs for a controller that handles authentication
using the restful_authentication plugin. I''m trying to find a
resource (tutorial or examples, if possible) about the best way to go
about writing mocks and specs to make sure that things like my
before_filters are working correctly. Does anyone know of any good
resources for this?
Thanks,
Les
2007 Sep 30
9
Problems with testing nested routes using mocking
...ck("virtual_hosts")
@virtual_host = mock("virtual_host")
Domain.should_receive(:find).with("1").and_return(@domain)
@domain.should_receive(:virtual_hosts).and_return(@virtual_hosts)
@virtual_hosts.should_receive(:find).and_return(@virtual_host)
login_as :admin
end
def do_get
get :show, :id => "1", :domain_id => "1"
end
it "should render show template" do
do_get
response.should render_template(''show'')
end
it "should find the virtual_host requested" do
#...
2007 May 30
6
authentication mocks
hi
I''m using restful_authentication
and have controller specs working using users fixtures (and login_as)
however i''ve been trying for hours without success to do it without
fixtures, using mocks and stubs instead.
anyone here done this? got code?
:)
thanks
2007 Aug 11
2
Rspec and acl_system2 plugin
...;
<li> /users Users management </li>
</ul>
<% end -%>
Then in my spec file ''spec/views/layout/admin.rhtml_spec.rb'' :
describe "Layout Admin if admin user" do
include UserMockViewHelper
it "should display the admin tabs" do
login_as :admin
render ''layouts/admin''
response.should have_tag("ul#admin-tabs")
end
end
the UserMockViewHelper module handle the mocking of the current user :
module UserMockViewHelper
def login_as(user)
@current_user = mock_model(User)
@role = mock_model(...
2007 Dec 30
6
Restful-Authentication Rspec Failure Rails 2.0.2
I am trying the Restful-Authentication (latest version, downloaded
today) and upon running the generator, doing the migration, prepping
the test system and putting the resources in routes.rb I get a Rspec
test failure:
''SessionsController logins and redirects'' FAILED
expected not nil, got nil
routes.rb has:
map.resources :users
map.resources :sessions
nothing else was
2010 Jan 12
8
tips on how to write a controller test for models associated with currently logged in user
I have a controller test here:
http://gist.github.com/275616, which works fine when account is an
independent model, however I want:
an account to be a property of user, ( and created and associated when
a user is)
when the user goes to /account/edit it should on edit the account of
the logged in user -
I can make rails do this, but I''m utterly baffled how I should alter
this test to
2007 Jun 22
5
assert_select trying to verify the presence of a textarea
Hello,
One of my functional tests looks like this:
def test_presence_of_free_text
profile = Profile.find :first
post :edit, {:id => profile.id}
assert_select "textarea", :name => "record[free_text_ec]"
end
The test results in a failure, because the element cannot be found.
I''m pretty sure the element should be there, and I''ve tried
2007 Nov 02
0
DATE_FORMATS and functional tests
...sc) fails
with something like:
ActionView::TemplateError: wrong number of arguments (1 for 0)
On line #20 of app/views/admin/invitation_requests.rhtml
20: <td><%= invite.created_at.to_s(:msc_short) %></td>
My functional test method is:
def test_invitation_requests
login_as :quentin
get :invitation_requests # <--- Fails here
assert_response :success
assert assigns(:invites)
end
My test_helper.rb file has the following at the the top:
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../conf...
2007 Oct 16
10
Scenarios Plugin Pre-Announcement
This is sort of a pre-announcement for a Rails plugin my friend Adam
Williams and I are working on. We''re in the process of extracting it
from a project we are working on so that it can be generally useful to
the Rails community. We are calling it "Scenarios". It is a drop in
replacement for Rails fixtures:
http://faithfulcode.rubyforge.org/svn/plugins/trunk/scenarios/README
2009 Apr 06
3
After Rails 2.3.2 upgrade: superclass mismatch for class TestCase (TypeError)
I upgraded a working app from rails 2.1 to 2.3.2. Now when I run rake
test:units I get this error: /usr/lib/ruby/gems/1.8/gems/
activesupport-2.3.2/lib/active_support/test_case.rb:17: superclass
mismatch for class TestCase (TypeError)
I generated a new test app and all tests run OK.
For the upgrade I ran rake:update and renamed the class in test_helper
to ActiveSupport::TestCase. Also renamed
2007 Dec 07
4
strange error on mock proxy
...hing is that I don''t get the error when
I run the spec file by itself.
Here is the spec (I know, fixtures are the devil):
describe "/units/new.html.erb here" do
fixtures :units, :accounts, :groups
it_should_behave_like ''/units/_form''
before do
login_as :cathy
assigns[:unit] = @unit = Unit.new
@groups = accounts(:dawson).groups
render "/units/new.html"
end
it "should render new form" do
response.should have_tag("form[action=?][method=post]", units_path)
end
end
And the error:
4)
Actio...
2007 May 17
2
Stubbing authentication across multiple controllers
...ost/sessions/create") and to a relative path ("/sessions/create"), but that doesn''t seem to work either.
Perhaps I''m going about this the wrong way, so if anyone has any suggestions it would be appreciated.
#Helper method that is included in controller specs
def login_as(username, password = "foo", id = "1")
user = mock(username)
user.stub!(:id).and_return(id)
user.stub!(:to_param).and_return(id)
User.should_receive(:authenticate).with(username, password).and_return(true)
#Here it fails if included in a controller that isn''t...