hoptoad_notifier 2.4.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ Version 2.4.2 - Sun Jan 09 09:37:31 -0500 2011
2
+ ===============================================================================
3
+
4
+ Matt Jankowski (1):
5
+ fix issue where the gsub to replace the html head with javascript was removing the head element entirely
6
+
7
+
1
8
  Version 2.4.1 - Sat Jan 08 12:17:15 -0500 2011
2
9
  ===============================================================================
3
10
 
@@ -368,5 +375,6 @@ Nick Quaranto (3):
368
375
 
369
376
 
370
377
 
378
+
371
379
 
372
380
 
@@ -34,9 +34,14 @@ module HoptoadNotifier
34
34
  end
35
35
 
36
36
  if response.body.respond_to?(:gsub)
37
- response.body = response.body.gsub(/<(head.*?)>/i, "<\1>\n" + javascript)
37
+ response.body = insert_javascript_after_head response.body, javascript
38
38
  end
39
39
  end
40
+
41
+ def insert_javascript_after_head(body, javascript)
42
+ body.gsub /<(head.*?)>/i, "<\\1>\n#{javascript}\n"
43
+ end
44
+
40
45
  end
41
46
  end
42
47
  end
@@ -1,3 +1,3 @@
1
1
  module HoptoadNotifier
2
- VERSION = "2.4.1".freeze
2
+ VERSION = "2.4.2".freeze
3
3
  end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ require 'hoptoad_notifier/rails/javascript_notifier'
4
+
5
+ class JavascriptNotifierTest < Test::Unit::TestCase
6
+
7
+ def self.after_filter(arg); end
8
+ include ::HoptoadNotifier::Rails::JavascriptNotifier
9
+
10
+ should "insert javascript after head" do
11
+ input_body =<<-EOS
12
+ <html><head><title></title></head><body></body></html>
13
+ EOS
14
+ javascript = "js-code"
15
+ expected =<<-EOS
16
+ <html><head>
17
+ js-code
18
+ <title></title></head><body></body></html>
19
+ EOS
20
+ output = send :insert_javascript_after_head, input_body, javascript
21
+ assert_equal expected, output
22
+ end
23
+
24
+ should "insert javascript after head when head has attributes" do
25
+ input_body =<<-EOS
26
+ <html><head lang="en"><title></title></head><body></body></html>
27
+ EOS
28
+ javascript = "js-code"
29
+ expected =<<-EOS
30
+ <html><head lang="en">
31
+ js-code
32
+ <title></title></head><body></body></html>
33
+ EOS
34
+ output = send :insert_javascript_after_head, input_body, javascript
35
+ assert_equal expected, output
36
+ end
37
+
38
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoptoad_notifier
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 4
9
- - 1
10
- version: 2.4.1
9
+ - 2
10
+ version: 2.4.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - thoughtbot, inc
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-01-08 00:00:00 -05:00
18
+ date: 2011-01-09 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -163,6 +163,7 @@ files:
163
163
  - test/configuration_test.rb
164
164
  - test/helper.rb
165
165
  - test/hoptoad_tasks_test.rb
166
+ - test/javascript_notifier_test.rb
166
167
  - test/logger_test.rb
167
168
  - test/notice_test.rb
168
169
  - test/notifier_test.rb
@@ -214,6 +215,7 @@ test_files:
214
215
  - test/catcher_test.rb
215
216
  - test/configuration_test.rb
216
217
  - test/hoptoad_tasks_test.rb
218
+ - test/javascript_notifier_test.rb
217
219
  - test/logger_test.rb
218
220
  - test/notice_test.rb
219
221
  - test/notifier_test.rb