Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Rack Middleware breaks RSpec integration tests #16

Merged
merged 1 commit into from Jun 11, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/versionist/middleware.rb
Expand Up @@ -19,7 +19,7 @@ def call(env)

def _call(env)
request = ::Rack::Request.new(env)
strategy = Versionist.configuration.versioning_strategies.detect {|vs| vs.is_a?(Versionist::VersioningStrategy::Header) && vs.config[:header] == ACCEPT && env[HTTP_ACCEPT].include?(vs.config[:value])}
strategy = Versionist.configuration.versioning_strategies.detect {|vs| vs.is_a?(Versionist::VersioningStrategy::Header) && vs.config[:header] == ACCEPT && env[HTTP_ACCEPT].try(:include?, vs.config[:value])}
if !strategy.nil?
entries = env[HTTP_ACCEPT].split(',')
index = -1
Expand Down
6 changes: 6 additions & 0 deletions spec/middleware_spec.rb
Expand Up @@ -35,5 +35,11 @@
status, headers, response = described_class.new(@app).call(request)
response[0].should == "audio/*; q=0.2, audio/basic, application/json, application/vnd.mycompany.com-v2.3.0"
end

it "should not alter the header if the accept header is not present" do
request = Rack::MockRequest.env_for("/foos", :lint => true, :fatal => true)
status, headers, response = described_class.new(@app).call(request)
response[0].should be_nil
end
end
end