Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adding support for Rails 1.2.6

  • Loading branch information...
commit 00770facc7ff3f2f196570db497ae75b9e87b1a1 1 parent 9650cef
@qrush qrush authored
View
7 ginger_scenarios.rb
@@ -14,6 +14,13 @@ def create_scenario(version)
config.aliases["active_support"] = "activesupport"
config.aliases["action_controller"] = "actionpack"
+ rails_1_2_6 = Ginger::Scenario.new
+ rails_1_2_6[/^active_?support$/] = "1.4.4"
+ rails_1_2_6[/^active_?record$/] = "1.15.6"
+ rails_1_2_6[/^action_?pack$/] = "1.13.6"
+ rails_1_2_6[/^action_?controller$/] = "1.13.6"
+
+ config.scenarios << rails_1_2_6
config.scenarios << create_scenario("2.0.2")
config.scenarios << create_scenario("2.1.2")
config.scenarios << create_scenario("2.2.2")
View
4 lib/hoptoad_notifier.rb
@@ -257,7 +257,9 @@ def ignore?(exception) #:nodoc:
end
def ignore_user_agent? #:nodoc:
- HoptoadNotifier.ignore_user_agent.flatten.any? { |ua| ua === request.user_agent }
+ # Rails 1.2.6 doesn't have request.user_agent, so check for it here
+ user_agent = request.respond_to?(:user_agent) ? request.user_agent : request.env["HTTP_USER_AGENT"]
+ HoptoadNotifier.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
end
def exception_to_data exception #:nodoc:
View
2  test/configuration_test.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/helper'
-class ConfigurationTest < ActiveSupport::TestCase
+class ConfigurationTest < Test::Unit::TestCase
context "HoptoadNotifier configuration" do
setup do
@controller = HoptoadController.new
View
2  test/controller_test.rb
@@ -125,7 +125,7 @@ def should_auto_include_catcher
end
end
-class ControllerTest < ActiveSupport::TestCase
+class ControllerTest < Test::Unit::TestCase
context "Hoptoad inclusion" do
should "be able to occur even outside Rails controllers" do
assert_nothing_raised do
View
50 test/helper.rb
@@ -12,7 +12,6 @@
require 'active_record'
require 'active_record/base'
require 'active_support'
-require 'active_support/test_case'
require File.join(File.dirname(__FILE__), "..", "lib", "hoptoad_notifier")
@@ -57,14 +56,59 @@ class HoptoadController < ActionController::Base
include TestMethods
end
-class ActiveSupport::TestCase
+class Test::Unit::TestCase
def request(action = nil, method = :get, user_agent = nil, params = {})
@request = ActionController::TestRequest.new
@request.action = action ? action.to_s : ""
- @request.user_agent = user_agent unless user_agent.nil?
+
+ if user_agent
+ if @request.respond_to?(:user_agent=)
+ @request.user_agent = user_agent
+ else
+ @request.env["HTTP_USER_AGENT"] = user_agent
+ end
+ end
@request.query_parameters = @request.query_parameters.merge(params)
@response = ActionController::TestResponse.new
@controller.process(@request, @response)
end
+
+ # Borrowed from ActiveSupport 2.3.2
+ def assert_difference(expression, difference = 1, message = nil, &block)
+ b = block.send(:binding)
+ exps = Array.wrap(expression)
+ before = exps.map { |e| eval(e, b) }
+
+ yield
+
+ exps.each_with_index do |e, i|
+ error = "#{e.inspect} didn't change by #{difference}"
+ error = "#{message}.\n#{error}" if message
+ assert_equal(before[i] + difference, eval(e, b), error)
+ end
+ end
+
+ def assert_no_difference(expression, message = nil, &block)
+ assert_difference expression, 0, message, &block
+ end
end
+# Also stolen from AS 2.3.2
+class Array
+ # Wraps the object in an Array unless it's an Array. Converts the
+ # object to an Array using #to_ary if it implements that.
+ def self.wrap(object)
+ case object
+ when nil
+ []
+ when self
+ object
+ else
+ if object.respond_to?(:to_ary)
+ object.to_ary
+ else
+ [object]
+ end
+ end
+ end
+end
View
2  test/hoptoad_tasks_test.rb
@@ -6,7 +6,7 @@
FakeWeb.allow_net_connect = false
-class HoptoadTasksTest < ActiveSupport::TestCase
+class HoptoadTasksTest < Test::Unit::TestCase
def successful_response(body = "")
response = Net::HTTPSuccess.new('1.2', '200', 'OK')
response.stubs(:body).returns(body)
View
2  test/logger_test.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/helper'
-class LoggerTest < ActiveSupport::TestCase
+class LoggerTest < Test::Unit::TestCase
class ::LoggerController < ::ActionController::Base
include HoptoadNotifier::Catcher
include TestMethods
View
2  test/notifier_test.rb
@@ -1,6 +1,6 @@
require File.dirname(__FILE__) + '/helper'
-class NotifierTest < ActiveSupport::TestCase
+class NotifierTest < Test::Unit::TestCase
context "Sending a notice" do
should "not fail without rails environment" do
assert_nothing_raised do
Please sign in to comment.
Something went wrong with that request. Please try again.