Test and fix contacts index page
This commit is contained in:
parent
f9bf34a73e
commit
0873ad5828
4 changed files with 55 additions and 12 deletions
|
|
@ -35,3 +35,14 @@ Feature: User manages contacts
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
Then I should have 0 contacts in "Cat People"
|
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
|
||||||
|
|
|
||||||
|
|
@ -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 }
|
wait_until(10) { all("#main_stream .stream_element").length == n_posts.to_i }
|
||||||
end
|
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
|
And /^I scroll down$/ do
|
||||||
evaluate_script("window.scrollBy(0,3000000)")
|
evaluate_script("window.scrollBy(0,3000000)")
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
@ -189,4 +193,4 @@ When /^I resize my window to 800x600$/ do
|
||||||
page.execute_script <<-JS
|
page.execute_script <<-JS
|
||||||
window.resizeTo(800,600);
|
window.resizeTo(800,600);
|
||||||
JS
|
JS
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -167,3 +167,28 @@ end
|
||||||
Then /^my "([^\"]*)" should be "([^\"]*)"$/ do |field, value|
|
Then /^my "([^\"]*)" should be "([^\"]*)"$/ do |field, value|
|
||||||
@me.reload.send(field).should == value
|
@me.reload.send(field).should == value
|
||||||
end
|
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
|
||||||
|
|
|
||||||
|
|
@ -29,21 +29,24 @@
|
||||||
|
|
||||||
this.reInitialize = function() {
|
this.reInitialize = function() {
|
||||||
self.clear();
|
self.clear();
|
||||||
self.initialize();
|
self.initialize();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.initialize = function() {
|
this.initialize = function() {
|
||||||
if($('#main_stream').length !== 0){
|
if($('#main_stream').length !== 0){
|
||||||
$('#main_stream').infinitescroll(this.options, function() {
|
$('#main_stream').infinitescroll(this.options, function() {
|
||||||
Diaspora.widgets.publish("stream/scrolled");
|
Diaspora.widgets.publish("stream/scrolled");
|
||||||
});
|
});
|
||||||
} else if($('#people_stream.contacts').length !== 0){
|
} else if($('#people_stream').length !== 0){
|
||||||
$("#people_stream.contacts").infinitescroll($.extend(self.options, {
|
$("#people_stream").infinitescroll($.extend(self.options, {
|
||||||
navSelector : ".pagination",
|
navSelector : ".pagination",
|
||||||
nextSelector : ".next_page",
|
nextSelector : ".next_page",
|
||||||
}), function() {
|
pathParse : function( pathStr, nextPage){
|
||||||
Diaspora.widgets.publish("stream/scrolled");
|
return pathStr.replace("page=2", "page=" + nextPage);
|
||||||
});
|
}
|
||||||
|
}), function() {
|
||||||
|
Diaspora.widgets.publish("stream/scrolled");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue