onebox 1.8.39 → 1.8.40

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -1
  3. data/.travis.yml +0 -1
  4. data/README.md +1 -1
  5. data/lib/onebox/engine/amazon_onebox.rb +98 -17
  6. data/lib/onebox/version.rb +3 -1
  7. data/onebox.gemspec +5 -5
  8. data/templates/amazon.mustache +7 -1
  9. metadata +7 -177
  10. data/spec/fixtures/amazon-og.response +0 -3675
  11. data/spec/fixtures/amazon.response +0 -3040
  12. data/spec/fixtures/cloudapp-gif.response +0 -66
  13. data/spec/fixtures/cloudapp-jpg.response +0 -66
  14. data/spec/fixtures/cloudapp-mp4.response +0 -65
  15. data/spec/fixtures/cloudapp-others.response +0 -66
  16. data/spec/fixtures/dailymail.response +0 -5914
  17. data/spec/fixtures/discourse_topic.response +0 -344
  18. data/spec/fixtures/discourse_topic_reply.response +0 -345
  19. data/spec/fixtures/douban.response +0 -4399
  20. data/spec/fixtures/etsy.response +0 -5827
  21. data/spec/fixtures/etsy_mobile.response +0 -4230
  22. data/spec/fixtures/gfycat.response +0 -1
  23. data/spec/fixtures/githubblob.response +0 -46
  24. data/spec/fixtures/githubcommit.response +0 -87
  25. data/spec/fixtures/githubgist.response +0 -310
  26. data/spec/fixtures/githubpullrequest.response +0 -216
  27. data/spec/fixtures/googleplayapp.response +0 -138
  28. data/spec/fixtures/image.response +0 -0
  29. data/spec/fixtures/meetup.response.html +0 -4419
  30. data/spec/fixtures/meetup_oembed.response +0 -1
  31. data/spec/fixtures/pubmed-electronic-xml.response +0 -175
  32. data/spec/fixtures/pubmed-electronic.response +0 -307
  33. data/spec/fixtures/pubmed-xml.response +0 -122
  34. data/spec/fixtures/pubmed.response +0 -300
  35. data/spec/fixtures/slides.response +0 -2852
  36. data/spec/fixtures/stackexchange-answer.response +0 -1
  37. data/spec/fixtures/stackexchange-question.response +0 -1
  38. data/spec/fixtures/twitterstatus.response +0 -2814
  39. data/spec/fixtures/video.response +0 -0
  40. data/spec/fixtures/wechat-mp.response +0 -631
  41. data/spec/fixtures/wikimedia.response +0 -1
  42. data/spec/fixtures/wikipedia.response +0 -566
  43. data/spec/fixtures/wikipediaredirected.response +0 -899
  44. data/spec/fixtures/xkcd.response +0 -1
  45. data/spec/fixtures/youku-meta.response +0 -1
  46. data/spec/fixtures/youku.response +0 -1443
  47. data/spec/fixtures/youtube-channel.response +0 -5446
  48. data/spec/fixtures/youtube-json.response +0 -1
  49. data/spec/fixtures/youtube-list-json.response +0 -1
  50. data/spec/fixtures/youtube.response +0 -1625
  51. data/spec/lib/onebox/engine/amazon_onebox_spec.rb +0 -116
  52. data/spec/lib/onebox/engine/audio_onebox_spec.rb +0 -31
  53. data/spec/lib/onebox/engine/cloudapp_onebox_spec.rb +0 -26
  54. data/spec/lib/onebox/engine/douban_onebox_spec.rb +0 -29
  55. data/spec/lib/onebox/engine/gfycat_onebox_spec.rb +0 -34
  56. data/spec/lib/onebox/engine/github_blob_onebox_spec.rb +0 -21
  57. data/spec/lib/onebox/engine/github_commit_onebox_spec.rb +0 -108
  58. data/spec/lib/onebox/engine/github_gist_onebox_spec.rb +0 -67
  59. data/spec/lib/onebox/engine/github_pullrequest_onebox_spec.rb +0 -46
  60. data/spec/lib/onebox/engine/google_docs_onebox_spec.rb +0 -35
  61. data/spec/lib/onebox/engine/google_maps_onebox_spec.rb +0 -72
  62. data/spec/lib/onebox/engine/google_play_app_onebox_spec.rb +0 -28
  63. data/spec/lib/onebox/engine/html_spec.rb +0 -25
  64. data/spec/lib/onebox/engine/image_onebox_spec.rb +0 -39
  65. data/spec/lib/onebox/engine/json_spec.rb +0 -25
  66. data/spec/lib/onebox/engine/pdf_onebox_spec.rb +0 -28
  67. data/spec/lib/onebox/engine/pubmed_onebox_spec.rb +0 -78
  68. data/spec/lib/onebox/engine/slides_onebox_spec.rb +0 -24
  69. data/spec/lib/onebox/engine/stack_exchange_onebox_spec.rb +0 -97
  70. data/spec/lib/onebox/engine/trello_onebox_spec.rb +0 -30
  71. data/spec/lib/onebox/engine/twitch_clips_onebox_spec.rb +0 -10
  72. data/spec/lib/onebox/engine/twitch_stream_onebox_spec.rb +0 -15
  73. data/spec/lib/onebox/engine/twitch_video_onebox_spec.rb +0 -10
  74. data/spec/lib/onebox/engine/twitter_status_onebox_spec.rb +0 -187
  75. data/spec/lib/onebox/engine/video_onebox_spec.rb +0 -31
  76. data/spec/lib/onebox/engine/wechat_mp_onebox_spec.rb +0 -26
  77. data/spec/lib/onebox/engine/whitelisted_generic_onebox_spec.rb +0 -179
  78. data/spec/lib/onebox/engine/wikimedia_onebox_spec.rb +0 -23
  79. data/spec/lib/onebox/engine/wikipedia_onebox_spec.rb +0 -21
  80. data/spec/lib/onebox/engine/xkcd_spec.rb +0 -27
  81. data/spec/lib/onebox/engine/youku_onebox_spec.rb +0 -13
  82. data/spec/lib/onebox/engine/youtube_onebox_spec.rb +0 -84
  83. data/spec/lib/onebox/engine_spec.rb +0 -101
  84. data/spec/lib/onebox/helpers_spec.rb +0 -73
  85. data/spec/lib/onebox/layout_spec.rb +0 -79
  86. data/spec/lib/onebox/matcher_spec.rb +0 -74
  87. data/spec/lib/onebox/preview_spec.rb +0 -74
  88. data/spec/lib/onebox/status_check_spec.rb +0 -68
  89. data/spec/lib/onebox_spec.rb +0 -65
  90. data/spec/spec_helper.rb +0 -90
  91. data/spec/support/html_spec_helper.rb +0 -18
  92. data/web/assets/javascripts/jquery.js +0 -4
  93. data/web/assets/javascripts/main.js +0 -23
  94. data/web/assets/stylesheets/normalize.css +0 -427
  95. data/web/assets/stylesheets/style.css +0 -25
  96. data/web/views/index.haml +0 -29
  97. data/web/views/layout.haml +0 -11
