Piku’s Blog

January 27, 2008

Testing subdomains as account keys

Filed under: Ruby on Rails — Tags: , , , — Mihai @ 6:49 pm

I am using subdomains as account keys and some tests failed for controllers, they were looking for the account but didn’t find it.

The trick is to rewrite the host in the tests. Here’s the code for rspec.



  before(:each) do

    @request.host = 'piku.mysite.net'

  end

Here, before each test the url is rewritten and the filter that finds the account happily does it job.

Advertisements

2 Comments »

  1. Thx for posting this. Came in handy just now!

    Comment by Shanti Braford — September 22, 2008 @ 1:01 am

  2. Thanks for this, I can stop pulling my hair out now!

    Comment by Scott Burton — July 31, 2009 @ 5:53 am


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: