Commit dbd9e56c by zubair-arbi

prevent caching of GET requests for xblock student view

STUD-1691
parent c08831b4
...@@ -87,6 +87,7 @@ define ["jquery", "js/spec_helpers/edit_helpers", "coffee/src/views/module_edit" ...@@ -87,6 +87,7 @@ define ["jquery", "js/spec_helpers/edit_helpers", "coffee/src/views/module_edit"
expect($.ajax).toHaveBeenCalledWith( expect($.ajax).toHaveBeenCalledWith(
url: "/xblock/#{@moduleEdit.model.id}/student_view" url: "/xblock/#{@moduleEdit.model.id}/student_view"
type: "GET" type: "GET"
cache: false
headers: headers:
Accept: 'application/json' Accept: 'application/json'
success: jasmine.any(Function) success: jasmine.any(Function)
...@@ -107,6 +108,7 @@ define ["jquery", "js/spec_helpers/edit_helpers", "coffee/src/views/module_edit" ...@@ -107,6 +108,7 @@ define ["jquery", "js/spec_helpers/edit_helpers", "coffee/src/views/module_edit"
expect($.ajax).not.toHaveBeenCalledWith( expect($.ajax).not.toHaveBeenCalledWith(
url: "/xblock/#{@moduleEdit.model.id}/studio_view" url: "/xblock/#{@moduleEdit.model.id}/studio_view"
type: "GET" type: "GET"
cache : false
headers: headers:
Accept: 'application/json' Accept: 'application/json'
success: jasmine.any(Function) success: jasmine.any(Function)
...@@ -131,6 +133,7 @@ define ["jquery", "js/spec_helpers/edit_helpers", "coffee/src/views/module_edit" ...@@ -131,6 +133,7 @@ define ["jquery", "js/spec_helpers/edit_helpers", "coffee/src/views/module_edit"
expect($.ajax).toHaveBeenCalledWith( expect($.ajax).toHaveBeenCalledWith(
url: "/xblock/#{@moduleEdit.model.id}/studio_view" url: "/xblock/#{@moduleEdit.model.id}/studio_view"
type: "GET" type: "GET"
cache: false
headers: headers:
Accept: 'application/json' Accept: 'application/json'
success: jasmine.any(Function) success: jasmine.any(Function)
......
...@@ -38,6 +38,7 @@ define ["jquery", "underscore", "gettext", "xblock/runtime.v1", ...@@ -38,6 +38,7 @@ define ["jquery", "underscore", "gettext", "xblock/runtime.v1",
$.ajax( $.ajax(
url: "#{decodeURIComponent(@model.url())}/#{viewName}" url: "#{decodeURIComponent(@model.url())}/#{viewName}"
type: 'GET' type: 'GET'
cache: false
headers: headers:
Accept: 'application/json' Accept: 'application/json'
success: (fragment) => success: (fragment) =>
......
...@@ -96,9 +96,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers ...@@ -96,9 +96,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
editButtons.first().click(); editButtons.first().click();
// Expect a request to be made to show the studio view for the container // Expect a request to be made to show the studio view for the container
expect(lastRequest().url).toBe( expect(lastRequest().url.startsWith('/xblock/locator-container/studio_view')).toBeTruthy();
'/xblock/locator-container/studio_view'
);
create_sinon.respondWithJson(requests, { create_sinon.respondWithJson(requests, {
html: mockContainerXBlockHtml, html: mockContainerXBlockHtml,
resources: [] resources: []
...@@ -114,9 +112,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers ...@@ -114,9 +112,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
expect(edit_helpers.isShowingModal()).toBeFalsy(); expect(edit_helpers.isShowingModal()).toBeFalsy();
// Expect the last request be to refresh the container page // Expect the last request be to refresh the container page
expect(lastRequest().url).toBe( expect(lastRequest().url.startsWith('/xblock/locator-container/container_preview')).toBeTruthy();
'/xblock/locator-container/container_preview'
);
create_sinon.respondWithJson(requests, { create_sinon.respondWithJson(requests, {
html: mockUpdatedContainerXBlockHtml, html: mockUpdatedContainerXBlockHtml,
resources: [] resources: []
...@@ -153,9 +149,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers ...@@ -153,9 +149,7 @@ define(["jquery", "underscore", "js/spec_helpers/create_sinon", "js/spec_helpers
expect(editButtons.length).toBe(6); expect(editButtons.length).toBe(6);
editButtons[0].click(); editButtons[0].click();
// Make sure that the correct xblock is requested to be edited // Make sure that the correct xblock is requested to be edited
expect(lastRequest().url).toBe( expect(lastRequest().url.startsWith('/xblock/locator-component-A1/studio_view')).toBeTruthy();
'/xblock/locator-component-A1/studio_view'
);
create_sinon.respondWithJson(requests, { create_sinon.respondWithJson(requests, {
html: mockXBlockEditorHtml, html: mockXBlockEditorHtml,
resources: [] resources: []
......
...@@ -204,9 +204,7 @@ define(["jquery", "underscore", "jasmine", "coffee/src/views/unit", "js/models/m ...@@ -204,9 +204,7 @@ define(["jquery", "underscore", "jasmine", "coffee/src/views/unit", "js/models/m
expect(editButtons.length).toBe(2); expect(editButtons.length).toBe(2);
editButtons[1].click(); editButtons[1].click();
// Make sure that the correct xblock is requested to be edited // Make sure that the correct xblock is requested to be edited
expect(lastRequest().url).toBe( expect(lastRequest().url.startsWith('/xblock/loc_2/studio_view')).toBeTruthy();
'/xblock/loc_2/studio_view'
);
create_sinon.respondWithJson(requests, { create_sinon.respondWithJson(requests, {
html: mockXBlockEditorHtml, html: mockXBlockEditorHtml,
resources: [] resources: []
......
...@@ -17,6 +17,7 @@ define(["jquery", "underscore", "js/views/baseview", "xblock/runtime.v1"], ...@@ -17,6 +17,7 @@ define(["jquery", "underscore", "js/views/baseview", "xblock/runtime.v1"],
return $.ajax({ return $.ajax({
url: decodeURIComponent(xblockUrl) + "/" + view, url: decodeURIComponent(xblockUrl) + "/" + view,
type: 'GET', type: 'GET',
cache: false,
headers: { Accept: 'application/json' }, headers: { Accept: 'application/json' },
success: function(fragment) { success: function(fragment) {
self.handleXBlockFragment(fragment, options); self.handleXBlockFragment(fragment, options);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment