cuking out new stream, refactors.

This commit is contained in:
Dennis Collinson 2012-05-21 15:14:23 -07:00
parent 481160bdcb
commit fe0156a18b
22 changed files with 114 additions and 25 deletions

View file

@ -24,7 +24,7 @@ app.pages.Framer = app.views.Base.extend({
},
postView : function(){
return new app.views.SmallFrame({model : this.model})
return new app.views.Post.SmallFrame({model : this.model})
},
navigateNext : function(){

View file

@ -1,4 +1,3 @@
//= require ../views/small_frame
//= require ../views/profile_info_view
app.pages.Profile = app.views.Base.extend({

View file

@ -1,11 +1,11 @@
app.views.NewStream = app.views.Base.extend(_.extend({}, app.views.infiniteScrollMixin, {
app.views.NewStream = app.views.InfScroll.extend({
initialize: function(){
this.stream = this.model
this.collection = this.stream.items
this.postClass = app.views.SmallFrame
this.postClass = app.views.Post.StreamFrame
this.setupInfiniteScroll()
}
}));
});
app.pages.Stream = app.views.Base.extend({
templateName : "stream",

View file

@ -95,7 +95,7 @@ app.views.Base = Backbone.View.extend({
// a #paginate div in the layout
// a call to setupInfiniteScroll
app.views.infiniteScrollMixin = {
app.views.InfScroll = app.views.Base.extend({
setupInfiniteScroll : function() {
this.postViews = this.postViews || []
@ -163,4 +163,5 @@ app.views.infiniteScrollMixin = {
this.trigger("loadMore")
}
}
};
});

View file

@ -1,8 +1,9 @@
app.views.Canvas = app.views.Base.extend(_.extend({}, app.views.infiniteScrollMixin, {
app.views.Canvas = app.views.InfScroll.extend({
initialize: function(){
this.stream = this.model
this.collection = this.stream.items
this.postClass = app.views.CanvasFrame
this.postClass = app.views.Post.CanvasFrame
this.postViews = []
this.setupInfiniteScroll()
this.stream.bind("reLayout", this.reLayout, this)
this.stream.bind("fetched", this.triggerRelayoutAfterImagesLoaded, this)
@ -57,10 +58,12 @@ app.views.Canvas = app.views.Base.extend(_.extend({}, app.views.infiniteScrollMi
},
triggerRelayoutAfterImagesLoaded : function(){
//event apparently only fires once
this.$el.imagesLoaded(_.bind(this.reLayout, this))
},
reLayout : function(){
console.log("relaying out")
this.$el.isotope("reLayout")
}
}));
});

View file

@ -1,4 +1,4 @@
app.views.Photos = Backbone.View.extend(_.extend({
app.views.Photos = app.views.InfScroll.extend({
initialize : function(options) {
this.stream = this.model;
this.collection = this.stream.items;
@ -20,4 +20,4 @@ app.views.Photos = Backbone.View.extend(_.extend({
});
$(this.el).delegate("a.photo-link", "click", this.lightbox.lightboxImageClicked);
}
}, app.views.infiniteScrollMixin));
});

View file

@ -1,7 +1,6 @@
//= require ./small_frame
app.views.CanvasFrame = app.views.SmallFrame.extend({
app.views.Post.CanvasFrame = app.views.Post.SmallFrame.extend({
SINGLE_COLUMN_WIDTH : 265,
DOUBLE_COLUMN_WIDTH : 560,
@ -32,12 +31,15 @@ app.views.CanvasFrame = app.views.SmallFrame.extend({
},
presenter : function(){
console.log("here")
return _.extend(this.smallFramePresenter(), {
adjustedImageHeight : this.adjustedImageHeight()
})
},
favoritePost : function(evt) {
console.log("in favorite post")
if(evt) {
/* follow links instead of faving the targeted post */
if($(evt.target).is('a')) { return }

View file

@ -1,6 +1,6 @@
//= require "./post_view"
//= require "../post_view"
app.views.SmallFrame = app.views.Post.extend({
app.views.Post.SmallFrame = app.views.Post.extend({
className : "canvas-frame",
templateName : "small-frame/default", // default to fall back to

View file

@ -0,0 +1,2 @@
app.views.Post.StreamFrame = app.views.Post.SmallFrame.extend({
})

View file

@ -1,4 +1,4 @@
app.views.Stream = Backbone.View.extend(_.extend( app.views.infiniteScrollMixin, {
app.views.Stream = app.views.InfScroll.extend({
initialize: function(options) {
this.stream = this.model
this.collection = this.stream.items
@ -24,4 +24,4 @@ app.views.Stream = Backbone.View.extend(_.extend( app.views.infiniteScrollMixin,
_.map(this.postViews, function(view){ view.render() })
}
}
}));
});

View file

@ -0,0 +1,22 @@
@javascript
Feature: Interacting with the stream
Background:
Given I am logged in as a beta user with email "bill@bill.com"
And "bill@bill.com" is an admin
And I make a new publisher post "I like it like that."
And I make a new publisher post "yeah baby."
And I make a new publisher post "I got soul."
When I go to the new stream
Scenario: Visiting the stream
Then "I got soul." should be frame 1
Then "yeah baby." should be frame 2
Then "I like it like that." should be frame 3
# Scenario: Clicking on a post show the interactions
# And I wait for 5 seconds
# When I click into the "I got soul." stream frame
# And I make a show page comment "you're such a pip"
# And I go to the new stream
# When I click the "I got soul." stream frame
# Then "you're such a pip" should be a comment for "I got soul."

View file

@ -40,7 +40,7 @@ Feature: Creating a new post
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 go through the default composer
And I go through the default framer
And I go to "/stream"
Then "check out these pictures" should have 2 pictures

View file

@ -0,0 +1,23 @@
Then /^"([^"]*)" should be frame (\d+)$/ do |post_text, position|
frame_numbers_content(position).find(".text-content").text.should == post_text
end
When /^I click the "([^"]*)" stream frame$/ do |post_text|
within "#stream-content" do
find_frame_by_text(post_text).find(".content").click
end
end
Then /^"([^"]*)" should be a comment for "([^"]*)"$/ do |comment_text, post_text|
post = find_frame_by_text(post_text)
post.find(".comment:contains('#{comment_text}')").should be_present
end
When /^I click into the "([^"]*)" stream frame$/ do |post_text|
find("#stream-content .content:contains('#{post_text}') .permalink").click
#within "#stream-content" do
# post = find_frame_by_text(post_text)
# link = post.find(".permalink")
# link.click
#end
end

View file

@ -0,0 +1,19 @@
def create_beta_user(opts)
user = create_user(opts)
Role.add_beta(user.person)
user
end
Given /^I am logged in as a beta user with email "(.*?)"$/ do |email|
@me = create_beta_user(:email => email, :password => 'password', :password_confirmation => 'password')
visit login_page
login_as(@me.username, 'password')
end
Given /^a beta user "(.*?)"$/ do |email|
create_beta_user(:email => email)
end
When /^"([^"]*)" is an admin$/ do |email|
Role.add_admin(User.find_by_email(email).person)
end

View file

@ -96,7 +96,14 @@ Then /^"([^"]*)" should have the "([^"]*)" picture$/ do |post_text, file_name|
end
end
When /^I go through the default composer$/ do
When /^I make a new publisher post "([^"]*)"$/ do |post_text|
visit new_post_path
fill_in 'text', :with => post_text
go_to_framer
finalize_frame
end
When /^I go through the default framer$/ do
go_to_framer
finalize_frame
end

View file

@ -32,6 +32,7 @@ Given /^"([^"]*)" has a non public post with text "([^"]*)"$/ do |email, text|
user.post(:status_message, :text => text, :public => false, :to => user.aspects)
end
When /^The user deletes their first post$/ do
@me.posts.first.destroy
end

View file

@ -6,7 +6,7 @@ end
When /^I try to sign in$/ do
@me ||= Factory(:user_with_aspect, :getting_started => false)
page.driver.visit(new_integration_sessions_path(:user_id => @me.id))
step %(I press "Login")
click_button "Login"
# To save time as compared to:
#step %(I go to the new user session page)
#step %(I fill in "Username" with "#{@me.username}")

View file

@ -29,6 +29,8 @@ module NavigationHelpers
edit_user_path
when /^my new profile page$/
person_path(@me.person, :ex => true)
when /^the new stream$/
stream_path(:ex => true)
when /^"(\/.*)"/
$1
else

View file

@ -37,6 +37,14 @@ module PublishingCukeHelpers
stream_element_numbers_content(1).text()
end
def frame_numbers_content(position)
find(".canvas-frame:nth-child(#{position}) .content")
end
def find_frame_by_text(text)
find(".canvas-frame:contains('#{text}')")
end
def stream_element_numbers_content(position)
find(".stream_element:nth-child(#{position}) .post-content")
end

View file

@ -1,4 +1,4 @@
describe("app.views.CanvasFrame", function(){
describe("app.views.Post.CanvasFrame", function(){
beforeEach(function(){
this.model = factory.post({
photos : [
@ -13,7 +13,7 @@ describe("app.views.CanvasFrame", function(){
]
})
this.view = new app.views.CanvasFrame({model : this.model})
this.view = new app.views.Post.CanvasFrame({model : this.model})
})
context("images", function() {

View file

@ -1,4 +1,4 @@
describe("app.views.SmallFrame", function(){
describe("app.views.Post.SmallFrame", function(){
beforeEach(function(){
this.model = factory.post({
photos : [
@ -19,7 +19,7 @@ describe("app.views.SmallFrame", function(){
}
})
this.view = new app.views.SmallFrame({model : this.model})
this.view = new app.views.Post.SmallFrame({model : this.model})
})
it("passes the model down to the oembed view", function(){