Skip to content

Commit 8539e60

Browse files
committed
Merge pull request rails#346 from rails/camel-case
Change snake_case usage to camelCase
2 parents 56ea707 + 20ca908 commit 8539e60

File tree

6 files changed

+66
-66
lines changed

6 files changed

+66
-66
lines changed

src/rails.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,18 +161,18 @@
161161
var href = rails.href(link),
162162
method = link.data('method'),
163163
target = link.attr('target'),
164-
csrf_token = $('meta[name=csrf-token]').attr('content'),
165-
csrf_param = $('meta[name=csrf-param]').attr('content'),
164+
csrfToken = $('meta[name=csrf-token]').attr('content'),
165+
csrfParam = $('meta[name=csrf-param]').attr('content'),
166166
form = $('<form method="post" action="' + href + '"></form>'),
167-
metadata_input = '<input name="_method" value="' + method + '" type="hidden" />';
167+
metadataInput = '<input name="_method" value="' + method + '" type="hidden" />';
168168

169-
if (csrf_param !== undefined && csrf_token !== undefined) {
170-
metadata_input += '<input name="' + csrf_param + '" value="' + csrf_token + '" type="hidden" />';
169+
if (csrfParam !== undefined && csrfToken !== undefined) {
170+
metadataInput += '<input name="' + csrfParam + '" value="' + csrfToken + '" type="hidden" />';
171171
}
172172

173173
if (target) { form.attr('target', target); }
174174

175-
form.hide().append(metadata_input).appendTo('body');
175+
form.hide().append(metadataInput).appendTo('body');
176176
form.submit();
177177
},
178178

@@ -385,9 +385,9 @@
385385

386386
$(function(){
387387
// making sure that all forms have actual up-to-date token(cached forms contain old one)
388-
var csrf_token = $('meta[name=csrf-token]').attr('content');
389-
var csrf_param = $('meta[name=csrf-param]').attr('content');
390-
$('form input[name="' + csrf_param + '"]').val(csrf_token);
388+
var csrfToken = $('meta[name=csrf-token]').attr('content');
389+
var csrfParam = $('meta[name=csrf-param]').attr('content');
390+
$('form input[name="' + csrfParam + '"]').val(csrfToken);
391391
});
392392
}
393393

test/public/test/call-remote-callbacks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ asyncTest('modifying data("type") with "ajax:before" requests new dataType in re
5353
$('form[data-remote]').data('type','html')
5454
.bind('ajax:before', function() {
5555
var form = $(this);
56-
form.data('type','xml')
56+
form.data('type','xml');
5757
});
5858

5959
submit(function(form) {
@@ -67,7 +67,7 @@ asyncTest('setting data("cross-domain",true) with "ajax:before" uses new setting
6767
$('form[data-remote]').data('cross-domain',false)
6868
.bind('ajax:before', function() {
6969
var form = $(this);
70-
form.data('cross-domain',true)
70+
form.data('cross-domain',true);
7171
});
7272

7373
submit(function(form) {
@@ -94,7 +94,7 @@ asyncTest('setting data("with-credentials",true) with "ajax:before" uses new set
9494
asyncTest('stopping the "ajax:beforeSend" event aborts the request', 1, function() {
9595
submit(function(form) {
9696
form.bind('ajax:beforeSend', function() {
97-
ok(true, 'aborting request in ajax:beforeSend')
97+
ok(true, 'aborting request in ajax:beforeSend');
9898
return false;
9999
});
100100
form.unbind('ajax:complete').bind('ajax:complete', function() {

test/public/test/call-remote.js

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(function(){
22

3-
function build_form(attrs) {
3+
function buildForm(attrs) {
44
attrs = $.extend({ action: '/echo', 'data-remote': 'true' }, attrs);
55

66
$('#qunit-fixture').append($('<form />', attrs))
@@ -17,47 +17,47 @@ function submit(fn) {
1717
}
1818

1919
asyncTest('form method is read from "method" and not from "data-method"', 1, function() {
20-
build_form({ method: 'post', 'data-method': 'get' });
20+
buildForm({ method: 'post', 'data-method': 'get' });
2121

2222
submit(function(e, data, status, xhr) {
23-
App.assert_post_request(data);
23+
App.assertPostRequest(data);
2424
});
2525
});
2626

2727
asyncTest('form method is not read from "data-method" attribute in case of missing "method"', 1, function() {
28-
build_form({ 'data-method': 'put' });
28+
buildForm({ 'data-method': 'put' });
2929

3030
submit(function(e, data, status, xhr) {
31-
App.assert_get_request(data);
31+
App.assertGetRequest(data);
3232
});
3333
});
3434

3535
asyncTest('form default method is GET', 1, function() {
36-
build_form();
36+
buildForm();
3737

3838
submit(function(e, data, status, xhr) {
39-
App.assert_get_request(data);
39+
App.assertGetRequest(data);
4040
});
4141
});
4242

4343
asyncTest('form url is picked up from "action"', 1, function() {
44-
build_form({ method: 'post' });
44+
buildForm({ method: 'post' });
4545

4646
submit(function(e, data, status, xhr) {
47-
App.assert_request_path(data, '/echo');
47+
App.assertRequestPath(data, '/echo');
4848
});
4949
});
5050

5151
asyncTest('form url is read from "action" not "href"', 1, function() {
52-
build_form({ method: 'post', href: '/echo2' });
52+
buildForm({ method: 'post', href: '/echo2' });
5353

5454
submit(function(e, data, status, xhr) {
55-
App.assert_request_path(data, '/echo');
55+
App.assertRequestPath(data, '/echo');
5656
});
5757
});
5858

5959
asyncTest('prefer JS, but accept any format', 1, function() {
60-
build_form({ method: 'post' });
60+
buildForm({ method: 'post' });
6161

6262
submit(function(e, data, status, xhr) {
6363
var accept = data.HTTP_ACCEPT;
@@ -66,7 +66,7 @@ asyncTest('prefer JS, but accept any format', 1, function() {
6666
});
6767

6868
asyncTest('accept application/json if "data-type" is json', 1, function() {
69-
build_form({ method: 'post', 'data-type': 'json' });
69+
buildForm({ method: 'post', 'data-type': 'json' });
7070

7171
submit(function(e, data, status, xhr) {
7272
equal(data.HTTP_ACCEPT, 'application/json, text/javascript, */*; q=0.01');
@@ -75,7 +75,7 @@ asyncTest('accept application/json if "data-type" is json', 1, function() {
7575

7676
asyncTest('allow empty "data-remote" attribute', 1, function() {
7777
var form = $('#qunit-fixture').append($('<form action="/echo" data-remote />')).find('form');
78-
78+
7979
submit(function() {
8080
ok(true, 'form with empty "data-remote" attribute is also allowed');
8181
});
@@ -84,7 +84,7 @@ asyncTest('allow empty "data-remote" attribute', 1, function() {
8484
asyncTest('allow empty form "action"', 1, function() {
8585
var currentLocation, ajaxLocation;
8686

87-
build_form({ action: '' });
87+
buildForm({ action: '' });
8888

8989
$('#qunit-fixture').find('form')
9090
.bind('ajax:beforeSend', function(e, xhr, settings) {
@@ -114,7 +114,7 @@ asyncTest('allow empty form "action"', 1, function() {
114114
});
115115

116116
asyncTest('sends CSRF token in custom header', 1, function() {
117-
build_form({ method: 'post' });
117+
buildForm({ method: 'post' });
118118
$('#qunit-fixture').append('<meta name="csrf-token" content="cf50faa3fe97702ca1ae" />');
119119

120120
submit(function(e, data, status, xhr) {
@@ -123,7 +123,7 @@ asyncTest('sends CSRF token in custom header', 1, function() {
123123
});
124124

125125
asyncTest('does not send CSRF token in custom header if crossDomain', 1, function() {
126-
build_form({ 'data-cross-domain': 'true' });
126+
buildForm({ 'data-cross-domain': 'true' });
127127
$('#qunit-fixture').append('<meta name="csrf-token" content="cf50faa3fe97702ca1ae" />');
128128

129129
// Manually set request header to be XHR, since setting crossDomain: true in .ajax()
@@ -141,7 +141,7 @@ asyncTest('does not send CSRF token in custom header if crossDomain', 1, functio
141141
asyncTest('intelligently guesses crossDomain behavior when target URL is a different domain', 1, function(e, xhr) {
142142

143143
// Don't set data-cross-domain here, just set action to be a different domain than localhost
144-
build_form({ action: 'http://www.alfajango.com' });
144+
buildForm({ action: 'http://www.alfajango.com' });
145145
$('#qunit-fixture').append('<meta name="csrf-token" content="cf50faa3fe97702ca1ae" />');
146146

147147
$('#qunit-fixture').find('form')
@@ -158,7 +158,7 @@ asyncTest('intelligently guesses crossDomain behavior when target URL is a diffe
158158
});
159159

160160
asyncTest('does not set crossDomain if explicitly set to false on element', 1, function() {
161-
build_form({ action: 'http://www.alfajango.com', 'data-cross-domain': false });
161+
buildForm({ action: 'http://www.alfajango.com', 'data-cross-domain': false });
162162
$('#qunit-fixture').append('<meta name="csrf-token" content="cf50faa3fe97702ca1ae" />');
163163

164164
$('#qunit-fixture').find('form')

test/public/test/data-confirm.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ asyncTest('clicking on a link with data-confirm attribute. Confirm yes.', 6, fun
2121

2222
$('a[data-confirm]')
2323
.bind('confirm:complete', function(e, data) {
24-
App.assert_callback_invoked('confirm:complete');
24+
App.assertCallbackInvoked('confirm:complete');
2525
ok(data == true, 'confirm:complete passes in confirm answer (true)');
2626
})
27-
.bind('ajax:success', function(e, data, status, xhr) {
28-
App.assert_callback_invoked('ajax:success');
29-
App.assert_request_path(data, '/echo');
30-
App.assert_get_request(data);
27+
.bind('ajax:success', function(e, data, status, xhr) {
28+
App.assertCallbackInvoked('ajax:success');
29+
App.assertRequestPath(data, '/echo');
30+
App.assertGetRequest(data);
3131

3232
equal(message, 'Are you absolutely sure?');
3333
start();
@@ -42,11 +42,11 @@ asyncTest('clicking on a link with data-confirm attribute. Confirm No.', 3, func
4242

4343
$('a[data-confirm]')
4444
.bind('confirm:complete', function(e, data) {
45-
App.assert_callback_invoked('confirm:complete');
45+
App.assertCallbackInvoked('confirm:complete');
4646
ok(data == false, 'confirm:complete passes in confirm answer (false)');
4747
})
4848
.bind('ajax:beforeSend', function(e, data, status, xhr) {
49-
App.assert_callback_not_invoked('ajax:beforeSend');
49+
App.assertCallbackNotInvoked('ajax:beforeSend');
5050
})
5151
.trigger('click');
5252

@@ -65,11 +65,11 @@ asyncTest('binding to confirm event and returning false', 1, function() {
6565

6666
$('a[data-confirm]')
6767
.bind('confirm', function() {
68-
App.assert_callback_invoked('confirm');
68+
App.assertCallbackInvoked('confirm');
6969
return false;
7070
})
7171
.bind('confirm:complete', function() {
72-
App.assert_callback_not_invoked('confirm:complete')
72+
App.assertCallbackNotInvoked('confirm:complete');
7373
})
7474
.trigger('click');
7575

@@ -87,11 +87,11 @@ asyncTest('binding to confirm:complete event and returning false', 2, function()
8787

8888
$('a[data-confirm]')
8989
.bind('confirm:complete', function() {
90-
App.assert_callback_invoked('confirm:complete');
90+
App.assertCallbackInvoked('confirm:complete');
9191
return false;
9292
})
9393
.bind('ajax:beforeSend', function() {
94-
App.assert_callback_not_invoked('ajax:beforeSend');
94+
App.assertCallbackNotInvoked('ajax:beforeSend');
9595
})
9696
.trigger('click');
9797

test/public/test/data-remote.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ asyncTest('ctrl-clicking on a link still fires ajax for non-GET links and for li
7474
asyncTest('clicking on a link with data-remote attribute', 5, function() {
7575
$('a[data-remote]')
7676
.bind('ajax:success', function(e, data, status, xhr) {
77-
App.assert_callback_invoked('ajax:success');
78-
App.assert_request_path(data, '/echo');
77+
App.assertCallbackInvoked('ajax:success');
78+
App.assertRequestPath(data, '/echo');
7979
equal(data.params.data1, 'value1', 'ajax arguments should have key data1 with right value');
8080
equal(data.params.data2, 'value2', 'ajax arguments should have key data2 with right value');
81-
App.assert_get_request(data);
81+
App.assertGetRequest(data);
8282
})
8383
.bind('ajax:complete', function() { start() })
8484
.trigger('click');
@@ -87,11 +87,11 @@ asyncTest('clicking on a link with data-remote attribute', 5, function() {
8787
asyncTest('clicking on a button with data-remote attribute', 5, function() {
8888
$('button[data-remote]')
8989
.bind('ajax:success', function(e, data, status, xhr) {
90-
App.assert_callback_invoked('ajax:success');
91-
App.assert_request_path(data, '/echo');
90+
App.assertCallbackInvoked('ajax:success');
91+
App.assertRequestPath(data, '/echo');
9292
equal(data.params.data1, 'value1', 'ajax arguments should have key data1 with right value');
9393
equal(data.params.data2, 'value2', 'ajax arguments should have key data2 with right value');
94-
App.assert_get_request(data);
94+
App.assertGetRequest(data);
9595
})
9696
.bind('ajax:complete', function() { start() })
9797
.trigger('click');
@@ -112,11 +112,11 @@ asyncTest('changing a select option with data-remote attribute', 5, function() {
112112

113113
$('select[data-remote]')
114114
.bind('ajax:success', function(e, data, status, xhr) {
115-
App.assert_callback_invoked('ajax:success');
116-
App.assert_request_path(data, '/echo');
115+
App.assertCallbackInvoked('ajax:success');
116+
App.assertRequestPath(data, '/echo');
117117
equal(data.params.user_data, 'optionValue2', 'ajax arguments should have key term with right value');
118118
equal(data.params.data1, 'value1', 'ajax arguments should have key data1 with right value');
119-
App.assert_get_request(data);
119+
App.assertGetRequest(data);
120120
})
121121
.bind('ajax:complete', function() { start() })
122122
.val('optionValue2')
@@ -126,10 +126,10 @@ asyncTest('changing a select option with data-remote attribute', 5, function() {
126126
asyncTest('submitting form with data-remote attribute', 4, function() {
127127
$('form[data-remote]')
128128
.bind('ajax:success', function(e, data, status, xhr) {
129-
App.assert_callback_invoked('ajax:success');
130-
App.assert_request_path(data, '/echo');
129+
App.assertCallbackInvoked('ajax:success');
130+
App.assertRequestPath(data, '/echo');
131131
equal(data.params.user_name, 'john', 'ajax arguments should have key user_name with right value');
132-
App.assert_post_request(data);
132+
App.assertPostRequest(data);
133133
})
134134
.bind('ajax:complete', function() { start() })
135135
.trigger('submit');

test/public/test/settings.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
var App = App || {};
22

3-
App.assert_callback_invoked = function(callback_name) {
4-
ok(true, callback_name + ' callback should have been invoked');
3+
App.assertCallbackInvoked = function(callbackName) {
4+
ok(true, callbackName + ' callback should have been invoked');
55
};
66

7-
App.assert_callback_not_invoked = function(callback_name) {
8-
ok(false, callback_name + ' callback should not have been invoked');
7+
App.assertCallbackNotInvoked = function(callbackName) {
8+
ok(false, callbackName + ' callback should not have been invoked');
99
};
1010

11-
App.assert_get_request = function(request_env){
12-
equal(request_env['REQUEST_METHOD'], 'GET', 'request type should be GET');
11+
App.assertGetRequest = function(requestEnv){
12+
equal(requestEnv['REQUEST_METHOD'], 'GET', 'request type should be GET');
1313
};
1414

15-
App.assert_post_request = function(request_env){
16-
equal(request_env['REQUEST_METHOD'], 'POST', 'request type should be POST');
15+
App.assertPostRequest = function(requestEnv){
16+
equal(requestEnv['REQUEST_METHOD'], 'POST', 'request type should be POST');
1717
};
1818

19-
App.assert_request_path = function(request_env, path) {
20-
equal(request_env['PATH_INFO'], path, 'request should be sent to right url');
19+
App.assertRequestPath = function(requestEnv, path) {
20+
equal(requestEnv['PATH_INFO'], path, 'request should be sent to right url');
2121
};
2222

2323
// hijacks normal form submit; lets it submit to an iframe to prevent
@@ -27,10 +27,10 @@ $(document).bind('submit', function(e) {
2727
var form = $(e.target), action = form.attr('action'),
2828
name = 'form-frame' + jQuery.guid++,
2929
iframe = $('<iframe name="' + name + '" />'),
30-
target_input = '<input name="_target" value="' + form.attr('target') + '" type="hidden" />';
30+
targetInput = '<input name="_target" value="' + form.attr('target') + '" type="hidden" />';
3131

3232
if (action.indexOf('iframe') < 0) form.attr('action', action + '?iframe=true')
33-
form.attr('target', name).append(target_input);
33+
form.attr('target', name).append(targetInput);
3434
$('#qunit-fixture').append(iframe);
3535
$.event.trigger('iframe:loading', form);
3636
}

0 commit comments

Comments
 (0)