search for: expandingbrain

Displaying 9 results from an estimated 9 matches for "expandingbrain".

2006 May 04
2
Testing associations
I have a pretty simple model, articles and users. class Article belongs_to :user end class User has_many :articles end In my unit tests I want to ensure that the associations work properly. What''s the best way to do this? The obvious thing to do is a test in each model. # user_test.rb def test_add_post u = users(:first) before_articles = u.articles.count u.articles
2006 May 08
3
operator overload on views
In my User auth scheme I have a userlevel. I''ve overloaded the User class operators like this: def >(item) if item.class == "User" self.userlevel > item.userlevel else self.userlevel > item end end (other operators are overloaded in essentially the same way). As I understand it, using the operator ">" inside the overloaded
2006 May 03
0
Accessing the params hash in a functional test not working
...;"login"}, "flash"=> {:error=>"The email address and/or password you entered is invalid."}, :return_to=>nil}>> I am stumped figuring out why the params are not being passed through - any help appreciated! Cheers, Dan. -- Dan Venkitachalam expandingbrain.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060503/40ec407a/attachment.html
2006 May 03
3
create test methods from Controller methods?
Can you somehow create a test that contains methods that relate to the methods in the controller that is being tested? Thanks Chris -- Posted via http://www.ruby-forum.com/.
2006 May 03
1
Nubee Fixtures + Tests problem
According to the book, @timesheets["first_timesheet"] should be accesible from within my functional test, but its not! Timesheets.yml : first_timesheet: status: 2 start_date: 2006-04-24 cost: 10 employee: 444 id: 10683 charge: 20 My Test : class AdminTimesheetsControllerTest < Test::Unit::TestCase fixtures :timesheets def test_viewTimesheet get
2006 May 10
1
model mixin module madness
If I have several models which exhibit the same functionality, it seems makes sense to create a mixin, ''include'' it in each model and save myself some work and repeated code. Where can I define a module which will be available to all models? I can''t seem to find a documented place for them. Alternatively, is there a Rails-standard way of achieving the effect? Ben
2006 Apr 28
1
how do I test links in templates?
Hello everyone! Sorry, if it''s stupid question, but I can''t figure out how to do this. I have a set of statements, for example, ''login page should have a link to register new user'' and ''login page should have a link to password recovery''. How do I transform it into tests? Where it should go? It does not look like functional tests or
2006 May 03
2
Conditional statement style
This is a bit of a nuby question methinks but i''ve had a play/search around and it''s just bugging me now :0) Say I have a conditional statement, testing a variable against a number of values. The first way i did this is like so: if myvar != "" and myvar != 0 and myvar != nil # .. code end This seems a bit messy - is there neater way of doing this? I thought of:
2006 May 04
3
@products["car"] is not being recognized in my tests!! help
@products["car"] is not being recognized in my tests: class ProductsControllerTest < Test::Unit::TestCase fixtures :products def test_view_product post :view_product, :id=>@products["car"].id assert_template "view_product" ... end end products.yml : car: id:1 name:test Does anyone have any idea why its not working? Im having to do