Commit 77db1f8a by David Baumgold

Fixups and test fixes post-rebase

parent 4b2eb79d
......@@ -36,17 +36,18 @@ describe "CMS.Views.TextbookShow", ->
expect(@collection.editing).toEqual(@model)
it "should pop a delete confirmation when the delete button is clicked", ->
promptSpies = spyOnConstructor(CMS.Views, "Prompt")
promptSpies = spyOnConstructor(CMS.Views.Prompt, "Warning", ["show", "hide"])
@view.render().$(".delete").click()
expect(promptSpies.constructor).toHaveBeenCalled()
msg = promptSpies.constructor.mostRecentCall.args[0].model
expect(msg.get("title")).toMatch(/Life Sciences/)
ctorOptions = promptSpies.constructor.mostRecentCall.args[0]
expect(ctorOptions.title).toMatch(/Life Sciences/)
# hasn't actually been removed
expect(@collection).toContain(@model)
expect(@collection.save).not.toHaveBeenCalled()
# run the primary function to indicate confirmation
view = jasmine.createSpyObj('view', ['hide'])
msg.get("actions").primary.click.call(msg, view)
context = jasmine.createSpy('context')
ctorOptions.actions.primary.click.call(context, view)
# now it's been removed
expect(@collection).not.toContain(@model)
expect(@collection.save).toHaveBeenCalled()
......@@ -150,7 +151,6 @@ describe "CMS.Views.ListTextbooks", ->
expect(@view.$el).not.toContainText(
"You haven't added any textbooks to this course yet")
expect(@view.$el).toBe("ul")
expect(@showSpies.constructor).toHaveBeenCalled()
expect(@showSpies.constructor.calls.length).toEqual(3);
expect(@editSpies.constructor).not.toHaveBeenCalled()
......
......@@ -22,7 +22,7 @@ CMS.Views.TextbookShow = Backbone.View.extend({
confirmDelete: function(e) {
if(e && e.preventDefault) { e.preventDefault(); }
var textbook = this.model, collection = this.model.collection;
var msg = new CMS.Models.WarningMessage({
var msg = new CMS.Views.Prompt.Warning({
title: _.str.sprintf(gettext("Delete “%s”?"),
textbook.escape('name')),
message: gettext("Deleting a textbook cannot be undone and once deleted any reference to it in your courseware's navigation will also be removed."),
......@@ -32,18 +32,14 @@ CMS.Views.TextbookShow = Backbone.View.extend({
click: function(view) {
view.hide();
collection.remove(textbook);
var delmsg = new CMS.Models.SystemFeedback({
intent: "saving",
title: gettext("Deleting…")
});
var notif = new CMS.Views.Notification({
model: delmsg,
var delmsg = new CMS.Views.Notification.Saving({
title: gettext("Deleting…"),
closeIcon: false,
minShown: 1250
});
}).show();
collection.save({
complete: function() {
notif.hide();
delmsg.hide();
}
});
}
......@@ -55,8 +51,7 @@ CMS.Views.TextbookShow = Backbone.View.extend({
}
}]
}
});
var prompt = new CMS.Views.Prompt({model: msg});
}).show();
},
showChapters: function(e) {
if(e && e.preventDefault) { e.preventDefault(); }
......@@ -93,7 +88,7 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
},
addOne: function(chapter) {
var view = new CMS.Views.ChapterEdit({model: chapter});
this.$("ol.chapters").append(view.render().el)
this.$("ol.chapters").append(view.render().el);
return this;
},
addAll: function() {
......@@ -116,19 +111,15 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
chapter.set({
"name": $(".chapter-name", li).val(),
"asset_path": $(".chapter-asset-path", li).val()
})
});
});
return this;
},
setAndClose: function(e) {
if(e && e.preventDefault) { e.preventDefault(); }
this.setValues();
msg = new CMS.Models.SystemFeedback({
intent: "saving",
title: gettext("Saving…")
});
notif = new CMS.Views.Notification({
model: msg,
var saving = new CMS.Views.Notification.Saving({
title: gettext("Saving…"),
closeIcon: false,
minShown: 1250
});
......@@ -138,7 +129,7 @@ CMS.Views.TextbookEdit = Backbone.View.extend({
that.close();
},
complete: function() {
notif.hide();
saving.hide();
}
});
},
......
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