search for: test_destroy

Displaying 14 results from an estimated 14 matches for "test_destroy".

2006 Feb 21
0
DB not being repopulated prior to Unit test execution
...;'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 find Product with ID=1". When I run product_test.rb without the test_destroy test case, the other two methods (test_create & test_update) find that record fine. When I add the test_destroy case in, though, it appears that the database isn''t being cleaned and restored before the test_update method is executed (which appears in this case to happen after the te...
2008 May 28
2
functional testing joins table problem
..., :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... test_destroy(FacilitiesControllerTest): NameError: uninitialized constant Facility::FacilitiesService /usr/lib/ruby/gems/1.8/gems/activesupport-1.4.4/lib/active_support/dependencies.rb:477:in `const_missing'' (eval):1:in `configure_dependency_for_has_many'' Is this because the Model for...
2006 Feb 01
3
Test data life cycle confusion
...first: id: 1 published: 1 publish_on: 2006-01-24 14:50:30 articles_controller_test.rb: <snip> def test_edit get :edit, :id => 1, :version_id => 1 assert_response :success assert_template ''edit'' assert_not_nil assigns(:article) assert assigns(:article).valid? end def test_destroy assert_not_nil Article.find(1) post :destroy, :id => 1 assert_response :redirect assert_redirected_to :action => ''list'' assert_raise(ActiveRecord::RecordNotFound) { Article.find(1) } end And finally, the error that''s being thrown when this is run: 1) Error: test_...
2005 Dec 22
1
How to write unit tests with respect to model callbacks?
...lasto_client).description, @client.description @client.description = "TEST UPDATE DESCRIPTION" assert @client.save, @client.errors.full_messages.join("; ") @client.reload assert_equal "TEST UPDATE DESCRIPTION", @client.description end def test_destroy @client.destroy assert_raise(ActiveRecord::RecordNotFound) { Client.find(@client.id) } end end larik@somehost $ ruby test/unit/client_test.rb Loaded suite test/unit/client_test Started .EE Finished in 0.577375 seconds. 1) Error: test_destroy(ClientTest): NoMethodError: You have a...
2006 May 05
7
Testing model: test becomes dependent on previous test
...al 59.95, @product.price end end ============================================================ it reports an error (<29.95> expected but was <99.95>)) in test_update2. it seems test_update2 becomes dependent on the previous test, which it should not. if i add new test methods (such as test_destroy, test_validate,...), they also become dependent on previous tests. but the book says "...the database is put back to its default state before the next test method is run." so how do i correct this? -- Posted via http://www.ruby-forum.com/.
2009 May 18
0
[PATCH server] fixed functional tests after recent controller refactoring and managed node controller fixes.
...=> 'show', :id => @host_id - - assert_not_nil assigns(:host) - assert assigns(:host).valid? - end - - def test_update - post :update, :id => @host_id - assert_response :redirect - assert_redirected_to :action => 'show', :id => @host_id - end - - def test_destroy - #FIXME: this controller method does nothing, do we even need it or a test? - post :destroy, :id => @host_id - assert_response :redirect - assert_redirected_to :action => 'show', :id => @host_id - end - def test_disable_host post :host_action, :action_type =&g...
2006 May 03
1
Test not Reseting
...= @chris_logged_in.try_to_login @sherri = User.find(2) @delete_victim = User.find(4) end # Replace this with your real tests. def test_truth assert_kind_of User, @chris_logged_in assert_kind_of User, @sherri assert_kind_of User, @investor end def test_destroy @delete_victim.destroy assert_raise(ActiveRecord::RecordNotFound){User.find(@delete_victim.id)} end def test_create_user @tom_lawyer = User.new @tom_lawyer.username = "tlawyer" @tom_lawyer.password = "i<3lawyers" @tom_lawyer.email...
2006 Mar 08
0
Unit tests dynamic finders
...in testing. questions.yml: first_question: id: 1 question: "Will fixture files work?" answer: "No" answers.yml: first_answer: id: 1 question_id: 1 question_test.rb: class QuestionTest < Test::Unit::TestCase fixtures :categories, :questions, :answers def test_destroy question = questions(:first) id = question.id question.destroy assert_raise(ActiveRecord::RecordNotFound) {Question.find(1)} assert_raise(ActiveRecord::RecordNotFound) {Answer.find(1)} assert_raise(ActiveRecord::RecordNotFound) {Answer.find_by_questi...
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??...
2006 Mar 20
2
Testing Models And Fixtures
...ype_cast end def test_update_title assert_equal "Title", @post.title @post.title = "New Title" assert @post.save, @post.errors.full_messages.join("; ") @post.reload assert_equal "New Title", @post.title end def test_destroy @post.destroy assert_raise(ActiveRecord::RecordNotFound) { Post.find(@post.id) } end end =========== Error Message =========== ... test_create(PostTest) [test/unit/post_test.rb:11]: <nil> expected to be kind_of? <Post> but was <NilClass>. =========== The basic_pos...
2005 Dec 20
0
Problem destroying in unit tests with HABTM
...iverecord-1.13.1/lib/active_record/transactions.rb:118:in `transactio c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/transactions.rb:122:in `destroy'' I have a category table an asset table and an assets_categories table My destroy unit tests looks like this: def test_destroy #check to ensure asset belongs to categories assert_equal false, @intl_image.categories.empty? @intl_image.categories.clear #check to ensure the asset now belongs to no categories assert_equal true, @intl_image.categories.empty? @intl_image.save @intl_image.reload @im...
2006 Jul 06
0
problema con i test automatizzati
...ilable_before_type_cast   end     def test_update         assert_equal 29.95, @product.prezzo         @product.prezzo = 99.99         assert @product.save, @product.errors.full_messages.join("; ")         @product.reload         assert_equal 99.99, @product.prezzo     end     def test_destroy         @product.destroy     end     def test_validate         assert_equal 29.95, @product.prezzo         @product.prezzo = 0.00         assert !@product.save         assert_equal 1, @product.errors.count         assert_equal "deve essere positivo", @product.errors.on(:prezzo)  ...
2006 Apr 21
2
destory Test Case Messes up all tests
..._user.errors.full_messages.join("; ") @first_user.reload assert_equal "Gavin", @first_user.firstname assert_equal "Steenkamp", @first_user.surname assert_equal "test@glasshouse.co.za", @first_user.email end # Test deleting of user def test_destroy @first_user.destroy assert_raise(ActiveRecord::RecordNotFound) {User.find(@first_user.id)} end end Here is the model : require "digest/sha1" class User < ActiveRecord::Base has_many :tasks has_many :assigned_tasks attr_accessor :password validates_presence_of...
2006 Feb 06
9
tests fine, but fail under rake
Hi there, So I have an odd error at the moment that only occurs when I run tests via rake. It''s happening with two tests now. Under a simple ruby run, the tests are fine, e.g.: D:\User\Code\ruby\prometheus>ruby test\functional\story_comments_controller_test .rb Loaded suite test/functional/story_comments_controller_test Started ......... Finished in 2.37 seconds. 9 tests, 65