Properly Setting HTTP_REFERER in a Rails Integration Test for a File Upload

February 3rd, 2009 by

This one had me frustrated for the past hour. I’ve been writing integration tests for a Rails project and got stuck on an error when I was trying to test that a file upload worked successfully and asserted a redirection was occuring correctly, but ran into the following error:

Expected response to be a <:redirect>, but was <500>
<"No HTTP_REFERER was set in the request to this action, so
redirect_to :back could not be called successfully. If this
is a test, make sure to specify
request.env[\"HTTP_REFERER\"].">

What a lovely error message to send me on a goose chase trying to set HTTP_REFERER directly on the @request as instructed.

Did Not Work

@request.env["HTTP_REFERER"] = '/'
post upload_path, { :file => fixture_file_upload("worddoc.docx", "application/msword") },
  { :html => {:multipart => true} }
assert_redirected_to '/', 'index'

This continued to spit out the same error. I finally stumbled across a post back from 2006 that held the answer. The HTTP_REFERER is not set the same way in an integration test:

Success!

post upload_path, { :file => fixture_file_upload("worddoc.docx", "application/msword") },
  { :html => {:multipart => true}, :referer => '/' }
assert_redirected_to '/', 'index'

Hope that saves anyone else some time if you encounter this error.

PureMVCGen 0.1.1 Released – Now Works on Windows

December 18th, 2008 by

I just released a minor update to PureMVCGen to fix a bug the original release had that caused the ANT commands to fail on Windows. If you’ve already installed the gem before, then simply run:

$> gem update puremvc-gen

to get the new version. If you’re installing for the first time, refer to the original blog post for instructions.

Getting git-svn to run on OS X

December 10th, 2008 by

I’ve been gitting into git (clever, I know) lately, so I was trying to migrate my git commits for a project back into an existing subversion repository – another post coming on that later.

When trying to run git-svn to import my subversion repository into git I got the following error, followed by a Perl stack trace:

Can't locate Term/ReadKey.pm

A couple of installs got this working, read on…

Read the rest of this entry »

Introducing PureMVCGen – an ANT based PureMVC Flex Generator

December 5th, 2008 by

I just published a PureMVC code generation tool I’ve been working on lately. It’s an ANT-based tool, but is distributed via Ruby Gems, which allows it to be easily installed as a command-line tool once you have Ruby, rubygems, and ANT installed.

Once you have those programs installed, simply enter ($> just denotes you are at a prompt on the command line)

$> gem install puremvc-gen

and the tool will be installed. Read on to see how to use it…

Read the rest of this entry »

Displaying an Image in a ComboBox

December 1st, 2008 by

I needed to display an Image inside of a ComboBox for a recent project. The image of a selectedItem needed to appear in the ComboBox when it is collapsed and the image needed to be specified as a String.

I was surprised that a quick search didn’t find any components to allow this. The closest was a post by Jason Hawryluk, however this required the image to be embedded into the application.

So I simply extended ComboBox to include an Image within it, and added some sizing calculations so it would respect padding. An example follows below:
Read the rest of this entry »

Presenting an Intro to Flex at Refresh Baltimore Tonight

November 12th, 2008 by

I’ll be presenting an introduction to Flex tonight at Refresh Baltimore. If you’ve been wondering what Flex is and have been meaning to look into it, this presentation will be right up your alley.

The presentation slides and code will be posted at http://www.smartlogicsolutions.com/wiki/Intro_to_Flex after the presentation.

RSVP at http://www.localist.com/event/6229 if you can make it.

I Won the AIR Cook-off

October 29th, 2008 by

I was waiting to post this until the results were announced which they were today. O’Reilly just posted the winners of the Adobe AIR Cook-off and I’m pleased to say I won the grand prize!

My recipe was Migrating Serialization Changes in AIR. Thanks to anyone who voted for it.

I have a follow-up recipe I haven’t gotten to write up yet, but I’ll try to get it up in the next week. It will provide a solution to add the marker which is required for this serialization to work to the front of your structures if you already have files being serialized in an existing AIR application and you want to start taking advantage of this migration technique.

Advanced CSS in Flex 4 – ID and Descendant Selectors

October 21st, 2008 by

NOTE: View my comment below for updated code on making this work with the latest SDK (as of 5/25/09).

A few days ago one of the commit messages in the Gumbo trunk mentioned some work for advanced CSS was beginning. I tried to create an example of using a descendant selector as well as an ID selector, but neither worked.

Tonight, another commit message said that this was now in place by default (I guess it would have worked earlier, but I needed to be specify a compiler argument). But now, after rebuilding the latest checkout of Gumbo you should now be able to compile the following example to see the advanced CSS selectors working. Below is the SWF (you’ll need Flash Player 10 to view it) and the code follows:

Read the rest of this entry »

Using SWFObject to Seamlessly Upgrade to Flash Player 10

October 15th, 2008 by

If you haven’t heard that Flash Player 10 was officially released, then get out of the hole you’ve been living in and go get Flash Player 10!

When you’re ready to deploy your first Flash Player 10 SWF, you’ll want to ensure your users have the latest Flash Player so they can actually view your content! Why not make it as easy as possible for them to upgrade and use SWFObject to embed your SWF and seamlessly upgrade older version of the Flash Player up to 10?

Let’s say you’re embedding a SWF called MyFlashPlayer10.swf. Using the dynamic publishing method there are just 3 simple steps to follow to get your SWF embedded with SWFObject…

Read the rest of this entry »

  • You are currently browsing the archives for the Greg Jastrab category.


viceroy red mug