JB Steadman's blog



JB SteadmanJB Steadman
javascriptTests.bind(reality)
edit Posted by JB Steadman on Friday February 05, 2010 at 12:05AM

Javascript tests are good, but manually-maintained HTML fixtures are painful. It's time consuming to keep fixture markup in sync with the actual markup produced by your app. Despite best efforts, deviations arise, leading to bugs and false positives in tests.

For the past few months on Mavenlink, we've been pre-generating real-life fixture markup and making it available in our javascript tests. Results have been positive.

JB SteadmanJB Steadman
more page dynamics, less client logic
edit Posted by JB Steadman on Saturday January 23, 2010 at 07:45PM

Ajaxed pages frequently need to update many parts of the page within ajax callbacks. Here I'll outline how we use jQuery and Rails do this on Mavenlink. Our approach encodes behavior declaratively in markup and minimizes client-side logic.

ActiveRecord's update_attribute() method is useful for setting a single attribute value while bypassing validation.

You may not know, however, that when invoked on a new record, update_attribute() saves the record, including all the fields, and bypassing validation for all fields.

This can lead to some unwelcome surprises. For example, acts_as_list uses update_attribute(), so if you're using acts_as_list, watch out for unexpected, unvalidated saves when using new records within the list.

Thanks to Adam Milligan for the heads-up.