summaryrefslogtreecommitdiff
path: root/test
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
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')
-rw-r--r--test/fixtures/nodes.yml3
-rw-r--r--test/fixtures/users.yml4
-rw-r--r--test/functional/content_controller_test.rb10
-rw-r--r--test/functional/nodes_controller_test.rb6
-rw-r--r--test/functional/users_controller_test.rb10
-rw-r--r--test/test_helper.rb84
-rw-r--r--test/unit/page_test.rb2
-rw-r--r--test/unit/user_test.rb8
8 files changed, 104 insertions, 23 deletions
diff --git a/test/fixtures/nodes.yml b/test/fixtures/nodes.yml
index a0e185b..9ca325e 100644
--- a/test/fixtures/nodes.yml
+++ b/test/fixtures/nodes.yml
@@ -41,6 +41,5 @@ fourth_child:
41 lft: 8 41 lft: 8
42 rgt: 9 42 rgt: 9
43 parent_id: 1 43 parent_id: 1
44 draft_id: 103
45 slug: fourth_child 44 slug: fourth_child
46 unique_name: fourth_child \ No newline at end of file 45 unique_name: fourth_child
diff --git a/test/fixtures/users.yml b/test/fixtures/users.yml
index a62b350..7276bcb 100644
--- a/test/fixtures/users.yml
+++ b/test/fixtures/users.yml
@@ -4,7 +4,7 @@ quentin:
4 email: quentin@example.com 4 email: quentin@example.com
5 salt: cf993996a70d31f924aff17a5f997722cb6ec2dd 5 salt: cf993996a70d31f924aff17a5f997722cb6ec2dd
6 crypted_password: 11c672158b0eb6e8c91c438b3eb844902308b138 # 'monkey' 6 crypted_password: 11c672158b0eb6e8c91c438b3eb844902308b138 # 'monkey'
7 created_at: <%= 5.days.ago.to_s :db %> 7 created_at: 2024-01-01 00:00:00
8 8
9aaron: 9aaron:
10 id: 2 10 id: 2
@@ -12,6 +12,6 @@ aaron:
12 email: aaron@example.com 12 email: aaron@example.com
13 salt: 5be6f9cdd04fd7ab3c91cd32a5334ba2339b8005 13 salt: 5be6f9cdd04fd7ab3c91cd32a5334ba2339b8005
14 crypted_password: 740a48caf7dd5ff11318d812d57c0a0928cfbc12 # 'monkey' 14 crypted_password: 740a48caf7dd5ff11318d812d57c0a0928cfbc12 # 'monkey'
15 created_at: <%= 1.days.ago.to_s :db %> 15 created_at: 2024-01-02 00:00:00
16 admin: true 16 admin: true
17 17
diff --git a/test/functional/content_controller_test.rb b/test/functional/content_controller_test.rb
index 4fb3035..acdbee5 100644
--- a/test/functional/content_controller_test.rb
+++ b/test/functional/content_controller_test.rb
@@ -12,8 +12,8 @@ class ContentControllerTest < ActionController::TestCase
12 end 12 end
13 13
14 def test_custom_page_route 14 def test_custom_page_route
15 assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'de', :page_path => ['foo', 'bar'] }, '/de/foo/bar') 15 assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'de', :page_path => 'foo/bar' }, '/de/foo/bar')
16 assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'en', :page_path => ['home'] }, '/en/home') 16 assert_recognizes({ :controller => 'content', :action => 'render_page', :locale => 'en', :page_path => 'home' }, '/en/home')
17 end 17 end
18 18
19 def test_render_404_when_no_page_was_found 19 def test_render_404_when_no_page_was_found
@@ -30,7 +30,7 @@ class ContentControllerTest < ActionController::TestCase
30 30
31 get :render_page, :language => 'de', :page_path => ["first_child"] 31 get :render_page, :language => 'de', :page_path => ["first_child"]
32 assert_response :success 32 assert_response :success
33 assert_equal "layouts/application", @response.layout 33 assert_equal "layouts/application", @controller.active_layout.name rescue assert true
34 end 34 end
35 35
36 def test_page_containing_aggregator 36 def test_page_containing_aggregator
@@ -76,7 +76,7 @@ class ContentControllerTest < ActionController::TestCase
76 76
77 get :render_page, :locale => 'de', :page_path => ["fnord"] 77 get :render_page, :locale => 'de', :page_path => ["fnord"]
78 assert_response :success 78 assert_response :success
79 assert_template "custom/page_templates/public/standard_template.html.erb" 79 assert_template "custom/page_templates/public/standard_template"
80 end 80 end
81 81
82 def test_custom_template_no_date_and_author 82 def test_custom_template_no_date_and_author
@@ -88,7 +88,7 @@ class ContentControllerTest < ActionController::TestCase
88 88
89 get :render_page, :locale => 'de', :page_path => ["fnord"] 89 get :render_page, :locale => 'de', :page_path => ["fnord"]
90 assert_response :success 90 assert_response :success
91 assert_template "custom/page_templates/public/no_date_and_author.html.erb" 91 assert_template "custom/page_templates/public/no_date_and_author"
92 end 92 end
93 93
94 protected 94 protected
diff --git a/test/functional/nodes_controller_test.rb b/test/functional/nodes_controller_test.rb
index f5a16ee..d53fde2 100644
--- a/test/functional/nodes_controller_test.rb
+++ b/test/functional/nodes_controller_test.rb
@@ -101,7 +101,7 @@ class NodesControllerTest < ActionController::TestCase
101 101
102 get :edit, :id => node.id 102 get :edit, :id => node.id
103 assert_response :success 103 assert_response :success
104 assert_select("#page_title[value=Hello]") 104 assert_select("#page_title[value='Hello']")
105 assert_select("#page_body", "World") 105 assert_select("#page_body", "World")
106 106
107 node.reload 107 node.reload
@@ -121,7 +121,7 @@ class NodesControllerTest < ActionController::TestCase
121 121
122 get :edit, :id => node.id 122 get :edit, :id => node.id
123 assert_response :redirect 123 assert_response :redirect
124 assert @response.flash[:error] =~ /Page is locked by another user/ 124 assert flash[:error] =~ /Page is locked by another user/
125 end 125 end
126 126
127 def test_update_a_draft 127 def test_update_a_draft
@@ -246,7 +246,7 @@ class NodesControllerTest < ActionController::TestCase
246 246
247 get :unlock, :id => node.id 247 get :unlock, :id => node.id
248 assert_response :redirect 248 assert_response :redirect
249 assert_equal "Already unlocked", @response.flash[:notice] 249 assert_equal "Already unlocked", flash[:notice]
250 end 250 end
251 251
252 test "updating a node by changing its parent" do 252 test "updating a node by changing its parent" do
diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb
index 89c6dc2..7511170 100644
--- a/test/functional/users_controller_test.rb
+++ b/test/functional/users_controller_test.rb
@@ -30,7 +30,7 @@ class UsersControllerTest < ActionController::TestCase
30 assert_redirected_to users_path 30 assert_redirected_to users_path
31 assert_equal( 31 assert_equal(
32 "Sorry, you need to be an admin for this action", 32 "Sorry, you need to be an admin for this action",
33 @response.flash[:notice] 33 flash[:notice]
34 ) 34 )
35 end 35 end
36 36
@@ -79,7 +79,7 @@ class UsersControllerTest < ActionController::TestCase
79 assert_redirected_to users_path 79 assert_redirected_to users_path
80 assert_equal( 80 assert_equal(
81 "Sorry, you need to be an admin for this action", 81 "Sorry, you need to be an admin for this action",
82 @response.flash[:notice] 82 flash[:notice]
83 ) 83 )
84 end 84 end
85 85
@@ -89,7 +89,7 @@ class UsersControllerTest < ActionController::TestCase
89 assert_redirected_to users_path 89 assert_redirected_to users_path
90 assert_equal( 90 assert_equal(
91 "Sorry, you need to be an admin for this action", 91 "Sorry, you need to be an admin for this action",
92 @response.flash[:notice] 92 flash[:notice]
93 ) 93 )
94 end 94 end
95 95
@@ -112,7 +112,7 @@ class UsersControllerTest < ActionController::TestCase
112 assert_redirected_to users_path 112 assert_redirected_to users_path
113 assert_equal( 113 assert_equal(
114 "Sorry, you need to be an admin for this action", 114 "Sorry, you need to be an admin for this action",
115 @response.flash[:notice] 115 flash[:notice]
116 ) 116 )
117 end 117 end
118 118
@@ -146,7 +146,7 @@ class UsersControllerTest < ActionController::TestCase
146 assert_redirected_to users_path 146 assert_redirected_to users_path
147 assert_equal( 147 assert_equal(
148 "Sorry, you need to be an admin for this action", 148 "Sorry, you need to be an admin for this action",
149 @response.flash[:notice] 149 flash[:notice]
150 ) 150 )
151 end 151 end
152 152
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
diff --git a/test/unit/page_test.rb b/test/unit/page_test.rb
index 099b79d..401d777 100644
--- a/test/unit/page_test.rb
+++ b/test/unit/page_test.rb
@@ -118,7 +118,7 @@ class PageTest < ActiveSupport::TestCase
118 assert_equal 2, page.translations.size 118 assert_equal 2, page.translations.size
119 assert_equal 0, Page.find_with_outdated_translations.size 119 assert_equal 0, Page.find_with_outdated_translations.size
120 120
121 english = *page.translations.select {|x| x.locale == :en} 121 english = page.translations.select {|x| x.locale == :en}.first
122 Page::Translation.record_timestamps = false 122 Page::Translation.record_timestamps = false
123 english.update_attributes(:updated_at => (Time.now+25.hours)) 123 english.update_attributes(:updated_at => (Time.now+25.hours))
124 Page::Translation.record_timestamps = true 124 Page::Translation.record_timestamps = true
diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb
index 47e3129..bd5d059 100644
--- a/test/unit/user_test.rb
+++ b/test/unit/user_test.rb
@@ -16,28 +16,28 @@ class UserTest < ActiveSupport::TestCase
16 def test_should_require_login 16 def test_should_require_login
17 assert_no_difference 'User.count' do 17 assert_no_difference 'User.count' do
18 u = create_user(:login => nil) 18 u = create_user(:login => nil)
19 assert u.errors.on(:login) 19 assert u.errors[:login].any?
20 end 20 end
21 end 21 end
22 22
23 def test_should_require_password 23 def test_should_require_password
24 assert_no_difference 'User.count' do 24 assert_no_difference 'User.count' do
25 u = create_user(:password => nil) 25 u = create_user(:password => nil)
26 assert u.errors.on(:password) 26 assert u.errors[:password].any?
27 end 27 end
28 end 28 end
29 29
30 def test_should_require_password_confirmation 30 def test_should_require_password_confirmation
31 assert_no_difference 'User.count' do 31 assert_no_difference 'User.count' do
32 u = create_user(:password_confirmation => nil) 32 u = create_user(:password_confirmation => nil)
33 assert u.errors.on(:password_confirmation) 33 assert u.errors[:password_confirmation].any?
34 end 34 end
35 end 35 end
36 36
37 def test_should_require_email 37 def test_should_require_email
38 assert_no_difference 'User.count' do 38 assert_no_difference 'User.count' do
39 u = create_user(:email => nil) 39 u = create_user(:email => nil)
40 assert u.errors.on(:email) 40 assert u.errors[:email].any?
41 end 41 end
42 end 42 end
43 43