diff --git a/spec/controllers/aspects_controller_spec.rb b/spec/controllers/aspects_controller_spec.rb index 4d12999ca..c82e8f58f 100644 --- a/spec/controllers/aspects_controller_spec.rb +++ b/spec/controllers/aspects_controller_spec.rb @@ -10,7 +10,7 @@ describe AspectsController do alice.getting_started = false alice.save sign_in :user, alice - @alices_aspect_1 = alice.aspects.first + @alices_aspect_1 = alice.aspects.where(:name => "generic").first @alices_aspect_2 = alice.aspects.create(:name => "another aspect") @controller.stub(:current_user).and_return(alice) @@ -84,7 +84,7 @@ describe AspectsController do end it 'generates a jasmine fixture with posts', :fixture => true do - bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.first.id) + bob.post(:status_message, :text => "Is anyone out there?", :to => @bob.aspects.where(:name => "generic").first.id) message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id) 5.times { bob.comment("what", :post => message) } get :index diff --git a/spec/javascripts/widgets/comment-stream-spec.js b/spec/javascripts/widgets/comment-stream-spec.js index 9f3fb2fa8..93da7acf5 100644 --- a/spec/javascripts/widgets/comment-stream-spec.js +++ b/spec/javascripts/widgets/comment-stream-spec.js @@ -1,24 +1,21 @@ describe("Diaspora.Widgets.CommentStream", function() { var commentStream; + var ajaxCommentResponse; + beforeEach(function() { - spec.readFixture("ajax_comments_on_post"); + ajaxCommentResponse = spec.readFixture("ajax_comments_on_post"); + spec.loadFixture("aspects_index_with_posts"); jasmine.Clock.useMock(); jasmine.Ajax.useMock(); - spec.loadFixture("aspects_index_with_posts"); Diaspora.I18n.locale = { }; - var post = $(".stream_element:first"), - postGUID = post.attr("id"); - commentStream = Diaspora.BaseWidget.instantiate("CommentStream", $(".stream_element:first .comment_stream")); }); describe("toggling comments", function() { it("toggles class hidden on the comments ul", function () { - spyOn($, "ajax").andCallThrough(); - expect($("ul.comments:first")).not.toHaveClass("hidden"); commentStream.showComments($.Event()); @@ -27,7 +24,7 @@ describe("Diaspora.Widgets.CommentStream", function() { responseHeaders: { "Content-type": "text/html" }, - responseText: spec.readFixture("ajax_comments_on_post"), + responseText: ajaxCommentResponse, status: 200 }); @@ -43,7 +40,6 @@ describe("Diaspora.Widgets.CommentStream", function() { }); it("changes the text on the show comments link", function() { - spyOn($, "ajax").andCallThrough(); Diaspora.I18n.loadLocale({'comments' : { 'show': 'show comments translation', 'hide': 'hide comments translation' @@ -53,11 +49,11 @@ describe("Diaspora.Widgets.CommentStream", function() { commentStream.showComments($.Event()); - mostRecentAjaxRequest().response({ + mostRecentAjaxRequest().response({ responseHeaders: { "Content-type": "text/html" }, - responseText: spec.readFixture("ajax_comments_on_post"), + responseText: ajaxCommentResponse, status: 200 }); @@ -74,7 +70,7 @@ describe("Diaspora.Widgets.CommentStream", function() { it("only requests the comments when the loaded class is not present", function() { spyOn($, "ajax").andCallThrough(); - + expect(commentStream.commentsList).not.toHaveClass("loaded"); commentStream.showComments($.Event()); @@ -83,11 +79,10 @@ describe("Diaspora.Widgets.CommentStream", function() { responseHeaders: { "Content-type": "text/html" }, - responseText: spec.readFixture("ajax_comments_on_post"), + responseText: ajaxCommentResponse, status: 200 }); - expect($.ajax.callCount).toEqual(1); expect(commentStream.commentsList).toHaveClass("loaded");