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:
parent
9960b5b189
commit
1a823d647e
2 changed files with 11 additions and 16 deletions
|
|
@ -10,7 +10,7 @@ describe AspectsController do
|
||||||
alice.getting_started = false
|
alice.getting_started = false
|
||||||
alice.save
|
alice.save
|
||||||
sign_in :user, alice
|
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")
|
@alices_aspect_2 = alice.aspects.create(:name => "another aspect")
|
||||||
|
|
||||||
@controller.stub(:current_user).and_return(alice)
|
@controller.stub(:current_user).and_return(alice)
|
||||||
|
|
@ -84,7 +84,7 @@ describe AspectsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'generates a jasmine fixture with posts', :fixture => true 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)
|
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)
|
message = alice.post(:status_message, :text => "hello "*800, :to => @alices_aspect_2.id)
|
||||||
5.times { bob.comment("what", :post => message) }
|
5.times { bob.comment("what", :post => message) }
|
||||||
get :index
|
get :index
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,21 @@
|
||||||
describe("Diaspora.Widgets.CommentStream", function() {
|
describe("Diaspora.Widgets.CommentStream", function() {
|
||||||
var commentStream;
|
var commentStream;
|
||||||
|
var ajaxCommentResponse;
|
||||||
|
|
||||||
beforeEach(function() {
|
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.Clock.useMock();
|
||||||
jasmine.Ajax.useMock();
|
jasmine.Ajax.useMock();
|
||||||
|
|
||||||
spec.loadFixture("aspects_index_with_posts");
|
|
||||||
Diaspora.I18n.locale = { };
|
Diaspora.I18n.locale = { };
|
||||||
|
|
||||||
var post = $(".stream_element:first"),
|
|
||||||
postGUID = post.attr("id");
|
|
||||||
|
|
||||||
commentStream = Diaspora.BaseWidget.instantiate("CommentStream", $(".stream_element:first .comment_stream"));
|
commentStream = Diaspora.BaseWidget.instantiate("CommentStream", $(".stream_element:first .comment_stream"));
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("toggling comments", function() {
|
describe("toggling comments", function() {
|
||||||
it("toggles class hidden on the comments ul", function () {
|
it("toggles class hidden on the comments ul", function () {
|
||||||
spyOn($, "ajax").andCallThrough();
|
|
||||||
|
|
||||||
expect($("ul.comments:first")).not.toHaveClass("hidden");
|
expect($("ul.comments:first")).not.toHaveClass("hidden");
|
||||||
|
|
||||||
commentStream.showComments($.Event());
|
commentStream.showComments($.Event());
|
||||||
|
|
@ -27,7 +24,7 @@ describe("Diaspora.Widgets.CommentStream", function() {
|
||||||
responseHeaders: {
|
responseHeaders: {
|
||||||
"Content-type": "text/html"
|
"Content-type": "text/html"
|
||||||
},
|
},
|
||||||
responseText: spec.readFixture("ajax_comments_on_post"),
|
responseText: ajaxCommentResponse,
|
||||||
status: 200
|
status: 200
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -43,7 +40,6 @@ describe("Diaspora.Widgets.CommentStream", function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("changes the text on the show comments link", function() {
|
it("changes the text on the show comments link", function() {
|
||||||
spyOn($, "ajax").andCallThrough();
|
|
||||||
Diaspora.I18n.loadLocale({'comments' : {
|
Diaspora.I18n.loadLocale({'comments' : {
|
||||||
'show': 'show comments translation',
|
'show': 'show comments translation',
|
||||||
'hide': 'hide comments translation'
|
'hide': 'hide comments translation'
|
||||||
|
|
@ -57,7 +53,7 @@ describe("Diaspora.Widgets.CommentStream", function() {
|
||||||
responseHeaders: {
|
responseHeaders: {
|
||||||
"Content-type": "text/html"
|
"Content-type": "text/html"
|
||||||
},
|
},
|
||||||
responseText: spec.readFixture("ajax_comments_on_post"),
|
responseText: ajaxCommentResponse,
|
||||||
status: 200
|
status: 200
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -83,11 +79,10 @@ describe("Diaspora.Widgets.CommentStream", function() {
|
||||||
responseHeaders: {
|
responseHeaders: {
|
||||||
"Content-type": "text/html"
|
"Content-type": "text/html"
|
||||||
},
|
},
|
||||||
responseText: spec.readFixture("ajax_comments_on_post"),
|
responseText: ajaxCommentResponse,
|
||||||
status: 200
|
status: 200
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
expect($.ajax.callCount).toEqual(1);
|
expect($.ajax.callCount).toEqual(1);
|
||||||
expect(commentStream.commentsList).toHaveClass("loaded");
|
expect(commentStream.commentsList).toHaveClass("loaded");
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue