Просмотр исходного кода

fix json feeds always requesting current page. better tests. fixes #3865

Adam Shaw 8 лет назад
Родитель
Сommit
5393dbea86
2 измененных файлов с 12 добавлено и 11 удалено
  1. 2 1
      src/models/event-source/JsonFeedEventSource.js
  2. 10 10
      tests/legacy/events-json-feed.js

+ 2 - 1
src/models/event-source/JsonFeedEventSource.js

@@ -24,10 +24,11 @@ var JsonFeedEventSource = EventSource.extend({
 
 		return Promise.construct(function(onResolve, onReject) {
 			$.ajax($.extend(
-				{ url: this.url },
+				{}, // destination
 				JsonFeedEventSource.AJAX_DEFAULTS,
 				ajaxSettings,
 				{
+					url: _this.url,
 					data: requestParams,
 					success: function(rawEventDefs) {
 						var callbackRes;

+ 10 - 10
tests/legacy/events-json-feed.js

@@ -12,7 +12,7 @@ describe('events as a json feed', function() {
 		};
 
 		$.mockjax({
-			url: '*',
+			url: '/my-feed.php',
 			contentType: 'text/json',
 			responseText: [
 				{
@@ -29,7 +29,7 @@ describe('events as a json feed', function() {
 	});
 
 	it('requests correctly when no timezone', function() {
-		options.events = 'my-feed.php';
+		options.events = '/my-feed.php';
 		$('#cal').fullCalendar(options);
 		var request = $.mockjax.mockedAjaxCalls()[0];
 		expect(request.data.start).toEqual('2014-04-27');
@@ -38,7 +38,7 @@ describe('events as a json feed', function() {
 	});
 
 	it('requests correctly when local timezone', function() {
-		options.events = 'my-feed.php';
+		options.events = '/my-feed.php';
 		options.timezone = 'local';
 		$('#cal').fullCalendar(options);
 		var request = $.mockjax.mockedAjaxCalls()[0];
@@ -48,7 +48,7 @@ describe('events as a json feed', function() {
 	});
 
 	it('requests correctly when UTC timezone', function() {
-		options.events = 'my-feed.php';
+		options.events = '/my-feed.php';
 		options.timezone = 'UTC';
 		$('#cal').fullCalendar(options);
 		var request = $.mockjax.mockedAjaxCalls()[0];
@@ -58,7 +58,7 @@ describe('events as a json feed', function() {
 	});
 
 	it('requests correctly when custom timezone', function() {
-		options.events = 'my-feed.php';
+		options.events = '/my-feed.php';
 		options.timezone = 'America/Chicago';
 		$('#cal').fullCalendar(options);
 		var request = $.mockjax.mockedAjaxCalls()[0];
@@ -69,7 +69,7 @@ describe('events as a json feed', function() {
 
 	it('requests correctly with event source extended form', function(done) {
 		var eventSource = {
-			url: 'my-feed.php',
+			url: '/my-feed.php',
 			className: 'customeventclass'
 		};
 		options.eventSources = [ eventSource ];
@@ -87,7 +87,7 @@ describe('events as a json feed', function() {
 
 	it('accepts jQuery.ajax params', function(done) {
 		var eventSource = {
-			url: 'my-feed.php',
+			url: '/my-feed.php',
 			data: {
 				customParam: 'yes'
 			},
@@ -103,7 +103,7 @@ describe('events as a json feed', function() {
 
 	it('accepts a dynamic data function', function(done) {
 		var eventSource = {
-			url: 'my-feed.php',
+			url: '/my-feed.php',
 			data: function() {
 				return {
 					customParam: 'heckyeah'
@@ -123,7 +123,7 @@ describe('events as a json feed', function() {
 		var loadingCallArgs = [];
 
 		initCalendar({
-			events: { url: 'my-feed.php' },
+			events: { url: '/my-feed.php' },
 			loading: function(bool) {
 				loadingCallArgs.push(bool);
 			},
@@ -135,7 +135,7 @@ describe('events as a json feed', function() {
 	});
 
 	it('has and Event Source object with certain props', function() {
-		var url = 'my-feed.php';
+		var url = '/my-feed.php';
 		var source;
 
 		initCalendar({