fix jasmine around contact-list.js
This commit is contained in:
parent
7aa906b463
commit
5e75c6d675
4 changed files with 44 additions and 36 deletions
|
|
@ -8,9 +8,6 @@
|
|||
- content_for :head do
|
||||
= include_javascripts :people
|
||||
= javascript_include_tag 'contact-list'
|
||||
- if @background_query.present?
|
||||
:javascript
|
||||
$(document).ready(function() { List.startSearchDelay('#{@background_query}') } );
|
||||
|
||||
.span-24.last
|
||||
= search_header
|
||||
|
|
@ -22,7 +19,14 @@
|
|||
#people_stream.stream
|
||||
- if @hashes.empty?
|
||||
- if @background_query.present?
|
||||
%p
|
||||
|
||||
/ this is gross, and should be extracted!
|
||||
:javascript
|
||||
$(document).ready( function() {
|
||||
List.startSearchDelay('#{@background_query}')
|
||||
} );
|
||||
|
||||
%p
|
||||
= t('.searching')
|
||||
= image_tag '/images/static-loader.png', :class => 'loader'
|
||||
- else
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ var List = {
|
|||
});
|
||||
});
|
||||
},
|
||||
|
||||
disconnectUser: function(contact_id){
|
||||
$.ajax({
|
||||
url: "/contacts/" + contact_id,
|
||||
|
|
@ -33,44 +34,48 @@ var List = {
|
|||
}
|
||||
});
|
||||
},
|
||||
|
||||
runDelayedSearch: function( searchTerm ) {
|
||||
$.ajax({
|
||||
dataType: 'json',
|
||||
url: '/people/refresh_search',
|
||||
data: { q: searchTerm },
|
||||
success: List.handleSearchRefresh
|
||||
});
|
||||
$.getJSON('/people/refresh_search',
|
||||
{ q: searchTerm },
|
||||
List.handleSearchRefresh
|
||||
);
|
||||
},
|
||||
|
||||
handleSearchRefresh: function( data ) {
|
||||
if ( data.search_count > 0 ) {
|
||||
$("#people_stream.stream").html( data.search_html );
|
||||
} else {
|
||||
$("#people_stream.stream").html( "<p>" + Diaspora.I18n.t("people.not_found") + "</p>" );
|
||||
}
|
||||
var streamEl = $("#people_stream.stream");
|
||||
var string = data.search_html || $("<p>", {
|
||||
text : Diaspora.I18n.t("people.not_found")
|
||||
});
|
||||
|
||||
streamEl.html(string);
|
||||
},
|
||||
startSearchDelay: function ( theSearch ) {
|
||||
|
||||
startSearchDelay: function (theSearch) {
|
||||
setTimeout( "List.runDelayedSearch('" + theSearch + "')", 10000);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$(document).ready(function() {
|
||||
$('.added').live('ajax:loading', function() {
|
||||
$(this).addClass('disabled');
|
||||
$(this).fadeTo(200,0.4);
|
||||
$('.added').bind('ajax:loading', function() {
|
||||
var $this = $(this);
|
||||
|
||||
$this.addClass('disabled');
|
||||
$this.fadeTo(200,0.4);
|
||||
});
|
||||
|
||||
$('.add').live('ajax:loading', function() {
|
||||
$(this).addClass('disabled');
|
||||
$(this).fadeTo(200,0.4);
|
||||
});
|
||||
$('.added').bind('hover',
|
||||
function() {
|
||||
var $this = $(this)
|
||||
$this.addClass("remove");
|
||||
$this.children("img").attr("src","/images/icons/monotone_close_exit_delete.png");
|
||||
},
|
||||
|
||||
$('.added').live('mouseover', function() {
|
||||
$(this).addClass("remove");
|
||||
$(this).children("img").attr("src","/images/icons/monotone_close_exit_delete.png");
|
||||
}).live('mouseout', function() {
|
||||
$(this).removeClass("remove");
|
||||
$(this).children("img").attr("src","/images/icons/monotone_check_yes.png");
|
||||
function() {
|
||||
var $this = $(this)
|
||||
$this.removeClass("remove");
|
||||
$this.children("img").attr("src","/images/icons/monotone_check_yes.png");
|
||||
});
|
||||
|
||||
List.initialize();
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ describe PeopleController do
|
|||
get :index
|
||||
save_fixture(html_for("body"), "empty_people_search")
|
||||
end
|
||||
|
||||
it "generates a jasmine fixture trying an external search", :fixture => true do
|
||||
get :index, :q => "sample@diaspor.us"
|
||||
save_fixture(html_for("body"), "pending_external_people_search")
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
/* Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
* licensed under the Affero General Public License version 3 or later. See
|
||||
* the COPYRIGHT file.
|
||||
*/
|
||||
* licensed under the Affero General Public License version 3 or later. See
|
||||
* the COPYRIGHT file.
|
||||
*/
|
||||
|
||||
describe("List", function() {
|
||||
|
||||
describe("runDelayedSearch", function() {
|
||||
|
||||
it('gets called on initialize', function(){
|
||||
spyOn( List, 'startSearchDelay');
|
||||
spyOn(List, 'startSearchDelay');
|
||||
spec.loadFixture('pending_external_people_search');
|
||||
expect(List.startSearchDelay).toHaveBeenCalled();
|
||||
});
|
||||
|
|
@ -22,7 +20,7 @@ describe("List", function() {
|
|||
|
||||
it('inserts contact html', function(){
|
||||
List.handleSearchRefresh( { count:1, search_html: "<div class='testing_insert_div'>hello</div>" } );
|
||||
expect($(".testing_insert_div").text().toEqual( "hello" ));
|
||||
expect($(".testing_insert_div").text()).toEqual("hello");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue