Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

jquery 1.7.1 and 1.7.2 breaks jasmine tests #262

Closed
marcagas opened this Issue · 4 comments

3 participants

@marcagas

We are using jquery_ujs (https://github.com/rails/jquery-ujs) for handling our ajax requests, when we've upgraded jquery from 1.6.4 to 1.7.1 it broke our tests. Specifically with regards to the binding of live events on jquery_ujs library.

e.g. $('a[data-confirm], a[data-method], a[data-remote]').live('click.rails', function() {
//handle ajax request
});

Since live method is deprecated in 1.7.1 we've upgraded the jquery_ujs library to it's latest which is now using delegate method for binding of events which calls our ajax requests.

e.g. $(document).delegate('a[data-remote]', 'click.rails', function(e) {
//handle ajax request
});

I've found out this issue when I reverted our upgrade from 1.7.2 to 1.6.4, sames goes with 1.7.1. Does anyone knows how to fix this issue or has it already been fixed or is there a patch for this? I'm pretty sure the sequence of my js files are correct. I just don't know why all my event bindings got unbind when running the tests.

Thanks

@ghost
@austinbv

I am not sure if this is the issue but quoting http://api.jquery.com/live/

As of jQuery 1.7, the .live() method is deprecated. Use .on() to attach event handlers. Users of older versions of jQuery should use .delegate() in preference to .live().

@marcagas

describe('ajax', function() {

beforeEach(function(){
$('#jasmine_content').append("hello");
spyOn($, 'ajax');

});

it("should insert some data so that Amazon ELB does not break our app", function(){
$("#mylink").attr('data-method', 'get');
$("#mylink").click();
expect($.ajax.mostRecentCall.args[0].data).toBeNull();
});
}):

$.ajax.mostRecentCall.args is undefined now. When I put some code in my click handler at jquery_ujs it doesn't alert or logged anything. When I use the previous version jquery 1.6.4 it still works. Note, we're no longer using live at the latest jquery_ujs, it's using delegate method which works like on() too.

Thanks for your replies.

@ragaskar
Owner

I think we'd need to see the code to offer more help, but I don't think this is a Jasmine issue -- it sounds like it's the upgrade is responsible for the test breakage. Closing, but feel free to discuss further (and post the implementation) on the jasmine-js mailing list (https://groups.google.com/forum/?fromgroups#!forum/jasmine-js)

@ragaskar ragaskar closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.