diff options
Diffstat (limited to 'test/test_helper.rb')
| -rw-r--r-- | test/test_helper.rb | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb index cda54bc..c494c68 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb | |||
| @@ -1,6 +1,21 @@ | |||
| 1 | ENV["RAILS_ENV"] = "test" | 1 | ENV["RAILS_ENV"] = "test" |
| 2 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment") | 2 | require File.expand_path(File.dirname(__FILE__) + "/../config/environment") |
| 3 | require 'test_help' | 3 | require 'rails/test_help' |
| 4 | |||
| 5 | module ActiveRecord | ||
| 6 | class FixtureSet | ||
| 7 | class << self | ||
| 8 | alias_method :original_create_fixtures, :create_fixtures | ||
| 9 | def create_fixtures(*args) | ||
| 10 | original_create_fixtures(*args) | ||
| 11 | rescue => e | ||
| 12 | puts "\nFIXTURE ERROR: #{e.class}: #{e.message}" | ||
| 13 | puts e.backtrace.first(20).join("\n") | ||
| 14 | raise | ||
| 15 | end | ||
| 16 | end | ||
| 17 | end | ||
| 18 | end | ||
| 4 | 19 | ||
| 5 | class ActiveSupport::TestCase | 20 | class ActiveSupport::TestCase |
| 6 | 21 | ||
| @@ -22,14 +37,7 @@ class ActiveSupport::TestCase | |||
| 22 | # The only drawback to using transactional fixtures is when you actually | 37 | # The only drawback to using transactional fixtures is when you actually |
| 23 | # need to test transactions. Since your test is bracketed by a transaction, | 38 | # need to test transactions. Since your test is bracketed by a transaction, |
| 24 | # any transactions started in your code will be automatically rolled back. | 39 | # any transactions started in your code will be automatically rolled back. |
| 25 | self.use_transactional_fixtures = true | 40 | self.use_transactional_tests = true |
| 26 | |||
| 27 | # Instantiated fixtures are slow, but give you @david where otherwise you | ||
| 28 | # would need people(:david). If you don't want to migrate your existing | ||
| 29 | # test cases which use the @david style and don't mind the speed hit (each | ||
| 30 | # instantiated fixtures translates to a database query per test method), | ||
| 31 | # then set this back to true. | ||
| 32 | self.use_instantiated_fixtures = false | ||
| 33 | 41 | ||
| 34 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. | 42 | # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. |
| 35 | # | 43 | # |
| @@ -38,7 +46,11 @@ class ActiveSupport::TestCase | |||
| 38 | fixtures :all | 46 | fixtures :all |
| 39 | 47 | ||
| 40 | # Add more helper methods to be used by all tests here... | 48 | # Add more helper methods to be used by all tests here... |
| 41 | 49 | ||
| 50 | setup do | ||
| 51 | I18n.locale = I18n.default_locale | ||
| 52 | end | ||
| 53 | |||
| 42 | def create_node_with_published_page | 54 | def create_node_with_published_page |
| 43 | node = create_node_with_draft | 55 | node = create_node_with_draft |
| 44 | draft = node.draft | 56 | draft = node.draft |
| @@ -51,6 +63,8 @@ class ActiveSupport::TestCase | |||
| 51 | end | 63 | end |
| 52 | 64 | ||
| 53 | def create_node_with_draft | 65 | def create_node_with_draft |
| 54 | Node.root.children.create :slug => "test_node" | 66 | node = Node.root.children.create! :slug => "test_node" |
| 67 | node.reload | ||
| 68 | node | ||
| 55 | end | 69 | end |
| 56 | end | 70 | end |