@@ -1,30 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Onebox::Engine::TrelloOnebox do
4
- context "Boards" do
5
- it "should onebox with SEF url corrrectly" do
6
- expect(Onebox.preview('https://trello.com/b/nC8QJJoZ/trello-development-roadmap').to_s).to match('iframe src="https://trello.com/b/nC8QJJoZ.html"')
7
- end
8
-
9
- it "should onebox without SEF url corrrectly" do
10
- expect(Onebox.preview('https://trello.com/b/nC8QJJoZ/').to_s).to match('iframe src="https://trello.com/b/nC8QJJoZ.html"')
11
-
12
- # Without trailing slash
13
- expect(Onebox.preview('https://trello.com/b/nC8QJJoZ').to_s).to match('iframe src="https://trello.com/b/nC8QJJoZ.html"')
14
- end
15
- end
16
-
17
- context "Cards" do
18
- it "should onebox with SEF url corrrectly" do
19
- expect(Onebox.preview('https://trello.com/c/NIRpzVDM/1211-what-can-you-expect-from-this-board').to_s).to match('iframe src="https://trello.com/c/NIRpzVDM.html"')
20
- end
21
-
22
- it "should onebox without SEF url corrrectly" do
23
- expect(Onebox.preview('https://trello.com/c/NIRpzVDM/').to_s).to match('iframe src="https://trello.com/c/NIRpzVDM.html"')
24
-
25
- # Without trailing slash
26
- expect(Onebox.preview('https://trello.com/c/NIRpzVDM').to_s).to match('iframe src="https://trello.com/c/NIRpzVDM.html"')
27
- end
28
- end
29
-
30
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Onebox::Engine::TwitchClipsOnebox do
4
-
5
- it "has the iframe with the correct channel" do
6
- expect(Onebox.preview('https://clips.twitch.tv/FunVastGalagoKlappa').to_s).to match(/<iframe src="\/\/clips\.twitch\.tv\/embed\?clip=FunVastGalagoKlappa/)
7
-
8
- end
9
-
10
- end
@@ -1,15 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Onebox::Engine::TwitchStreamOnebox do
4
-
5
- it "has the iframe with the correct channel" do
6
- expect(Onebox.preview('https://www.twitch.tv/theduckie908').to_s).to match(/<iframe src="\/\/player\.twitch\.tv\/\?channel=theduckie908/)
7
-
8
- end
9
-
10
- it "works in the twitch new interface/url" do
11
- expect(Onebox.preview('https://go.twitch.tv/admiralbulldog').to_s).to match(/<iframe src="\/\/player\.twitch\.tv\/\?channel=admiralbulldog/)
12
-
13
- end
14
-
15
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Onebox::Engine::TwitchVideoOnebox do
4
-
5
- it "has the iframe with the correct channel" do
6
- expect(Onebox.preview('https://www.twitch.tv/videos/140675974').to_s).to match(/<iframe src="\/\/player\.twitch\.tv\/\?video=v140675974/)
7
-
8
- end
9
-
10
- end
@@ -1,187 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Onebox::Engine::TwitterStatusOnebox do
4
- before(:all) do
5
- @link = "https://twitter.com/vyki_e/status/363116819147538433"
6
- end
7
-
8
- shared_examples_for "#to_html" do
9
- it "includes tweet" do
10
- expect(html).to include("I'm a sucker for pledges.")
11
- end
12
-
13
- # TODO: handle t.co links
14
- # it "includes link" do
15
- # expect(html).to include("http://www.peers.org/action/peers-pledgea")
16
- # end
17
-
18
- it "gets the correct timestamp" do
19
- expect(onebox.send(:timestamp)).to eq("6:59 PM - 1 Aug 2013")
20
- end
21
-
22
- it "includes name" do
23
- expect(html).to include("Vyki Englert")
24
- end
25
-
26
- it "includes username" do
27
- expect(html).to include("vyki_e")
28
- end
29
-
30
- it "includes user avatar" do
31
- expect(html).to include("732349210264133632/RTNgZLrm_400x400.jpg")
32
- end
33
- end
34
-
35
- context "with html" do
36
- include_context "engines"
37
- it_behaves_like "an engine"
38
- it_behaves_like "#to_html"
39
- end
40
-
41
- context "with twitter client" do
42
- before(:each) do
43
- @twitter_client = double("TwitterClient")
44
- allow(@twitter_client).to receive("status")
45
- .and_return mockTwitterAPIReponse
46
-
47
- allow(@twitter_client).to receive("prettify_tweet") do
48
- "I'm a sucker for pledges. <a href='https://twitter.com/Peers' target='_blank'>@Peers</a> Pledge <a href='https://twitter.com/search?q=%23sharingeconomy' target='_blank'>#sharingeconomy</a> <a target='_blank' href='http://www.peers.org/action/peers-pledgea/'>peers.org/action/peers-p…</a>"
49
- end
50
- allow(@twitter_client).to receive("twitter_credentials_missing?") do
51
- false
52
- end
53
- Onebox.options = { twitter_client: @twitter_client }
54
- end
55
-
56
- after(:each) do
57
- Onebox.options = { twitter_client: nil }
58
- end
59
-
60
- include_context "engines"
61
- it_behaves_like "an engine"
62
- it_behaves_like "#to_html"
63
- end
64
-
65
- def mockTwitterAPIReponse
66
- {
67
- created_at: "Fri Aug 02 01:59:30 +0000 2013",
68
- id: 363116819147538400,
69
- id_str: "363116819147538433",
70
- text: "I'm a sucker for pledges. @Peers Pledge #sharingeconomy http://t.co/T4Sc47KAzh",
71
- truncated: false,
72
- entities: {
73
- hashtags: [
74
- {
75
- text: "sharingeconomy",
76
- indices: [
77
- 41,
78
- 56
79
- ]
80
- }
81
- ],
82
- symbols: [],
83
- user_mentions: [
84
- {
85
- screen_name: "peers",
86
- name: "Peers",
87
- id: 1428357889,
88
- id_str: "1428357889",
89
- indices: [
90
- 27,
91
- 33
92
- ]
93
- }
94
- ],
95
- urls: [
96
- {
97
- url: "http://t.co/T4Sc47KAzh",
98
- expanded_url: "http://www.peers.org/action/peers-pledgea/",
99
- display_url: "peers.org/action/peers-p…",
100
- indices: [
101
- 57,
102
- 79
103
- ]
104
- }
105
- ]
106
- },
107
- source: "<a href=\"https://dev.twitter.com/docs/tfw\" rel=\"nofollow\">Twitter for Websites</a>",
108
- in_reply_to_status_id: nil,
109
- in_reply_to_status_id_str: nil,
110
- in_reply_to_user_id: nil,
111
- in_reply_to_user_id_str: nil,
112
- in_reply_to_screen_name: nil,
113
- user: {
114
- id: 1087064150,
115
- id_str: "1087064150",
116
- name: "Vyki Englert",
117
- screen_name: "vyki_e",
118
- location: "Los Angeles, CA",
119
- description: "Rides bikes, writes code, likes maps. @CompilerLA / @CityGrows / Brigade Captain @HackforLA",
120
- url: "http://t.co/YCAP3asRG1",
121
- entities: {
122
- url: {
123
- urls: [
124
- {
125
- url: "http://t.co/YCAP3asRG1",
126
- expanded_url: "http://www.compiler.la",
127
- display_url: "compiler.la",
128
- indices: [
129
- 0,
130
- 22
131
- ]
132
- }
133
- ]
134
- },
135
- description: {
136
- urls: []
137
- }
138
- },
139
- protected: false,
140
- followers_count: 1128,
141
- friends_count: 2244,
142
- listed_count: 83,
143
- created_at: "Sun Jan 13 19:53:00 +0000 2013",
144
- favourites_count: 2928,
145
- utc_offset: -25200,
146
- time_zone: "Pacific Time (US & Canada)",
147
- geo_enabled: true,
148
- verified: false,
149
- statuses_count: 3295,
150
- lang: "en",
151
- contributors_enabled: false,
152
- is_translator: false,
153
- is_translation_enabled: false,
154
- profile_background_color: "ACDED6",
155
- profile_background_image_url: "http://abs.twimg.com/images/themes/theme18/bg.gif",
156
- profile_background_image_url_https: "https://abs.twimg.com/images/themes/theme18/bg.gif",
157
- profile_background_tile: false,
158
- profile_image_url: "http://pbs.twimg.com/profile_images/732349210264133632/RTNgZLrm_normal.jpg",
159
- profile_image_url_https: "https://pbs.twimg.com/profile_images/732349210264133632/RTNgZLrm_normal.jpg",
160
- profile_banner_url: "https://pbs.twimg.com/profile_banners/1087064150/1424315468",
161
- profile_link_color: "4E99D1",
162
- profile_sidebar_border_color: "EEEEEE",
163
- profile_sidebar_fill_color: "F6F6F6",
164
- profile_text_color: "333333",
165
- profile_use_background_image: true,
166
- has_extended_profile: false,
167
- default_profile: false,
168
- default_profile_image: false,
169
- following: false,
170
- follow_request_sent: false,
171
- notifications: false
172
- },
173
- geo: nil,
174
- coordinates: nil,
175
- place: nil,
176
- contributors: nil,
177
- is_quote_status: false,
178
- retweet_count: 0,
179
- favorite_count: 0,
180
- favorited: false,
181
- retweeted: false,
182
- possibly_sensitive: false,
183
- possibly_sensitive_appealable: false,
184
- lang: "en"
185
- }
186
- end
187
- end
@@ -1,31 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Onebox::Engine::VideoOnebox do
4
- it "supports ogv" do
5
- expect(Onebox.preview('http://upload.wikimedia.org/wikipedia/commons/3/37/STS-134_launch_2.ogv').to_s).to match(/<video/)
6
- end
7
-
8
- it "supports mp4" do
9
- expect(Onebox.preview('http://download.wavetlan.com/svv/dev/test.mp4').to_s).to match(/<video/)
10
- end
11
-
12
- it "supports mov" do
13
- expect(Onebox.preview('http://download.wavetlan.com/SVV/Media/HTTP/BlackBerry.MOV').to_s).to match(/<video/)
14
- end
15
-
16
- it "supports webm" do
17
- expect(Onebox.preview('http://video.webmfiles.org/big-buck-bunny_trailer.webm').to_s).to match(/<video/)
18
- end
19
-
20
- it "supports URLs with query parameters" do
21
- expect(Onebox.preview('http://video.webmfiles.org/big-buck-bunny_trailer.webm?foo=bar').to_s).to match(/<video/)
22
- end
23
-
24
- it "supports protocol relative URLs" do
25
- expect(Onebox.preview('//video.webmfiles.org/big-buck-bunny_trailer.webm').to_s).to match(/<video/)
26
- end
27
-
28
- it "includes a fallback direct link to the video" do
29
- expect(Onebox.preview('http://download.wavetlan.com/svv/dev/test.mp4').to_s).to match(/<a.*mp4/)
30
- end
31
- end
@@ -1,26 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Onebox::Engine::WechatMpOnebox do
4
-
5
- let(:link) { "https://mp.weixin.qq.com/s?__biz=MjM5NjM4MDAxMg==&mid=2655075181&idx=1&sn=7c58f17de2c687f4763f17359ecc6e72&chksm=bd5fb76e8a283e7856cae30a74e905a18d9511e81c047b6e12390889de15976fb2c297b04106#rd" }
6
- let(:html) { described_class.new(link).to_html }
7
-
8
- describe "#to_html" do
9
- before do
10
- fake("https://mp.weixin.qq.com/s?__biz=MjM5NjM4MDAxMg==&mid=2655075181&idx=1&sn=7c58f17de2c687f4763f17359ecc6e72&chksm=bd5fb76e8a283e7856cae30a74e905a18d9511e81c047b6e12390889de15976fb2c297b04106", response("wechat-mp"))
11
- end
12
-
13
- it "has the article's title" do
14
- expect(html).to include("不是月光宝盒,但也能回到过去")
15
- end
16
-
17
- it "has the article's description" do
18
- expect(html).to include("你知道吗?从今天起,公众号后台编辑文章时可以……")
19
- end
20
-
21
- it "has the article's author" do
22
- expect(html).to include("微信派")
23
- end
24
- end
25
-
26
- end
@@ -1,179 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Onebox::Engine::WhitelistedGenericOnebox do
4
-
5
- describe ".===" do
6
- before do
7
- described_class.whitelist = %w(eviltrout.com discourse.org)
8
- end
9
-
10
- it "matches an entire domain" do
11
- expect(described_class === URI('http://eviltrout.com/resource')).to eq(true)
12
- end
13
-
14
- it "matches a subdomain" do
15
- expect(described_class === URI('http://www.eviltrout.com/resource')).to eq(true)
16
- end
17
-
18
- it "doesn't match a different domain" do
19
- expect(described_class === URI('http://goodtuna.com/resource')).to eq(false)
20
- end
21
-
22
- it "doesn't match the period as any character" do
23
- expect(described_class === URI('http://eviltrouticom/resource')).to eq(false)
24
- end
25
-
26
- it "doesn't match a prefixed domain" do
27
- expect(described_class === URI('http://aneviltrout.com/resource')).to eq(false)
28
- end
29
- end
30
-
31
- describe 'html_providers' do
32
- class HTMLOnebox < Onebox::Engine::WhitelistedGenericOnebox
33
- def data
34
- {
35
- html: 'cool html',
36
- height: 123,
37
- provider_name: 'CoolSite',
38
- }
39
- end
40
- end
41
-
42
- it "doesn't return the HTML when not in the `html_providers`" do
43
- Onebox::Engine::WhitelistedGenericOnebox.html_providers = []
44
- expect(HTMLOnebox.new("http://coolsite.com").to_html).to be_nil
45
- end
46
-
47
- it "returns the HMTL when in the `html_providers`" do
48
- Onebox::Engine::WhitelistedGenericOnebox.html_providers = ['CoolSite']
49
- expect(HTMLOnebox.new("http://coolsite.com").to_html).to eq "cool html"
50
- end
51
- end
52
-
53
- describe 'rewrites' do
54
- class DummyOnebox < Onebox::Engine::WhitelistedGenericOnebox
55
- def generic_html
56
- "<iframe src='http://youtube.com/asdf'></iframe>"
57
- end
58
- end
59
-
60
- it "doesn't rewrite URLs that arent in the list" do
61
- Onebox::Engine::WhitelistedGenericOnebox.rewrites = []
62
- expect(DummyOnebox.new("http://youtube.com").to_html).to eq "<iframe src='http://youtube.com/asdf'></iframe>"
63
- end
64
-
65
- it "rewrites URLs when whitelisted" do
66
- Onebox::Engine::WhitelistedGenericOnebox.rewrites = %w(youtube.com)
67
- expect(DummyOnebox.new("http://youtube.com").to_html).to eq "<iframe src='https://youtube.com/asdf'></iframe>"
68
- end
69
- end
70
-
71
- describe 'oembed_providers' do
72
- let(:url) { "http://www.meetup.com/Toronto-Ember-JS-Meetup/events/219939537" }
73
-
74
- before do
75
- fake(url, response('meetup'))
76
- fake("http://api.meetup.com/oembed?url=#{url}", response('meetup_oembed'))
77
- end
78
-
79
- it 'uses the endpoint for the url' do
80
- onebox = described_class.new("http://www.meetup.com/Toronto-Ember-JS-Meetup/events/219939537")
81
- expect(onebox.raw).not_to be_nil
82
- expect(onebox.raw[:title]).to eq "February EmberTO Meet-up"
83
- end
84
- end
85
-
86
- describe "cookie support" do
87
- let(:url) { "http://www.dailymail.co.uk/news/article-479146/Brutality-justice-The-truth-tarred-feathered-drug-dealer.html" }
88
- before do
89
- fake(url, response('dailymail'))
90
- end
91
-
92
- it "sends the cookie with the request" do
93
- onebox = described_class.new(url)
94
- onebox.options = { cookie: "evil=trout" }
95
- expect(onebox.to_html).not_to be_empty
96
- expect(FakeWeb.last_request['Cookie']).to eq('evil=trout')
97
- end
98
-
99
- it "fetches site_name and article_published_time tags" do
100
- onebox = described_class.new(url)
101
- expect(onebox.to_html).not_to be_empty
102
-
103
- expect(onebox.to_html).to include("Mail Online &ndash; 8 Aug 14")
104
- end
105
- end
106
-
107
- describe 'canonical link' do
108
- context 'uses canonical link if available' do
109
- let(:mobile_url) { "https://m.etsy.com/in-en/listing/87673424/personalized-word-pillow-case-letter" }
110
- let(:canonical_url) { "https://www.etsy.com/in-en/listing/87673424/personalized-word-pillow-case-letter" }
111
- before do
112
- fake(mobile_url, response('etsy_mobile'))
113
- fake(canonical_url, response('etsy'))
114
- end
115
-
116
- it 'fetches opengraph data and twitter labels from canonical link' do
117
- onebox = described_class.new(mobile_url)
118
- expect(onebox.to_html).not_to be_nil
119
- expect(onebox.to_html).to include("images/favicon.ico")
120
- expect(onebox.to_html).to include("Etsy")
121
- expect(onebox.to_html).to include("Personalized Word Pillow Case")
122
- expect(onebox.to_html).to include("Allow your personality to shine through your decor; this contemporary and modern accent will help you do just that.")
123
- expect(onebox.to_html).to include("https://img1.etsystatic.com/028/1/6088772/il_570xN.613262127_e0zl.jpg")
124
- expect(onebox.to_html).to include("CAD: $46.00")
125
- expect(onebox.to_html).not_to include("Available: 4")
126
- end
127
- end
128
-
129
- context 'does not use canonical link for Discourse topics' do
130
- let(:discourse_topic_url) { "https://meta.discourse.org/t/congratulations-most-stars-in-2013-github-octoverse/12483" }
131
- let(:discourse_topic_reply_url) { "https://meta.discourse.org/t/congratulations-most-stars-in-2013-github-octoverse/12483/2" }
132
- before do
133
- fake(discourse_topic_url, response('discourse_topic'))
134
- fake(discourse_topic_reply_url, response('discourse_topic_reply'))
135
- end
136
-
137
- it 'fetches opengraph data from original link' do
138
- onebox = described_class.new(discourse_topic_reply_url)
139
- expect(onebox.to_html).not_to be_nil
140
- expect(onebox.to_html).to include("Congratulations, most stars in 2013 GitHub Octoverse!")
141
- expect(onebox.to_html).to include("Thanks for that link and thank you -- and everyone else who is contributing to the project!")
142
- expect(onebox.to_html).to include("https://cdn-enterprise.discourse.org/meta/user_avatar/meta.discourse.org/codinghorror/200/5297_1.png")
143
- end
144
- end
145
- end
146
-
147
- describe 'to_html' do
148
- after(:each) do
149
- Onebox.options = Onebox::DEFAULTS
150
- end
151
-
152
- let(:original_link) { "http://www.dailymail.co.uk/pages/live/articles/news/news.html?in_article_id=479146&in_page_id=1770" }
153
- let(:redirect_link) { 'http://www.dailymail.co.uk/news/article-479146/Brutality-justice-The-truth-tarred-feathered-drug-dealer.html' }
154
-
155
- before do
156
- described_class.whitelist = %w(dailymail.co.uk discourse.org)
157
- FakeWeb.register_uri(
158
- :get,
159
- original_link,
160
- status: ["301", "Moved Permanently"],
161
- location: redirect_link
162
- )
163
- fake(redirect_link, response('dailymail'))
164
- end
165
-
166
- it "follows redirects and includes the summary" do
167
- Onebox.options = { redirect_limit: 2 }
168
- onebox = described_class.new(original_link)
169
- expect(onebox.to_html).to include("It was the most chilling image of the week")
170
- end
171
-
172
- it "recives an error with too many redirects" do
173
- Onebox.options = { redirect_limit: 1 }
174
- onebox = described_class.new(original_link)
175
- expect(onebox.to_html).to be_nil
176
- end
177
- end
178
-
179
- end