make tests happy

This commit is contained in:
Florian Staudacher 2012-03-15 19:44:18 +01:00
parent e6b403434f
commit 7b4c377df1
2 changed files with 32 additions and 20 deletions

View file

@ -1,20 +1,27 @@
require 'oembed'
require 'uri'
OEmbedCubbies = OEmbed::Provider.new("http://cubbi.es/oembed")
OEmbed::Providers.register(
OEmbed::Providers::Youtube,
OEmbed::Providers::Vimeo,
OEmbed::Providers::Flickr,
OEmbed::Providers::SoundCloud,
OEmbedCubbies
)
OEmbed::Providers.register_fallback(OEmbed::ProviderDiscovery)
#
# SECURITY NOTICE! CROSS-SITE SCRIPTING!
# these endpoints may inject html code into our page
# note that 'trusted_endpoint_url' is the only information
# in OEmbed that we can trust. anything else may be spoofed!
OEmbedCubbies = OEmbed::Provider.new("http://cubbi.es/oembed")
oembed_provider_list = [
OEmbed::Providers::Youtube,
OEmbed::Providers::Vimeo,
OEmbed::Providers::Flickr,
OEmbed::Providers::SoundCloud,
OEmbedCubbies
]
SECURE_ENDPOINTS = oembed_provider_list.map do |provider|
OEmbed::Providers.register(provider)
provider.endpoint
end
OEmbed::Providers.register_fallback(OEmbed::ProviderDiscovery)
TRUSTED_OEMBED_PROVIDERS = OEmbed::Providers

View file

@ -320,19 +320,24 @@ STR
end
end
describe '#contains_url_in_text?' do
it 'returns an array of all urls found in the raw message' do
sm = Factory(:status_message, :text => 'http://youtube.com is so cool. so is https://joindiaspora.com')
sm.contains_oembed_url_in_text?.should_not be_nil
sm.oembed_url.should == 'http://youtube.com'
end
end
describe 'oembed' do
before do
@youtube_url = "https://www.youtube.com/watch?v=3PtFwlKfvHI"
@message_text = "#{@youtube_url} is so cool. so is this link -> https://joindiaspora.com"
end
it 'should queue a GatherOembedData if it includes a link' do
sm = Factory.build(:status_message, :text => 'http://youtube.com is so cool. so is https://joindiaspora.com')
sm = Factory.build(:status_message, :text => @message_text)
Resque.should_receive(:enqueue).with(Jobs::GatherOEmbedData, instance_of(Fixnum), instance_of(String))
sm.save
end
describe '#contains_oembed_url_in_text?' do
it 'returns the oembed urls found in the raw message' do
sm = Factory(:status_message, :text => @message_text)
sm.contains_oembed_url_in_text?.should_not be_nil
sm.oembed_url.should == @youtube_url
end
end
end
end