heroku-nav 0.1.17 → 0.1.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -21,7 +21,7 @@ begin
21
21
  gemspec.add_dependency(%q<rest-client>, [">= 1.0"])
22
22
  gemspec.add_dependency(%q<json>, [">= 0"])
23
23
 
24
- gemspec.version = '0.1.17'
24
+ gemspec.version = '0.1.18'
25
25
  end
26
26
  rescue LoadError
27
27
  puts "Jeweler not available. Install it with: gem install jeweler"
data/heroku-nav.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{heroku-nav}
8
- s.version = "0.1.17"
8
+ s.version = "0.1.18"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Dollar", "Pedro Belo", "Todd Matthews"]
12
- s.date = %q{2010-08-02}
12
+ s.date = %q{2010-09-10}
13
13
  s.description = %q{}
14
14
  s.email = ["david@heroku.com", "pedro@heroku.com", "todd@heroku.com"]
15
15
  s.files = [
data/lib/heroku/nav.rb CHANGED
@@ -118,10 +118,14 @@ module Heroku
118
118
  end
119
119
  end
120
120
 
121
+ def can_insert?(env)
122
+ super && env['HTTP_COOKIE'] && env['HTTP_COOKIE'].include?('heroku-nav-data')
123
+ end
124
+
121
125
  def insert!
122
126
  if @nav
123
127
  match = @body.match(/(\<body[^\>]*\>)/i)
124
- if match.size > 0
128
+ if match && match.size > 0
125
129
  @body.insert(match.end(0), @nav)
126
130
  @headers['Content-Length'] = @body.length.to_s
127
131
  end
data/spec/nav_spec.rb CHANGED
@@ -112,30 +112,52 @@ describe Heroku::Nav::Provider do
112
112
  Heroku::Nav::Provider.stubs(:fetch).returns('<!-- heroku header -->')
113
113
  end
114
114
 
115
- def app
116
- make_app { use Heroku::Nav::Provider }
117
- end
115
+ describe "when there's no heroku-nav-data cookie" do
116
+ def app
117
+ make_app { use Heroku::Nav::Provider }
118
+ end
118
119
 
119
- it "adds the body" do
120
- get '/', :body => '<html><body>hi</body>'
121
- last_response.body.should.equal '<html><body><!-- heroku header -->hi</body>'
120
+ it "doesn't add the body" do
121
+ get '/', :body => '<html><body>hi</body>'
122
+ last_response.body.should.equal '<html><body>hi</body>'
123
+ end
122
124
  end
123
125
 
124
- describe "special chars" do
126
+ describe "when there's a heroku-nav-data cookie" do
125
127
  before do
126
- Heroku::Nav::Provider.stubs(:fetch).returns('<!-- \+ nav -->')
128
+ set_cookie("heroku-nav-data=data")
127
129
  end
128
130
 
129
131
  def app
130
132
  make_app { use Heroku::Nav::Provider }
131
133
  end
132
134
 
133
- # tricky situation, the first implementation of Heroku::Nav would inject the
134
- # html by using gsub. That worked out alright until the html got a sequence of
135
- # chars like "\+". those got interpreted by gsub and resulted in a bad output
136
- it "doesn't freakout if the header contains special chars relevant to Ruby's gsub" do
135
+ it "adds the body" do
137
136
  get '/', :body => '<html><body>hi</body>'
138
- last_response.body.should.equal '<html><body><!-- \+ nav -->hi</body>'
137
+ last_response.body.should.equal '<html><body><!-- heroku header -->hi</body>'
138
+ end
139
+
140
+ it "doesn't add if there is no body tag" do
141
+ get '/', :body => 'no body!'
142
+ last_response.body.should.equal 'no body!'
143
+ end
144
+
145
+ describe "special chars" do
146
+ before do
147
+ Heroku::Nav::Provider.stubs(:fetch).returns('<!-- \+ nav -->')
148
+ end
149
+
150
+ def app
151
+ make_app { use Heroku::Nav::Provider }
152
+ end
153
+
154
+ # tricky situation, the first implementation of Heroku::Nav would inject the
155
+ # html by using gsub. That worked out alright until the html got a sequence of
156
+ # chars like "\+". those got interpreted by gsub and resulted in a bad output
157
+ it "doesn't freakout if the header contains special chars relevant to Ruby's gsub" do
158
+ get '/', :body => '<html><body>hi</body>'
159
+ last_response.body.should.equal '<html><body><!-- \+ nav -->hi</body>'
160
+ end
139
161
  end
140
162
  end
141
163
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 17
9
- version: 0.1.17
8
+ - 18
9
+ version: 0.1.18
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Dollar
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-08-02 00:00:00 -07:00
19
+ date: 2010-09-10 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency