Merge branch 'fix_stream_order'

This commit is contained in:
Dennis Collinson 2012-02-06 16:52:35 -08:00
commit 9b5f5b8129
10 changed files with 155 additions and 4 deletions

View file

@ -32,7 +32,6 @@ class StreamsController < ApplicationController
end
def participate
puts params.inspect
stream_responder(Stream::Participate)
end

View 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

View file

@ -24,6 +24,11 @@ Feature: posting from the main page
And I go to the aspects page
Then I should see "I am eating a yogurt" within ".stream_element"
Scenario: posting a message appends it to the top of the stream
When I click the publisher and post "sup dog"
And I click the publisher and post "hello there"
Then I should see "hello there" as the first post in my stream
Scenario: post a text-only message to just one aspect
When I select only "PostingTo" aspect
And I expand the publisher

View file

@ -1,5 +1,5 @@
When /^I focus the comment field$/ do
find("a.focus_comment_textarea").click
focus_comment_box
end
Then /^the first comment field should be open/ do
@ -9,3 +9,8 @@ end
Then /^the first comment field should be closed$/ do
find("#main_stream .stream_element .new_comment").should_not be_visible
end
When /^I comment "([^"]*)" on "([^"]*)"$/ do |comment_text, post_text|
comment_on_post(post_text, comment_text)
end

View file

@ -103,7 +103,7 @@ Then /^(?:|I )should not see a "([^\"]*)"(?: within "([^\"]*)")?$/ do |selector,
end
When /^I wait for the ajax to finish$/ do
wait_until(15) { evaluate_script("$.active") == 0 }
wait_for_ajax_to_finish
end
When /^I have turned off jQuery effects$/ do

View file

@ -0,0 +1,18 @@
Then /^I should see the "(.*)" message$/ do |message|
text = case message
when "alice is excited"
@alice ||= Factory(:user, :username => "Alice")
I18n.translate('invitation_codes.excited', :name => @alice.name)
when "welcome to diaspora"
I18n.translate('users.getting_started.well_hello_there')
when 'you are safe for work'
I18n.translate('profiles.edit.you_are_safe_for_work')
when 'you are nsfw'
I18n.translate('profiles.edit.you_are_nsfw')
when 'hello'
"well hello there man"
else
raise "muriel, you don't have that message key, add one here"
end
page.should have_content(text)
end

View file

@ -34,3 +34,16 @@ end
When /^I click on the first block button/ do
find(".block_user").click
end
Then /^I should see "([^"]*)" as the first post in my stream$/ do |text|
first_post_text.should include(text)
end
When /^I post "([^"]*)"$/ do |text|
click_and_post(text)
end
When /^I click the publisher and post "([^"]*)"$/ do |text|
click_and_post(text)
end

View file

@ -0,0 +1,11 @@
Then /^I should see an image in the publisher$/ do
photo_in_publisher.should be_present
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

View file

@ -0,0 +1,72 @@
module PublishingCukeHelpers
def make_post(text)
fill_in 'status_message_fake_text', :with => text
click_button :submit
wait_for_ajax_to_finish
end
def click_and_post(text)
click_publisher
make_post(text)
end
def click_publisher
page.execute_script('
$("#publisher").removeClass("closed");
$("#publisher").find("textarea").focus();
')
end
def first_post_text
find('.stream_element:first .post-content').text()
end
def find_post_by_text(text)
find(".stream_element:contains('#{text}')")
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)
wait_until(wait_time) { evaluate_script("$.active") == 0 }
end
def assert_nsfw(text)
post = find_post_by_text(text)
post.find(".shield").should be_present
end
end
World(PublishingCukeHelpers)

View file

@ -1,6 +1,13 @@
app.models.Stream = Backbone.Collection.extend({
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(){