Sha256: 7dff8fba61081e578d8b8c7794f5abc0dc659868a87abeeadf1f4a1b321a2ce6

Contents?: true

Size: 1.46 KB

Versions: 12

Compression:

Stored size: 1.46 KB

Contents

require File.join(File.dirname(__FILE__), "..", "spec_helper")

describe "When recognizing requests," do

  # predicate_matchers[:redirects] = :redirect
  
  describe "a route that redirects" do
    
    it "should set the request as a redirect" do
      Merb::Router.prepare do
        match("/foo").redirect("/bar")
      end
      
      route_for("/foo").should have_rack(:status => 302, :headers => { "Location" => "/bar" })
    end
    
    it "should be able to set the redirect as a temporary redirect" do
      Merb::Router.prepare do
        match("/foo").redirect("/bar", :permanent => true)
      end
      
      route_for("/foo").should have_rack(:status => 301, :headers => { "Location" => "/bar" })
    end
    
    it "should still redirect even if there was a deferred block assigned to the route" do
      Merb::Router.prepare do
        block = Proc.new { |r,p| p }
        defer(block) do
          match("/hello").redirect("/goodbye")
        end
      end
      
      route_for("/hello").should have_rack(:status => 302, :headers => { "Location" => "/goodbye" })
    end
    
    it "should redirect to the URL in the deferred block" do
      Merb::Router.prepare do
        block = Proc.new { |r,p| redirect("/deferred-goodbye") }
        defer(block) do
          match("/hello").redirect("/goodbye")
        end
      end
      
      route_for("/hello").should have_rack(:status => 302, :headers => { "Location" => "/deferred-goodbye" })
    end
    
  end
  
end

Version data entries

12 entries across 6 versions & 1 rubygems

Version Path
merb-core-1.1.3 spec/public/router/recognition/redirect_spec.rb
merb-core-1.1.3 spec10/public/router/recognition/redirect_spec.rb
merb-core-1.1.2 spec10/public/router/recognition/redirect_spec.rb
merb-core-1.1.2 spec/public/router/recognition/redirect_spec.rb
merb-core-1.1.1 spec/public/router/recognition/redirect_spec.rb
merb-core-1.1.1 spec10/public/router/recognition/redirect_spec.rb
merb-core-1.1.0 spec10/public/router/recognition/redirect_spec.rb
merb-core-1.1.0 spec/public/router/recognition/redirect_spec.rb
merb-core-1.1.0.rc1 spec/public/router/recognition/redirect_spec.rb
merb-core-1.1.0.rc1 spec10/public/router/recognition/redirect_spec.rb
merb-core-1.1.0.pre spec/public/router/recognition/redirect_spec.rb
merb-core-1.1.0.pre spec10/public/router/recognition/redirect_spec.rb