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
|
||||
|
||||
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.save!
|
||||
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", "helper_methods")
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "spec", "support","user_methods")
|
||||
include HelperMethods
|
||||
|
||||
Before do
|
||||
|
|
@ -52,6 +53,8 @@ end
|
|||
silence_warnings do
|
||||
SERVICES['facebook'] = {'app_id' => :fake}
|
||||
end
|
||||
|
||||
require File.join(File.dirname(__FILE__), "..", "..", "spec", "support", "fake_resque")
|
||||
module Resque
|
||||
def enqueue(klass, *args)
|
||||
klass.send(:perform, *args)
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@
|
|||
*/
|
||||
|
||||
(function() {
|
||||
var InfiniteScroll = function() {
|
||||
this.options = {
|
||||
var InfiniteScroll = function() { };
|
||||
InfiniteScroll.prototype.options = {
|
||||
navSelector : "#pagination",
|
||||
nextSelector : ".paginate",
|
||||
itemSelector : ".stream_element",
|
||||
|
|
@ -21,15 +21,17 @@
|
|||
loadingImg: '/images/ajax-loader.gif'
|
||||
};
|
||||
|
||||
this.start = function() {
|
||||
Diaspora.widgets.subscribe("stream/reloaded", InfiniteScroll.initialize);
|
||||
|
||||
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)
|
||||
Diaspora.widgets.add("infinitescroll", InfiniteScroll);
|
||||
})();
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ Diaspora.widgets.add("timeago", function() {
|
|||
this.selector = "abbr.timeago";
|
||||
this.start = function() {
|
||||
Diaspora.widgets.subscribe("stream/scrolled", this.updateTimeAgo);
|
||||
Diaspora.widgets.subscribe("stream/reloaded", this.updateTimeAgo);
|
||||
|
||||
if(Diaspora.widgets.i18n.language !== "en") {
|
||||
$.each($.timeago.settings.strings, function(index, element) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue