MS DC Post framer process init
This commit is contained in:
parent
65f20f439c
commit
7ec1ef87c2
15 changed files with 124 additions and 35 deletions
|
|
@ -17,6 +17,14 @@ def select_from_dropdown(option_text, dropdown)
|
||||||
#assert dropdown text is link
|
#assert dropdown text is link
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def go_to_framer
|
||||||
|
click_button "Next"
|
||||||
|
end
|
||||||
|
|
||||||
|
def finalize_frame
|
||||||
|
click_button "done"
|
||||||
|
end
|
||||||
|
|
||||||
When /^I trumpet$/ do
|
When /^I trumpet$/ do
|
||||||
visit new_post_path
|
visit new_post_path
|
||||||
end
|
end
|
||||||
|
|
@ -59,6 +67,23 @@ Then /^"([^"]*)" should have the "([^"]*)" picture$/ do |post_text, file_name|
|
||||||
image.should be_present
|
image.should be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I go through the default composer$/ do
|
||||||
|
go_to_framer
|
||||||
|
finalize_frame
|
||||||
|
end
|
||||||
|
|
||||||
|
When /^I start the framing process$/ do
|
||||||
|
go_to_framer
|
||||||
|
end
|
||||||
|
|
||||||
|
When /^I finalize my frame$/ do
|
||||||
|
finalize_frame
|
||||||
|
end
|
||||||
|
|
||||||
Then /^"([^"]*)" should have (\d+) pictures$/ do |post_text, number_of_pictures|
|
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
|
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
|
||||||
end
|
end
|
||||||
|
|
@ -9,7 +9,7 @@ Feature: Creating a new post
|
||||||
And I write "I love RMS"
|
And I write "I love RMS"
|
||||||
When I select "Public" in my aspects dropdown
|
When I select "Public" in my aspects dropdown
|
||||||
And I upload a fixture picture with filename "button.gif"
|
And I upload a fixture picture with filename "button.gif"
|
||||||
When I press "Share"
|
When I go through the default composer
|
||||||
When I go to "/stream"
|
When I go to "/stream"
|
||||||
Then I should see "I love RMS" as the first post in my stream
|
Then I should see "I love RMS" as the first post in my stream
|
||||||
And "I love RMS" should be a public post in my stream
|
And "I love RMS" should be a public post in my stream
|
||||||
|
|
@ -18,7 +18,7 @@ Feature: Creating a new post
|
||||||
Scenario: Posting to Aspects
|
Scenario: Posting to Aspects
|
||||||
And I write "This is super skrunkle"
|
And I write "This is super skrunkle"
|
||||||
When I select "All Aspects" in my aspects dropdown
|
When I select "All Aspects" in my aspects dropdown
|
||||||
And I press "Share"
|
And I go through the default composer
|
||||||
When I go to "/stream"
|
When I go to "/stream"
|
||||||
Then I should see "This is super skrunkle" as the first post in my stream
|
Then I should see "This is super skrunkle" as the first post in my stream
|
||||||
Then "This is super skrunkle" should be a limited post in my stream
|
Then "This is super skrunkle" should be a limited post in my stream
|
||||||
|
|
@ -27,7 +27,7 @@ Feature: Creating a new post
|
||||||
Given a user named "Alice Smith" with email "alice@alice.alice"
|
Given a user named "Alice Smith" with email "alice@alice.alice"
|
||||||
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
|
And a user with email "bob@bob.bob" is connected with "alice@alice.alice"
|
||||||
And I mention "alice@alice.alice"
|
And I mention "alice@alice.alice"
|
||||||
And I press "Share"
|
And I go through the default composer
|
||||||
And I go to "/stream"
|
And I go to "/stream"
|
||||||
Then I follow "Alice Smith"
|
Then I follow "Alice Smith"
|
||||||
|
|
||||||
|
|
@ -35,6 +35,15 @@ Feature: Creating a new post
|
||||||
When I write "check out these pictures"
|
When I write "check out these pictures"
|
||||||
And I upload a fixture picture with filename "button.gif"
|
And I upload a fixture picture with filename "button.gif"
|
||||||
And I upload a fixture picture with filename "button.gif"
|
And I upload a fixture picture with filename "button.gif"
|
||||||
And I press "Share"
|
And I go through the default composer
|
||||||
And I go to "/stream"
|
And I go to "/stream"
|
||||||
Then "check out these pictures" should have 2 pictures
|
Then "check out these pictures" should have 2 pictures
|
||||||
|
|
||||||
|
Scenario: Framing your frame
|
||||||
|
When I write "This shit is super 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
|
||||||
|
When I finalize my frame
|
||||||
|
Then "This is super skrunkle" should be the first post in my stream
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@ app.forms.Picture = app.forms.Base.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
submitForm : function (){
|
submitForm : function (){
|
||||||
console.log("meow")
|
|
||||||
this.$("form").submit();
|
this.$("form").submit();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,16 +3,14 @@ app.models.StatusMessage = app.models.Post.extend({
|
||||||
return this.isNew() ? '/status_messages' : '/posts/' + this.get("id");
|
return this.isNew() ? '/status_messages' : '/posts/' + this.get("id");
|
||||||
},
|
},
|
||||||
|
|
||||||
mungeAndSave : function(){
|
toJSON : function(){
|
||||||
var mungedAttrs = {
|
return {
|
||||||
status_message : _.clone(this.attributes),
|
status_message : _.clone(this.attributes),
|
||||||
'aspect_ids[]' : this.get("aspect_ids"),
|
'aspect_ids' : this.get("aspect_ids").split(","),
|
||||||
photos : this.photos.pluck("id"),
|
photos : this.photos && this.photos.pluck("id"),
|
||||||
services : mungeServices(this.get("services"))
|
services : mungeServices(this.get("services"))
|
||||||
}
|
}
|
||||||
|
|
||||||
this.save(mungedAttrs)
|
|
||||||
|
|
||||||
function mungeServices (values) {
|
function mungeServices (values) {
|
||||||
if(!values) { return; }
|
if(!values) { return; }
|
||||||
return values.length > 1 ? values : [values]
|
return values.length > 1 ? values : [values]
|
||||||
|
|
|
||||||
12
public/javascripts/app/pages/framer.js
Normal file
12
public/javascripts/app/pages/framer.js
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
app.pages.Framer = app.views.Base.extend({
|
||||||
|
templateName : "framer",
|
||||||
|
|
||||||
|
events : {
|
||||||
|
"click button.done" : "saveFrame"
|
||||||
|
},
|
||||||
|
|
||||||
|
saveFrame : function(){
|
||||||
|
console.log(app.frame.toJSON(), app.frame)
|
||||||
|
app.frame.save()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
@ -3,14 +3,18 @@ app.pages.PostNew = app.views.Base.extend({
|
||||||
|
|
||||||
subviews : { "#new-post" : "postForm"},
|
subviews : { "#new-post" : "postForm"},
|
||||||
|
|
||||||
|
events : {
|
||||||
|
"click button.next" : "navigateNext"
|
||||||
|
},
|
||||||
|
|
||||||
initialize : function(){
|
initialize : function(){
|
||||||
this.model = new app.models.StatusMessage()
|
this.model = new app.models.StatusMessage()
|
||||||
this.postForm = new app.forms.Post({model : this.model})
|
this.postForm = new app.forms.Post({model : this.model})
|
||||||
|
|
||||||
this.model.bind("setFromForm", this.saveModel, this)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
saveModel : function(){
|
navigateNext : function(){
|
||||||
this.model.mungeAndSave();
|
this.postForm.setModelAttributes()
|
||||||
|
app.frame = this.model;
|
||||||
|
app.router.navigate("framer", true)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -18,25 +18,25 @@ app.Router = Backbone.Router.extend({
|
||||||
|
|
||||||
"posts/new" : "newPost",
|
"posts/new" : "newPost",
|
||||||
"posts/:id": "singlePost",
|
"posts/:id": "singlePost",
|
||||||
"p/:id": "singlePost"
|
"p/:id": "singlePost",
|
||||||
|
"framer": "framer"
|
||||||
},
|
},
|
||||||
|
|
||||||
stream : function() {
|
stream : function() {
|
||||||
app.stream = new app.models.Stream();
|
app.stream = new app.models.Stream();
|
||||||
app.page = new app.views.Stream({model : app.stream}).render();
|
app.page = new app.views.Stream({model : app.stream});
|
||||||
app.publisher = app.publisher || new app.views.Publisher({collection : app.stream.posts});
|
app.publisher = app.publisher || new app.views.Publisher({collection : app.stream.posts});
|
||||||
|
|
||||||
var streamFacesView = new app.views.StreamFaces({collection : app.stream.posts}).render();
|
var streamFacesView = new app.views.StreamFaces({collection : app.stream.posts});
|
||||||
|
|
||||||
$("#main_stream").html(app.page.el);
|
$("#main_stream").html(app.page.render().el);
|
||||||
$('#selected_aspect_contacts .content').html(streamFacesView.el);
|
$('#selected_aspect_contacts .content').html(streamFacesView.render().el);
|
||||||
},
|
},
|
||||||
|
|
||||||
photos : function() {
|
photos : function() {
|
||||||
app.photos = new app.models.Photos();
|
app.photos = new app.models.Photos();
|
||||||
app.page = new app.views.Photos({model : app.photos}).render();
|
app.page = new app.views.Photos({model : app.photos});
|
||||||
|
$("#main_stream").html(app.page.render().el);
|
||||||
$("#main_stream").html(app.page.el);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
newPost : function(){
|
newPost : function(){
|
||||||
|
|
@ -44,6 +44,11 @@ app.Router = Backbone.Router.extend({
|
||||||
$("#container").html(page.render().el)
|
$("#container").html(page.render().el)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
framer : function(){
|
||||||
|
var page = new app.pages.Framer();
|
||||||
|
$("#container").html(page.render().el)
|
||||||
|
},
|
||||||
|
|
||||||
singlePost : function(id) {
|
singlePost : function(id) {
|
||||||
var page = new app.pages.PostViewer({ id: id });
|
var page = new app.pages.PostViewer({ id: id });
|
||||||
$("#container").html(page.el);
|
$("#container").html(page.el);
|
||||||
|
|
|
||||||
1
public/javascripts/app/templates/framer.handlebars
Normal file
1
public/javascripts/app/templates/framer.handlebars
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
<button class="done btn-primary">done</button>
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div id="new-post"></div>
|
<div id="new-post"></div>
|
||||||
|
<button class="btn-primary next">Next</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ app.views.Base = Backbone.View.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
defaultPresenter : function(){
|
defaultPresenter : function(){
|
||||||
var modelJson = this.model ? this.model.toJSON() : {}
|
var modelJson = this.model ? _.clone(this.model.attributes) : {}
|
||||||
return _.extend(modelJson, {
|
return _.extend(modelJson, {
|
||||||
current_user : app.currentUser.attributes,
|
current_user : app.currentUser.attributes,
|
||||||
loggedIn : app.currentUser.authenticated()
|
loggedIn : app.currentUser.authenticated()
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,9 @@ app.views.Publisher = Backbone.View.extend({
|
||||||
|
|
||||||
var serializedForm = $(evt.target).closest("form").serializeObject();
|
var serializedForm = $(evt.target).closest("form").serializeObject();
|
||||||
|
|
||||||
// save status message
|
// lulz this code should be killed.
|
||||||
var statusMessage = new app.models.StatusMessage();
|
var statusMessage = new app.models.Post();
|
||||||
|
|
||||||
statusMessage.save({
|
statusMessage.save({
|
||||||
"status_message" : {
|
"status_message" : {
|
||||||
"text" : serializedForm["status_message[text]"]
|
"text" : serializedForm["status_message[text]"]
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ describe("app.forms.Post", function(){
|
||||||
this.view.render()
|
this.view.render()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
describe("submitting a valid form", function(){
|
describe("submitting a valid form", function(){
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
this.view.$("form #text_with_markup").val("Oh My")
|
this.view.$("form #text_with_markup").val("Oh My")
|
||||||
|
|
|
||||||
18
spec/javascripts/app/pages/framer_spec.js
Normal file
18
spec/javascripts/app/pages/framer_spec.js
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
describe("app.pages.Framer", function(){
|
||||||
|
beforeEach(function(){
|
||||||
|
app.frame = new app.models.StatusMessage();
|
||||||
|
this.page = new app.pages.Framer();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("rendering", function(){
|
||||||
|
beforeEach(function(){
|
||||||
|
this.page.render();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("saves the model when you click done",function(){
|
||||||
|
spyOn(app.frame, "save");
|
||||||
|
this.page.$("button.done").click();
|
||||||
|
expect(app.frame.save).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -3,15 +3,30 @@ describe("app.pages.PostNew", function(){
|
||||||
this.page = new app.pages.PostNew()
|
this.page = new app.pages.PostNew()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("renders", function(){
|
describe("rendering", function(){
|
||||||
this.page.render();
|
beforeEach(function(){
|
||||||
})
|
this.page.render();
|
||||||
|
})
|
||||||
|
|
||||||
context("when the model receives setFromForm", function(){
|
describe("clicking next", function(){
|
||||||
it("it calls mungeAndSave", function(){
|
beforeEach(function(){
|
||||||
spyOn(this.page.model, "mungeAndSave")
|
spyOn(app.router, "navigate")
|
||||||
this.page.model.trigger("setFromForm")
|
spyOn(this.page.postForm, "setModelAttributes")
|
||||||
expect(this.page.model.mungeAndSave).toHaveBeenCalled();
|
this.page.$("button.next").click()
|
||||||
|
})
|
||||||
|
|
||||||
|
it("calls tells the form to set the models attributes", function(){
|
||||||
|
expect(this.page.postForm.setModelAttributes).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("stores a reference to the form as app.composer" , function(){
|
||||||
|
expect(this.page.model).toBeDefined()
|
||||||
|
expect(app.frame).toBe(this.page.model)
|
||||||
|
});
|
||||||
|
|
||||||
|
it("navigates to the framer", function(){
|
||||||
|
expect(app.router.navigate).toHaveBeenCalledWith("framer", true)
|
||||||
|
});
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
|
|
@ -18,8 +18,8 @@ src_files:
|
||||||
- public/javascripts/vendor/underscore.js
|
- public/javascripts/vendor/underscore.js
|
||||||
- public/javascripts/vendor/jquery-1.7.1.min.js
|
- public/javascripts/vendor/jquery-1.7.1.min.js
|
||||||
- public/javascripts/vendor/jquery-ui-1.8.9.custom.min.js
|
- public/javascripts/vendor/jquery-ui-1.8.9.custom.min.js
|
||||||
- public/javascripts/vendor/bootstrap/bootstrap-popover.js
|
|
||||||
- public/javascripts/vendor/bootstrap/bootstrap-twipsy.js
|
- public/javascripts/vendor/bootstrap/bootstrap-twipsy.js
|
||||||
|
- public/javascripts/vendor/bootstrap/bootstrap-popover.js
|
||||||
- public/javascripts/vendor/jquery.tipsy.js
|
- public/javascripts/vendor/jquery.tipsy.js
|
||||||
- public/javascripts/vendor/jquery.infinitescroll.min.js
|
- public/javascripts/vendor/jquery.infinitescroll.min.js
|
||||||
- public/javascripts/vendor/jquery.autoresize.js
|
- public/javascripts/vendor/jquery.autoresize.js
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue