Displaying 20 results from an estimated 200 matches similar to: "Problem destroying in unit tests with HABTM"
2006 Jul 31
0
Issues with has_many, belongs_to and dependency settings
I have 2 models SmsAddress & OutboundSmsAtom
SmsAddress {
has_many :other_objects, :dependency => :nullify
}
OutboundSmsAtom {
#note this object also "belongs_to" other objects if that matters
belongs_to :this_object
}
Whenever I try to destroy an object of type ThisObject, which at the time
has 0 "children" OtherObjects I get the following type of
2006 Feb 01
3
Test data life cycle confusion
Hi,
It states on page 140 of Agile Web Development with Rails:
Here?s the bottom line: even if a test method updates the test database,
the database is put back to its default state before the next test method is
run. This is important because we don?t want tests to become dependent
on the results of previous tests.
Well, I''ve been running into a brick wall with some functional tests
2005 Dec 22
1
How to write unit tests with respect to model callbacks?
Hello,
I am exploring the "Testing" part of Rails, but It seems some things
work differently than I thought it would.
Consider the following model:
class Client < ActiveRecord::Base
has_one :project
def after_create
Project.new(:name => self.name, :is_client => true, :client_id
=> self.id).save
end
def after_update
2006 Mar 29
0
Intermittent error - undefined method ''destroy_without_callbacks''
When testing my app locally I''m getting intermittent errors which are
driving me mad!
The error is:
NameError ((eval):1:in `alias_method'': undefined method
`destroy_without_callbacks'' for class `Exercise''):
Refreshing the browser sometimes fixes it, as does restarting WEBrick.
Annoying to debug as it only happens intermittently.
Any ideas on why this is
2006 Feb 21
0
DB not being repopulated prior to Unit test execution
I''m working my way through the AWD book and have just started the testing chapter. The first two unit tests run as expected. When I add the test for the ''destroy'' function to product_test.rb, however, I''m getting a failure I don''t understand.
The error I''m getting says that in the setup method for test_update, it "couldn''t
2006 Mar 08
0
Unit tests dynamic finders
Hi all,
I am having a problem with unit tests. Whenever I have a dependency
between two models (B depends on A) deleting A should also delete B.
This is simple with the dependent parameter in the model file of A. But
when I write a test the dependency seems to work, I can''t find the
answer with id 1 anymore(Answer.find(1)). But I appearently _do_ find it
with
2005 Dec 31
6
habtm recursion via destroy_without_callbacks
I am having a problem with two models that each have a HABTM
relationship to the other. For example:
CREATE TABLE people (id INT, name TEXT);
CREATE TABLE teams (id INT, name TEXT);
CREATE TABLE people_teams (person_id INT, team_id INT);
The person model has:
has_and_belongs_to_many :teams
And the team model has:
has_and_belongs_to_many :people
The trouble comes when trying to destroy
2006 May 03
1
Test not Reseting
My test are not resetting for each method in the test class.
It was promised to me on page 146 of Agile Web Development on Rails that
it would.
Am I doing something wrong? The "@delete_victim = User.find(4)" bust
the setup class each time it comes around, even though that is in my
users.yml
class UserTest < Test::Unit::TestCase
fixtures :users
def setup
2006 Mar 20
2
Testing Models And Fixtures
I have finally decided to look into testing and I am going through
the examples in the AWDWR book and I tried the following and it does
not work... even though I don''t see why it shouldn''t.
===========
posts.yml
===========
basic_post:
id: 1
title: Title
body: Body
created_at: 2006-02-01 00:00:00
updated_at: 2006_02-02 00:00:00
2008 May 28
2
functional testing joins table problem
I have models/controllers
Class Facility
has_many :facilities_services, :dependent => :delete_all
Class Service
has_many :facilities_services, :dependent => :delete_all
Class FacilitiesServices
belongs_to :facility
belongs_to :service
so in my test/functional/facilities_controller_test.rb, I have
post :destroy, :id => 5
which tosses an error...
2006 Apr 21
2
destory Test Case Messes up all tests
I am trying to create unit tests for my users model but when I add a
test that destroys a user, that user is not available in any of the
other test. If I remove the test that destroys the user all my other
tests work again.
All the fixtures are suppose be reloaded between tests right?
Here is my testcase :
require File.dirname(__FILE__) + ''/../test_helper''
class UserTest
2006 Mar 31
1
Active Record: subclassing a model
Hi there,
I have a model
class Account < ActiveRecord::Base
has_many: projects
The accounts table holds company information so as I created another
model to represent project partners thus:
class Partner < Account
has_and_belongs_to_many :projects
#project.account pulls up the project owner and #project.partners pulls
up all partners, including the owner.
Now, this all seems to
2006 May 05
7
Testing model: test becomes dependent on previous test
Im having trouble with Testing models. im following the tutorials in the
book Agile Web Development with Rails. if i execute the code
product_test.rb, i get this error:
============================================================
1) Failure:
test_update2(ProductTest) [test/unit/product_test.rb:30]:
<29.95> expected but was
<99.95>.
3 tests, 11 assertions, 1 failures, 0 errors
2009 May 18
0
[PATCH server] fixed functional tests after recent controller refactoring and managed node controller fixes.
Signed-off-by: Scott Seago <sseago at redhat.com>
---
src/test/functional/host_controller_test.rb | 41 --------------------
.../functional/managed_node_configuration_test.rb | 14 ++++---
src/test/functional/nic_controller_test.rb | 8 ----
src/test/functional/permission_controller_test.rb | 15 ++++---
src/test/functional/quota_controller_test.rb | 2 +-
2006 Mar 17
0
unit_tests and deleting from the database
I get errors when running rake test_units:
test_destroy(LocationTest):
ActiveRecord::StatementInvalid: Mysql::Error: #23000Cannot delete or
update a pa
rent row: a foreign key constraint fails (`overblijf_tst/groups`,
CONSTRAINT `fk
_groups_locations` FOREIGN KEY (`location_id`) REFERENCES `locations`
(`id`)): D
ELETE FROM locations
Any pointers??
--
Posted via http://www.ruby-forum.com/.
2007 Jun 01
0
"Exception: stack level too deep" on collection.clear?
Without getting too deep into my app I''m wondering if anyone has any
clues what might give rise to the error posted below. It occurs when
I run my unit tests.
class Actor < AR:Base
belongs_to :court_case
end
class CaseCause < AR:Base
belongs_to :court_case
end
class CourtCase < AR:Base
has_many :actors
has_many :case_causes
...
end
def my_test_method
...
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__) +
2007 Mar 01
1
ActiveRecord::StatementInvalid error
When I try to run my webserver in the production environment I just
get an application error message. This is all I can find in the log:
ActiveRecord::StatementInvalid
/usr/lib/ruby/gems/1.8/gems/activerecord-1.15.1/lib/active_record/
connection_adapters/sqlite_adapter.rb:274:in `table_structure''
/usr/lib/ruby/gems/1.8/gems/activesupport-1.4.0/lib/active_support/
2007 Oct 29
2
error message after upgrading to Gusty Gibbon Ubuntu
I have started to get the error message "wrong number of arguments (1
for 0)" since I upgraded to Gusty Gibbon.
I am new to ROR so I have no clue.
This is the code that was running
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = ''User was successfully created.''
redirect_to :action => ''list''
else
2007 Jan 22
0
rail 1.2.1: Fireruby exception with firebird
Rubyonrails application which was working fine with rails 1.1.6,
fireruby and firebird 1.5.3 does not work with rails 1.2.1. The error
is reproduced below. Could not get over this problem. Any help coming
through? Thanks in advance.
ActiveRecord::StatementInvalid in
TimekeeperadminController#authenticate
FireRuby::FireRubyException: Error preparing a SQL statement.
Dynamic SQL Error
SQL error