Change save_item and create_item to RESTful URL.
Part of STUD-847.
This commit is contained in:
@@ -182,7 +182,7 @@ define([
|
||||
"coffee/spec/main_spec",
|
||||
|
||||
"coffee/spec/models/course_spec", "coffee/spec/models/metadata_spec",
|
||||
"coffee/spec/models/module_spec", "coffee/spec/models/section_spec",
|
||||
"coffee/spec/models/section_spec",
|
||||
"coffee/spec/models/settings_course_grader_spec",
|
||||
"coffee/spec/models/settings_grading_spec", "coffee/spec/models/textbook_spec",
|
||||
"coffee/spec/models/upload_spec",
|
||||
@@ -193,9 +193,11 @@ define([
|
||||
"coffee/spec/views/overview_spec",
|
||||
"coffee/spec/views/textbook_spec", "coffee/spec/views/upload_spec",
|
||||
|
||||
"js_spec/transcripts/utils_spec", "js_spec/transcripts/editor_spec",
|
||||
"js_spec/transcripts/videolist_spec", "js_spec/transcripts/message_manager_spec",
|
||||
"js_spec/transcripts/file_uploader_spec"
|
||||
"js/spec/transcripts/utils_spec", "js/spec/transcripts/editor_spec",
|
||||
"js/spec/transcripts/videolist_spec", "js/spec/transcripts/message_manager_spec",
|
||||
"js/spec/transcripts/file_uploader_spec",
|
||||
|
||||
"js/spec/utils/module_spec"
|
||||
|
||||
# these tests are run separate in the cms-squire suite, due to process
|
||||
# isolation issues with Squire.js
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
define ["coffee/src/models/module"], (Module) ->
|
||||
describe "Module", ->
|
||||
it "set the correct URL", ->
|
||||
expect(new Module().url).toEqual("/save_item")
|
||||
|
||||
it "set the correct default", ->
|
||||
expect(new Module().defaults).toEqual(undefined)
|
||||
@@ -1,9 +1,9 @@
|
||||
define ["js/models/section", "sinon"], (Section, sinon) ->
|
||||
define ["js/models/section", "sinon", "js/utils/module"], (Section, sinon, ModuleUtils) ->
|
||||
describe "Section", ->
|
||||
describe "basic", ->
|
||||
beforeEach ->
|
||||
@model = new Section({
|
||||
id: 42,
|
||||
id: 42
|
||||
name: "Life, the Universe, and Everything"
|
||||
})
|
||||
|
||||
@@ -14,11 +14,10 @@ define ["js/models/section", "sinon"], (Section, sinon) ->
|
||||
expect(@model.get("name")).toEqual("Life, the Universe, and Everything")
|
||||
|
||||
it "should have a URL set", ->
|
||||
expect(@model.url).toEqual("/save_item")
|
||||
expect(@model.url()).toEqual(ModuleUtils.getUpdateUrl(42))
|
||||
|
||||
it "should serialize to JSON correctly", ->
|
||||
expect(@model.toJSON()).toEqual({
|
||||
id: 42,
|
||||
metadata:
|
||||
{
|
||||
display_name: "Life, the Universe, and Everything"
|
||||
@@ -30,7 +29,7 @@ define ["js/models/section", "sinon"], (Section, sinon) ->
|
||||
spyOn(Section.prototype, 'showNotification')
|
||||
spyOn(Section.prototype, 'hideNotification')
|
||||
@model = new Section({
|
||||
id: 42,
|
||||
id: 42
|
||||
name: "Life, the Universe, and Everything"
|
||||
})
|
||||
@requests = requests = []
|
||||
|
||||
@@ -4,6 +4,9 @@ define ["coffee/src/views/module_edit", "xmodule"], (ModuleEdit) ->
|
||||
beforeEach ->
|
||||
@stubModule = jasmine.createSpy("Module")
|
||||
@stubModule.id = 'stub-id'
|
||||
@stubModule.get = (param)->
|
||||
if param == 'old_id'
|
||||
return 'stub-old-id'
|
||||
|
||||
setFixtures """
|
||||
<li class="component" id="stub-id">
|
||||
@@ -59,7 +62,7 @@ define ["coffee/src/views/module_edit", "xmodule"], (ModuleEdit) ->
|
||||
@moduleEdit.render()
|
||||
|
||||
it "loads the module preview and editor via ajax on the view element", ->
|
||||
expect(@moduleEdit.$el.load).toHaveBeenCalledWith("/preview_component/#{@moduleEdit.model.id}", jasmine.any(Function))
|
||||
expect(@moduleEdit.$el.load).toHaveBeenCalledWith("/preview_component/#{@moduleEdit.model.get('old_id')}", jasmine.any(Function))
|
||||
@moduleEdit.$el.load.mostRecentCall.args[1]()
|
||||
expect(@moduleEdit.loadDisplay).toHaveBeenCalled()
|
||||
expect(@moduleEdit.delegateEvents).toHaveBeenCalled()
|
||||
|
||||
@@ -8,7 +8,7 @@ define ["js/views/overview", "js/views/feedback_notification", "sinon", "js/base
|
||||
<span class="published-status">
|
||||
<strong>Will Release:</strong> 06/12/2013 at 04:00 UTC
|
||||
</span>
|
||||
<a href="#" class="edit-button" data-date="06/12/2013" data-time="04:00" data-id="i4x://pfogg/42/chapter/d6b47f7b084f49debcaf67fe5436c8e2">Edit</a>
|
||||
<a href="#" class="edit-button" data-date="06/12/2013" data-time="04:00" data-locator="i4x://pfogg/42/chapter/d6b47f7b084f49debcaf67fe5436c8e2">Edit</a>
|
||||
</div>
|
||||
"""
|
||||
|
||||
@@ -35,8 +35,8 @@ define ["js/views/overview", "js/views/feedback_notification", "sinon", "js/base
|
||||
"""
|
||||
|
||||
appendSetFixtures """
|
||||
<section class="courseware-section branch" data-id="a-location-goes-here">
|
||||
<li class="branch collapsed id-holder" data-id="an-id-goes-here">
|
||||
<section class="courseware-section branch" data-locator="a-location-goes-here">
|
||||
<li class="branch collapsed id-holder" data-id="an-id-goes-here" data-locator="an-id-goes-here">
|
||||
<a href="#" class="delete-section-button"></a>
|
||||
</li>
|
||||
</section>
|
||||
@@ -44,19 +44,19 @@ define ["js/views/overview", "js/views/feedback_notification", "sinon", "js/base
|
||||
|
||||
appendSetFixtures """
|
||||
<ol>
|
||||
<li class="subsection-list branch" data-id="subsection-1-id" id="subsection-1">
|
||||
<li class="subsection-list branch" id="subsection-1" data-locator="subsection-1-id">
|
||||
<ol class="sortable-unit-list" id="subsection-list-1">
|
||||
<li class="unit" id="unit-1" data-id="first-unit-id" data-parent-id="subsection-1-id"></li>
|
||||
<li class="unit" id="unit-2" data-id="second-unit-id" data-parent-id="subsection-1-id"></li>
|
||||
<li class="unit" id="unit-3" data-id="third-unit-id" data-parent-id="subsection-1-id"></li>
|
||||
<li class="unit" id="unit-1" data-parent="subsection-1-id" data-locator="first-unit-id"></li>
|
||||
<li class="unit" id="unit-2" data-parent="subsection-1-id" data-locator="second-unit-id"></li>
|
||||
<li class="unit" id="unit-3" data-parent="subsection-1-id" data-locator="third-unit-id"></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li class="subsection-list branch" data-id="subsection-2-id" id="subsection-2">
|
||||
<li class="subsection-list branch" id="subsection-2" data-locator="subsection-2-id">
|
||||
<ol class="sortable-unit-list" id="subsection-list-2">
|
||||
<li class="unit" id="unit-4" data-id="fourth-unit-id" data-parent-id="subsection-2"></li>
|
||||
<li class="unit" id="unit-4" data-parent="subsection-2" data-locator="fourth-unit-id"></li>
|
||||
</ol>
|
||||
</li>
|
||||
<li class="subsection-list branch" data-id="subsection-3-id" id="subsection-3">
|
||||
<li class="subsection-list branch" id="subsection-3" data-locator="subsection-3-id">
|
||||
<ol class="sortable-unit-list" id="subsection-list-3">
|
||||
</li>
|
||||
</ol>
|
||||
@@ -366,10 +366,10 @@ define ["js/views/overview", "js/views/feedback_notification", "sinon", "js/base
|
||||
expect($('#unit-1')).toHaveClass('was-dropped')
|
||||
# We expect 2 requests to be sent-- the first for removing Unit 1 from Subsection 1,
|
||||
# and the second for adding Unit 1 to the end of Subsection 2.
|
||||
expect(@requests[0].requestBody).toEqual('{"id":"subsection-1-id","children":["second-unit-id","third-unit-id"]}')
|
||||
expect(@requests[0].requestBody).toEqual('{"children":["second-unit-id","third-unit-id"]}')
|
||||
@requests[0].respond(200)
|
||||
expect(@savingSpies.hide).not.toHaveBeenCalled()
|
||||
expect(@requests[1].requestBody).toEqual('{"id":"subsection-2-id","children":["fourth-unit-id","first-unit-id"]}')
|
||||
expect(@requests[1].requestBody).toEqual('{"children":["fourth-unit-id","first-unit-id"]}')
|
||||
@requests[1].respond(200)
|
||||
expect(@savingSpies.hide).toHaveBeenCalled()
|
||||
# Class is removed in a timeout.
|
||||
|
||||
Reference in New Issue
Block a user