only request comments once
This commit is contained in:
parent
31239df8b9
commit
cbc168fc27
3 changed files with 25 additions and 6 deletions
|
|
@ -39,7 +39,10 @@
|
|||
$.get(self.commentToggler.attr("href"), function(data) {
|
||||
self.commentToggler.html(Diaspora.I18n.t("comments.hide"));
|
||||
|
||||
self.commentsList.html(data);
|
||||
self.commentsList
|
||||
.html(data)
|
||||
.addClass("loaded")
|
||||
.removeClass("hidden");
|
||||
|
||||
self.instantiateCommentWidgets();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ describe AspectsController do
|
|||
it 'generates a jasmine fixture with posts', :fixture => true do
|
||||
bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.first.id)
|
||||
message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id)
|
||||
3.times { bob.comment("what", :post => message) }
|
||||
5.times { bob.comment("what", :post => message) }
|
||||
get :index
|
||||
save_fixture(html_for("body"), "aspects_index_with_posts")
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,12 +11,9 @@ describe("Diaspora.Widgets.CommentStream", function() {
|
|||
commentStream = Diaspora.BaseWidget.instantiate("CommentStream", $(".stream_element:first .comment_stream"));
|
||||
});
|
||||
|
||||
describe("hideComments", function() {
|
||||
|
||||
});
|
||||
|
||||
describe("toggling comments", function() {
|
||||
it("toggles class hidden on the comments ul", function () {
|
||||
spyOn($, "ajax");
|
||||
|
||||
expect($("ul.comments:first")).not.toHaveClass("hidden");
|
||||
|
||||
|
|
@ -28,6 +25,7 @@ describe("Diaspora.Widgets.CommentStream", function() {
|
|||
|
||||
commentStream.showComments($.Event());
|
||||
|
||||
$.ajax.mostRecentCall.args[0].success("comment response");
|
||||
jasmine.Clock.tick(200);
|
||||
|
||||
expect($("ul.comments:first")).not.toHaveClass("hidden");
|
||||
|
|
@ -53,5 +51,23 @@ describe("Diaspora.Widgets.CommentStream", function() {
|
|||
|
||||
expect(link.text()).toEqual("show comments translation");
|
||||
});
|
||||
|
||||
it("only requests the comments when the loaded class is not present", function() {
|
||||
spyOn($, "ajax");
|
||||
|
||||
expect(commentStream.commentsList).not.toHaveClass("loaded");
|
||||
|
||||
commentStream.showComments($.Event());
|
||||
|
||||
$.ajax.mostRecentCall.args[0].success("comment response");
|
||||
|
||||
expect($.ajax.callCount).toEqual(1);
|
||||
expect(commentStream.commentsList).toHaveClass("loaded");
|
||||
|
||||
commentStream.showComments($.Event());
|
||||
|
||||
expect($.ajax.callCount).toEqual(1);
|
||||
expect(commentStream.commentsList).toHaveClass("loaded");
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue