Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Adding support for Rails 1.2.6

  • Loading branch information...
commit 00770facc7ff3f2f196570db497ae75b9e87b1a1 1 parent 9650cef
Nick Quaranto qrush authored
7 ginger_scenarios.rb
@@ -14,6 +14,13 @@ def create_scenario(version)
14 14 config.aliases["active_support"] = "activesupport"
15 15 config.aliases["action_controller"] = "actionpack"
16 16
  17 + rails_1_2_6 = Ginger::Scenario.new
  18 + rails_1_2_6[/^active_?support$/] = "1.4.4"
  19 + rails_1_2_6[/^active_?record$/] = "1.15.6"
  20 + rails_1_2_6[/^action_?pack$/] = "1.13.6"
  21 + rails_1_2_6[/^action_?controller$/] = "1.13.6"
  22 +
  23 + config.scenarios << rails_1_2_6
17 24 config.scenarios << create_scenario("2.0.2")
18 25 config.scenarios << create_scenario("2.1.2")
19 26 config.scenarios << create_scenario("2.2.2")
4 lib/hoptoad_notifier.rb
@@ -257,7 +257,9 @@ def ignore?(exception) #:nodoc:
257 257 end
258 258
259 259 def ignore_user_agent? #:nodoc:
260   - HoptoadNotifier.ignore_user_agent.flatten.any? { |ua| ua === request.user_agent }
  260 + # Rails 1.2.6 doesn't have request.user_agent, so check for it here
  261 + user_agent = request.respond_to?(:user_agent) ? request.user_agent : request.env["HTTP_USER_AGENT"]
  262 + HoptoadNotifier.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
261 263 end
262 264
263 265 def exception_to_data exception #:nodoc:
2  test/configuration_test.rb
... ... @@ -1,6 +1,6 @@
1 1 require File.dirname(__FILE__) + '/helper'
2 2
3   -class ConfigurationTest < ActiveSupport::TestCase
  3 +class ConfigurationTest < Test::Unit::TestCase
4 4 context "HoptoadNotifier configuration" do
5 5 setup do
6 6 @controller = HoptoadController.new
2  test/controller_test.rb
@@ -125,7 +125,7 @@ def should_auto_include_catcher
125 125 end
126 126 end
127 127
128   -class ControllerTest < ActiveSupport::TestCase
  128 +class ControllerTest < Test::Unit::TestCase
129 129 context "Hoptoad inclusion" do
130 130 should "be able to occur even outside Rails controllers" do
131 131 assert_nothing_raised do
50 test/helper.rb
@@ -12,7 +12,6 @@
12 12 require 'active_record'
13 13 require 'active_record/base'
14 14 require 'active_support'
15   -require 'active_support/test_case'
16 15
17 16 require File.join(File.dirname(__FILE__), "..", "lib", "hoptoad_notifier")
18 17
@@ -57,14 +56,59 @@ class HoptoadController < ActionController::Base
57 56 include TestMethods
58 57 end
59 58
60   -class ActiveSupport::TestCase
  59 +class Test::Unit::TestCase
61 60 def request(action = nil, method = :get, user_agent = nil, params = {})
62 61 @request = ActionController::TestRequest.new
63 62 @request.action = action ? action.to_s : ""
64   - @request.user_agent = user_agent unless user_agent.nil?
  63 +
  64 + if user_agent
  65 + if @request.respond_to?(:user_agent=)
  66 + @request.user_agent = user_agent
  67 + else
  68 + @request.env["HTTP_USER_AGENT"] = user_agent
  69 + end
  70 + end
65 71 @request.query_parameters = @request.query_parameters.merge(params)
66 72 @response = ActionController::TestResponse.new
67 73 @controller.process(@request, @response)
68 74 end
  75 +
  76 + # Borrowed from ActiveSupport 2.3.2
  77 + def assert_difference(expression, difference = 1, message = nil, &block)
  78 + b = block.send(:binding)
  79 + exps = Array.wrap(expression)
  80 + before = exps.map { |e| eval(e, b) }
  81 +
  82 + yield
  83 +
  84 + exps.each_with_index do |e, i|
  85 + error = "#{e.inspect} didn't change by #{difference}"
  86 + error = "#{message}.\n#{error}" if message
  87 + assert_equal(before[i] + difference, eval(e, b), error)
  88 + end
  89 + end
  90 +
  91 + def assert_no_difference(expression, message = nil, &block)
  92 + assert_difference expression, 0, message, &block
  93 + end
69 94 end
70 95
  96 +# Also stolen from AS 2.3.2
  97 +class Array
  98 + # Wraps the object in an Array unless it's an Array. Converts the
  99 + # object to an Array using #to_ary if it implements that.
  100 + def self.wrap(object)
  101 + case object
  102 + when nil
  103 + []
  104 + when self
  105 + object
  106 + else
  107 + if object.respond_to?(:to_ary)
  108 + object.to_ary
  109 + else
  110 + [object]
  111 + end
  112 + end
  113 + end
  114 +end
2  test/hoptoad_tasks_test.rb
@@ -6,7 +6,7 @@
6 6
7 7 FakeWeb.allow_net_connect = false
8 8
9   -class HoptoadTasksTest < ActiveSupport::TestCase
  9 +class HoptoadTasksTest < Test::Unit::TestCase
10 10 def successful_response(body = "")
11 11 response = Net::HTTPSuccess.new('1.2', '200', 'OK')
12 12 response.stubs(:body).returns(body)
2  test/logger_test.rb
... ... @@ -1,6 +1,6 @@
1 1 require File.dirname(__FILE__) + '/helper'
2 2
3   -class LoggerTest < ActiveSupport::TestCase
  3 +class LoggerTest < Test::Unit::TestCase
4 4 class ::LoggerController < ::ActionController::Base
5 5 include HoptoadNotifier::Catcher
6 6 include TestMethods
2  test/notifier_test.rb
... ... @@ -1,6 +1,6 @@
1 1 require File.dirname(__FILE__) + '/helper'
2 2
3   -class NotifierTest < ActiveSupport::TestCase
  3 +class NotifierTest < Test::Unit::TestCase
4 4 context "Sending a notice" do
5 5 should "not fail without rails environment" do
6 6 assert_nothing_raised do

0 comments on commit 00770fa

Please sign in to comment.
Something went wrong with that request. Please try again.