diff --git a/features/posts_from_main_page.feature b/features/posts_from_main_page.feature index 9b45e5aaf..45cf2df2f 100644 --- a/features/posts_from_main_page.feature +++ b/features/posts_from_main_page.feature @@ -25,8 +25,8 @@ Feature: posting from the main 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 - Given I have a prexisting post - And I post "hey there" + 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 diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 8bc1cd921..950c6ca9f 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -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 diff --git a/features/step_definitions/factory_steps.rb b/features/step_definitions/factory_steps.rb index 91032b057..15e406e78 100644 --- a/features/step_definitions/factory_steps.rb +++ b/features/step_definitions/factory_steps.rb @@ -32,10 +32,6 @@ end World(FactoryMethods) -Given /I have a prexisting post/ do - Factory(:status_message, :author => @me.person, :public => true) -end - Given %r{^I have a (.+)$} do |model_name| create_from_table(model_name, {}, 'user' => @me) end diff --git a/features/step_definitions/posts_steps.rb b/features/step_definitions/posts_steps.rb index e454eb5e4..c57b7b169 100644 --- a/features/step_definitions/posts_steps.rb +++ b/features/step_definitions/posts_steps.rb @@ -36,13 +36,14 @@ When /^I click on the first block button/ do end - -Then /^"I should see "([^"]*)" as the first post in my stream$/ do |text| +Then /^I should see "([^"]*)" as the first post in my stream$/ do |text| first_post_text.should include(text) end -Given /^"I post "([^"]*)"$/ do |text| - make_post(text) +When /^I post "([^"]*)"$/ do |text| + click_and_post(text) end - +When /^I click the publisher and post "([^"]*)"$/ do |text| + click_and_post(text) +end diff --git a/features/step_definitions/stream_steps.rb b/features/step_definitions/stream_steps.rb new file mode 100644 index 000000000..795557b9a --- /dev/null +++ b/features/step_definitions/stream_steps.rb @@ -0,0 +1,3 @@ +Then /^I should see an image in the publisher$/ do + photo_in_publisher.should be_present +end \ No newline at end of file diff --git a/features/support/publishing_cuke_helpers.rb b/features/support/publishing_cuke_helpers.rb index 4bcb3b61e..d4cb597ef 100644 --- a/features/support/publishing_cuke_helpers.rb +++ b/features/support/publishing_cuke_helpers.rb @@ -1,14 +1,19 @@ module PublishingCukeHelpers def make_post(text) - click_publisher 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(); + $("#publisher").removeClass("closed"); + $("#publisher").find("textarea").focus(); ') end @@ -20,6 +25,10 @@ module PublishingCukeHelpers find(".stream_element:contains('#{text}')") 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 diff --git a/public/javascripts/app/collections/posts.js b/public/javascripts/app/collections/posts.js index 37fb1a206..f5899248c 100644 --- a/public/javascripts/app/collections/posts.js +++ b/public/javascripts/app/collections/posts.js @@ -9,4 +9,9 @@ app.collections.Posts = Backbone.Collection.extend({ parse: function(resp){ return resp.posts; } +// +// +// comparator : function(post) { +// return -post.createdAt(); +// } });