Take me home

Third Rails patch

Written by August Lilleaas, published December 19, 2007

This is probably the last time I post explicitly about patches here, it’s not special anymore

So right, here it is:

http://dev.rubyonrails.org/ticket/10568

The setup method is subclassed tests isn’t run. Not cool if you need to do something like this:

class FooControllerTest < ActiveSupport::TestCase
  def setup
    # subdomain authentication coming in!
    @request.host = "subdomain.local.host"
  end

  def test_me
    assert important_thing_relying_on_subdomain
  end

  def test_but_oh_noes
    raise @request.host.inspect
    # it'll go "test.host", which is the default
  end
end

Annoying. You could even do this:

class FooControllerTest < ActiveSupport::TestCase
  def setup
    raise "BUT OMG LOL"
  end

  def test_me
    assert important_thing_relying_on_subdomain
  end

  def test_but_oh_noes
    assert something_else
  end
end

And none of the test would get raised, because the setup method simply doesn’t run.

This was because of fancyness added in changeset #8392. Brynary is working some magic, so it’ll hopefully be a fix soon. If not, it’ll get rolled back. Yarr.


Questions or comments?

Feel free to contact me on Twitter, @augustl, or e-mail me at august@augustl.com.