mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 09:23:44 +08:00
283b08d45f
* Move onebox gem in core library * Update template file path * Remove warning for onebox gem caching * Remove onebox version file * Remove onebox gem * Add sanitize gem * Require onebox library in lazy-yt plugin * Remove onebox web specific code This code was used in standalone onebox Sinatra application * Merge Discourse specific AllowlistedGenericOnebox engine in core * Fix onebox engine filenames to match class name casing * Move onebox specs from gem into core * DEV: Rename `response` helper to `onebox_response` Fixes a naming collision. * Require rails_helper * Don't use `before/after(:all)` * Whitespace * Remove fakeweb * Remove poor unit tests * DEV: Re-add fakeweb, plugins are using it * Move onebox helpers * Stub Instagram API * FIX: Follow additional redirect status codes (#476) Don’t throw errors if we encounter 303, 307 or 308 HTTP status codes in responses * Remove an empty file * DEV: Update the license file Using the copy from https://choosealicense.com/licenses/gpl-2.0/# Hopefully this will enable GitHub to show the license UI? * DEV: Update embedded copyrights * DEV: Add Onebox copyright notice * DEV: Add MIT license, convert COPYRIGHT.txt to md * DEV: Remove an incorrect copyright claim Co-authored-by: Jarek Radosz <jradosz@gmail.com> Co-authored-by: jbrw <jamie@goatforce5.org>
59 lines
1.9 KiB
Ruby
59 lines
1.9 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require "rails_helper"
|
|
|
|
describe Onebox::Engine::KalturaOnebox do
|
|
let(:link) { 'https://videos.kaltura.com/id/0_e2ea6ygt' }
|
|
|
|
before do
|
|
stub_request(:get, link).to_return(status: 200, body: onebox_response('kaltura'))
|
|
end
|
|
|
|
shared_examples 'Pulling the width and height from OpenGraph' do
|
|
it 'Pulls the width from the OG video width' do
|
|
og_video_width = '534'
|
|
actual_width = inspect_html_fragment(html, tag_name, 'width')
|
|
|
|
expect(actual_width).to eq og_video_width
|
|
end
|
|
|
|
it 'Pulls the height from the OG video height' do
|
|
og_video_height = '300'
|
|
actual_height = inspect_html_fragment(html, tag_name, 'height')
|
|
|
|
expect(actual_height).to eq og_video_height
|
|
end
|
|
end
|
|
|
|
describe '#to_html' do
|
|
let(:html) { described_class.new(link).to_html }
|
|
let(:tag_name) { 'iframe' }
|
|
|
|
it_behaves_like 'Pulling the width and height from OpenGraph'
|
|
|
|
it 'Pulls the src from the OG view secure url' do
|
|
og_video_secure_url = 'https://cdnapisec.kaltura.com//p/811441/sp/81144100/embedIframeJs/uiconf_id/40430081/' \
|
|
'partner_id/811441?iframeembed=true&playerId=kaltura_playe' \
|
|
'r&entry_id=0_e2ea6ygt&widget_id=1_c6hc9mf5'
|
|
|
|
actual_src = inspect_html_fragment(html, tag_name, 'src')
|
|
|
|
expect(actual_src).to eq og_video_secure_url
|
|
end
|
|
end
|
|
|
|
describe '#placeholder_html' do
|
|
let(:html) { described_class.new(link).preview_html }
|
|
let(:tag_name) { 'img' }
|
|
|
|
it_behaves_like 'Pulling the width and height from OpenGraph'
|
|
|
|
it 'Pulls the thumbnail from the OG video thumbnail' do
|
|
og_video_thumbnail = 'https://cdnapisec.kaltura.com/p/811441/sp/81144100/thumbnail/entry_id/0_e2ea6ygt/width/534'
|
|
actual_thumbnail = inspect_html_fragment(html, tag_name, 'src')
|
|
|
|
expect(actual_thumbnail).to eq og_video_thumbnail
|
|
end
|
|
end
|
|
end
|