Fix comment jasmine fixture generation to be more consistent (i.e. take out more aspects.first stuff). Fix comment jasmine spec to be more consistent - remove unneeded spies, etc.

This commit is contained in:
Sarah Mei 2011-09-03 12:02:51 -07:00
parent 9960b5b189
commit 1a823d647e
2 changed files with 11 additions and 16 deletions

View file

@ -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

View file

@ -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'
@ -57,7 +53,7 @@ describe("Diaspora.Widgets.CommentStream", function() {
responseHeaders: {
"Content-type": "text/html"
},
responseText: spec.readFixture("ajax_comments_on_post"),
responseText: ajaxCommentResponse,
status: 200
});
@ -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");