From dbd9e56c6c98e305aa28610401210c3ea466195b Mon Sep 17 00:00:00 2001 From: zubair-arbi Date: Wed, 4 Jun 2014 14:45:34 +0500 Subject: [PATCH] prevent caching of GET requests for xblock student view STUD-1691 --- cms/static/coffee/spec/views/module_edit_spec.coffee | 3 +++ cms/static/coffee/src/views/module_edit.coffee | 1 + cms/static/js/spec/views/pages/container_spec.js | 12 +++--------- cms/static/js/spec/views/unit_spec.js | 4 +--- cms/static/js/views/xblock.js | 1 + 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/cms/static/coffee/spec/views/module_edit_spec.coffee b/cms/static/coffee/spec/views/module_edit_spec.coffee index f61d03935d..93a7b476d5 100644 --- a/cms/static/coffee/spec/views/module_edit_spec.coffee +++ b/cms/static/coffee/spec/views/module_edit_spec.coffee @@ -87,6 +87,7 @@ define ["jquery", "js/spec_helpers/edit_helpers", "coffee/src/views/module_edit" expect($.ajax).toHaveBeenCalledWith( url: "/xblock/#{@moduleEdit.model.id}/student_view" type: "GET" + cache: false headers: Accept: 'application/json' success: jasmine.any(Function) @@ -107,6 +108,7 @@ define ["jquery", "js/spec_helpers/edit_helpers", "coffee/src/views/module_edit" expect($.ajax).not.toHaveBeenCalledWith( url: "/xblock/#{@moduleEdit.model.id}/studio_view" type: "GET" + cache : false headers: Accept: 'application/json' success: jasmine.any(Function) @@ -131,6 +133,7 @@ define ["jquery", "js/spec_helpers/edit_helpers", "coffee/src/views/module_edit" expect($.ajax).toHaveBeenCalledWith( url: "/xblock/#{@moduleEdit.model.id}/studio_view" type: "GET" + cache: false headers: Accept: 'application/json' success: jasmine.any(Function) diff --git a/cms/static/coffee/src/views/module_edit.coffee b/cms/static/coffee/src/views/module_edit.coffee index 1f093b3fdb..b4fc7b1787 100644 --- a/cms/static/coffee/src/views/module_edit.coffee +++ b/cms/static/coffee/src/views/module_edit.coffee @@ -38,6 +38,7 @@ define ["jquery", "underscore", "gettext", "xblock/runtime.v1", $.ajax( url: "#{decodeURIComponent(@model.url())}/#{viewName}" type: 'GET' + cache: false headers: Accept: 'application/json' success: (fragment) => diff --git a/cms/static/js/spec/views/pages/container_spec.js b/cms/static/js/spec/views/pages/container_spec.js index 59d06e79e4..130b945ee4 100644 --- a/cms/static/js/spec/views/pages/container_spec.js +++ b/cms/static/js/spec/views/pages/container_spec.js @@ -96,9 +96,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers editButtons.first().click(); // Expect a request to be made to show the studio view for the container - expect(lastRequest().url).toBe( - '/xblock/locator-container/studio_view' - ); + expect(lastRequest().url.startsWith('/xblock/locator-container/studio_view')).toBeTruthy(); create_sinon.respondWithJson(requests, { html: mockContainerXBlockHtml, resources: [] @@ -114,9 +112,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers expect(edit_helpers.isShowingModal()).toBeFalsy(); // Expect the last request be to refresh the container page - expect(lastRequest().url).toBe( - '/xblock/locator-container/container_preview' - ); + expect(lastRequest().url.startsWith('/xblock/locator-container/container_preview')).toBeTruthy(); create_sinon.respondWithJson(requests, { html: mockUpdatedContainerXBlockHtml, resources: [] @@ -153,9 +149,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers expect(editButtons.length).toBe(6); editButtons[0].click(); // Make sure that the correct xblock is requested to be edited - expect(lastRequest().url).toBe( - '/xblock/locator-component-A1/studio_view' - ); + expect(lastRequest().url.startsWith('/xblock/locator-component-A1/studio_view')).toBeTruthy(); create_sinon.respondWithJson(requests, { html: mockXBlockEditorHtml, resources: [] diff --git a/cms/static/js/spec/views/unit_spec.js b/cms/static/js/spec/views/unit_spec.js index 8ef66536d1..d8b34ea121 100644 --- a/cms/static/js/spec/views/unit_spec.js +++ b/cms/static/js/spec/views/unit_spec.js @@ -204,9 +204,7 @@ define(["jquery", "underscore", "jasmine", "coffee/src/views/unit", "js/models/m expect(editButtons.length).toBe(2); editButtons[1].click(); // Make sure that the correct xblock is requested to be edited - expect(lastRequest().url).toBe( - '/xblock/loc_2/studio_view' - ); + expect(lastRequest().url.startsWith('/xblock/loc_2/studio_view')).toBeTruthy(); create_sinon.respondWithJson(requests, { html: mockXBlockEditorHtml, resources: [] diff --git a/cms/static/js/views/xblock.js b/cms/static/js/views/xblock.js index 6dbdbfa296..0252eb07e3 100644 --- a/cms/static/js/views/xblock.js +++ b/cms/static/js/views/xblock.js @@ -17,6 +17,7 @@ define(["jquery", "underscore", "js/views/baseview", "xblock/runtime.v1"], return $.ajax({ url: decodeURIComponent(xblockUrl) + "/" + view, type: 'GET', + cache: false, headers: { Accept: 'application/json' }, success: function(fragment) { self.handleXBlockFragment(fragment, options);