heroku-nav 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -21,8 +21,8 @@ begin
21
21
  gemspec.add_dependency(%q<rest-client>, ["~> 1.2.0"])
22
22
  gemspec.add_dependency(%q<json>, [">= 0"])
23
23
 
24
- gemspec.version = '0.1.2'
24
+ gemspec.version = '0.1.3'
25
25
  end
26
26
  rescue LoadError
27
27
  puts "Jeweler not available. Install it with: gem install jeweler"
28
- end
28
+ end
data/heroku-nav.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{heroku-nav}
8
- s.version = "0.1.2"
8
+ s.version = "0.1.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Todd Matthews", "Pedro Belo"]
data/lib/heroku/nav.rb CHANGED
@@ -6,9 +6,9 @@ module Heroku
6
6
  class Base
7
7
  def initialize(app, options={})
8
8
  @app = app
9
- if @except = options[:except]
10
- @except = [@except] unless @except.is_a?(Array)
11
- end
9
+ @options = options
10
+ @options[:except] = [@options[:except]] unless @options[:except].is_a?(Array)
11
+ @options[:status] ||= [200]
12
12
  refresh
13
13
  end
14
14
 
@@ -19,12 +19,12 @@ module Heroku
19
19
  end
20
20
 
21
21
  def can_insert?(env)
22
- return unless @status == 200
22
+ return unless @options[:status].include?(@status)
23
23
  return unless @headers['Content-Type'] =~ /text\/html/ || (@body.respond_to?(:headers) && @body.headers['Content-Type'] =~ /text\/html/)
24
24
  @body_accessor = [:first, :body].detect { |m| @body.respond_to?(m) }
25
25
  return unless @body_accessor
26
26
  return unless @body.send(@body_accessor) =~ /<body.*?>/i
27
- return if @except && @except.any? { |route| env['PATH_INFO'] =~ route }
27
+ return if @options[:except].any? { |route| env['PATH_INFO'] =~ route }
28
28
  true
29
29
  end
30
30
 
data/spec/nav_spec.rb CHANGED
@@ -47,6 +47,22 @@ describe Heroku::Nav::Header do
47
47
  last_response.body.should.not =~ /<!-- header -->/
48
48
  end
49
49
 
50
+ describe "defining response status" do
51
+ def app
52
+ make_app { use Heroku::Nav::Header, :status => [404] }
53
+ end
54
+
55
+ it "respects the :status option" do
56
+ get '/404', :body => '<html><body>hi'
57
+ last_response.body.should =~ /<!-- header -->/
58
+ end
59
+
60
+ it "allows overriding the default status" do
61
+ get '/', :body => '<html><body>hi'
62
+ last_response.body.should.not =~ /<!-- header -->/
63
+ end
64
+ end
65
+
50
66
  describe "excluding paths" do
51
67
  def app
52
68
  make_app { use Heroku::Nav::Header, :except => [/x/, /alt/] }
@@ -54,7 +70,7 @@ describe Heroku::Nav::Header do
54
70
 
55
71
  it "respects the :except option" do
56
72
  get '/alternate', :body => '<html><body>hi'
57
- last_response.body.should.equal '<html><body>hi'
73
+ last_response.body.should.not =~ /<!-- header -->/
58
74
  end
59
75
  end
60
76
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 2
9
- version: 0.1.2
8
+ - 3
9
+ version: 0.1.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Todd Matthews