auto_html 1.6.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +47 -98
  3. data/Rakefile +6 -7
  4. data/lib/auto_html.rb +9 -15
  5. data/lib/auto_html/emoji.rb +57 -0
  6. data/lib/auto_html/html_escape.rb +10 -0
  7. data/lib/auto_html/image.rb +23 -0
  8. data/lib/auto_html/link.rb +31 -0
  9. data/lib/auto_html/markdown.rb +15 -0
  10. data/lib/auto_html/pipeline.rb +15 -0
  11. data/lib/auto_html/simple_format.rb +22 -0
  12. data/spec/emoji_spec.rb +9 -0
  13. data/spec/html_escape_spec.rb +8 -0
  14. data/spec/image_spec.rb +39 -0
  15. data/spec/link_spec.rb +39 -0
  16. data/spec/markdown_spec.rb +7 -0
  17. data/spec/pipeline_spec.rb +24 -0
  18. data/spec/simple_format_spec.rb +16 -0
  19. data/spec/spec_helper.rb +11 -0
  20. metadata +121 -88
  21. data/lib/auto_html/auto_html_for.rb +0 -64
  22. data/lib/auto_html/base.rb +0 -18
  23. data/lib/auto_html/builder.rb +0 -21
  24. data/lib/auto_html/capistrano.rb +0 -17
  25. data/lib/auto_html/filter.rb +0 -22
  26. data/lib/auto_html/filters/dailymotion.rb +0 -6
  27. data/lib/auto_html/filters/flickr.rb +0 -20
  28. data/lib/auto_html/filters/gist.rb +0 -8
  29. data/lib/auto_html/filters/google_map.rb +0 -19
  30. data/lib/auto_html/filters/google_video.rb +0 -6
  31. data/lib/auto_html/filters/hashtag.rb +0 -7
  32. data/lib/auto_html/filters/html_escape.rb +0 -9
  33. data/lib/auto_html/filters/image.rb +0 -16
  34. data/lib/auto_html/filters/instagram.rb +0 -10
  35. data/lib/auto_html/filters/link.rb +0 -16
  36. data/lib/auto_html/filters/liveleak.rb +0 -19
  37. data/lib/auto_html/filters/metacafe.rb +0 -13
  38. data/lib/auto_html/filters/redcarpet.rb +0 -4
  39. data/lib/auto_html/filters/sanitize.rb +0 -5
  40. data/lib/auto_html/filters/simple_format.rb +0 -12
  41. data/lib/auto_html/filters/soundcloud.rb +0 -21
  42. data/lib/auto_html/filters/ted.rb +0 -13
  43. data/lib/auto_html/filters/twitter.rb +0 -19
  44. data/lib/auto_html/filters/vimeo.rb +0 -15
  45. data/lib/auto_html/filters/worldstar.rb +0 -8
  46. data/lib/auto_html/filters/youtube.rb +0 -19
  47. data/lib/auto_html/filters/youtube_image.rb +0 -17
  48. data/lib/auto_html/filters/youtube_js_api.rb +0 -6
  49. data/lib/auto_html/railtie.rb +0 -10
  50. data/lib/auto_html/rake_tasks.rb +0 -27
  51. data/lib/auto_html/task.rb +0 -9
  52. data/test/fixture_setup.rb +0 -13
  53. data/test/fixtures/database.yml +0 -5
  54. data/test/fixtures/schema.rb +0 -20
  55. data/test/functional/auto_html_for_options_test.rb +0 -26
  56. data/test/functional/auto_html_for_test.rb +0 -56
  57. data/test/functional/filter_test.rb +0 -27
  58. data/test/test_helper.rb +0 -9
  59. data/test/unit/auto_html_test.rb +0 -37
  60. data/test/unit/filters/dailymotion_test.rb +0 -20
  61. data/test/unit/filters/gist_test.rb +0 -15
  62. data/test/unit/filters/google_map_test.rb +0 -24
  63. data/test/unit/filters/hashtag_test.rb +0 -25
  64. data/test/unit/filters/html_escape_test.rb +0 -15
  65. data/test/unit/filters/image_test.rb +0 -65
  66. data/test/unit/filters/instagram_test.rb +0 -8
  67. data/test/unit/filters/link_test.rb +0 -55
  68. data/test/unit/filters/liveleak_test.rb +0 -15
  69. data/test/unit/filters/metacafe_test.rb +0 -29
  70. data/test/unit/filters/redcarpet_test.rb +0 -38
  71. data/test/unit/filters/sanitize_test.rb +0 -36
  72. data/test/unit/filters/simple_format_test.rb +0 -15
  73. data/test/unit/filters/soundcloud_test.rb +0 -29
  74. data/test/unit/filters/ted_test.rb +0 -18
  75. data/test/unit/filters/twitter_test.rb +0 -45
  76. data/test/unit/filters/vimeo_test.rb +0 -50
  77. data/test/unit/filters/worldstar_test.rb +0 -14
  78. data/test/unit/filters/youtube_image_test.rb +0 -59
  79. data/test/unit/filters/youtube_js_api_test.rb +0 -30
  80. data/test/unit/filters/youtube_test.rb +0 -59
  81. data/test/unit/unit_test_helper.rb +0 -3
