Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaideng123 <jaideng123@yahoo.com>2014-09-08 05:28:02 +0400
committerjaideng123 <jaideng123@yahoo.com>2014-09-08 05:28:02 +0400
commitd16eabae21f98ba570bf652cffadb3e82c6955e8 (patch)
treef210dee8fad64d3cccfa5e21fc10a7c62ea576bf /spec/workers
parent642e5ab45b1a011ac0ad6ff63f4786e2c2d51d30 (diff)
Added test for truncation to gather OG data spec
Diffstat (limited to 'spec/workers')
-rw-r--r--spec/workers/gather_open_graph_data_spec.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/spec/workers/gather_open_graph_data_spec.rb b/spec/workers/gather_open_graph_data_spec.rb
index 7c2397e4f..3416047c4 100644
--- a/spec/workers/gather_open_graph_data_spec.rb
+++ b/spec/workers/gather_open_graph_data_spec.rb
@@ -16,12 +16,25 @@ describe Workers::GatherOpenGraphData do
<meta property=\"og:description\" content=\"#{@ogsite_description}\" />
</head><body></body></html>"
+ @oglong_title = "D" * 256
+ @oglong_url = 'http://www.we-are-too-long.com'
+ @oglong_body =
+ "<html><head><title>#{@oglong_title}</title>
+ <meta property=\"og:title\" content=\"#{@oglong_title}\"/>
+ <meta property=\"og:type\" content=\"#{@ogsite_type}\" />
+ <meta property=\"og:image\" content=\"#{@ogsite_image}\" />
+ <meta property=\"og:url\" content=\"#{@oglong_url}\" />
+ <meta property=\"og:description\" content=\"#{@ogsite_description}\" />
+ </head><body></body></html>"
+
@no_open_graph_url = 'http://www.we-do-not-support-open-graph.com/index.html'
@status_message = FactoryGirl.create(:status_message)
stub_request(:get, @ogsite_url).to_return(:status => 200, :body => @ogsite_body)
stub_request(:get, @no_open_graph_url).to_return(:status => 200, :body => '<html><body>hello there</body></html>')
+ stub_request(:get, @oglong_url).to_return(:status => 200, :body => @oglong_body)
+
end
describe '.perform' do
@@ -65,5 +78,11 @@ describe Workers::GatherOpenGraphData do
Workers::GatherOpenGraphData.new.perform(0, @ogsite_url)
}.to_not raise_error
end
+ it 'truncates + inserts titles that are too long' do
+ Workers::GatherOpenGraphData.new.perform(@status_message.id, @oglong_url)
+ ogc = OpenGraphCache.find_by_url(@oglong_url)
+ expect(ogc).to be_truthy
+ expect(ogc.title.length).to be <= 255
+ end
end
end