diff --git a/features/manages_aspects.feature b/features/manages_aspects.feature index af918bf4712cd1d90618498c279452c783c940a6..aaec948271d46bbd47c9a0b780c8faa856de8cca 100644 --- a/features/manages_aspects.feature +++ b/features/manages_aspects.feature @@ -35,3 +35,14 @@ Feature: User manages contacts And I wait for the ajax to finish Then I should have 0 contacts in "Cat People" + Scenario: scrolling through contacts index + Given I am signed in + And I have 60 contacts + And I am on the contacts page + Then I should see 25 contacts + + When I scroll down + Then I should see 50 contacts + + When I scroll down + Then I should see 60 contacts diff --git a/features/step_definitions/custom_web_steps.rb b/features/step_definitions/custom_web_steps.rb index 8233da35e899241cb67eb3329e64cbf7a6e831ef..bf895dff9184945cbe9f5ec0603bce110ba7cc74 100644 --- a/features/step_definitions/custom_web_steps.rb +++ b/features/step_definitions/custom_web_steps.rb @@ -167,6 +167,10 @@ Then /^I should see (\d+) posts$/ do |n_posts| wait_until(10) { all("#main_stream .stream_element").length == n_posts.to_i } end +Then /^I should see (\d+) contacts$/ do |n_posts| + wait_until(10) { all("#people_stream .stream_element").length == n_posts.to_i } +end + And /^I scroll down$/ do evaluate_script("window.scrollBy(0,3000000)") sleep 1 @@ -189,4 +193,4 @@ When /^I resize my window to 800x600$/ do page.execute_script <<-JS window.resizeTo(800,600); JS -end \ No newline at end of file +end diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb index 797ea99e95ef9081e1b2b853d8f0e2a3661d52f1..6666a54a6858dd83e729fcb6bd0749a4f571daa3 100644 --- a/features/step_definitions/user_steps.rb +++ b/features/step_definitions/user_steps.rb @@ -167,3 +167,28 @@ end Then /^my "([^\"]*)" should be "([^\"]*)"$/ do |field, value| @me.reload.send(field).should == value end + +Given /^I have (\d+) contacts$/ do |n| + count = n.to_i - @me.contacts.count + + people = [] + contacts = [] + aspect_memberships = [] + + count.times do + person = Factory.create(:person) + people << person + end + + people.each do |person| + contacts << Contact.new(:person_id => person.id, :user_id => @me.id, :sharing => true, :receiving => true) + end + Contact.import(contacts) + contacts = @me.contacts.limit(n.to_i) + + aspect_id = @me.aspects.first.id + contacts.each do |contact| + aspect_memberships << AspectMembership.new(:contact_id => contact.id, :aspect_id => @me.aspects.first.id) + end + AspectMembership.import(aspect_memberships) +end diff --git a/public/javascripts/widgets/infinite-scroll.js b/public/javascripts/widgets/infinite-scroll.js index 86e0548c7052c3c9713280957f3ba570612c7833..721c54758306fe20fb9f7a6715425e88fa32c120 100644 --- a/public/javascripts/widgets/infinite-scroll.js +++ b/public/javascripts/widgets/infinite-scroll.js @@ -29,21 +29,24 @@ this.reInitialize = function() { self.clear(); - self.initialize(); + self.initialize(); }; this.initialize = function() { if($('#main_stream').length !== 0){ - $('#main_stream').infinitescroll(this.options, function() { - Diaspora.widgets.publish("stream/scrolled"); - }); - } else if($('#people_stream.contacts').length !== 0){ - $("#people_stream.contacts").infinitescroll($.extend(self.options, { - navSelector : ".pagination", - nextSelector : ".next_page", - }), function() { - Diaspora.widgets.publish("stream/scrolled"); - }); + $('#main_stream').infinitescroll(this.options, function() { + Diaspora.widgets.publish("stream/scrolled"); + }); + } else if($('#people_stream').length !== 0){ + $("#people_stream").infinitescroll($.extend(self.options, { + navSelector : ".pagination", + nextSelector : ".next_page", + pathParse : function( pathStr, nextPage){ + return pathStr.replace("page=2", "page=" + nextPage); + } + }), function() { + Diaspora.widgets.publish("stream/scrolled"); + }); } };