Skip to content
Extraits de code Groupes Projets
Valider 50e67524 rédigé par Dan Hansen's avatar Dan Hansen
Parcourir les fichiers

content update wip

parent fc25c9be
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
/* Copyright (c) 2010, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
var ContentUpdates = {
addPostToStream: function(postId, html) {
if( $(".stream_element[data-guid='" + postId + "']").length === 0 ) {
var streamElement = $(html);
if($("#no_posts").length) {
$("#no_posts").detach();
}
streamElement.prependTo("#main_stream:not('.show')").fadeIn("fast", function() {
streamElement.find("label").inFieldLabels();
});
Diaspora.widgets.publish("stream/postAdded", [postId]);
Diaspora.widgets.timeago.updateTimeAgo();
Diaspora.widgets.directionDetector.updateBinds();
}
}
};
\ No newline at end of file
......@@ -133,25 +133,7 @@ var WebSocketReceiver = {
},
addPostToStream: function(postId, html) {
if( $(".stream_element[data-guid='" + postId + "']").length === 0 ) {
var streamElement = $(html);
var showMessage = function() {
$("#main_stream:not('.show')").prepend(
streamElement.fadeIn("fast", function() {
streamElement.find("label").inFieldLabels();
})
);
};
if( $("#no_posts").is(":visible") ) {
$("#no_posts").fadeOut(400, showMessage()).hide();
} else {
showMessage();
}
Diaspora.widgets.timeago.updateTimeAgo();
Diaspora.widgets.directionDetector.updateBinds();
}
},
onPageForClass: function(className) {
......
......@@ -68,6 +68,8 @@ describe AspectsController do
bob.comment("what", :on => message)
get :index
save_fixture(html_for("body"), "aspects_index_with_posts")
save_fixture(html_for(".stream_element:first"), "status_message_in_stream")
end
context 'with getting_started = true' do
......
/* Copyright (c) 2010, Diaspora Inc. This file is
* licensed under the Affero General Public License version 3 or later. See
* the COPYRIGHT file.
*/
describe("ContentUpdates", function() {
describe("addPostToStream", function() {
beforeEach(function() {
$("#jasmine_content").empty();
spec.loadFixture("aspects_index_with_posts");
});
it("adds a post to the stream", function() {
var originalPostCount = $(".stream_element").length;
ContentUpdates.addPostToStream("guid", spec.fixtureHtml("status_message_in_stream"));
expect($(".stream_element").length).toBeGreaterThan(originalPostCount);
});
it("does not add duplicate posts", function() {
ContentUpdates.addPostToStream("guid", spec.fixtureHtml("status_message_in_stream"));
var originalPostCount = $(".stream_element").length;
ContentUpdates.addPostToStream("guid", spec.fixtureHtml("status_message_in_stream"));
expect($(".stream_element").length).toEqual(originalPostCount);
});
it("removes the div that says you have no posts if it exists", function() {
spec.loadFixture("aspects_index");
expect($("#no_posts").length).toEqual(1);
ContentUpdates.addPostToStream("guid", spec.fixtureHtml("status_message_in_stream"));
expect($("#no_posts").length).toEqual(0);
});
});
});
......@@ -40,6 +40,7 @@ src_files:
- public/javascripts/validation.js
- public/javascripts/rails.js
- public/javascripts/aspect-filters.js
- public/javascripts/content-updates.js
# stylesheets
#
# Return an array of stylesheet filepaths relative to src_dir to include before jasmine specs.
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter