From bf4dabc4f49495c62f44546503a5dbf760f070e0 Mon Sep 17 00:00:00 2001 From: Dennis Collinson Date: Tue, 6 Mar 2012 16:26:19 -0800 Subject: [PATCH] MS DC posting from post/new werks --- features/trumpeter.feature | 4 ++-- .../javascripts/app/models/status_message.js | 12 +++++++++- public/javascripts/app/pages/post-new.js | 10 +++++--- .../app/templates/post-form.handlebars | 2 +- .../javascripts/app/views/post_form_view.js | 23 ++++++++++++++---- spec/javascripts/app/app_spec.js | 10 +++----- .../app/models/status_message_spec.js | 12 ++++++++++ spec/javascripts/app/pages/post_new_spec.js | 8 +++++++ spec/javascripts/app/views/post_form_spec.js | 24 +++++++++++++++++-- 9 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 spec/javascripts/app/models/status_message_spec.js diff --git a/features/trumpeter.feature b/features/trumpeter.feature index 28a8b0288..7b42452d7 100644 --- a/features/trumpeter.feature +++ b/features/trumpeter.feature @@ -8,5 +8,5 @@ Feature: Creating a new post When I trumpet And I write "Rectangles are awesome" And I press "Share" -# When I go to the stream page -# Then I should see "Rectangles are awesome" as the first post in my stream + When I go to "/stream" + Then I should see "Rectangles are awesome" as the first post in my stream diff --git a/public/javascripts/app/models/status_message.js b/public/javascripts/app/models/status_message.js index 7a2c8120a..50190883d 100644 --- a/public/javascripts/app/models/status_message.js +++ b/public/javascripts/app/models/status_message.js @@ -1 +1,11 @@ -app.models.StatusMessage = app.models.Post.extend({ }); +app.models.StatusMessage = app.models.Post.extend({ + url : function(){ + return this.isNew() ? '/status_messages' : '/posts/' + this.get("id"); + }, + + mungeAndSave : function(){ + var mungedAttrs = {status_message : _.clone(this.attributes), aspect_ids : ["public"]} + + this.save(mungedAttrs) + } +}); diff --git a/public/javascripts/app/pages/post-new.js b/public/javascripts/app/pages/post-new.js index 339f19424..0e2e446d1 100644 --- a/public/javascripts/app/pages/post-new.js +++ b/public/javascripts/app/pages/post-new.js @@ -4,9 +4,13 @@ app.pages.PostNew = app.views.Base.extend({ subviews : { "#new-post" : "postForm"}, initialize : function(){ - console.log("In the page") - - this.model = new app.models.Post() + this.model = new app.models.StatusMessage() this.postForm = new app.views.PostForm({model : this.model}) + + this.model.bind("setFromForm", this.saveModel, this) + }, + + saveModel : function(){ + this.model.mungeAndSave(); } }) diff --git a/public/javascripts/app/templates/post-form.handlebars b/public/javascripts/app/templates/post-form.handlebars index 4d5253c6a..0c8ffb88c 100644 --- a/public/javascripts/app/templates/post-form.handlebars +++ b/public/javascripts/app/templates/post-form.handlebars @@ -1,4 +1,4 @@