@@ -1,13 +0,0 @@
1
- module FixtureSetup
2
- fixtures_dir = File.dirname(__FILE__) + '/fixtures'
3
- connections = YAML.load_file("#{fixtures_dir}/database.yml")
4
- ActiveRecord::Base.establish_connection(connections['sqlite3'])
5
- ActiveRecord::Migration.verbose = false
6
- load "#{fixtures_dir}/schema.rb"
7
-
8
- def setup
9
- fixtures_dir = File.dirname(__FILE__) + '/fixtures'
10
- ActiveRecord::Migration.verbose = false
11
- load "#{fixtures_dir}/schema.rb"
12
- end
13
- end
@@ -1,5 +0,0 @@
1
- sqlite3:
2
- adapter: sqlite3
3
- database: test.sqlite3
4
- pool: 5
5
- timeout: 5000
@@ -1,20 +0,0 @@
1
- ActiveRecord::Schema.define(:version => Time.now.to_i) do
2
- create_table "articles", :force => true do |t|
3
- t.column "title", :string
4
- t.column "body", :text
5
- t.column "body_html", :text
6
- t.column "created_at", :datetime
7
- t.column "updated_at", :datetime
8
- end
9
-
10
- create_table "users", :force => true do |t|
11
- t.column "name", :string
12
- t.column "bio", :text
13
- end
14
-
15
- create_table "posts", :force => true do |t|
16
- t.column "topic_id", :integer
17
- t.column "user_id", :integer
18
- t.column "content", :text
19
- end
20
- end
@@ -1,26 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
- require File.expand_path('../../fixture_setup', __FILE__)
3
-
4
- # store default so we can revert so that other tests use default option
5
- default_suffix = AutoHtmlFor.auto_html_for_options[:htmlized_attribute_suffix]
6
- AutoHtmlFor.auto_html_for_options[:htmlized_attribute_suffix] = '_htmlized'
7
-
8
- class Post < ActiveRecord::Base
9
- auto_html_for :content do
10
- simple_format
11
- end
12
- end
13
-
14
- class AutoHtmlForOptionsTest < Test::Unit::TestCase
15
- include FixtureSetup
16
-
17
- def test_transform_after_save
18
- @article = Post.new(:content => 'Yo!')
19
- assert_equal '<p>Yo!</p>', @article.content_htmlized
20
- @article.save!
21
- assert_equal '<p>Yo!</p>', @article.content_htmlized
22
- end
23
- end
24
-
25
- # reverting to default so that other tests use default option
26
- AutoHtmlFor.auto_html_for_options[:htmlized_attribute_suffix] = default_suffix
@@ -1,56 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
- require File.expand_path('../../fixture_setup', __FILE__)
3
-
4
- class Article < ActiveRecord::Base
5
- auto_html_for :body do
6
- html_escape
7
- youtube(:width => 400, :height => 250)
8
- image
9
- link(:target => "_blank")
10
- simple_format
11
- end
12
-
13
- alias_attribute :plain_body, :body
14
- auto_html_for :plain_body do
15
- html_escape
16
- end
17
- end
18
-
19
- class AutoHtmlForTest < Test::Unit::TestCase
20
- include FixtureSetup
21
-
22
- def test_transform_on_initialization
23
- @article = Article.new(:body => 'Yo!')
24
- assert_equal '<p>Yo!</p>', @article.body_html
25
- end
26
-
27
- def test_html_safe
28
- return unless "".respond_to?(:html_safe?)
29
- @article = Article.new(:body => 'Yo!')
30
- assert @article.body_html.html_safe?
31
- end
32
-
33
- def test_transform_after_save
34
- @article = Article.new(:body => 'Yo!')
35
- @article.save!
36
- assert_equal '<p>Yo!</p>', @article.body_html
37
- end
38
-
39
- def test_transform_of_nil
40
- @article = Article.new(:body => nil)
41
- @article.save!
42
- assert_equal '', @article.body_html
43
- end
44
-
45
- def test_transform_after_update
46
- @article = Article.create!(:body => 'Yo!')
47
- @article.update_attributes(:body => 'http://vukajlija.com')
48
- @article.save!
49
- assert_equal '<p><a href="http://vukajlija.com" target="_blank">http://vukajlija.com</a></p>', @article.body_html
50
- end
51
-
52
- def test_transform_of_alias_attribute
53
- @article = Article.new(:body => 'Hello there.')
54
- assert_equal 'Hello there.', @article.plain_body_html
55
- end
56
- end
@@ -1,27 +0,0 @@
1
- require File.expand_path('../../test_helper', __FILE__)
2
- require File.expand_path('../../fixture_setup', __FILE__)
3
-
4
- AutoHtml.add_filter(:foo) do |text|
5
- nil
6
- end
7
-
8
- AutoHtml.add_filter(:bar) do |text|
9
- "bar"
10
- end
11
-
12
- class User < ActiveRecord::Base
13
- auto_html_for :bio do
14
- foo
15
- foo
16
- bar
17
- end
18
- end
19
-
20
- class FilterTest < Test::Unit::TestCase
21
- include FixtureSetup
22
-
23
- def test_transform_after_save
24
- @article = User.new(:bio => 'in progress...')
25
- assert_equal 'bar', @article.bio_html
26
- end
27
- end
@@ -1,9 +0,0 @@
1
- require 'rubygems'
2
-
3
- require 'test/unit'
4
- require 'active_record'
5
- require 'action_view'
6
- require 'active_support/core_ext/class'
7
-
8
- require File.dirname(__FILE__) + '/../init'
9
-
@@ -1,37 +0,0 @@
1
- require File.expand_path('../unit_test_helper', __FILE__)
2
-
3
-
4
- class AutoHtmlTest < Test::Unit::TestCase
5
-
6
- def test_should_be_raw_input_when_no_filters_provided
7
- input = "Hey check out my blog => http://rors.org"
8
- result = auto_html(input) { }
9
- assert_equal result, input
10
- end
11
-
12
- def test_should_apply_simple_format_filter
13
- result = auto_html("Hey check out my blog => http://rors.org") { simple_format }
14
- assert_equal "<p>Hey check out my blog => http://rors.org</p>", result
15
- end
16
-
17
- def test_should_apply_simple_format_and_image_filter
18
- result = auto_html("Check the logo: http://rors.org/images/rails.png") { simple_format; image(:alt => nil) }
19
- assert_equal '<p>Check the logo: <img src="http://rors.org/images/rails.png" alt=""/></p>', result
20
- end
21
-
22
- def test_should_apply_simple_format_image_and_link_filter
23
- result = auto_html("Check the logo: http://rors.org/images/rails.png. Visit: http://rubyonrails.org") { simple_format; image(:alt => nil); link }
24
- assert_equal '<p>Check the logo: <img src="http://rors.org/images/rails.png" alt=""/>. Visit: <a href="http://rubyonrails.org" >http://rubyonrails.org</a></p>', result
25
- end
26
-
27
- def test_should_return_blank_if_input_is_blank
28
- result = auto_html("") { simple_format; image(:alt => nil); link }
29
- assert_equal "", result
30
- end
31
-
32
- def test_should_not_apply_simple_format_if_input_is_nil
33
- result = auto_html(nil) { simple_format; image(:alt => nil); link }
34
- assert_equal "", result
35
- end
36
-
37
- end
@@ -1,20 +0,0 @@
1
- require File.expand_path('../../unit_test_helper', __FILE__)
2
-
3
- class DailyMotionTest < Test::Unit::TestCase
4
-
5
- def test_transform
6
- result = auto_html("http://www.dailymotion.com/en/featured/video/xag4p2_tempsmorttv-episode-01_shortfilms") { dailymotion }
7
- assert_equal '<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/xag4p2_tempsmorttv-episode-01_shortfilms&related=0" width="480" height="360"><param name="movie" value="http://www.dailymotion.com/swf/xag4p2_tempsmorttv-episode-01_shortfilms&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/xag4p2_tempsmorttv-episode-01_shortfilms?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/xag4p2_tempsmorttv-episode-01_shortfilms" width="480" height="360"/></a></object>', result
8
- end
9
-
10
- def test_transform_with_tweaked_width
11
- result = auto_html("http://www.dailymotion.com/related/x9cyf6/video/x9tinl_happy-tree-friends-as-you-wish-part_fun") { dailymotion :width => 500 }
12
- assert_equal '<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/x9tinl_happy-tree-friends-as-you-wish-part_fun&related=0" width="500" height="360"><param name="movie" value="http://www.dailymotion.com/swf/x9tinl_happy-tree-friends-as-you-wish-part_fun&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/x9tinl_happy-tree-friends-as-you-wish-part_fun?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/x9tinl_happy-tree-friends-as-you-wish-part_fun" width="500" height="360"/></a></object>', result
13
- end
14
-
15
- def test_transform_with_options
16
- result = auto_html("http://www.dailymotion.com/video/xakv5i") { dailymotion(:width => 500, :height => 300) }
17
- assert_equal '<object type="application/x-shockwave-flash" data="http://www.dailymotion.com/swf/xakv5i&related=0" width="500" height="300"><param name="movie" value="http://www.dailymotion.com/swf/xakv5i&related=0"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><a href="http://www.dailymotion.com/video/xakv5i?embed=1"><img src="http://www.dailymotion.com/thumbnail/video/xakv5i" width="500" height="300"/></a></object>', result
18
- end
19
-
20
- end
@@ -1,15 +0,0 @@
1
- require File.expand_path('../../unit_test_helper', __FILE__)
2
-
3
- class GistTest < Test::Unit::TestCase
4
-
5
- def test_transform
6
- result = auto_html('https://gist.github.com/1710276') { gist }
7
- assert_equal '<script type="text/javascript" src="https://gist.github.com/1710276.js"></script>', result
8
- end
9
-
10
- def test_transform_with_username
11
- result = auto_html('https://gist.github.com/toctan/6547840') { gist }
12
- assert_equal '<script type="text/javascript" src="https://gist.github.com/6547840.js"></script>', result
13
- end
14
-
15
- end
@@ -1,24 +0,0 @@
1
- require File.expand_path('../../unit_test_helper', __FILE__)
2
-
3
- class GoogleMapTest < Test::Unit::TestCase
4
-
5
- def test_transform
6
- result = auto_html('http://maps.google.co.kr/maps?q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A') { google_map }
7
- assert_equal '<iframe width="420" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="//maps.google.co.kr/maps?f=q&amp;source=s_q&amp;q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A&amp;output=embed&amp;t=m&amp;z=18"></iframe><br /><small><a href="//maps.google.co.kr/maps?f=q&amp;source=embed&amp;q=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&hl=ko&ie=UTF8&ll=37.472942,126.884762&spn=0.00774,0.010053&sll=37.473027,126.88451&sspn=0.003887,0.005026&vpsrc=6&gl=kr&hq=%ED%8C%8C%ED%8A%B8%EB%84%88%EC%8A%A4%ED%83%80%EC%9B%8C+1%EC%B0%A8&t=m&z=17&iwloc=A" style="color:#000;text-align:left">View Larger Map</a></small>', result
8
- end
9
-
10
- def test_transform_2
11
- result = auto_html('http://maps.google.com/maps?hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl') { google_map }
12
- assert_equal '<iframe width="420" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="//maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl&amp;output=embed&amp;t=m&amp;z=18"></iframe><br /><small><a href="//maps.google.com/maps?f=q&amp;source=embed&amp;hl=en&q=newyork&gs_sm=e&gs_upl=917l917l0l1666l1l1l0l0l0l0l317l317l3-1l1l0&bav=on.2,or.r_gc.r_pw.,cf.osb&biw=1280&bih=679&um=1&ie=UTF-8&sa=N&tab=wl" style="color:#000;text-align:left">View Larger Map</a></small>', result
13
- end
14
-
15
- def test_show_info
16
- result = auto_html('http://maps.google.com.br/maps?q=Joinville+-+Santa+Catarina') { google_map(:show_info => false) }
17
- assert_equal '<iframe width="420" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="//maps.google.com.br/maps?f=q&amp;source=s_q&amp;q=Joinville+-+Santa+Catarina&amp;output=embed&amp;iwloc=near&amp;t=m&amp;z=18"></iframe><br /><small><a href="//maps.google.com.br/maps?f=q&amp;source=embed&amp;q=Joinville+-+Santa+Catarina" style="color:#000;text-align:left">View Larger Map</a></small>', result
18
- end
19
-
20
- def test_type_and_zoom
21
- result = auto_html('http://maps.google.com.br/maps?q=Joinville+-+Santa+Catarina') { google_map(:type => :satellite, :zoom => 3) }
22
- assert_equal '<iframe width="420" height="315" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="//maps.google.com.br/maps?f=q&amp;source=s_q&amp;q=Joinville+-+Santa+Catarina&amp;output=embed&amp;t=k&amp;z=3"></iframe><br /><small><a href="//maps.google.com.br/maps?f=q&amp;source=embed&amp;q=Joinville+-+Santa+Catarina" style="color:#000;text-align:left">View Larger Map</a></small>', result
23
- end
24
- end
@@ -1,25 +0,0 @@
1
- require File.expand_path('../../unit_test_helper', __FILE__)
2
-
3
- class HashtagTest < Test::Unit::TestCase
4
-
5
- def test_transform
6
- result = auto_html("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel ipsum et leo adipiscing ultrices. Etiam ac elementum cras amet. #LoremIpsum") { hashtag }
7
- assert_equal 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel ipsum et leo adipiscing ultrices. Etiam ac elementum cras amet. <a href="http://twitter.com/search?q=%23LoremIpsum&f=realtime" class="hashtag" target="_blank">#LoremIpsum</a>', result
8
- end
9
-
10
- def test_transform_with_multiple_hashtags
11
- result = auto_html("Lorem ipsum #dolor sit amet, consectetur adipiscing elit. Donec vel ipsum et leo #adipiscingUltrices. Etiam ac elementum cras amet.") { hashtag }
12
- assert_equal 'Lorem ipsum <a href="http://twitter.com/search?q=%23dolor&f=realtime" class="hashtag" target="_blank">#dolor</a> sit amet, consectetur adipiscing elit. Donec vel ipsum et leo <a href="http://twitter.com/search?q=%23adipiscingUltrices.&f=realtime" class="hashtag" target="_blank">#adipiscingUltrices.</a> Etiam ac elementum cras amet.', result
13
- end
14
-
15
- def test_transform_with_twitter_source
16
- result = auto_html("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel ipsum et leo adipiscing ultrices. Etiam ac elementum cras amet. #LoremIpsum") { hashtag source: :twitter }
17
- assert_equal 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel ipsum et leo adipiscing ultrices. Etiam ac elementum cras amet. <a href="http://twitter.com/search?q=%23LoremIpsum&f=realtime" class="hashtag" target="_blank">#LoremIpsum</a>', result
18
- end
19
-
20
- def test_transform_with_facebook_source
21
- result = auto_html("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel ipsum et leo adipiscing ultrices. Etiam ac elementum cras amet. #LoremIpsum") { hashtag source: :facebook }
22
- assert_equal 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vel ipsum et leo adipiscing ultrices. Etiam ac elementum cras amet. <a href="https://www.facebook.com/hashtag/LoremIpsum" class="hashtag" target="_blank">#LoremIpsum</a>', result
23
- end
24
-
25
- end
@@ -1,15 +0,0 @@
1
- require File.expand_path('../../unit_test_helper', __FILE__)
2
-
3
- class HtmlEscapeTest < Test::Unit::TestCase
4
-
5
- def test_trasform
6
- result = auto_html("<script>alert(0)</script>") { html_escape }
7
- assert_equal "&lt;script&gt;alert(0)&lt;/script&gt;", result
8
- end
9
-
10
- def test_trasform2
11
- result = auto_html("<div>test</div>") { html_escape }
12
- assert_equal "&lt;div&gt;test&lt;/div&gt;", result
13
- end
14
-
15
- end
@@ -1,65 +0,0 @@
1
- require File.expand_path('../../unit_test_helper', __FILE__)
2
-
3
- class ImageTest < Test::Unit::TestCase
4
-
5
- def test_transform
6
- result = auto_html('http://rors.org/images/rails.png') { image({:alt => nil}) }
7
- assert_equal '<img src="http://rors.org/images/rails.png" alt=""/>', result
8
- end
9
-
10
- def test_dont_transform
11
- result = auto_html('http://blog.phusion.nl/2009/04/16/phusions-one-year-anniversary-gift-phusion-passenger-220/') { image }
12
- assert_equal 'http://blog.phusion.nl/2009/04/16/phusions-one-year-anniversary-gift-phusion-passenger-220/', result
13
- end
14
-
15
- def test_dont_transform_a_formatted_image
16
- result = auto_html('<img src="http://farm4.static.flickr.com/3459/3270173112_5099d3d730.jpg" alt=""/>'){ image({:alt => nil}) }
17
- assert_equal '<img src="http://farm4.static.flickr.com/3459/3270173112_5099d3d730.jpg" alt=""/>', result
18
- end
19
-
20
- def test_transform2
21
- result = auto_html('http://farm4.static.flickr.com/3459/3270173112_5099d3d730.jpg') { image({:alt => nil}) }
22
- assert_equal '<img src="http://farm4.static.flickr.com/3459/3270173112_5099d3d730.jpg" alt=""/>', result
23
- end
24
-
25
- def test_transform3
26
- result = auto_html('http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG') { image({:alt => nil}) }
27
- assert_equal '<img src="http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG" alt=""/>', result
28
- end
29
-
30
- def test_transform4
31
- result = auto_html('http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG') { image({:alt => nil}) }
32
- assert_equal '<img src="http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG" alt=""/>', result
33
- end
34
-
35
- def test_transform5
36
- result = auto_html('http://farm4.static.flickr.com/3664/3512431377_71b8d002ef.jpg?v=0') { image({:alt => nil}) }
37
- assert_equal '<img src="http://farm4.static.flickr.com/3664/3512431377_71b8d002ef.jpg?v=0" alt=""/>', result
38
- end
39
-
40
- def test_transform6
41
- result = auto_html('Do you like this logo http://rors.org/images/rails.png? Yeah?') { image({:alt => nil}) }
42
- assert_equal 'Do you like this logo <img src="http://rors.org/images/rails.png" alt=""/>? Yeah?', result
43
- end
44
-
45
- def test_transform7
46
- result = auto_html('http://tbn3.google.com/images?q=tbn:vS-jtEi9Xc8K6M:http://upload.wikimedia.org/wikipedia/commons/b/ba/Potturinn.jpeg') { image({:alt => nil}) }
47
- assert_equal '<img src="http://tbn3.google.com/images?q=tbn:vS-jtEi9Xc8K6M:http://upload.wikimedia.org/wikipedia/commons/b/ba/Potturinn.jpeg" alt=""/>', result
48
- end
49
-
50
- def test_transform8
51
- result = auto_html('Which do you prefer, this one http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG, or this one http://rors.org/images/rails.png?') { image({:alt => nil}) }
52
- assert_equal 'Which do you prefer, this one <img src="http://www.lockhartfineart.com/images/Rio_Grande_Frost.JPG" alt=""/>, or this one <img src="http://rors.org/images/rails.png" alt=""/>?', result
53
- end
54
-
55
- def test_https
56
- result = auto_html('https://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png') { image({:alt => nil}) }
57
- assert_equal '<img src="https://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png" alt=""/>', result
58
- end
59
-
60
- def test_proxy_option
61
- result = auto_html('http://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png') { image({:alt => nil,:proxy => "https://proxy/?url="}) }
62
- assert_equal '<img src="https://proxy/?url=http://img.skitch.com/20100910-1wrbg5749xe29ya5t3s85bnaiy.png" alt=""/>', result
63
- end
64
-
65
- end
@@ -1,8 +0,0 @@
1
- require File.expand_path('../../unit_test_helper', __FILE__)
2
-
3
- class InstagramTest < Test::Unit::TestCase
4
- def test_instagram_embed
5
- result = auto_html('http://instagram.com/p/WsQTLAGvx7/') { instagram }
6
- assert_equal '<iframe src="http://instagram.com/p/WsQTLAGvx7/embed" height="714" width="616" frameborder="0" scrolling="no"></iframe>', result
7
- end
8
- end
@@ -1,55 +0,0 @@
1
- require File.expand_path('../../unit_test_helper', __FILE__)
2
-
3
- class LinkTest < Test::Unit::TestCase
4
-
5
- def test_transform
6
- result = auto_html("http://vukajlija.com") { link }
7
- assert_equal '<a href="http://vukajlija.com" >http://vukajlija.com</a>', result
8
- end
9
-
10
- def test_transform_with_the_slash_at_the_end
11
- result = auto_html("http://github.com/") { link }
12
- assert_equal '<a href="http://github.com/" >http://github.com/</a>', result
13
- end
14
-
15
- def test_transform_with_param
16
- result = auto_html('http://example.com/abc?query=ruby') { link }
17
- assert_equal '<a href="http://example.com/abc?query=ruby" >http://example.com/abc?query=ruby</a>', result
18
- end
19
-
20
- def test_transform_with_param_and_trailing_dot
21
- result = auto_html('http://example.com/abc?query=ruby.') { link }
22
- assert_equal '<a href="http://example.com/abc?query=ruby" >http://example.com/abc?query=ruby</a>.', result
23
- end
24
-
25
- def test_transform_with_anchor_and_trailing_dot
26
- result = auto_html('http://example.com/example#id=123.12.') { link }
27
- assert_equal '<a href="http://example.com/example#id=123.12" >http://example.com/example#id=123.12</a>.', result
28
- end
29
-
30
- def test_transform_with_commas
31
- result = auto_html('http://www.dw-world.de/dw/article/0,,4708386,00.html?maca=ser-rss-ser-all-1494-rdf') { link }
32
- assert_equal '<a href="http://www.dw-world.de/dw/article/0,,4708386,00.html?maca=ser-rss-ser-all-1494-rdf" >http://www.dw-world.de/dw/article/0,,4708386,00.html?maca=ser-rss-ser-all-1494-rdf</a>', result
33
- end
34
-
35
- def test_transform_complex_url
36
- url = 'http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0'
37
- # uses auto_link instead raw to support both Rails 2 & 3
38
- assert_equal('<a href="http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0" >http://www.google.com/#q=nikola+tesla&ct=tesla09&oi=ddle&fp=Xmf0jJ9P_V0</a>', auto_html(url) { link })
39
- end
40
-
41
- def test_transform_with_options
42
- result = auto_html("http://rors.org") { link :target => "_blank" }
43
- assert_equal '<a href="http://rors.org" target="_blank">http://rors.org</a>', result
44
- end
45
-
46
- def test_transform_with_short_link_name_option
47
- result = auto_html("http://rors.org?some=params&and=more") { link :short_link_name => true }
48
- assert_equal '<a href="http://rors.org?some=params&and=more" >http://rors.org</a>', result
49
- end
50
-
51
- def test_transform_with_short_link_name_option_false
52
- result = auto_html("http://rors.org?some=params&and=more") { link :short_link_name => false }
53
- assert_equal '<a href="http://rors.org?some=params&and=more" >http://rors.org?some=params&and=more</a>', result
54
- end
55
- end
@@ -1,15 +0,0 @@
1
- require File.expand_path('../../unit_test_helper', __FILE__)
2
-
3
- class LiveLeakTest < Test::Unit::TestCase
4
-
5
- def test_transform
6
- result = auto_html('http://www.liveleak.com/view?i=BwNrmYRiX_o') { liveleak }
7
- assert_equal '<iframe width="420" height="315" src="http://www.liveleak.com/ll_embed?f=BwNrmYRiX_o" frameborder="0" allowfullscreen></iframe>', result
8
- end
9
-
10
- def test_transform2
11
- result = auto_html('http://www.liveleak.com/ll_embed?f=ef8304ab85e5') { liveleak }
12
- assert_equal '<iframe width="420" height="315" src="http://www.liveleak.com/ll_embed?f=ef8304ab85e5" frameborder="0" allowfullscreen></iframe>', result
13
- end
14
-
15
- end