| 1 |
Index: actionmailer/test/mail_service_test.rb |
|---|
| 2 |
=================================================================== |
|---|
| 3 |
--- actionmailer/test/mail_service_test.rb (revision 1873) |
|---|
| 4 |
+++ actionmailer/test/mail_service_test.rb (working copy) |
|---|
| 5 |
@@ -18,8 +18,11 @@ |
|---|
| 6 |
end |
|---|
| 7 |
|
|---|
| 8 |
class Net::SMTP |
|---|
| 9 |
- def self.start(*args) |
|---|
| 10 |
- yield MockSMTP.new |
|---|
| 11 |
+ class << self |
|---|
| 12 |
+ alias old_start start |
|---|
| 13 |
+ def start(*args) |
|---|
| 14 |
+ yield MockSMTP.new |
|---|
| 15 |
+ end |
|---|
| 16 |
end |
|---|
| 17 |
end |
|---|
| 18 |
|
|---|
| 19 |
Index: actionmailer/Rakefile |
|---|
| 20 |
=================================================================== |
|---|
| 21 |
--- actionmailer/Rakefile (revision 1873) |
|---|
| 22 |
+++ actionmailer/Rakefile (working copy) |
|---|
| 23 |
@@ -24,6 +24,7 @@ |
|---|
| 24 |
t.libs << "test" |
|---|
| 25 |
t.pattern = 'test/*_test.rb' |
|---|
| 26 |
t.verbose = true |
|---|
| 27 |
+ t.warning = true |
|---|
| 28 |
} |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
@@ -194,4 +195,4 @@ |
|---|
| 32 |
first_file = false |
|---|
| 33 |
end |
|---|
| 34 |
end |
|---|
| 35 |
-end |
|---|
| 36 |
\ No newline at end of file |
|---|
| 37 |
+end |
|---|
| 38 |
Index: actionmailer/lib/action_mailer/adv_attr_accessor.rb |
|---|
| 39 |
=================================================================== |
|---|
| 40 |
--- actionmailer/lib/action_mailer/adv_attr_accessor.rb (revision 1873) |
|---|
| 41 |
+++ actionmailer/lib/action_mailer/adv_attr_accessor.rb (working copy) |
|---|
| 42 |
@@ -26,31 +26,3 @@ |
|---|
| 43 |
end |
|---|
| 44 |
end |
|---|
| 45 |
|
|---|
| 46 |
-module ActionMailer |
|---|
| 47 |
- module AdvAttrAccessor #:nodoc: |
|---|
| 48 |
- def self.append_features(base) |
|---|
| 49 |
- super |
|---|
| 50 |
- base.extend(ClassMethods) |
|---|
| 51 |
- end |
|---|
| 52 |
- |
|---|
| 53 |
- module ClassMethods #:nodoc: |
|---|
| 54 |
- def adv_attr_accessor(*names) |
|---|
| 55 |
- names.each do |name| |
|---|
| 56 |
- define_method("#{name}=") do |value| |
|---|
| 57 |
- instance_variable_set("@#{name}", value) |
|---|
| 58 |
- end |
|---|
| 59 |
- |
|---|
| 60 |
- define_method(name) do |*parameters| |
|---|
| 61 |
- raise ArgumentError, "expected 0 or 1 parameters" unless parameters.length <= 1 |
|---|
| 62 |
- if parameters.empty? |
|---|
| 63 |
- instance_variable_get("@#{name}") |
|---|
| 64 |
- else |
|---|
| 65 |
- instance_variable_set("@#{name}", parameters.first) |
|---|
| 66 |
- end |
|---|
| 67 |
- end |
|---|
| 68 |
- end |
|---|
| 69 |
- end |
|---|
| 70 |
- |
|---|
| 71 |
- end |
|---|
| 72 |
- end |
|---|
| 73 |
-end |
|---|
| 74 |
Index: actionmailer/lib/action_mailer/quoting.rb |
|---|
| 75 |
=================================================================== |
|---|
| 76 |
--- actionmailer/lib/action_mailer/quoting.rb (revision 1873) |
|---|
| 77 |
+++ actionmailer/lib/action_mailer/quoting.rb (working copy) |
|---|
| 78 |
@@ -46,54 +46,3 @@ |
|---|
| 79 |
end |
|---|
| 80 |
end |
|---|
| 81 |
end |
|---|
| 82 |
- |
|---|
| 83 |
-module ActionMailer |
|---|
| 84 |
- module Quoting #:nodoc: |
|---|
| 85 |
- # Convert the given text into quoted printable format, with an instruction |
|---|
| 86 |
- # that the text be eventually interpreted in the given charset. |
|---|
| 87 |
- def quoted_printable(text, charset) |
|---|
| 88 |
- text = text.gsub( /[^a-z ]/i ) { "=%02x" % $&[0] }.gsub( / /, "_" ) |
|---|
| 89 |
- "=?#{charset}?Q?#{text}?=" |
|---|
| 90 |
- end |
|---|
| 91 |
- |
|---|
| 92 |
- # A quick-and-dirty regexp for determining whether a string contains any |
|---|
| 93 |
- # characters that need escaping. |
|---|
| 94 |
- if !defined?(CHARS_NEEDING_QUOTING) |
|---|
| 95 |
- CHARS_NEEDING_QUOTING = /[\000-\011\013\014\016-\037\177-\377]/ |
|---|
| 96 |
- end |
|---|
| 97 |
- |
|---|
| 98 |
- # Quote the given text if it contains any "illegal" characters |
|---|
| 99 |
- def quote_if_necessary(text, charset) |
|---|
| 100 |
- (text =~ CHARS_NEEDING_QUOTING) ? |
|---|
| 101 |
- quoted_printable(text, charset) : |
|---|
| 102 |
- text |
|---|
| 103 |
- end |
|---|
| 104 |
- |
|---|
| 105 |
- # Quote any of the given strings if they contain any "illegal" characters |
|---|
| 106 |
- def quote_any_if_necessary(charset, *args) |
|---|
| 107 |
- args.map { |v| quote_if_necessary(v, charset) } |
|---|
| 108 |
- end |
|---|
| 109 |
- |
|---|
| 110 |
- # Quote the given address if it needs to be. The address may be a |
|---|
| 111 |
- # regular email address, or it can be a phrase followed by an address in |
|---|
| 112 |
- # brackets. The phrase is the only part that will be quoted, and only if |
|---|
| 113 |
- # it needs to be. This allows extended characters to be used in the |
|---|
| 114 |
- # "to", "from", "cc", and "bcc" headers. |
|---|
| 115 |
- def quote_address_if_necessary(address, charset) |
|---|
| 116 |
- if Array === address |
|---|
| 117 |
- address.map { |a| quote_address_if_necessary(a, charset) } |
|---|
| 118 |
- elsif address =~ /^(\S.*)\s+(<.*>)$/ |
|---|
| 119 |
- address = $2 |
|---|
| 120 |
- phrase = quote_if_necessary($1.gsub(/^['"](.*)['"]$/, '\1'), charset) |
|---|
| 121 |
- "\"#{phrase}\" #{address}" |
|---|
| 122 |
- else |
|---|
| 123 |
- address |
|---|
| 124 |
- end |
|---|
| 125 |
- end |
|---|
| 126 |
- |
|---|
| 127 |
- # Quote any of the given addresses, if they need to be. |
|---|
| 128 |
- def quote_any_address_if_necessary(charset, *args) |
|---|
| 129 |
- args.map { |v| quote_address_if_necessary(v, charset) } |
|---|
| 130 |
- end |
|---|
| 131 |
- end |
|---|
| 132 |
-end |
|---|
| 133 |
Index: actionmailer/lib/action_mailer/vendor/text/format.rb |
|---|
| 134 |
=================================================================== |
|---|
| 135 |
--- actionmailer/lib/action_mailer/vendor/text/format.rb (revision 1873) |
|---|
| 136 |
+++ actionmailer/lib/action_mailer/vendor/text/format.rb (working copy) |
|---|
| 137 |
@@ -831,7 +831,7 @@ |
|---|
| 138 |
|
|---|
| 139 |
def __create(arg = nil, &block) #:nodoc: |
|---|
| 140 |
# Format::Text.new(text-to-wrap) |
|---|
| 141 |
- @text = arg unless arg.nil? |
|---|
| 142 |
+ @text = arg.nil? ? nil : arg |
|---|
| 143 |
# Defaults |
|---|
| 144 |
@columns = 72 |
|---|
| 145 |
@tabstop = 8 |
|---|
| 146 |
Index: actionmailer/lib/action_mailer/vendor/tmail/facade.rb |
|---|
| 147 |
=================================================================== |
|---|
| 148 |
--- actionmailer/lib/action_mailer/vendor/tmail/facade.rb (revision 1873) |
|---|
| 149 |
+++ actionmailer/lib/action_mailer/vendor/tmail/facade.rb (working copy) |
|---|
| 150 |
@@ -464,6 +464,8 @@ |
|---|
| 151 |
### utils |
|---|
| 152 |
### |
|---|
| 153 |
|
|---|
| 154 |
+ alias old_create_reply create_reply |
|---|
| 155 |
+ |
|---|
| 156 |
def create_reply |
|---|
| 157 |
mail = TMail::Mail.parse('') |
|---|
| 158 |
mail.subject = 'Re: ' + subject('').sub(/\A(?:\[[^\]]+\])?(?:\s*Re:)*\s*/i, '') |
|---|
| 159 |
Index: activesupport/test/inflector_test.rb |
|---|
| 160 |
=================================================================== |
|---|
| 161 |
--- activesupport/test/inflector_test.rb (revision 1873) |
|---|
| 162 |
+++ activesupport/test/inflector_test.rb (working copy) |
|---|
| 163 |
@@ -1,5 +1,5 @@ |
|---|
| 164 |
require 'test/unit' |
|---|
| 165 |
-require File.dirname(__FILE__) + '/../lib/active_support/inflector' |
|---|
| 166 |
+require File.dirname(__FILE__) + '/../lib/active_support/inflector' unless defined? Inflector |
|---|
| 167 |
|
|---|
| 168 |
module Ace |
|---|
| 169 |
module Base |
|---|
| 170 |
Index: activesupport/test/core_ext/string_ext_test.rb |
|---|
| 171 |
=================================================================== |
|---|
| 172 |
--- activesupport/test/core_ext/string_ext_test.rb (revision 1873) |
|---|
| 173 |
+++ activesupport/test/core_ext/string_ext_test.rb (working copy) |
|---|
| 174 |
@@ -1,11 +1,8 @@ |
|---|
| 175 |
require 'test/unit' |
|---|
| 176 |
require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/string' |
|---|
| 177 |
-require File.dirname(__FILE__) + '/../../lib/active_support/misc' |
|---|
| 178 |
+require File.dirname(__FILE__) + '/../../lib/active_support/misc' unless defined? silence_warnings |
|---|
| 179 |
+require File.dirname(__FILE__) + '/../inflector_test' unless defined? InflectorTest |
|---|
| 180 |
|
|---|
| 181 |
-silence_warnings do |
|---|
| 182 |
- require File.dirname(__FILE__) + '/../inflector_test' |
|---|
| 183 |
-end |
|---|
| 184 |
- |
|---|
| 185 |
class StringInflectionsTest < Test::Unit::TestCase |
|---|
| 186 |
def test_pluralize |
|---|
| 187 |
InflectorTest::SingularToPlural.each do |singular, plural| |
|---|
| 188 |
Index: activesupport/test/misc_test.rb |
|---|
| 189 |
=================================================================== |
|---|
| 190 |
--- activesupport/test/misc_test.rb (revision 1873) |
|---|
| 191 |
+++ activesupport/test/misc_test.rb (working copy) |
|---|
| 192 |
@@ -1,5 +1,5 @@ |
|---|
| 193 |
require 'test/unit' |
|---|
| 194 |
-require File.dirname(__FILE__) + '/../lib/active_support/misc' |
|---|
| 195 |
+require File.dirname(__FILE__) + '/../lib/active_support/misc' unless defined? silence_warnings |
|---|
| 196 |
|
|---|
| 197 |
class MiscTest < Test::Unit::TestCase |
|---|
| 198 |
def test_silence_warnings |
|---|
| 199 |
Index: activesupport/Rakefile |
|---|
| 200 |
=================================================================== |
|---|
| 201 |
--- activesupport/Rakefile (revision 1873) |
|---|
| 202 |
+++ activesupport/Rakefile (working copy) |
|---|
| 203 |
@@ -16,6 +16,7 @@ |
|---|
| 204 |
task :default => :test |
|---|
| 205 |
Rake::TestTask.new { |t| |
|---|
| 206 |
t.pattern = 'test/**/*_test.rb' |
|---|
| 207 |
+ t.warning = true |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
# Create compressed packages |
|---|
| 211 |
@@ -180,4 +181,4 @@ |
|---|
| 212 |
first_file = false |
|---|
| 213 |
end |
|---|
| 214 |
end |
|---|
| 215 |
-end |
|---|
| 216 |
\ No newline at end of file |
|---|
| 217 |
+end |
|---|
| 218 |
Index: activesupport/lib/active_support/breakpoint.rb |
|---|
| 219 |
=================================================================== |
|---|
| 220 |
--- activesupport/lib/active_support/breakpoint.rb (revision 1873) |
|---|
| 221 |
+++ activesupport/lib/active_support/breakpoint.rb (working copy) |
|---|
| 222 |
@@ -16,7 +16,7 @@ |
|---|
| 223 |
# license please contact me. |
|---|
| 224 |
|
|---|
| 225 |
require 'irb' |
|---|
| 226 |
-require File.dirname(__FILE__) + '/binding_of_caller' |
|---|
| 227 |
+require File.dirname(__FILE__) + '/binding_of_caller' unless defined? Binding.of_caller |
|---|
| 228 |
require 'drb' |
|---|
| 229 |
require 'drb/acl' |
|---|
| 230 |
|
|---|
| 231 |
@@ -460,6 +460,10 @@ |
|---|
| 232 |
old_CurrentContext |
|---|
| 233 |
end |
|---|
| 234 |
end |
|---|
| 235 |
+ class << self |
|---|
| 236 |
+ alias old_parse_opts parse_opts |
|---|
| 237 |
+ remove_method :parse_opts |
|---|
| 238 |
+ end |
|---|
| 239 |
def IRB.parse_opts() end |
|---|
| 240 |
|
|---|
| 241 |
class Context #:nodoc: |
|---|
| 242 |
Index: activesupport/lib/active_support/class_inheritable_attributes.rb |
|---|
| 243 |
=================================================================== |
|---|
| 244 |
--- activesupport/lib/active_support/class_inheritable_attributes.rb (revision 1873) |
|---|
| 245 |
+++ activesupport/lib/active_support/class_inheritable_attributes.rb (working copy) |
|---|
| 246 |
@@ -113,5 +113,8 @@ |
|---|
| 247 |
if respond_to?(:inherited) |
|---|
| 248 |
alias_method :inherited_without_inheritable_attributes, :inherited |
|---|
| 249 |
end |
|---|
| 250 |
- alias_method :inherited, :inherited_with_inheritable_attributes |
|---|
| 251 |
+ |
|---|
| 252 |
+ alias old_inherited inherited |
|---|
| 253 |
+ alias inherited inherited_with_inheritable_attributes |
|---|
| 254 |
+ |
|---|
| 255 |
end |
|---|
| 256 |
Index: activesupport/lib/active_support/clean_logger.rb |
|---|
| 257 |
=================================================================== |
|---|
| 258 |
--- activesupport/lib/active_support/clean_logger.rb (revision 1873) |
|---|
| 259 |
+++ activesupport/lib/active_support/clean_logger.rb (working copy) |
|---|
| 260 |
@@ -12,7 +12,8 @@ |
|---|
| 261 |
private |
|---|
| 262 |
remove_const "Format" |
|---|
| 263 |
Format = "%s\n" |
|---|
| 264 |
+ alias old_format_message format_message |
|---|
| 265 |
def format_message(severity, timestamp, msg, progname) |
|---|
| 266 |
Format % [msg] |
|---|
| 267 |
end |
|---|
| 268 |
-end |
|---|
| 269 |
\ No newline at end of file |
|---|
| 270 |
+end |
|---|
| 271 |
Index: activesupport/lib/active_support/core_ext/integer/inflections.rb |
|---|
| 272 |
=================================================================== |
|---|
| 273 |
--- activesupport/lib/active_support/core_ext/integer/inflections.rb (revision 1873) |
|---|
| 274 |
+++ activesupport/lib/active_support/core_ext/integer/inflections.rb (working copy) |
|---|
| 275 |
@@ -1,4 +1,4 @@ |
|---|
| 276 |
-require File.dirname(__FILE__) + '/../../inflector' |
|---|
| 277 |
+require File.dirname(__FILE__) + '/../../inflector' unless defined? Inflector |
|---|
| 278 |
module ActiveSupport #:nodoc: |
|---|
| 279 |
module CoreExtensions #:nodoc: |
|---|
| 280 |
module Integer #:nodoc: |
|---|
| 281 |
Index: activesupport/lib/active_support/core_ext/string/inflections.rb |
|---|
| 282 |
=================================================================== |
|---|
| 283 |
--- activesupport/lib/active_support/core_ext/string/inflections.rb (revision 1873) |
|---|
| 284 |
+++ activesupport/lib/active_support/core_ext/string/inflections.rb (working copy) |
|---|
| 285 |
@@ -1,4 +1,4 @@ |
|---|
| 286 |
-require File.dirname(__FILE__) + '/../../inflector' |
|---|
| 287 |
+require File.dirname(__FILE__) + '/../../inflector' unless defined? Inflector |
|---|
| 288 |
module ActiveSupport #:nodoc: |
|---|
| 289 |
module CoreExtensions #:nodoc: |
|---|
| 290 |
module String #:nodoc: |
|---|
| 291 |
Index: activesupport/lib/active_support/dependencies.rb |
|---|
| 292 |
=================================================================== |
|---|
| 293 |
--- activesupport/lib/active_support/dependencies.rb (revision 1873) |
|---|
| 294 |
+++ activesupport/lib/active_support/dependencies.rb (working copy) |
|---|
| 295 |
@@ -172,6 +172,9 @@ |
|---|
| 296 |
Object.send(:define_method, :require_association) { |file_name| Dependencies.associate_with(file_name) } unless Object.respond_to?(:require_association) |
|---|
| 297 |
|
|---|
| 298 |
class Module #:nodoc: |
|---|
| 299 |
+ |
|---|
| 300 |
+ alias old_const_missing const_missing |
|---|
| 301 |
+ |
|---|
| 302 |
# Use const_missing to autoload associations so we don't have to |
|---|
| 303 |
# require_association when using single-table inheritance. |
|---|
| 304 |
def const_missing(class_id) |
|---|
| 305 |
Index: activerecord/test/deprecated_associations_test.rb |
|---|
| 306 |
=================================================================== |
|---|
| 307 |
--- activerecord/test/deprecated_associations_test.rb (revision 1873) |
|---|
| 308 |
+++ activerecord/test/deprecated_associations_test.rb (working copy) |
|---|
| 309 |
@@ -113,17 +113,6 @@ |
|---|
| 310 |
assert_raises(RuntimeError) { !Company.find(3).firm?(Company.find(3)) } # "Summit shouldn't have itself as firm" |
|---|
| 311 |
end |
|---|
| 312 |
|
|---|
| 313 |
- def test_has_one |
|---|
| 314 |
- assert companies(:first_firm).account?(Account.find(1)) |
|---|
| 315 |
- assert_equal Account.find(1).credit_limit, companies(:first_firm).account.credit_limit |
|---|
| 316 |
- assert companies(:first_firm).has_account?, "37signals should have an account" |
|---|
| 317 |
- assert Account.find(1).firm?(companies(:first_firm)), "37signals account should be able to backtrack" |
|---|
| 318 |
- assert Account.find(1).has_firm?, "37signals account should be able to backtrack" |
|---|
| 319 |
- |
|---|
| 320 |
- assert !Account.find(2).has_firm?, "Unknown isn't linked" |
|---|
| 321 |
- assert !Account.find(2).firm?(companies(:first_firm)), "Unknown isn't linked" |
|---|
| 322 |
- end |
|---|
| 323 |
- |
|---|
| 324 |
def test_has_many_dependence_on_account |
|---|
| 325 |
assert_equal 2, Account.find_all.length |
|---|
| 326 |
companies(:first_firm).destroy |
|---|
| 327 |
@@ -317,12 +306,18 @@ |
|---|
| 328 |
|
|---|
| 329 |
def test_has_one |
|---|
| 330 |
assert companies(:first_firm).account?(Account.find(1)) |
|---|
| 331 |
- assert companies(:first_firm).has_account?, "37signals should have an account" |
|---|
| 332 |
- assert Account.find(1).firm?(companies(:first_firm)), "37signals account should be able to backtrack" |
|---|
| 333 |
- assert Account.find(1).has_firm?, "37signals account should be able to backtrack" |
|---|
| 334 |
+ assert_equal(Account.find(1).credit_limit, |
|---|
| 335 |
+ companies(:first_firm).account.credit_limit) |
|---|
| 336 |
+ assert(companies(:first_firm).has_account?, |
|---|
| 337 |
+ "37signals should have an account") |
|---|
| 338 |
+ assert(Account.find(1).firm?(companies(:first_firm)), |
|---|
| 339 |
+ "37signals account should be able to backtrack") |
|---|
| 340 |
+ assert(Account.find(1).has_firm?, |
|---|
| 341 |
+ "37signals account should be able to backtrack") |
|---|
| 342 |
|
|---|
| 343 |
assert !Account.find(2).has_firm?, "Unknown isn't linked" |
|---|
| 344 |
- assert !Account.find(2).firm?(companies(:first_firm)), "Unknown isn't linked" |
|---|
| 345 |
+ assert(!Account.find(2).firm?(companies(:first_firm)), |
|---|
| 346 |
+ "Unknown isn't linked") |
|---|
| 347 |
end |
|---|
| 348 |
|
|---|
| 349 |
def test_has_one_build |
|---|
| 350 |
Index: activerecord/test/associations_test.rb |
|---|
| 351 |
=================================================================== |
|---|
| 352 |
--- activerecord/test/associations_test.rb (revision 1873) |
|---|
| 353 |
+++ activerecord/test/associations_test.rb (working copy) |
|---|
| 354 |
@@ -138,15 +138,6 @@ |
|---|
| 355 |
assert_equal account, firm.account |
|---|
| 356 |
end |
|---|
| 357 |
|
|---|
| 358 |
- def test_failing_build_association |
|---|
| 359 |
- firm = Firm.new("name" => "GlobalMegaCorp") |
|---|
| 360 |
- firm.save |
|---|
| 361 |
- |
|---|
| 362 |
- account = firm.build_account |
|---|
| 363 |
- assert !account.save |
|---|
| 364 |
- assert_equal "can't be empty", account.errors.on("credit_limit") |
|---|
| 365 |
- end |
|---|
| 366 |
- |
|---|
| 367 |
def test_create_association |
|---|
| 368 |
firm = Firm.new("name" => "GlobalMegaCorp") |
|---|
| 369 |
firm.save |
|---|
| 370 |
Index: activerecord/test/fixtures_test.rb |
|---|
| 371 |
=================================================================== |
|---|
| 372 |
--- activerecord/test/fixtures_test.rb (revision 1873) |
|---|
| 373 |
+++ activerecord/test/fixtures_test.rb (working copy) |
|---|
| 374 |
@@ -125,14 +125,14 @@ |
|---|
| 375 |
fixtures :topics, :developers, :accounts |
|---|
| 376 |
|
|---|
| 377 |
def test_without_complete_instantiation |
|---|
| 378 |
- assert_nil @first |
|---|
| 379 |
- assert_nil @topics |
|---|
| 380 |
- assert_nil @developers |
|---|
| 381 |
- assert_nil @accounts |
|---|
| 382 |
+ assert !defined? @first |
|---|
| 383 |
+ assert !defined? @topics |
|---|
| 384 |
+ assert !defined? @developers |
|---|
| 385 |
+ assert !defined? @accounts |
|---|
| 386 |
end |
|---|
| 387 |
|
|---|
| 388 |
def test_fixtures_from_root_yml_without_instantiation |
|---|
| 389 |
- assert_nil @unknown |
|---|
| 390 |
+ assert !defined? @unknown |
|---|
| 391 |
end |
|---|
| 392 |
|
|---|
| 393 |
def test_accessor_methods |
|---|
| 394 |
@@ -150,7 +150,7 @@ |
|---|
| 395 |
fixtures :topics, :developers, :accounts |
|---|
| 396 |
|
|---|
| 397 |
def test_without_instance_instantiation |
|---|
| 398 |
- assert_nil @first |
|---|
| 399 |
+ assert !defined? @first |
|---|
| 400 |
assert_not_nil @topics |
|---|
| 401 |
assert_not_nil @developers |
|---|
| 402 |
assert_not_nil @accounts |
|---|
| 403 |
Index: activerecord/test/base_test.rb |
|---|
| 404 |
=================================================================== |
|---|
| 405 |
--- activerecord/test/base_test.rb (revision 1873) |
|---|
| 406 |
+++ activerecord/test/base_test.rb (working copy) |
|---|
| 407 |
@@ -571,7 +571,7 @@ |
|---|
| 408 |
|
|---|
| 409 |
def test_multiparameter_mass_assignment_protector |
|---|
| 410 |
task = Task.new |
|---|
| 411 |
- time = Time.mktime(0) |
|---|
| 412 |
+ time = Time.at 1_234_567 |
|---|
| 413 |
task.starting = time |
|---|
| 414 |
attributes = { "starting(1i)" => "2004", "starting(2i)" => "6", "starting(3i)" => "24" } |
|---|
| 415 |
task.attributes = attributes |
|---|
| 416 |
@@ -685,7 +685,7 @@ |
|---|
| 417 |
def test_auto_id |
|---|
| 418 |
auto = AutoId.new |
|---|
| 419 |
auto.save |
|---|
| 420 |
- assert (auto.id > 0) |
|---|
| 421 |
+ assert(auto.id > 0) |
|---|
| 422 |
end |
|---|
| 423 |
|
|---|
| 424 |
def quote_column_name(name) |
|---|
| 425 |
@@ -780,7 +780,7 @@ |
|---|
| 426 |
assert_equal 1, topics(:first, :reload).replies_count |
|---|
| 427 |
|
|---|
| 428 |
topics(:first).decrement(:replies_count).decrement!(:replies_count) |
|---|
| 429 |
- assert_equal -1, topics(:first, :reload).replies_count |
|---|
| 430 |
+ assert_equal(-1, topics(:first, :reload).replies_count) |
|---|
| 431 |
end |
|---|
| 432 |
|
|---|
| 433 |
def test_toggle_attribute |
|---|
| 434 |
Index: activerecord/test/deprecated_finder_test.rb |
|---|
| 435 |
=================================================================== |
|---|
| 436 |
--- activerecord/test/deprecated_finder_test.rb (revision 1873) |
|---|
| 437 |
+++ activerecord/test/deprecated_finder_test.rb (working copy) |
|---|
| 438 |
@@ -4,16 +4,9 @@ |
|---|
| 439 |
require 'fixtures/entrant' |
|---|
| 440 |
require 'fixtures/developer' |
|---|
| 441 |
|
|---|
| 442 |
-class FinderTest < Test::Unit::TestCase |
|---|
| 443 |
+class DeprecatedFinderTest < Test::Unit::TestCase |
|---|
| 444 |
fixtures :companies, :topics, :entrants, :developers |
|---|
| 445 |
|
|---|
| 446 |
- def test_find_all_with_limit |
|---|
| 447 |
- entrants = Entrant.find_all nil, "id ASC", 2 |
|---|
| 448 |
- |
|---|
| 449 |
- assert_equal(2, entrants.size) |
|---|
| 450 |
- assert_equal(entrants(:first).name, entrants.first.name) |
|---|
| 451 |
- end |
|---|
| 452 |
- |
|---|
| 453 |
def test_find_all_with_prepared_limit_and_offset |
|---|
| 454 |
if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter |
|---|
| 455 |
if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter) |
|---|
| 456 |
@@ -101,6 +94,11 @@ |
|---|
| 457 |
end |
|---|
| 458 |
|
|---|
| 459 |
def test_find_all_with_limit |
|---|
| 460 |
+ entrants = Entrant.find_all nil, "id ASC", 2 |
|---|
| 461 |
+ |
|---|
| 462 |
+ assert_equal(2, entrants.size) |
|---|
| 463 |
+ assert_equal(entrants(:first).name, entrants.first.name) |
|---|
| 464 |
+ |
|---|
| 465 |
first_five_developers = Developer.find_all nil, 'id ASC', 5 |
|---|
| 466 |
assert_equal 5, first_five_developers.length |
|---|
| 467 |
assert_equal 'David', first_five_developers.first.name |
|---|
| 468 |
Index: activerecord/test/migration_test.rb |
|---|
| 469 |
=================================================================== |
|---|
| 470 |
--- activerecord/test/migration_test.rb (revision 1873) |
|---|
| 471 |
+++ activerecord/test/migration_test.rb (working copy) |
|---|
| 472 |
@@ -1,7 +1,5 @@ |
|---|
| 473 |
require 'abstract_unit' |
|---|
| 474 |
require 'fixtures/person' |
|---|
| 475 |
-require File.dirname(__FILE__) + '/fixtures/migrations/1_people_have_last_names' |
|---|
| 476 |
-require File.dirname(__FILE__) + '/fixtures/migrations/2_we_need_reminders' |
|---|
| 477 |
|
|---|
| 478 |
if ActiveRecord::Base.connection.supports_migrations? |
|---|
| 479 |
|
|---|
| 480 |
@@ -67,7 +65,7 @@ |
|---|
| 481 |
assert_equal TrueClass, bob.male?.class |
|---|
| 482 |
end |
|---|
| 483 |
|
|---|
| 484 |
- def test_add_remove_single_field |
|---|
| 485 |
+ def test_zz_add_remove_single_field # last for autoloading |
|---|
| 486 |
assert !Person.column_methods_hash.include?(:last_name) |
|---|
| 487 |
|
|---|
| 488 |
PeopleHaveLastNames.up |
|---|
| 489 |
@@ -116,7 +114,7 @@ |
|---|
| 490 |
assert !Person.new.administrator? |
|---|
| 491 |
end |
|---|
| 492 |
|
|---|
| 493 |
- def test_add_table |
|---|
| 494 |
+ def test_zz_add_table # last for autoloading |
|---|
| 495 |
assert_raises(ActiveRecord::StatementInvalid) { Reminder.column_methods_hash } |
|---|
| 496 |
|
|---|
| 497 |
WeNeedReminders.up |
|---|
| 498 |
@@ -198,4 +196,4 @@ |
|---|
| 499 |
assert_equal "hello world", Reminder.find(:first).content |
|---|
| 500 |
end |
|---|
| 501 |
end |
|---|
| 502 |
-end |
|---|
| 503 |
\ No newline at end of file |
|---|
| 504 |
+end |
|---|
| 505 |
Index: activerecord/test/inheritance_test.rb |
|---|
| 506 |
=================================================================== |
|---|
| 507 |
--- activerecord/test/inheritance_test.rb (revision 1873) |
|---|
| 508 |
+++ activerecord/test/inheritance_test.rb (working copy) |
|---|
| 509 |
@@ -138,6 +138,9 @@ |
|---|
| 510 |
c.save |
|---|
| 511 |
end |
|---|
| 512 |
|
|---|
| 513 |
- def Company.inheritance_column() "ruby_type" end |
|---|
| 514 |
+ class << Company |
|---|
| 515 |
+ undef_method :inheritance_column |
|---|
| 516 |
+ def inheritance_column() "ruby_type" end |
|---|
| 517 |
+ end |
|---|
| 518 |
end |
|---|
| 519 |
end |
|---|
| 520 |
Index: activerecord/test/finder_test.rb |
|---|
| 521 |
=================================================================== |
|---|
| 522 |
--- activerecord/test/finder_test.rb (revision 1873) |
|---|
| 523 |
+++ activerecord/test/finder_test.rb (working copy) |
|---|
| 524 |
@@ -12,7 +12,7 @@ |
|---|
| 525 |
end |
|---|
| 526 |
|
|---|
| 527 |
def test_exists |
|---|
| 528 |
- assert (Topic.exists?(1)) |
|---|
| 529 |
+ assert Topic.exists?(1) |
|---|
| 530 |
assert !(Topic.exists?(45)) |
|---|
| 531 |
assert !(Topic.exists?("foo")) |
|---|
| 532 |
assert !(Topic.exists?([1,2])) |
|---|
| 533 |
@@ -38,13 +38,6 @@ |
|---|
| 534 |
} |
|---|
| 535 |
end |
|---|
| 536 |
|
|---|
| 537 |
- def test_find_all_with_limit |
|---|
| 538 |
- entrants = Entrant.find(:all, :order => "id ASC", :limit => 2) |
|---|
| 539 |
- |
|---|
| 540 |
- assert_equal(2, entrants.size) |
|---|
| 541 |
- assert_equal(entrants(:first).name, entrants.first.name) |
|---|
| 542 |
- end |
|---|
| 543 |
- |
|---|
| 544 |
def test_find_all_with_prepared_limit_and_offset |
|---|
| 545 |
if ActiveRecord::ConnectionAdapters.const_defined? :OracleAdapter |
|---|
| 546 |
if ActiveRecord::Base.connection.instance_of?(ActiveRecord::ConnectionAdapters::OracleAdapter) |
|---|
| 547 |
@@ -276,6 +269,11 @@ |
|---|
| 548 |
end |
|---|
| 549 |
|
|---|
| 550 |
def test_find_all_with_limit |
|---|
| 551 |
+ entrants = Entrant.find(:all, :order => "id ASC", :limit => 2) |
|---|
| 552 |
+ |
|---|
| 553 |
+ assert_equal(2, entrants.size) |
|---|
| 554 |
+ assert_equal(entrants(:first).name, entrants.first.name) |
|---|
| 555 |
+ |
|---|
| 556 |
first_five_developers = Developer.find :all, :order => 'id ASC', :limit => 5 |
|---|
| 557 |
assert_equal 5, first_five_developers.length |
|---|
| 558 |
assert_equal 'David', first_five_developers.first.name |
|---|
| 559 |
Index: activerecord/test/fixtures/migrations/1_people_have_last_names.rb |
|---|
| 560 |
=================================================================== |
|---|
| 561 |
--- activerecord/test/fixtures/migrations/1_people_have_last_names.rb (revision 1873) |
|---|
| 562 |
+++ activerecord/test/fixtures/migrations/1_people_have_last_names.rb (working copy) |
|---|
| 563 |
@@ -6,4 +6,4 @@ |
|---|
| 564 |
def self.down |
|---|
| 565 |
remove_column "people", "last_name" |
|---|
| 566 |
end |
|---|
| 567 |
-end |
|---|
| 568 |
\ No newline at end of file |
|---|
| 569 |
+end |
|---|
| 570 |
Index: activerecord/Rakefile |
|---|
| 571 |
=================================================================== |
|---|
| 572 |
--- activerecord/Rakefile (revision 1873) |
|---|
| 573 |
+++ activerecord/Rakefile (working copy) |
|---|
| 574 |
@@ -30,12 +30,14 @@ |
|---|
| 575 |
t.libs << "test" << "test/connections/native_mysql" |
|---|
| 576 |
t.pattern = 'test/*_test{,_mysql}.rb' |
|---|
| 577 |
t.verbose = true |
|---|
| 578 |
+ t.warning = true |
|---|
| 579 |
} |
|---|
| 580 |
|
|---|
| 581 |
Rake::TestTask.new("test_mysql_ruby") { |t| |
|---|
| 582 |
t.libs << "test" << "test/connections/native_mysql" |
|---|
| 583 |
t.pattern = 'test/*_test{,_mysql}.rb' |
|---|
| 584 |
t.verbose = true |
|---|
| 585 |
+ t.warning = true |
|---|
| 586 |
} |
|---|
| 587 |
|
|---|
| 588 |
for adapter in %w( postgresql sqlite sqlite3 sqlserver sqlserver_odbc db2 oci ) |
|---|
| 589 |
@@ -43,6 +45,7 @@ |
|---|
| 590 |
t.libs << "test" << "test/connections/native_#{adapter}" |
|---|
| 591 |
t.pattern = "test/*_test{,_#{adapter}}.rb" |
|---|
| 592 |
t.verbose = true |
|---|
| 593 |
+ t.warning = true |
|---|
| 594 |
} |
|---|
| 595 |
end |
|---|
| 596 |
|
|---|
| 597 |
Index: activerecord/lib/active_record/validations.rb |
|---|
| 598 |
=================================================================== |
|---|
| 599 |
--- activerecord/lib/active_record/validations.rb (revision 1873) |
|---|
| 600 |
+++ activerecord/lib/active_record/validations.rb (working copy) |
|---|
| 601 |
@@ -310,7 +310,7 @@ |
|---|
| 602 |
configuration = { :message => ActiveRecord::Errors.default_error_messages[:confirmation], :on => :save } |
|---|
| 603 |
configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash) |
|---|
| 604 |
|
|---|
| 605 |
- attr_accessor *(attr_names.map { |n| "#{n}_confirmation" }) |
|---|
| 606 |
+ attr_accessor(*(attr_names.map { |n| "#{n}_confirmation" })) |
|---|
| 607 |
|
|---|
| 608 |
validates_each(attr_names, configuration) do |record, attr_name, value| |
|---|
| 609 |
record.errors.add(attr_name, configuration[:message]) unless record.send("#{attr_name}_confirmation").nil? or value == record.send("#{attr_name}_confirmation") |
|---|
| 610 |
@@ -339,7 +339,7 @@ |
|---|
| 611 |
configuration = { :message => ActiveRecord::Errors.default_error_messages[:accepted], :on => :save, :allow_nil => true, :accept => "1" } |
|---|
| 612 |
configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash) |
|---|
| 613 |
|
|---|
| 614 |
- attr_accessor *attr_names |
|---|
| 615 |
+ attr_accessor(*attr_names) |
|---|
| 616 |
|
|---|
| 617 |
validates_each(attr_names,configuration) do |record, attr_name, value| |
|---|
| 618 |
record.errors.add(attr_name, configuration[:message]) unless value == configuration[:accept] |
|---|
| 619 |
@@ -684,7 +684,7 @@ |
|---|
| 620 |
|
|---|
| 621 |
# Returns the Errors object that holds all information about attribute error messages. |
|---|
| 622 |
def errors |
|---|
| 623 |
- @errors = Errors.new(self) if @errors.nil? |
|---|
| 624 |
+ @errors = Errors.new(self) unless defined? @errors |
|---|
| 625 |
@errors |
|---|
| 626 |
end |
|---|
| 627 |
|
|---|
| 628 |
Index: activerecord/lib/active_record/connection_adapters/abstract_adapter.rb |
|---|
| 629 |
=================================================================== |
|---|
| 630 |
--- activerecord/lib/active_record/connection_adapters/abstract_adapter.rb (revision 1873) |
|---|
| 631 |
+++ activerecord/lib/active_record/connection_adapters/abstract_adapter.rb (working copy) |
|---|
| 632 |
@@ -410,10 +410,6 @@ |
|---|
| 633 |
raise NotImplementedError, "change_column_default is not implemented" |
|---|
| 634 |
end |
|---|
| 635 |
|
|---|
| 636 |
- def supports_migrations? |
|---|
| 637 |
- false |
|---|
| 638 |
- end |
|---|
| 639 |
- |
|---|
| 640 |
def rename_column(table_name, column_name, new_column_name) |
|---|
| 641 |
raise NotImplementedError, "rename_column is not implemented" |
|---|
| 642 |
end |
|---|
| 643 |
Index: activerecord/lib/active_record/connection_adapters/oci_adapter.rb |
|---|
| 644 |
=================================================================== |
|---|
| 645 |
--- activerecord/lib/active_record/connection_adapters/oci_adapter.rb (revision 1873) |
|---|
| 646 |
+++ activerecord/lib/active_record/connection_adapters/oci_adapter.rb (working copy) |
|---|
| 647 |
@@ -55,7 +55,7 @@ |
|---|
| 648 |
|
|---|
| 649 |
def cast_to_date_or_time(value) |
|---|
| 650 |
return value if value.is_a? Date |
|---|
| 651 |
- guess_date_or_time (value.is_a? Time) ? value : cast_to_time(value) |
|---|
| 652 |
+ guess_date_or_time value.is_a?(Time) ? value : cast_to_time(value) |
|---|
| 653 |
end |
|---|
| 654 |
|
|---|
| 655 |
def cast_to_time(value) |
|---|
| 656 |
Index: activerecord/lib/active_record/query_cache.rb |
|---|
| 657 |
=================================================================== |
|---|
| 658 |
--- activerecord/lib/active_record/query_cache.rb (revision 1873) |
|---|
| 659 |
+++ activerecord/lib/active_record/query_cache.rb (working copy) |
|---|
| 660 |
@@ -42,9 +42,11 @@ |
|---|
| 661 |
end |
|---|
| 662 |
end |
|---|
| 663 |
|
|---|
| 664 |
- class Base |
|---|
| 665 |
+ class << Base |
|---|
| 666 |
+ alias old_connection= connection= |
|---|
| 667 |
+ |
|---|
| 668 |
# Set the connection for the class with caching on |
|---|
| 669 |
- def self.connection=(spec) |
|---|
| 670 |
+ def connection=(spec) |
|---|
| 671 |
raise ConnectionNotEstablished unless spec |
|---|
| 672 |
|
|---|
| 673 |
conn = spec.config[:query_cache] ? |
|---|
| 674 |
Index: activerecord/lib/active_record/migration.rb |
|---|
| 675 |
=================================================================== |
|---|
| 676 |
--- activerecord/lib/active_record/migration.rb (revision 1873) |
|---|
| 677 |
+++ activerecord/lib/active_record/migration.rb (working copy) |
|---|
| 678 |
@@ -182,7 +182,7 @@ |
|---|
| 679 |
private |
|---|
| 680 |
def migration_classes |
|---|
| 681 |
migrations = migration_files.collect do |migration_file| |
|---|
| 682 |
- load(migration_file) |
|---|
| 683 |
+ require migration_file |
|---|
| 684 |
version, name = migration_version_and_name(migration_file) |
|---|
| 685 |
[ version.to_i, migration_class(name) ] |
|---|
| 686 |
end |
|---|
| 687 |
Index: activerecord/lib/active_record/vendor/simple.rb |
|---|
| 688 |
=================================================================== |
|---|
| 689 |
--- activerecord/lib/active_record/vendor/simple.rb (revision 1873) |
|---|
| 690 |
+++ activerecord/lib/active_record/vendor/simple.rb (working copy) |
|---|
| 691 |
@@ -186,6 +186,7 @@ |
|---|
| 692 |
|
|---|
| 693 |
# Returns the Transaction::Simple debug object. It must respond to #<<. |
|---|
| 694 |
def self.debug_io |
|---|
| 695 |
+ @tdi = nil unless defined? @tdi |
|---|
| 696 |
@tdi |
|---|
| 697 |
end |
|---|
| 698 |
|
|---|
| 699 |
@@ -368,18 +369,19 @@ |
|---|
| 700 |
end |
|---|
| 701 |
end |
|---|
| 702 |
|
|---|
| 703 |
- if respond_to?(:instance_variable_get) |
|---|
| 704 |
+ if r.instance_variables.include? TRANSACTION_CHECKPOINT then |
|---|
| 705 |
return r.instance_variable_get(TRANSACTION_CHECKPOINT) |
|---|
| 706 |
else |
|---|
| 707 |
- return r.instance_eval(TRANSACTION_CHECKPOINT) |
|---|
| 708 |
+ return nil |
|---|
| 709 |
end |
|---|
| 710 |
end |
|---|
| 711 |
|
|---|
| 712 |
def __commit_transaction #:nodoc: |
|---|
| 713 |
- if respond_to?(:instance_variable_get) |
|---|
| 714 |
- @__transaction_checkpoint__ = Marshal.restore(@__transaction_checkpoint__).instance_variable_get(TRANSACTION_CHECKPOINT) |
|---|
| 715 |
+ val = Marshal.restore(@__transaction_checkpoint__) |
|---|
| 716 |
+ if val.instance_variables.include? TRANSACTION_CHECKPOINT then |
|---|
| 717 |
+ @__transaction_checkpoint__ = val.instance_variable_get(TRANSACTION_CHECKPOINT) |
|---|
| 718 |
else |
|---|
| 719 |
- @__transaction_checkpoint__ = Marshal.restore(@__transaction_checkpoint__).instance_eval(TRANSACTION_CHECKPOINT) |
|---|
| 720 |
+ @@__transaction_checkpoint__ = nil |
|---|
| 721 |
end |
|---|
| 722 |
|
|---|
| 723 |
@__transaction_level__ -= 1 |
|---|
| 724 |
Index: activerecord/lib/active_record/associations.rb |
|---|
| 725 |
=================================================================== |
|---|
| 726 |
--- activerecord/lib/active_record/associations.rb (revision 1873) |
|---|
| 727 |
+++ activerecord/lib/active_record/associations.rb (working copy) |
|---|
| 728 |
@@ -365,13 +365,16 @@ |
|---|
| 729 |
|
|---|
| 730 |
require_association_class(association_class_name) |
|---|
| 731 |
|
|---|
| 732 |
+ ivar_name = "\"@#{association_name}\"" |
|---|
| 733 |
module_eval do |
|---|
| 734 |
after_save <<-EOF |
|---|
| 735 |
- association = instance_variable_get("@#{association_name}") |
|---|
| 736 |
- unless association.nil? |
|---|
| 737 |
- association["#{association_class_primary_key_name}"] = id |
|---|
| 738 |
- association.save(true) |
|---|
| 739 |
- association.send(:construct_sql) |
|---|
| 740 |
+ if instance_variables.include? #{ivar_name} then |
|---|
| 741 |
+ association = instance_variable_get #{ivar_name} |
|---|
| 742 |
+ unless association.nil? |
|---|
| 743 |
+ association["#{association_class_primary_key_name}"] = id |
|---|
| 744 |
+ association.save(true) |
|---|
| 745 |
+ association.send(:construct_sql) |
|---|
| 746 |
+ end |
|---|
| 747 |
end |
|---|
| 748 |
EOF |
|---|
| 749 |
end |
|---|
| 750 |
@@ -442,9 +445,13 @@ |
|---|
| 751 |
association_constructor_method(:build, association_name, association_class_name, association_class_primary_key_name, options, BelongsToAssociation) |
|---|
| 752 |
association_constructor_method(:create, association_name, association_class_name, association_class_primary_key_name, options, BelongsToAssociation) |
|---|
| 753 |
|
|---|
| 754 |
+ ivar_name = "\"@#{association_name}\"" |
|---|
| 755 |
module_eval do |
|---|
| 756 |
before_save <<-EOF |
|---|
| 757 |
- association = instance_variable_get("@#{association_name}") |
|---|
| 758 |
+ association = nil |
|---|
| 759 |
+ if instance_variables.include? #{ivar_name} then |
|---|
| 760 |
+ association = instance_variable_get #{ivar_name} |
|---|
| 761 |
+ end |
|---|
| 762 |
if not association.nil? and association.new_record? |
|---|
| 763 |
association.save(true) |
|---|
| 764 |
self["#{association_class_primary_key_name}"] = association.id |
|---|
| 765 |
@@ -600,18 +607,22 @@ |
|---|
| 766 |
end |
|---|
| 767 |
|
|---|
| 768 |
def association_accessor_methods(association_name, association_class_name, association_class_primary_key_name, options, association_proxy_class) |
|---|
| 769 |
+ ivar_name = "@#{association_name}" |
|---|
| 770 |
define_method(association_name) do |*params| |
|---|
| 771 |
force_reload = params.first unless params.empty? |
|---|
| 772 |
- association = instance_variable_get("@#{association_name}") |
|---|
| 773 |
+ association = nil |
|---|
| 774 |
+ if instance_variables.include? ivar_name then |
|---|
| 775 |
+ association = instance_variable_get ivar_name |
|---|
| 776 |
+ end |
|---|
| 777 |
if association.nil? or force_reload |
|---|
| 778 |
association = association_proxy_class.new(self, |
|---|
| 779 |
association_name, association_class_name, |
|---|
| 780 |
association_class_primary_key_name, options) |
|---|
| 781 |
retval = association.reload |
|---|
| 782 |
unless retval.nil? |
|---|
| 783 |
- instance_variable_set("@#{association_name}", association) |
|---|
| 784 |
+ instance_variable_set ivar_name, association |
|---|
| 785 |
else |
|---|
| 786 |
- instance_variable_set("@#{association_name}", nil) |
|---|
| 787 |
+ instance_variable_set ivar_name, nil |
|---|
| 788 |
return nil |
|---|
| 789 |
end |
|---|
| 790 |
end |
|---|
| 791 |
@@ -619,7 +630,10 @@ |
|---|
| 792 |
end |
|---|
| 793 |
|
|---|
| 794 |
define_method("#{association_name}=") do |new_value| |
|---|
| 795 |
- association = instance_variable_get("@#{association_name}") |
|---|
| 796 |
+ association = nil |
|---|
| 797 |
+ if instance_variables.include? ivar_name then |
|---|
| 798 |
+ association = instance_variable_get ivar_name |
|---|
| 799 |
+ end |
|---|
| 800 |
if association.nil? |
|---|
| 801 |
association = association_proxy_class.new(self, |
|---|
| 802 |
association_name, association_class_name, |
|---|
| 803 |
@@ -627,9 +641,9 @@ |
|---|
| 804 |
end |
|---|
| 805 |
association.replace(new_value) |
|---|
| 806 |
unless new_value.nil? |
|---|
| 807 |
- instance_variable_set("@#{association_name}", association) |
|---|
| 808 |
+ instance_variable_set ivar_name, association |
|---|
| 809 |
else |
|---|
| 810 |
- instance_variable_set("@#{association_name}", nil) |
|---|
| 811 |
+ instance_variable_set ivar_name, nil |
|---|
| 812 |
return nil |
|---|
| 813 |
end |
|---|
| 814 |
association |
|---|
| 815 |
@@ -641,31 +655,41 @@ |
|---|
| 816 |
association_name, association_class_name, |
|---|
| 817 |
association_class_primary_key_name, options) |
|---|
| 818 |
association.target = target |
|---|
| 819 |
- instance_variable_set("@#{association_name}", association) |
|---|
| 820 |
+ instance_variable_set ivar_name, association |
|---|
| 821 |
end |
|---|
| 822 |
end |
|---|
| 823 |
|
|---|
| 824 |
def collection_accessor_methods(association_name, association_class_name, association_class_primary_key_name, options, association_proxy_class) |
|---|
| 825 |
+ ivar_name = "@#{association_name}" |
|---|
| 826 |
+ |
|---|
| 827 |
define_method(association_name) do |*params| |
|---|
| 828 |
force_reload = params.first unless params.empty? |
|---|
| 829 |
- association = instance_variable_get("@#{association_name}") |
|---|
| 830 |
+ association = nil |
|---|
| 831 |
+ |
|---|
| 832 |
+ if instance_variables.include? ivar_name then |
|---|
| 833 |
+ association = instance_variable_get ivar_name |
|---|
| 834 |
+ end |
|---|
| 835 |
+ |
|---|
| 836 |
unless association.respond_to?(:loaded?) |
|---|
| 837 |
association = association_proxy_class.new(self, |
|---|
| 838 |
association_name, association_class_name, |
|---|
| 839 |
association_class_primary_key_name, options) |
|---|
| 840 |
- instance_variable_set("@#{association_name}", association) |
|---|
| 841 |
+ instance_variable_set ivar_name, association |
|---|
| 842 |
end |
|---|
| 843 |
association.reload if force_reload |
|---|
| 844 |
association |
|---|
| 845 |
end |
|---|
| 846 |
|
|---|
| 847 |
define_method("#{association_name}=") do |new_value| |
|---|
| 848 |
- association = instance_variable_get("@#{association_name}") |
|---|
| 849 |
+ association = nil |
|---|
| 850 |
+ if instance_variables.include? ivar_name then |
|---|
| 851 |
+ association = instance_variable_get ivar_name |
|---|
| 852 |
+ end |
|---|
| 853 |
unless association.respond_to?(:loaded?) |
|---|
| 854 |
association = association_proxy_class.new(self, |
|---|
| 855 |
association_name, association_class_name, |
|---|
| 856 |
association_class_primary_key_name, options) |
|---|
| 857 |
- instance_variable_set("@#{association_name}", association) |
|---|
| 858 |
+ instance_variable_set ivar_name, association |
|---|
| 859 |
end |
|---|
| 860 |
association.replace(new_value) |
|---|
| 861 |
association |
|---|
| 862 |
@@ -681,10 +705,14 @@ |
|---|
| 863 |
end |
|---|
| 864 |
|
|---|
| 865 |
def add_multiple_associated_save_callbacks(association_name) |
|---|
| 866 |
+ ivar_name = "\"@#{association_name}\"" |
|---|
| 867 |
module_eval do |
|---|
| 868 |
before_save <<-end_eval |
|---|
| 869 |
@new_record_before_save = new_record? |
|---|
| 870 |
- association = instance_variable_get("@#{association_name}") |
|---|
| 871 |
+ association = nil |
|---|
| 872 |
+ if instance_variables.include? #{ivar_name} then |
|---|
| 873 |
+ association = instance_variable_get #{ivar_name} |
|---|
| 874 |
+ end |
|---|
| 875 |
if association.respond_to?(:loaded?) |
|---|
| 876 |
if new_record? |
|---|
| 877 |
records_to_save = association |
|---|
| 878 |
@@ -700,7 +728,10 @@ |
|---|
| 879 |
|
|---|
| 880 |
module_eval do |
|---|
| 881 |
after_callback = <<-end_eval |
|---|
| 882 |
- association = instance_variable_get("@#{association_name}") |
|---|
| 883 |
+ association = nil |
|---|
| 884 |
+ if instance_variables.include? #{ivar_name} then |
|---|
| 885 |
+ association = instance_variable_get #{ivar_name} |
|---|
| 886 |
+ end |
|---|
| 887 |
if association.respond_to?(:loaded?) |
|---|
| 888 |
if @new_record_before_save |
|---|
| 889 |
records_to_save = association |
|---|
| 890 |
@@ -719,16 +750,20 @@ |
|---|
| 891 |
end |
|---|
| 892 |
|
|---|
| 893 |
def association_constructor_method(constructor, association_name, association_class_name, association_class_primary_key_name, options, association_proxy_class) |
|---|
| 894 |
+ ivar_name = "@#{association_name}" |
|---|
| 895 |
define_method("#{constructor}_#{association_name}") do |*params| |
|---|
| 896 |
attributees = params.first unless params.empty? |
|---|
| 897 |
replace_existing = params[1].nil? ? true : params[1] |
|---|
| 898 |
- association = instance_variable_get("@#{association_name}") |
|---|
| 899 |
+ association = nil |
|---|
| 900 |
+ if instance_variables.include? ivar_name then |
|---|
| 901 |
+ association = instance_variable_get ivar_name |
|---|
| 902 |
+ end |
|---|
| 903 |
|
|---|
| 904 |
if association.nil? |
|---|
| 905 |
association = association_proxy_class.new(self, |
|---|
| 906 |
association_name, association_class_name, |
|---|
| 907 |
association_class_primary_key_name, options) |
|---|
| 908 |
- instance_variable_set("@#{association_name}", association) |
|---|
| 909 |
+ instance_variable_set ivar_name, association |
|---|
| 910 |
end |
|---|
| 911 |
|
|---|
| 912 |
if association_proxy_class == HasOneAssociation |
|---|
| 913 |
Index: activerecord/lib/active_record/fixtures.rb |
|---|
| 914 |
=================================================================== |
|---|
| 915 |
--- activerecord/lib/active_record/fixtures.rb (revision 1873) |
|---|
| 916 |
+++ activerecord/lib/active_record/fixtures.rb (working copy) |
|---|
| 917 |
@@ -447,6 +447,7 @@ |
|---|
| 918 |
end |
|---|
| 919 |
|
|---|
| 920 |
def self.uses_transaction?(method) |
|---|
| 921 |
+ @uses_transaction = nil unless defined? @uses_transaction |
|---|
| 922 |
@uses_transaction && @uses_transaction.include?(method.to_s) |
|---|
| 923 |
end |
|---|
| 924 |
|
|---|
| 925 |
@@ -483,7 +484,8 @@ |
|---|
| 926 |
instantiate_fixtures if use_instantiated_fixtures |
|---|
| 927 |
end |
|---|
| 928 |
|
|---|
| 929 |
- alias_method :setup, :setup_with_fixtures |
|---|
| 930 |
+ alias old_setup setup |
|---|
| 931 |
+ alias setup setup_with_fixtures |
|---|
| 932 |
|
|---|
| 933 |
def teardown_with_fixtures |
|---|
| 934 |
# Rollback changes. |
|---|
| 935 |
@@ -493,7 +495,8 @@ |
|---|
| 936 |
end |
|---|
| 937 |
end |
|---|
| 938 |
|
|---|
| 939 |
- alias_method :teardown, :teardown_with_fixtures |
|---|
| 940 |
+ alias old_teardown teardown |
|---|
| 941 |
+ alias teardown teardown_with_fixtures |
|---|
| 942 |
|
|---|
| 943 |
def self.method_added(method) |
|---|
| 944 |
case method.to_s |
|---|
| 945 |
Index: activerecord/lib/active_record/aggregations.rb |
|---|
| 946 |
=================================================================== |
|---|
| 947 |
--- activerecord/lib/active_record/aggregations.rb (revision 1873) |
|---|
| 948 |
+++ activerecord/lib/active_record/aggregations.rb (working copy) |
|---|
| 949 |
@@ -144,7 +144,7 @@ |
|---|
| 950 |
def reader_method(name, class_name, mapping) |
|---|
| 951 |
module_eval <<-end_eval |
|---|
| 952 |
def #{name}(force_reload = false) |
|---|
| 953 |
- if @#{name}.nil? || force_reload |
|---|
| 954 |
+ if (not defined? @#{name}) || @#{name}.nil? || force_reload |
|---|
| 955 |
@#{name} = #{class_name}.new(#{(Array === mapping.first ? mapping : [ mapping ]).collect{ |pair| "read_attribute(\"#{pair.first}\")"}.join(", ")}) |
|---|
| 956 |
end |
|---|
| 957 |
|
|---|
| 958 |
Index: activerecord/lib/active_record/base.rb |
|---|
| 959 |
=================================================================== |
|---|
| 960 |
--- activerecord/lib/active_record/base.rb (revision 1873) |
|---|
| 961 |
+++ activerecord/lib/active_record/base.rb (working copy) |
|---|
| 962 |
@@ -831,7 +831,11 @@ |
|---|
| 963 |
def define_attr_method(name, value=nil, &block) |
|---|
| 964 |
sing = class << self; self; end |
|---|
| 965 |
block = proc { value.to_s } if value |
|---|
| 966 |
- sing.send( :alias_method, "original_#{name}", name ) |
|---|
| 967 |
+ original_name = "original_#{name}" |
|---|
| 968 |
+ if sing.instance_methods.include? original_name then |
|---|
| 969 |
+ sing.send :undef_method, original_name |
|---|
| 970 |
+ end |
|---|
| 971 |
+ sing.send( :alias_method, original_name, name ) |
|---|
| 972 |
sing.send( :define_method, name, &block ) |
|---|
| 973 |
end |
|---|
| 974 |
|
|---|
| 975 |
@@ -958,6 +962,7 @@ |
|---|
| 976 |
|
|---|
| 977 |
# Returns true if this object hasn't been saved yet -- that is, a record for the object doesn't exist yet. |
|---|
| 978 |
def new_record? |
|---|
| 979 |
+ @new_record = nil unless defined? @new_record # HACK true is default? |
|---|
| 980 |
@new_record |
|---|
| 981 |
end |
|---|
| 982 |
|
|---|
| 983 |
Index: actionpack/Rakefile |
|---|
| 984 |
=================================================================== |
|---|
| 985 |
--- actionpack/Rakefile (revision 1873) |
|---|
| 986 |
+++ actionpack/Rakefile (working copy) |
|---|
| 987 |
@@ -28,6 +28,7 @@ |
|---|
| 988 |
t.test_files=Dir.glob( "test/c*/*_test.rb" ) + Dir.glob( "test/[ft]*/*_test.rb" ) |
|---|
| 989 |
# t.pattern = 'test/*/*_test.rb' |
|---|
| 990 |
t.verbose = true |
|---|
| 991 |
+ t.warning = true |
|---|
| 992 |
} |
|---|
| 993 |
|
|---|
| 994 |
|
|---|
| 995 |
@@ -239,4 +240,4 @@ |
|---|
| 996 |
first_file = false |
|---|
| 997 |
end |
|---|
| 998 |
end |
|---|
| 999 |
-end |
|---|
| 1000 |
\ No newline at end of file |
|---|
| 1001 |
+end |
|---|
| 1002 |
Index: actionpack/lib/action_controller/request.rb |
|---|
| 1003 |
=================================================================== |
|---|
| 1004 |
--- actionpack/lib/action_controller/request.rb (revision 1873) |
|---|
| 1005 |
+++ actionpack/lib/action_controller/request.rb (working copy) |
|---|
| 1006 |
@@ -1,7 +1,7 @@ |
|---|
| 1007 |
module ActionController |
|---|
| 1008 |
# These methods are available in both the production and test Request objects. |
|---|
| 1009 |
class AbstractRequest |
|---|
| 1010 |
- cattr_accessor :relative_url_root |
|---|
| 1011 |
+ cattr_writer :relative_url_root |
|---|
| 1012 |
|
|---|
| 1013 |
# Returns both GET and POST parameters in a single hash. |
|---|
| 1014 |
def parameters |
|---|
| 1015 |
Index: actionpack/lib/action_controller/base.rb |
|---|
| 1016 |
=================================================================== |
|---|
| 1017 |
--- actionpack/lib/action_controller/base.rb (revision 1873) |
|---|
| 1018 |
+++ actionpack/lib/action_controller/base.rb (working copy) |
|---|
| 1019 |
@@ -300,6 +300,7 @@ |
|---|
| 1020 |
|
|---|
| 1021 |
# Convert the class name from something like "OneModule::TwoModule::NeatController" to "one_module/two_module/neat". |
|---|
| 1022 |
def controller_path |
|---|
| 1023 |
+ return unless defined? @controller_path |
|---|
| 1024 |
unless @controller_path |
|---|
| 1025 |
components = self.name.to_s.split('::') |
|---|
| 1026 |
components[-1] = $1 if /^(.*)Controller$/ =~ components.last |
|---|
| 1027 |
Index: actionpack/lib/action_controller/test_process.rb |
|---|
| 1028 |
=================================================================== |
|---|
| 1029 |
--- actionpack/lib/action_controller/test_process.rb (revision 1873) |
|---|
| 1030 |
+++ actionpack/lib/action_controller/test_process.rb (working copy) |
|---|
| 1031 |
@@ -15,13 +15,15 @@ |
|---|
| 1032 |
|
|---|
| 1033 |
class TestRequest < AbstractRequest #:nodoc: |
|---|
| 1034 |
attr_accessor :cookies |
|---|
| 1035 |
- attr_accessor :query_parameters, :request_parameters, :path, :session, :env |
|---|
| 1036 |
+ attr_accessor :query_parameters, :request_parameters, :session, :env |
|---|
| 1037 |
attr_accessor :host |
|---|
| 1038 |
+ attr_writer :path |
|---|
| 1039 |
|
|---|
| 1040 |
def initialize(query_parameters = nil, request_parameters = nil, session = nil) |
|---|
| 1041 |
@query_parameters = query_parameters || {} |
|---|
| 1042 |
@request_parameters = request_parameters || {} |
|---|
| 1043 |
@session = session || TestSession.new |
|---|
| 1044 |
+ @path = nil |
|---|
| 1045 |
|
|---|
| 1046 |
initialize_containers |
|---|
| 1047 |
initialize_default_values |
|---|
| 1048 |
Index: actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb |
|---|
| 1049 |
=================================================================== |
|---|
| 1050 |
--- actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb (revision 1873) |
|---|
| 1051 |
+++ actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb (working copy) |
|---|
| 1052 |
@@ -1,6 +1,7 @@ |
|---|
| 1053 |
class CGI #:nodoc: |
|---|
| 1054 |
# Add @request.env['RAW_POST_DATA'] for the vegans. |
|---|
| 1055 |
module QueryExtension |
|---|
| 1056 |
+ alias old_initialize_query initialize_query |
|---|
| 1057 |
# Initialize the data from the query. |
|---|
| 1058 |
# |
|---|
| 1059 |
# Handles multipart forms (in particular, forms that involve file uploads). |
|---|
| 1060 |
Index: actionpack/lib/action_controller/session.rb |
|---|
| 1061 |
=================================================================== |
|---|
| 1062 |
--- actionpack/lib/action_controller/session.rb (revision 1873) |
|---|
| 1063 |
+++ actionpack/lib/action_controller/session.rb (working copy) |
|---|
| 1064 |
@@ -7,8 +7,12 @@ |
|---|
| 1065 |
|
|---|
| 1066 |
private |
|---|
| 1067 |
def clear_persistant_model_associations #:doc: |
|---|
| 1068 |
+ unless defined? @session and |
|---|
| 1069 |
+ @session.instance_variables.include? '@data' then |
|---|
| 1070 |
+ return |
|---|
| 1071 |
+ end |
|---|
| 1072 |
session = @session.instance_variable_get("@data") |
|---|
| 1073 |
session.each { |key, obj| obj.clear_association_cache if obj.respond_to?(:clear_association_cache) } if session |
|---|
| 1074 |
end |
|---|
| 1075 |
end |
|---|
| 1076 |
-end |
|---|
| 1077 |
\ No newline at end of file |
|---|
| 1078 |
+end |
|---|
| 1079 |
Index: actionwebservice/Rakefile |
|---|
| 1080 |
=================================================================== |
|---|
| 1081 |
--- actionwebservice/Rakefile (revision 1873) |
|---|
| 1082 |
+++ actionwebservice/Rakefile (working copy) |
|---|
| 1083 |
@@ -27,6 +27,7 @@ |
|---|
| 1084 |
t.libs << "test" |
|---|
| 1085 |
t.test_files = Dir['test/*_test.rb'] |
|---|
| 1086 |
t.verbose = true |
|---|
| 1087 |
+ t.warning = true |
|---|
| 1088 |
} |
|---|
| 1089 |
|
|---|
| 1090 |
|
|---|