Skip to content

Commit

Permalink
MS DC framer shows rudimentary version of post
Browse files Browse the repository at this point in the history
  • Loading branch information
dnsco committed Mar 27, 2012
1 parent 7ec1ef8 commit 3584143
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 20 deletions.
9 changes: 8 additions & 1 deletion features/step_definitions/trumpeter_steps.rb
Expand Up @@ -25,6 +25,12 @@ def finalize_frame
click_button "done"
end

def within_frame_preview
within ".post-view .post" do
yield
end
end

When /^I trumpet$/ do
visit new_post_path
end
Expand Down Expand Up @@ -84,6 +90,7 @@ def finalize_frame
find_post_by_text(post_text).all(".photo_attachments img").size.should == number_of_pictures.to_i
end


Then /^I should see "([^"]*)" in the framer preview$/ do |post_text|
pending
within_frame_preview { page.should have_content(post_text) }
end
7 changes: 4 additions & 3 deletions features/trumpeter.feature
Expand Up @@ -40,10 +40,11 @@ Feature: Creating a new post
Then "check out these pictures" should have 2 pictures

Scenario: Framing your frame
When I write "This shit is super customized"
When I write "This is hella customized"
And I upload a fixture picture with filename "button.gif"
And I start the framing process
Then I should see "This shit is super customized" in the framer preview
Then I should see "This is hella customized" in the framer preview
When I finalize my frame
Then "This is super skrunkle" should be the first post in my stream
And I go to "/stream"
Then "This is hella customized" should be post 1

1 change: 0 additions & 1 deletion public/javascripts/app/forms/post_form.js
Expand Up @@ -29,7 +29,6 @@ app.forms.Post = app.forms.Base.extend({
this.model.set(_.inject(this.formAttrs, setValueFromField, {}))
//pass collections across
this.model.photos = this.pictureForm.photos
this.model.trigger("setFromForm")

function setValueFromField(memo, attribute, selector){
var selectors = form.find(selector);
Expand Down
7 changes: 6 additions & 1 deletion public/javascripts/app/models/status_message.js
Expand Up @@ -3,10 +3,15 @@ app.models.StatusMessage = app.models.Post.extend({
return this.isNew() ? '/status_messages' : '/posts/' + this.get("id");
},

defaults : {
'post_type' : 'StatusMessage',
'author' : app.currentUser ? app.currentUser.attributes : {}
},

toJSON : function(){
return {
status_message : _.clone(this.attributes),
'aspect_ids' : this.get("aspect_ids").split(","),
aspect_ids : this.get("aspect_ids") && this.get("aspect_ids").split(","),
photos : this.photos && this.photos.pluck("id"),
services : mungeServices(this.get("services"))
}
Expand Down
24 changes: 22 additions & 2 deletions public/javascripts/app/pages/framer.js
Expand Up @@ -5,8 +5,28 @@ app.pages.Framer = app.views.Base.extend({
"click button.done" : "saveFrame"
},

subviews : {
".post-view" : "postView"
},

initialize : function(){
this.model = app.frame

var templateType = "status"

this.model.authorIsNotCurrentUser = function(){ return false }

this.postView = new app.views.Post({
model : this.model,
className : templateType + " post loaded",
templateName : "post-viewer/content/" + templateType,
attributes : {"data-template" : templateType}
});

this.postView.feedbackView = new Backbone.View
},

saveFrame : function(){
console.log(app.frame.toJSON(), app.frame)
app.frame.save()
this.model.save()
}
})
3 changes: 2 additions & 1 deletion public/javascripts/app/templates/framer.handlebars
@@ -1 +1,2 @@
<button class="done btn-primary">done</button>
<button class="done btn-primary">done</button>
<div class="post-view"></div>
7 changes: 0 additions & 7 deletions spec/javascripts/app/forms/post_form_spec.js
Expand Up @@ -37,13 +37,6 @@ describe("app.forms.Post", function(){
expect(this.view.model.get("aspect_ids")).toBe("public")
expect(this.view.model.get("services").length).toBe(2)
})

it("triggers a 'setFromForm' event", function(){
var spy = jasmine.createSpy();
this.view.model.bind("setFromForm", spy);
this.view.$(".new-post").submit();
expect(spy).toHaveBeenCalled();
})
})
})
})
3 changes: 2 additions & 1 deletion spec/javascripts/app/pages/framer_spec.js
@@ -1,6 +1,7 @@
describe("app.pages.Framer", function(){
beforeEach(function(){
app.frame = new app.models.StatusMessage();
loginAs(factory.user())
app.frame = new factory.statusMessage();
this.page = new app.pages.Framer();
});

Expand Down
13 changes: 10 additions & 3 deletions spec/javascripts/helpers/factory.js
Expand Up @@ -52,16 +52,15 @@ factory = {
return _.extend(defaultAttrs, overrides)
},

post : function(overrides) {
var defaultAttrs = {
postAttrs : function(){
return {
"provider_display_name" : null,
"created_at" : "2012-01-03T19:53:13Z",
"interacted_at" : '2012-01-03T19:53:13Z',
"last_three_comments" : null,
"public" : false,
"guid" : this.guid(),
"image_url" : null,
"author" : this.author(),
"o_embed_cache" : null,
"photos" : [],
"text" : "jasmine is bomb",
Expand All @@ -73,10 +72,18 @@ factory = {
"likes_count" : 0,
"comments_count" : 0
}
},

post : function(overrides) {
defaultAttrs = _.extend(factory.postAttrs(), {"author" : this.author()})
return new app.models.Post(_.extend(defaultAttrs, overrides))
},

statusMessage : function(overrides){
//intentionally doesn't have an author to mirror creation process, maybe we should change the creation process
return new app.models.StatusMessage(_.extend(factory.postAttrs(), overrides))
},

comment: function(overrides) {
var defaultAttrs = {
"text" : "This is an awesome comment!",
Expand Down

0 comments on commit 3584143

Please sign in to comment.