MS DC framer shows rudimentary version of post

This commit is contained in:
Dennis Collinson 2012-03-20 12:44:21 -07:00
parent 7ec1ef87c2
commit 358414371e
9 changed files with 54 additions and 20 deletions

View file

@ -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
@ -84,6 +90,7 @@ Then /^"([^"]*)" should have (\d+) pictures$/ do |post_text, number_of_pictures|
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

View file

@ -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

View file

@ -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);

View file

@ -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"))
}

View file

@ -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()
}
})

View file

@ -1 +1,2 @@
<button class="done btn-primary">done</button>
<button class="done btn-primary">done</button>
<div class="post-view"></div>

View file

@ -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();
})
})
})
})

View file

@ -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();
});

View file

@ -52,8 +52,8 @@ 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',
@ -61,7 +61,6 @@ factory = {
"public" : false,
"guid" : this.guid(),
"image_url" : null,
"author" : this.author(),
"o_embed_cache" : null,
"photos" : [],
"text" : "jasmine is bomb",
@ -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!",