Displaying 20 results from an estimated 8000 matches similar to: "create test methods from Controller methods?"
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
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 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 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 Feb 22
5
Auditing mixin for model classes. Small problem
I want to include common auditing functionality in my models. This
involves storing the changes made to a model in a seperate table :
I have created the functions in an Audit module :
module Audit
before_update :before_changes
after_update :after_changes
def before_changes
old=self.class.find(id).attributes
@changes=[]
attributes.each do |key, val|
if val != old[key]
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
7
AJAX effects
I was at http://rails.techno-weenie.net/ and I like what ajax does when
you click on "login" how can I do this on my own website? Is this with
the defualt JS libary?
--
Posted via http://www.ruby-forum.com/.
2006 Jan 13
2
Change Password with acts_as_authenticated
I want to have a form to change a users password. I can''t figure out
what the method in the controller should look like. I tried @user.save
and @user.update_attributes, but can''t get it to work.
My Form:
##############################
<%= start_form_tag :action => "update_password", :id => @user.id %>
<%= password_field ("user",
2006 Jan 09
11
Scaleability and Sharing of code between apps
Application 1 is an auditing application called AuditSystem.
Application 2 is a quality control appllication called QC.
App1 has a couple of classes, including models, that i would like to use
with App2. I would like a change in a class to be felt in both
applications. How do i acheive this without copying and pasting code??
At the moment im feeling i should have made the whole thing one
2006 Feb 08
8
Liquid with database?
Hello,
Just wondering if someone here as successfully ported Liquid to use with a database. I would like to try it out but not sure how Liquid integrates with current templates.
Thanks
Frank
---------------------------------
Yahoo! Mail - Helps protect you from nasty viruses.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
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 Aug 10
6
Login Restfully
In DHH''s keynote, he alluded to doing logins with REST. Has anyone
implemented this, and if so, would you mind elaborating on how you did
it please?
Thanks in advance.
--
Posted via http://www.ruby-forum.com/.
2007 May 08
2
Install plugin acts_as_auth.. no access to techno-weenie.net
please help me get this plugin installed...
I have no access to techo-weenie.net due to a firewall blocking the
weenie crap in its domain name.
more specifically, i''m trying to do this:
script/plugin install http://svn.techno-weenie.net/projects/plugins
and it bombs.
On a machine w/ access to this repository, I did an svn checkout and
tar''d up the contents... then
2006 Mar 23
3
migrations: how to have all data dumped into rb ?
Hi,
I dumped the schema using rake db_schema_dump.
Now how do I create a migration containing all the data I have in my dev
db ?
--
Jean-Christophe Michel
2005 Dec 27
3
execution timeout
Hi!
I have a rails action controller method which takes long time to
complete.
After about 4-5 minutes running, I get a "execution expired" error which
stops this method''s execution.
I looked and looked, searched and searched, but could not find how to
configure my ActionController''s timeout to be greater than the default.
Could anyone help?
--
Posted via
2006 Mar 01
4
STI, subclasses and callbacks
I have a STI class tree. I want to set some default values (calculated
values so I can''t set it in the database as defaults) on every created
instance regardless of what subclass is actually instantiated. So I
figured adding a after_create callback in the top class in the hierarchy
should do the trick. It seems it doesn''t get called :(
Code:
class SuperClass <
2006 Jan 03
5
Are cache sweepers used?
After drawing many virtual blank stares in the IRC channel and finding
zero results on the wiki for ''sweeper'' I''m left to wonder whether
these are actually officially supported, or are on their way toward
being deprecated. Is there a better way of expiring caches on model
saves and deletions?
Sincerely,
Tom Lieber
tom@alltom.com
http://AllTom.com/
2006 Jan 07
8
Using find_by_sql to get the sum of a column
Hello,
I was wondering if there was a method in Rails that returns the sum of a
column. For example, I have a column called ''score'' and writing a SQL
statement such a ''select sum(score) from table_name'' does return the sum
of the values in the column. In the past (not too long ago being a
newbie), I defined all sorts of methods only to discover that Rails
2005 Dec 19
2
Validation that works in the controller
Hi,
Is there a way of validating input inside the controller? or an equivalent to
ActiveRecord::Validations::ClassMethods.validates_presence_of ?
Cheers,
-- Colin