Merge pull request #2841 from Raven24/bookmarklet-specs
intentionally failing specs - dirty input breaks bookmarklet (+fix)
This commit is contained in:
commit
1638f32042
3 changed files with 68 additions and 2 deletions
|
|
@ -21,8 +21,9 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
var contents = "#{params[:title]} - #{params[:url]}";
|
var contents = "#{params[:title]} - #{params[:url]}";
|
||||||
if ("#{params[:notes]}".length > 0){
|
var notes = "#{escape_javascript params[:notes]}";
|
||||||
contents = contents + " - #{params[:notes]}";
|
if (notes.length > 0){
|
||||||
|
contents = contents + " - " + notes;
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#publisher #status_message_fake_text").val(contents);
|
$("#publisher #status_message_fake_text").val(contents);
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,35 @@ describe StatusMessagesController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#bookmarklet' do
|
describe '#bookmarklet' do
|
||||||
|
def pass_test_args(text='cute kitty')
|
||||||
|
get :bookmarklet, {:url => 'https://www.youtube.com/watch?v=0Bmhjf0rKe8',
|
||||||
|
:title => 'Surprised Kitty',
|
||||||
|
:notes => text}
|
||||||
|
end
|
||||||
|
|
||||||
it 'succeeds' do
|
it 'succeeds' do
|
||||||
get :bookmarklet
|
get :bookmarklet
|
||||||
response.should be_success
|
response.should be_success
|
||||||
|
|
||||||
|
#TODO replace response.body with html_for('body') as soon as there is a <body>
|
||||||
|
save_fixture(response.body, 'empty_bookmarklet')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'accepts get params' do
|
||||||
|
pass_test_args
|
||||||
|
response.should be_success
|
||||||
|
|
||||||
|
#TODO replace response.body with html_for('body') as soon as there is a <body>
|
||||||
|
save_fixture(response.body, 'prefilled_bookmarklet')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'correctly deals with dirty input' do
|
||||||
|
test_text = "**love** This is such a\n\n great \"cute kitty\" '''blabla'''"
|
||||||
|
pass_test_args(test_text)
|
||||||
|
response.should be_success
|
||||||
|
|
||||||
|
#TODO replace response.body with html_for('body') as soon as there is a <body>
|
||||||
|
save_fixture(response.body, 'prefilled_bookmarklet_dirty')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
39
spec/javascripts/bookmarklet-spec.js
Normal file
39
spec/javascripts/bookmarklet-spec.js
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/* Copyright (c) 2010-2012, Diaspora Inc. This file is
|
||||||
|
* licensed under the Affero General Public License version 3 or later. See
|
||||||
|
* the COPYRIGHT file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
describe("bookmarklet", function() {
|
||||||
|
|
||||||
|
describe("base functionality", function(){
|
||||||
|
beforeEach( function(){
|
||||||
|
spec.loadFixture('empty_bookmarklet');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('verifies the publisher is loaded', function(){
|
||||||
|
expect(typeof Publisher === "object").toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('verifies we are using the bookmarklet', function(){
|
||||||
|
expect(Publisher.bookmarklet).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("prefilled bookmarklet", function(){
|
||||||
|
it('fills in some text into the publisher', function(){
|
||||||
|
spec.loadFixture('prefilled_bookmarklet');
|
||||||
|
expect($("#publisher #status_message_fake_text").val() == "").toBeFalsy();
|
||||||
|
expect($("#publisher #status_message_text").val() == "").toBeFalsy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles dirty input well', function(){
|
||||||
|
spec.loadFixture('prefilled_bookmarklet_dirty');
|
||||||
|
expect($("#publisher #status_message_fake_text").val() == "").toBeFalsy();
|
||||||
|
expect($("#publisher #status_message_text").val() == "").toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
Loading…
Reference in a new issue