Fix weird error in jasmine suite

This commit is contained in:
Raphael Sofaer 2011-08-05 14:45:40 -07:00
parent 5cea922cb8
commit f0f388d9e1
3 changed files with 12 additions and 7 deletions

View file

@ -68,8 +68,6 @@ describe AspectsController do
3.times { bob.comment("what", :post => 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
@ -77,7 +75,7 @@ describe AspectsController do
alice.getting_started = true
alice.save
end
it 'does not redirect mobile users to getting_started' do
get :index, :format => :mobile
response.should_not be_redirect

View file

@ -61,6 +61,13 @@ describe StatusMessagesController do
json['html'].should_not be_nil
end
it 'saves the html as a fixture', :fixture => true do
post :create, status_message_hash.merge(:format => 'js')
json = JSON.parse(response.body)
save_fixture(json['html'], "created_status_message")
end
it 'escapes XSS' do
xss = "<script> alert('hi browser') </script>"
post :create, status_message_hash.merge(:format => 'js', :text => xss)

View file

@ -13,21 +13,21 @@ describe("ContentUpdater", function() {
it("adds a post to the stream", function() {
var originalPostCount = $(".stream_element").length;
ContentUpdater.addPostToStream(spec.fixtureHtml("status_message_in_stream"));
ContentUpdater.addPostToStream(spec.fixtureHtml("created_status_message"));
expect($(".stream_element").length).toEqual(originalPostCount + 1);
});
it("does not add duplicate posts", function() {
var originalPostCount = $(".stream_element").length;
ContentUpdater.addPostToStream(spec.fixtureHtml("status_message_in_stream"));
ContentUpdater.addPostToStream(spec.fixtureHtml("created_status_message"));
expect($(".stream_element").length).toEqual(originalPostCount + 1);
ContentUpdater.addPostToStream(spec.fixtureHtml("status_message_in_stream"));
ContentUpdater.addPostToStream(spec.fixtureHtml("created_status_message"));
expect($(".stream_element").length).toEqual(originalPostCount + 1);
});
it("removes the div that says you have no posts if it exists", function() {
expect($("#no_posts").length).toEqual(1);
ContentUpdater.addPostToStream(spec.fixtureHtml("status_message_in_stream"));
ContentUpdater.addPostToStream(spec.fixtureHtml("created_status_message"));
expect($("#no_posts").length).toEqual(0);
});
});