")
+ cpp.post_process_oneboxes
end
- context "crawl_images is disabled" do
-
- before { SiteSetting.stubs(:crawl_images?).returns(false) }
-
- it "doesn't call FastImage" do
- FastImage.expects(:size).never
- cpp.get_size("http://foo.bar/image1.png").should == nil
- end
-
- it "is always allowed to crawl our own images" do
- store = {}
- Discourse.expects(:store).returns(store)
- store.expects(:has_been_uploaded?).returns(true)
- FastImage.expects(:size).returns([100, 200])
- cpp.get_size("http://foo.bar/image2.png").should == [100, 200]
- end
-
+ it "is dirty" do
+ cpp.should be_dirty
end
- it "caches the results" do
- SiteSetting.stubs(:crawl_images?).returns(true)
- FastImage.expects(:size).returns([200, 400])
- cpp.get_size("http://foo.bar/image3.png")
- cpp.get_size("http://foo.bar/image3.png").should == [200, 400]
+ it "inserts the onebox without wrapping p" do
+ cpp.html.should match_html "GANGNAM STYLE
"
end
end
- context "is_valid_image_uri?" do
+ context ".optimize_urls" do
+
+ let(:post) { build(:post_with_uploads_and_links) }
+ let(:cpp) { CookedPostProcessor.new(post) }
+
+ it "uses schemaless url for uploads" do
+ cpp.optimize_urls
+ cpp.html.should match_html ''
+ end
+
+ context "when CDN is enabled" do
+
+ it "uses schemaless CDN url for uploads" do
+ Rails.configuration.action_controller.stubs(:asset_host).returns("http://my.cdn.com")
+ cpp.optimize_urls
+ cpp.html.should match_html '
'
+ end
+
+ end
+
+ end
+
+ context ".pull_hotlinked_images" do
let(:post) { build(:post) }
let(:cpp) { CookedPostProcessor.new(post) }
- it "needs the scheme to be either http or https" do
- cpp.is_valid_image_uri?("http://domain.com").should == true
- cpp.is_valid_image_uri?("https://domain.com").should == true
- cpp.is_valid_image_uri?("ftp://domain.com").should == false
- cpp.is_valid_image_uri?("ftps://domain.com").should == false
- cpp.is_valid_image_uri?("//domain.com").should == false
- cpp.is_valid_image_uri?("/tmp/image.png").should == false
+ it "does not run when crawl images is disabled" do
+ SiteSetting.stubs(:crawl_images).returns(false)
+ Jobs.expects(:cancel_scheduled_job).never
+ cpp.pull_hotlinked_images
end
- it "doesn't throw an exception with a bad URI" do
- cpp.is_valid_image_uri?("http://do