Commit 9cbfee98 by David Baumgold

Fix Jasmine tests related to invalid messages for section model

parent 2b01273f
...@@ -31,7 +31,7 @@ describe "CMS.Views.SectionEdit", -> ...@@ -31,7 +31,7 @@ describe "CMS.Views.SectionEdit", ->
setFixtures($("<script>", {id: "section-name-edit-tpl", type: "text/template"}).text(tpl)) setFixtures($("<script>", {id: "section-name-edit-tpl", type: "text/template"}).text(tpl))
spyOn(CMS.Views.SectionEdit.prototype, "switchToShowView") spyOn(CMS.Views.SectionEdit.prototype, "switchToShowView")
.andCallThrough() .andCallThrough()
spyOn(CMS.Views.SectionEdit.prototype, "showErrorMessage") spyOn(CMS.Views.SectionEdit.prototype, "showInvalidMessage")
.andCallThrough() .andCallThrough()
window.analytics = jasmine.createSpyObj('analytics', ['track']) window.analytics = jasmine.createSpyObj('analytics', ['track'])
window.course_location_analytics = jasmine.createSpy() window.course_location_analytics = jasmine.createSpy()
...@@ -68,12 +68,9 @@ describe "CMS.Views.SectionEdit", -> ...@@ -68,12 +68,9 @@ describe "CMS.Views.SectionEdit", ->
@requests[0].respond(200) @requests[0].respond(200)
expect(@view.switchToShowView).toHaveBeenCalled() expect(@view.switchToShowView).toHaveBeenCalled()
it "should call showErrorMessage when save() is unsuccessful", -> it "should call showInvalidMessage when validation is unsuccessful", ->
spyOn(@model, 'validate').andReturn("BLARRGH")
@view.$("input[type=submit]").click() @view.$("input[type=submit]").click()
@requests[0].respond(500) expect(@view.showInvalidMessage).toHaveBeenCalledWith(
expect(@view.showErrorMessage).toHaveBeenCalled() jasmine.any(Object), "BLARRGH", jasmine.any(Object))
expect(@view.switchToShowView).not.toHaveBeenCalled() expect(@view.switchToShowView).not.toHaveBeenCalled()
...@@ -26,7 +26,7 @@ CMS.Views.SectionEdit = Backbone.View.extend({ ...@@ -26,7 +26,7 @@ CMS.Views.SectionEdit = Backbone.View.extend({
}, },
initialize: function() { initialize: function() {
this.template = _.template($("#section-name-edit-tpl").text()); this.template = _.template($("#section-name-edit-tpl").text());
this.listenTo(this.model, "invalid", this.showErrorMessage); this.listenTo(this.model, "invalid", this.showInvalidMessage);
this.render(); this.render();
}, },
events: { events: {
...@@ -58,7 +58,7 @@ CMS.Views.SectionEdit = Backbone.View.extend({ ...@@ -58,7 +58,7 @@ CMS.Views.SectionEdit = Backbone.View.extend({
this.stopListening(); this.stopListening();
this.showView.render(); this.showView.render();
}, },
showErrorMessage: function(model, error, options) { showInvalidMessage: function(model, error, options) {
var that = this; var that = this;
var msg = new CMS.Models.ErrorMessage({ var msg = new CMS.Models.ErrorMessage({
title: "Validation Error", title: "Validation Error",
......
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