Skip to content

Anonymous controller problem #573

@Exoth

Description

@Exoth

I've got such a before_filter in ApplicationController:

def foo
  redirect_to(params.except(:ref, :marker), status: 301) if params[:ref] || params[:marker]
end

And I want to test it using anonymous controller like this:

require 'spec_helper'

describe ApplicationController, type: :controller do
  controller do
    def index
      head :ok
    end
  end

  it "should redirect without ref and marker if any of them is given in request" do
    get :index, ref: 1, marker: 2, foo: 3
    response.should redirect_to('/anonymous/?foo=3')
  end
end

But this results in "was a redirect to http://test.host/flights/?controller=anonymous&foo=3" as inside ApplicationController it continues to use usual routing of the application where anonymous controller is not defined.

What is the supposed way to test such before_filters?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions