Commit 77db1f8a by David Baumgold

Fixups and test fixes post-rebase

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