MS DC; fix participate stream ordering problem that was putting new posts on the bottom of things
This commit is contained in:
parent
578e8ef269
commit
a399572995
7 changed files with 78 additions and 9 deletions
|
|
@ -32,7 +32,6 @@ class StreamsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def participate
|
def participate
|
||||||
puts params.inspect
|
|
||||||
stream_responder(Stream::Participate)
|
stream_responder(Stream::Participate)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
21
features/participate_stream.feature
Normal file
21
features/participate_stream.feature
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
@javascript
|
||||||
|
Feature: The participate stream
|
||||||
|
Scenario: Sorting
|
||||||
|
Given a user with username "bob"
|
||||||
|
When I sign in as "bob@bob.bob"
|
||||||
|
|
||||||
|
And I post "A- I like turtles"
|
||||||
|
And I post "B- barack obama is your new bicycle"
|
||||||
|
And I post "C- barack obama is a square"
|
||||||
|
|
||||||
|
When I pin the post "A- I like turtles"
|
||||||
|
And I wait for 1 second
|
||||||
|
And I comment "Sassy sawfish" on "C- barack obama is a square"
|
||||||
|
And I wait for 1 second
|
||||||
|
And I pin the post "B- barack obama is your new bicycle"
|
||||||
|
And I wait for 1 second
|
||||||
|
|
||||||
|
When I go to the participate stream page
|
||||||
|
Then "B- barack obama is your new bicycle" should be post 1
|
||||||
|
And "C- barack obama is a square" should be post 2
|
||||||
|
And "A- I like turtles" should be post 3
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
When /^I focus the comment field$/ do
|
When /^I focus the comment field$/ do
|
||||||
find("a.focus_comment_textarea").click
|
focus_comment_box
|
||||||
end
|
end
|
||||||
|
|
||||||
Then /^the first comment field should be open/ do
|
Then /^the first comment field should be open/ do
|
||||||
|
|
@ -9,3 +9,8 @@ end
|
||||||
Then /^the first comment field should be closed$/ do
|
Then /^the first comment field should be closed$/ do
|
||||||
find("#main_stream .stream_element .new_comment").should_not be_visible
|
find("#main_stream .stream_element .new_comment").should_not be_visible
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
When /^I comment "([^"]*)" on "([^"]*)"$/ do |comment_text, post_text|
|
||||||
|
comment_on_post(post_text, comment_text)
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
Then /^I should see an image in the publisher$/ do
|
Then /^I should see an image in the publisher$/ do
|
||||||
photo_in_publisher.should be_present
|
photo_in_publisher.should be_present
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^I pin the post "([^"]*)"$/ do |post_text|
|
||||||
|
pin_post(post_text)
|
||||||
|
end
|
||||||
|
|
||||||
|
Then /^"([^"]*)" should be post (\d+)$/ do |post_text, position|
|
||||||
|
find(".stream_element:nth-child(#{position}) .post-content").text.should == post_text
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,40 @@ module PublishingCukeHelpers
|
||||||
find(".stream_element:contains('#{text}')")
|
find(".stream_element:contains('#{text}')")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def pin_post(post_text)
|
||||||
|
within_post(post_text) do
|
||||||
|
click_link 'Pin'
|
||||||
|
end
|
||||||
|
wait_for_ajax_to_finish
|
||||||
|
end
|
||||||
|
|
||||||
|
def within_post(post_text)
|
||||||
|
within find_post_by_text(post_text) do
|
||||||
|
yield
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def stream_posts
|
||||||
|
all('.stream_element')
|
||||||
|
end
|
||||||
|
|
||||||
|
def comment_on_post(post_text, comment_text)
|
||||||
|
within_post(post_text) do
|
||||||
|
focus_comment_box
|
||||||
|
make_comment(comment_text)
|
||||||
|
end
|
||||||
|
wait_for_ajax_to_finish
|
||||||
|
end
|
||||||
|
|
||||||
|
def make_comment(text)
|
||||||
|
fill_in "text", :with => text
|
||||||
|
click_button :submit
|
||||||
|
end
|
||||||
|
|
||||||
|
def focus_comment_box
|
||||||
|
find("a.focus_comment_textarea").click
|
||||||
|
end
|
||||||
|
|
||||||
def wait_for_ajax_to_finish(wait_time=15)
|
def wait_for_ajax_to_finish(wait_time=15)
|
||||||
wait_until(wait_time) { evaluate_script("$.active") == 0 }
|
wait_until(wait_time) { evaluate_script("$.active") == 0 }
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,4 @@ app.collections.Posts = Backbone.Collection.extend({
|
||||||
parse: function(resp){
|
parse: function(resp){
|
||||||
return resp.posts;
|
return resp.posts;
|
||||||
}
|
}
|
||||||
//
|
|
||||||
//
|
|
||||||
// comparator : function(post) {
|
|
||||||
// return -post.createdAt();
|
|
||||||
// }
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,13 @@
|
||||||
app.models.Stream = Backbone.Collection.extend({
|
app.models.Stream = Backbone.Collection.extend({
|
||||||
initialize : function(){
|
initialize : function(){
|
||||||
this.posts = new app.collections.Posts();
|
this.posts = new app.collections.Posts([], this.postOptions());
|
||||||
|
},
|
||||||
|
|
||||||
|
postOptions :function(){
|
||||||
|
var order = this.sortOrder();
|
||||||
|
return {
|
||||||
|
comparator : function(post) { return -post[order](); }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
url : function(){
|
url : function(){
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue