Sha256: 5097b2075dd2f1ec2eec37397b89eb11ab7099e121bdf20d413fcdd7357e7f7b

Contents?: true

Size: 1.64 KB

Versions: 3

Compression:

Stored size: 1.64 KB

Contents

require 'test_helper'

class VersionedRoutingTest < ActionDispatch::IntegrationTest
  test "a request without a verison cascades to versionless routes" do
    get '/final_fallback'
    assert_equal(response.body, 'v0')
  end

  test "a route with an override will match on the higher verison" do
    get '/a_path_overridden_from_v1/somevalue/whats/anothervalue', {}, {'Accept' => 'version=2'}
    assert_equal(response.body, 'v2')
  end

  test "a route with an override will match on the lower verison if specified" do
    get '/a_path_overridden_from_v1/somevalue/whats/anothervalue', {}, {'Accept' => 'version=1'}
    assert_equal(response.body, 'v1')
  end

  test "a route not defined on a specific verison will cascade to until a lower version match is found" do
    get '/a_path_in_v2', {}, {'Accept' => 'version=3'}
    assert_equal(response.body, 'v2')
  end

  test "a route defined in a higher version will cascade on lower versions" do
    assert_raise ActionController::RoutingError do
      get '/a_path_only_in_v3', {}, {'Accept' => 'version=2'}
    end
  end

  test "a route removed in a version will return a 404" do
    get '/another_path_in_v1', {}, {'Accept' => 'version=1'}
    assert_equal(response.status, 200)

    assert_raise ActionController::RoutingError do
      get '/another_path_in_v1', {}, {'Accept' => 'version=2'}
    end
  end

  test "a route removed in a version lower than it self will return a 404" do
    get '/another_path_in_v1', {}, {'Accept' => 'version=1'}
    assert_equal(response.status, 200)

    assert_raise ActionController::RoutingError do
      get '/another_path_in_v1', {}, {'Accept' => 'version=3'}
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_versioned_routing-1.3.1 test/versioned_routing_test.rb
rails_versioned_routing-1.3.0 test/versioned_routing_test.rb
rails_versioned_routing-1.2.0 test/versioned_routing_test.rb