Red feature for infinite scroll after changing aspects
This commit is contained in:
parent
24ea518b6f
commit
2517653d34
6 changed files with 79 additions and 25 deletions
24
features/infinite_scroll.feature
Normal file
24
features/infinite_scroll.feature
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
@javascript
|
||||||
|
Feature: infinite scroll
|
||||||
|
In order to browse without disruption
|
||||||
|
As medium-sized internet grazing animal
|
||||||
|
I want the stream to infinite scroll
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given many posts from bob and alice
|
||||||
|
|
||||||
|
Scenario: on the main stream
|
||||||
|
When I sign in as "bob@bob.bob"
|
||||||
|
Then I should see 15 posts
|
||||||
|
|
||||||
|
When I scroll down
|
||||||
|
And I wait for the ajax to finish
|
||||||
|
Then I should see 30 posts
|
||||||
|
|
||||||
|
When I follow "generic"
|
||||||
|
And I wait for the ajax to finish
|
||||||
|
Then I should see 15 posts
|
||||||
|
|
||||||
|
When I scroll down
|
||||||
|
And I wait for the ajax to finish
|
||||||
|
Then I should see 30 posts
|
||||||
|
|
@ -188,3 +188,11 @@ Then /^the "([^"]*)" field(?: within "([^"]*)")? should be filled with "([^"]*)"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^I should see (\d+) posts$/ do |n_posts|
|
||||||
|
evaluate_script("$('#main_stream .stream_element').length").should == n_posts.to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
And /^I scroll down$/ do
|
||||||
|
visit('#footer_nav')
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -139,3 +139,19 @@ Given /^there is a user "([^\"]*)" who's tagged "([^\"]*)"$/ do |full_name, tag|
|
||||||
user.profile.build_tags
|
user.profile.build_tags
|
||||||
user.profile.save!
|
user.profile.save!
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Given /^many posts from bob and alice$/ 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_interval = 1000
|
||||||
|
(1..20).each do |n|
|
||||||
|
[alice, bob].each do |u|
|
||||||
|
post = u.post :status_message, :text => "#{u.username} - #{n} - #seeded", :to => u.aspects.first.id
|
||||||
|
post.created_at = post.created_at - time_interval
|
||||||
|
post.updated_at = post.updated_at - time_interval
|
||||||
|
post.save
|
||||||
|
time_interval += 1000
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ require File.join(File.dirname(__FILE__), "database_cleaner_patches")
|
||||||
|
|
||||||
require File.join(File.dirname(__FILE__), "..", "..", "spec", "support", "fake_redis")
|
require File.join(File.dirname(__FILE__), "..", "..", "spec", "support", "fake_redis")
|
||||||
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
|
require File.join(File.dirname(__FILE__), "..", "..", "spec", "helper_methods")
|
||||||
|
require File.join(File.dirname(__FILE__), "..", "..", "spec", "support","user_methods")
|
||||||
include HelperMethods
|
include HelperMethods
|
||||||
|
|
||||||
Before do
|
Before do
|
||||||
|
|
@ -52,6 +53,8 @@ end
|
||||||
silence_warnings do
|
silence_warnings do
|
||||||
SERVICES['facebook'] = {'app_id' => :fake}
|
SERVICES['facebook'] = {'app_id' => :fake}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
require File.join(File.dirname(__FILE__), "..", "..", "spec", "support", "fake_resque")
|
||||||
module Resque
|
module Resque
|
||||||
def enqueue(klass, *args)
|
def enqueue(klass, *args)
|
||||||
klass.send(:perform, *args)
|
klass.send(:perform, *args)
|
||||||
|
|
|
||||||
|
|
@ -4,32 +4,34 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var InfiniteScroll = function() {
|
var InfiniteScroll = function() { };
|
||||||
this.options = {
|
InfiniteScroll.prototype.options = {
|
||||||
navSelector : "#pagination",
|
navSelector : "#pagination",
|
||||||
nextSelector : ".paginate",
|
nextSelector : ".paginate",
|
||||||
itemSelector : ".stream_element",
|
itemSelector : ".stream_element",
|
||||||
pathParse : function( pathStr, nextPage ){
|
pathParse : function( pathStr, nextPage ){
|
||||||
var newPath = pathStr.replace("?", "?only_posts=true&");
|
var newPath = pathStr.replace("?", "?only_posts=true&");
|
||||||
var last_time = $('#main_stream .stream_element').last().find('.time').attr('integer');
|
var last_time = $('#main_stream .stream_element').last().find('.time').attr('integer');
|
||||||
return newPath.replace( /max_time=\d+/, 'max_time=' + last_time);
|
return newPath.replace( /max_time=\d+/, 'max_time=' + last_time);
|
||||||
},
|
},
|
||||||
bufferPx: 500,
|
bufferPx: 500,
|
||||||
debug: false,
|
debug: false,
|
||||||
donetext: Diaspora.widgets.i18n.t("infinite_scroll.no_more"),
|
donetext: Diaspora.widgets.i18n.t("infinite_scroll.no_more"),
|
||||||
loadingText: "",
|
loadingText: "",
|
||||||
loadingImg: '/images/ajax-loader.gif'
|
loadingImg: '/images/ajax-loader.gif'
|
||||||
};
|
|
||||||
|
|
||||||
this.start = function() {
|
|
||||||
Diaspora.widgets.subscribe("stream/reloaded", InfiniteScroll.initialize);
|
|
||||||
|
|
||||||
$('#main_stream').infinitescroll(this.options, function() {
|
|
||||||
Diaspora.widgets.publish("stream/scrolled");
|
|
||||||
});
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Diaspora.widgets.add("infinitescroll", InfiniteScroll)
|
InfiniteScroll.prototype.initialize = function(){
|
||||||
|
$('#main_stream').infinitescroll(this.options, function() {
|
||||||
|
Diaspora.widgets.publish("stream/scrolled");
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
InfiniteScroll.prototype.start = function() {
|
||||||
|
Diaspora.widgets.subscribe("stream/reloaded", this.initialize);
|
||||||
|
this.initialize();
|
||||||
|
};
|
||||||
|
|
||||||
|
Diaspora.widgets.add("infinitescroll", InfiniteScroll);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ Diaspora.widgets.add("timeago", function() {
|
||||||
this.selector = "abbr.timeago";
|
this.selector = "abbr.timeago";
|
||||||
this.start = function() {
|
this.start = function() {
|
||||||
Diaspora.widgets.subscribe("stream/scrolled", this.updateTimeAgo);
|
Diaspora.widgets.subscribe("stream/scrolled", this.updateTimeAgo);
|
||||||
|
Diaspora.widgets.subscribe("stream/reloaded", this.updateTimeAgo);
|
||||||
|
|
||||||
if(Diaspora.widgets.i18n.language !== "en") {
|
if(Diaspora.widgets.i18n.language !== "en") {
|
||||||
$.each($.timeago.settings.strings, function(index, element) {
|
$.each($.timeago.settings.strings, function(index, element) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue