From d7a77e672bcfb0e9edc9936c31f8060afce6cdd9 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 9 May 2011 21:47:00 -0400 Subject: [PATCH] update some templates --- templates/collection_spec.coffee.erb | 7 +++++++ templates/view.coffee.erb | 1 + templates/view.js.erb | 1 + templates/view.jst.erb | 2 +- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/templates/collection_spec.coffee.erb b/templates/collection_spec.coffee.erb index 5931453..cb28b81 100644 --- a/templates/collection_spec.coffee.erb +++ b/templates/collection_spec.coffee.erb @@ -4,4 +4,11 @@ describe '<%= plural_object_name %>', -> withServer() it 'should fetch records from the API', -> + collection = new <%= plural_object_name %>() + + @server.respondWith('GET', '/<%= plural_underscore_name %>', @validJSONResponse([{id: 1}])) + collection.fetch() + @server.respond() + + expect(collection.length).toEqual(1) diff --git a/templates/view.coffee.erb b/templates/view.coffee.erb index 59d55d6..83eff0f 100644 --- a/templates/view.coffee.erb +++ b/templates/view.coffee.erb @@ -13,6 +13,7 @@ class window.<%= object_name %>View extends Backbone.View render: => $(@el).html(@template(@model.toJSON())) this.$('button.save').text(if @model.isNew() then 'Create' else 'Update') + this.$('button.delete')[if @model.isNew() then 'hide' else 'show'](); this save: => @model.save(@attributes()) diff --git a/templates/view.js.erb b/templates/view.js.erb index faa51c6..e766b0a 100644 --- a/templates/view.js.erb +++ b/templates/view.js.erb @@ -16,6 +16,7 @@ var <%= object_name %>View = Backbone.View.extend({ render: function() { $(this.el).html(this.template(this.model.toJSON())); this.$('button.save').text(this.model.isNew() ? 'Create' : 'Update'); + this.$('button.delete')[this.model.isNew() ? 'hide' : 'show'](); return this; }, save: function() { diff --git a/templates/view.jst.erb b/templates/view.jst.erb index eaaffac..c7c3004 100644 --- a/templates/view.jst.erb +++ b/templates/view.jst.erb @@ -1,2 +1,2 @@ -