Displaying 20 results from an estimated 6000 matches similar to: "Where to add ActiveRecord::Base#find! tests"
2006 Apr 28
2
Accessing fixtures from unit tests
I have set up some fixtures in test/fixtures/users.xml:
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
admin:
id: 1
username: admin
password: admin
pbarry:
id: 2
username: pbarry
I have a unit test for my user model:
require File.dirname(__FILE__) + ''/../test_helper''
class UserTest < Test::Unit::TestCase
fixtures :users
def
2008 May 07
1
Assigning to the foreign key on a belongs_to association
I''ve encountered what seems like an odd omission in the behaviour of
belongs_to associations: if you assign to the foreign key attribute,
it doesn''t update the associated object (or mark a previously loaded
one as stale) until you explicitly save or reload it.
Let''s say we have a Company model, which belongs_to :city :
>> torchbox =
2006 Jul 23
0
[PATCH] (+tests) with_scope :order doesn''t work with included associations
(I''ve had this patch lying around for a couple of weeks, waiting for
Trac to come back up. noradio''s already had a look at it on IRC.
What''s the best way to submit patches while Trac is down?)
with_scope doesn''t support :order in the presence of :include. For
example:
{{{
# We''re testing the interaction between :order, :include, and
2007 Oct 07
0
Rails AR/Oracle Unit Test: [7769] failed (getting worse)
"bitsweat" has kicked AR/Oracle while it was down...
http://dev.rubyonrails.org/changeset/7769
------------------------------------------------------------------------
r7769 | bitsweat | 2007-10-06 22:29:37 -0700 (Sat, 06 Oct 2007) | 1 line
MySQL: speedup date/time parsing.
------------------------------------------------------------------------
U
2013 Mar 28
1
undefined method 'sanitize_limit' for #<ActiveRecord::Relation:0x2aaaad35d720>
I am trying to upgrate rails from 3.0 to 3.1, while updating rails version
I am getting following error
rake aborted!
undefined method `sanitize_limit'' for
#<ActiveRecord::Relation:0x2aaaad35d720>
/some_package/lib/ruby/gems/1.8/gems/activerecord-3.1.12/lib/active_record/relation.rb:460:in
`method_missing''
2006 Jan 10
1
Can somebody explain when to reload an ActiveRecord
Hi all,
I''ve the following test method in my controller_test which increment the
''qty'' attribute in a has_many association, ''sa_report_products''. The
''item_count'' method returns the sum of all qty''s in ''sa_report_products'':
def test_add_product_to_report
sa_rpt = SaReport.find(1)
assert_equal 3,
2006 Jun 04
0
[SUMMARY] Rails Core Weekly May 29 - June 4
Rails Core Weekly May 29 - June 4
Dear List,
Another week has passed, here''s RCW, the McCartney Edition:
This weeks kicks of with Josh Susser fixing has_and_belongs_to_many
#create method to properly populate joins with new records
:http://www.ruby-forum.com/topic/67478#new. Check out his test:
def test_create_by_new_record
devel = Developer.new(:name => "Marcel",
2007 Mar 13
0
ActiveRecord: strange tree behavior???
hi,
can someone help me with understanding, why i can''t get my
set_sub_tree method to run correctly and what to do to make it work?
when i run the testcase below i get
---
D:\ruby\test>ruby test/unit/demo_test.rb
Loaded suite test/unit/demo_test
Started
F
Finished in 0.625 seconds.
1) Failure:
test_set_sub_tree(DemoTest) [test/unit/demo_test.rb:13]:
fails@4.
<200> expected
2006 Feb 10
1
Bizarre ActiveRecord::Errors/validation problem
I could be going mad and missing something really obvious here but I''m
getting an unexpected result from the following.
The schema:
create_table :services, :force => true do |t|
t.column :id, :primary_key
t.column :name, :string, :ilmit => 5, :null => false
t.column :port, :integer, :null => false
t.column :status, :string
end
The model:
class Service <
2006 Apr 04
1
has_many fails where find_by_sql succeeds
Can anyone explain why the method form of the following works, but
the (apparently identical) has_many fails?
I have 3 sites in my fixtures. Initially, for a new StockGroup,
sites_not_using_this_stock_group should return all 3 sites (which it
does). When you add a site to the StockGroup, it should disappear
from the output of sites_not_using_this_stock_group. But the
has_many form
2007 Nov 13
4
question about activerecord test_numeric_fields in base_test.rb
There''s a test for activerecord called test_numeric_fields in
base_test.rb. here''s the test
def test_numeric_fields
m = NumericData.new(
:bank_balance => 1586.43,
:big_bank_balance => BigDecimal("1000234000567.95"),
:world_population => 6000000000,
:my_house_population => 3
)
assert m.save
m1 =
2007 Mar 18
5
Automatically mocking ActiveRecord methods
Seems like I do a fair amount of mocking ActiveRecord''s automatically
generated routines when I''m testing controllers. Things like:
@portalspace = PortalSpace.new :public_readable => true,
:public_writable => true, :name => ''public''
@portalspace.stubs(:id).returns(203)
PortalSpace.stubs(:find).with(203).returns(@portalspace)
2008 Jul 21
0
Re: find_by_name won't return record id
UGH. Totally dumb.
My Role model had:
def id
end
Thus, overriding the accessor. Not sure how that got there - but,
problem solved.
On Jul 21, 7:28 am, bubba_baloo <bubba_ba...-/E1597aS9LQAvxtiuMwx3w@public.gmane.org> wrote:
> Okay - so I''m finally making my first post after a couple of months
> with RoR. Thanks for all the great information so far.
>
> I''m
2011 Apr 24
2
False Positives In ActiveRecord Tests
Every now and then when I am working on making the SQL Server adapter pass all the ActiveRecord tests, I notice one that looks like a false positive in the core DBs. Here is one case in relations_test.rb. Can someone look at this and just tell me it is normal for other DBs and just odd for SQL Server? Or maybe it is just my understand of some SQL standard. I''m really not that SQL smart.
2007 Oct 21
0
Taking a stab at a pure Ruby Dir.glob
Hi all,
Here''s what I''ve come up with so far for a pure Ruby Dir.glob for MS
Windows. It almost works. The problem right now is the [] notation,
which I''m not translating properly into a regex.
I haven''t started on the ''**'' notation yet either, but I figure that''s
more of a control flow issue. Feel free to disagree with me and/or
2006 Apr 28
1
Where to put localization strings
Hello!
I have a model that validates presence of the attribute title
class Entry < ActiveRecord::Base
validates_presence_of :title
:message => ''empty title is a no no''
end
I also have a test of this valitation.
class EntryTest < Test::Unit::TestCase
fixtures :entries
def test_validate_title
first = entries(1)
first.title = ''''
2017 Jun 15
0
[PATCH v6 10/41] mllib, v2v: Split out OCaml utils bindings ‘common/mlutils’.
Create a module ‘C_utils’ containing functions like ‘drive_name’ and
‘shell_unquote’ which come from the C utilities.
The new directory ‘common/mlutils’ also contains the ‘Unix_utils’
wrappers around POSIX functions missing from the OCaml stdlib.
---
.gitignore | 3 +
Makefile.am | 24 ++---
builder/Makefile.am
2019 Jan 17
1
[hivex PATCH] ruby: improve test functions
Use better functions to check for proper values instead of assert:
- refute_nil for non-null functions
- assert_equal for checking equality
Also, make sure that the parameters for assert_equal are correct:
expected value, then got value.
---
ruby/tests/tc_120_rlenvalue.rb | 4 ++--
ruby/tests/tc_130_special.rb | 12 ++++++------
ruby/tests/tc_200_write.rb | 4 ++--
2013 Aug 22
1
How do I deal with ActiveRecord::RecordInvalid: Validation failed:
Hello all,
I am currently writing model tests in rails 4. I am attempting to add an
error to a reservation object if the total number of reservations for a
given date and time has reached a pre-determined limit.
When my test runs, it is hitting the appropriate code but it is raising the
following error as opposed to just giving me an error in the object that I
can use.
2006 Jul 06
0
problema con i test automatizzati
ciao a tutti.
come al solito, sto andando avanti a piccoli passi nel creare
l''applicazione depot del libro "Sviluppare Applicazioni Web con Rails".
Ora mi trovo nella fase di creazione dei test automatizzati.
Ma c''è una cosa che proprio non capisco:
Ho la seguente classe in ~/depot/test/unit/product_test.rb
require File.dirname(__FILE__) +