ActionMailer, Named Routes and Testing

I’ve immersed myself in Ruby and Rails for the last several weeks, working on a project I hope to complete in the next month or so. The other day, I created a new mailer to send a welcome message when a user registers with the site. I’d done a mailer before and written a unit test for it, and was surprised to see the following when I wrote a unit test for the new one:

1) Error:
test_welcome(UserAccountMailerTest):
ActionView::TemplateError: confirm_user_url failed to generate from {:controller=>"users", :email_address_id=>"1", :secret=>nil, :action=>"confirm"}, expected: {:controller=>"users", :action=>"confirm"}, diff: {:email_address_id=>"1", :secret=>nil}

It looks like ActionMailer isn’t happy when a mail template makes use of named routes when run inside the test framework, but that doesn’t make any sense. Here is the route, from routes.rb:

map.confirm_user "users/confirm/:email_address_id/:secret",
:controller => "users",
:action => "confirm",
:requirements => { :email_address_id => /\d+/,
:secret => /\d+/ }

The error seems to say that the routing framework is not parsing my route correctly, and fails to see that :email_address_id and :secret are both requirements for the route (“expected:” specifically excludes those two parameters).

This is one of those times where the error message didn’t help as much as I hope it would. It turns out that the entire problem is because “secret” is a new column, and I hadn’t added it to my fixtures yet. Fixing that fixes the problem, and my test passes.

Usually, the net is amazingly wise and I can find either an answer or a hint in the right direction after a few searches. This time, I had to rely on a “hey, wait a second…” moment.

The Value of Customer Service

A couple of months ago, there was a little bit of discussion on the web about customer service. Ryan Carson (of Carson Systems) related his experience from the business owner’s perspective that didn’t go very well.

Surprisingly, it doesn’t take an abusive customer to get the brush off from a company. My wife’s cell phone got wet one day. Not soaking wet, but wet enough that within a week or so it started turning itself off at random times.

She went shopping on eBay, found the same model (used) for $30 and bought it. It is locked to the Cingular network. We’re Cingular customers, though the merger with AT&T Wireless, but the phone doesn’t know about the merger. We hadn’t considered this, and her old SIM card didn’t work in the new phone.

Calling Cingular doesn’t help. They’re willing to sell us a new, Cingular SIM card for $30 or sign us up to a new contract and give her a new, free phone.

A quick Google search later and we’re reading instructions for how to unlock the phone ourselves, for free. Now her SIM card works fine in the phone. She’s moved over her contacts, wallpaper and wants her old ringtone back, too.

Next problem: the used phone from eBay isn’t set up quite the same and is having trouble getting to the ringtone she’s purchased. Another call to tech support is equally as fruitless. They won’t help us at all and outright lie about the phone not having the same features since it’s a Cingular phone and we’re AT&T customers. Or maybe it’s because it’s an unlocked phone. It’s so bad, they can’t keep their lies straight. She got it working herself by comparing the settings of the two phones side-by-side.

The moral of the story is this: we’re long-time customers, past the end of our contract, and nothing but momentum is keeping us with Cingular. They should realize this, and make an effort to keep us happy. Instead, they attempt to squeeze more money out of us and lie. All they have accomplished is to give us another reason to leave.


On a different note, how much fun is Ohio weather? Last week, it was 80. Today, 28 and:

Snow in April