summaryrefslogtreecommitdiff
path: root/test/test_helper.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-06-24 04:13:16 +0200
committererdgeist <erdgeist@erdgeist.org>2026-06-24 04:13:16 +0200
commite0a7e0fec760ba12c8067a37e10c96f1f05876e2 (patch)
treed0cf745592a46aee4d4913911fd34c7c24515220 /test/test_helper.rb
parent6424e10be5a89f175a74c71c55660412a169b8b8 (diff)
Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade
- Converted plugins to gems (Gemfile) - Updated config structure (application.rb, boot.rb, environment.rb) - Converted routes to Rails 3 DSL - Converted named_scope to scope throughout models - Converted find(:all, :conditions) to where() chains - Fixed has_many :order to use ordering scope - Updated session store and secret token configuration - Fixed exception_notification middleware configuration - Patched Ruby 2.4 / Rails 3.2 incompatibilities: - Integer/Float duration arithmetic (ActiveSupport) - Arel visit_Integer for PostgreSQL adapter - create_database String/Integer coercion - ActionController consider_all_requests_local - Migrated taggings schema for acts-as-taggable-on - Replaced dynamic_form gem with custom form_error_messages helper - Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for) - Fixed admin layout yield - Updated test suite for Rails 3 APIs
Diffstat (limited to 'test/test_helper.rb')
-rw-r--r--test/test_helper.rb84
1 files changed, 83 insertions, 1 deletions
diff --git a/test/test_helper.rb b/test/test_helper.rb
index cda54bc..27e1f0d 100644
--- a/test/test_helper.rb
+++ b/test/test_helper.rb
@@ -1,6 +1,88 @@
1ENV["RAILS_ENV"] = "test" 1ENV["RAILS_ENV"] = "test"
2require File.expand_path(File.dirname(__FILE__) + "/../config/environment") 2require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3require 'test_help' 3require 'rails/test_help'
4
5module ActiveRecord
6 class Fixtures
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
18end
19
20class Integer
21 def days
22 ActiveSupport::Duration.new(self * 86400, [[:days, self]])
23 end
24 alias :day :days
25
26 def weeks
27 ActiveSupport::Duration.new(self * 7 * 86400, [[:days, self * 7]])
28 end
29 alias :week :weeks
30
31 def hours
32 ActiveSupport::Duration.new(self * 3600, [[:seconds, self * 3600]])
33 end
34 alias :hour :hours
35
36 def minutes
37 ActiveSupport::Duration.new(self * 60, [[:seconds, self * 60]])
38 end
39 alias :minute :minutes
40
41 def seconds
42 ActiveSupport::Duration.new(self, [[:seconds, self]])
43 end
44 alias :second :seconds
45
46 def months
47 ActiveSupport::Duration.new(self * 30 * 86400, [[:months, self]])
48 end
49 alias :month :months
50
51 def years
52 ActiveSupport::Duration.new((self * 365.25 * 86400).to_i, [[:years, self]])
53 end
54 alias :year :years
55end
56
57class Float
58 def days
59 ActiveSupport::Duration.new((self * 86400).to_i, [[:days, self]])
60 end
61 alias :day :days
62
63 def hours
64 ActiveSupport::Duration.new((self * 3600).to_i, [[:seconds, (self * 3600).to_i]])
65 end
66 alias :hour :hours
67
68 def minutes
69 ActiveSupport::Duration.new((self * 60).to_i, [[:seconds, (self * 60).to_i]])
70 end
71 alias :minute :minutes
72end
73
74require 'arel'
75module Arel
76 module Visitors
77 [ToSql, DepthFirst].each do |visitor|
78 visitor.class_eval do
79 def visit_Integer(o, collector = nil)
80 collector ? collector << o.to_s : o.to_s
81 end
82 end
83 end
84 end
85end
4 86
5class ActiveSupport::TestCase 87class ActiveSupport::TestCase
6 88