diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 221c3da15..f0aabb68a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,6 +4,9 @@ module ApplicationHelper @@youtube_title_cache = Hash.new("no-title") + def time_for_sort post + post.created_at + end def timeago(time, options={}) options[:class] ||= "timeago" @@ -285,7 +288,7 @@ module ApplicationHelper "(r)" => "®", "(c)" => "©" } - + map.each do |search, replace| message.gsub!(search, replace) end diff --git a/app/helpers/aspects_helper.rb b/app/helpers/aspects_helper.rb index 7d9519287..8cc08efe1 100644 --- a/app/helpers/aspects_helper.rb +++ b/app/helpers/aspects_helper.rb @@ -7,6 +7,10 @@ module AspectsHelper aspects_path(:max_time => @posts.last.send(session[:sort_order].to_sym).to_i, :a_ids => params[:a_ids]) end + def time_for_sort post + post.send(session[:sort_order].to_sym) + end + def remove_link(aspect) if aspect.contacts.size == 0 link_to I18n.t('aspects.helper.remove'), aspect, :method => :delete, :confirm => I18n.t('aspects.helper.are_you_sure') diff --git a/app/views/shared/_stream_element.html.haml b/app/views/shared/_stream_element.html.haml index 44ce12d3a..2b13768c5 100644 --- a/app/views/shared/_stream_element.html.haml +++ b/app/views/shared/_stream_element.html.haml @@ -21,7 +21,7 @@ .content .from = person_link(post.author, :class => 'author') - %time.time.timeago{:datetime => post.created_at, :integer => post.created_at.to_i} + %time.time.timeago{:datetime => post.created_at, :integer => time_for_sort(post).to_i} = render 'status_messages/status_message', :post => post, :photos => post.photos .info diff --git a/features/infinite_scroll.feature b/features/infinite_scroll.feature index 98181bff1..c0afdd52a 100644 --- a/features/infinite_scroll.feature +++ b/features/infinite_scroll.feature @@ -8,7 +8,39 @@ Feature: infinite scroll Given many posts from alice for bob When I sign in as "bob@bob.bob" - Scenario: on the main stream + Scenario: on the main stream by activity + Then I should see 15 posts + And I should see "alice - 26 - #seeded" + + When I scroll down + Then I should see 30 posts + And I should see "alice - 11 - #seeded" + + When I scroll down + Then I should see 40 posts + And I should see "alice - 1 - #seeded" + + When I scroll down + Then I should see "No more" + + When I follow "generic" + And I wait for the ajax to finish + Then I should see 15 posts + And I should see "alice - 26 - #seeded" + + When I scroll down + Then I should see 30 posts + And I should see "alice - 11 - #seeded" + + When I scroll down + Then I should see 40 posts + And I should see "alice - 1 - #seeded" + + When I scroll down + Then I should see "No more" + + Scenario: on the main stream post created time + When I follow "post time" Then I should see 15 posts And I should see "alice - 15 - #seeded" diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 624682688..2a8e4ac2f 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -144,11 +144,12 @@ Given /^many posts from alice for bob$/ do alice = Factory(:user_with_aspect, :username => 'alice', :email => 'alice@alice.alice', :password => 'password', :getting_started => false) bob = Factory(:user_with_aspect, :username => 'bob', :email => 'bob@bob.bob', :password => 'password', :getting_started => false) connect_users_with_aspects(alice, bob) + time_fulcrum = Time.now - 40000 time_interval = 1000 (1..40).each do |n| post = alice.post :status_message, :text => "#{alice.username} - #{n} - #seeded", :to => alice.aspects.first.id - post.created_at = post.created_at - time_interval - post.updated_at = post.updated_at - time_interval + post.created_at = time_fulcrum - time_interval + post.updated_at = time_fulcrum + time_interval post.save time_interval += 1000 end