When embedding a video in our site YouTube stores cookies in the user's computer that aren't necessary to watch the video, so we'd have to make people accept those cookies before letting them watch the video. Using a URL that doesn't use cookies, like mentioned in YouTube Help [1], is easier, though, and respects people's privacy without affecting the user experience. That I've found some references saying that youtube does store cookies once you hit the "play" button even when using the nocookie server [2]. Not sure whether that's an old behavior or I'm doing something wrong, but I don't see this is the case; even after playing the video, cookies aren't stored on my browser. [1] https://support.google.com/youtube/answer/171780#zippy=%2Cturn-on-privacy-enhanced-mode [2] https://www.cnet.com/news/privacy/youtubes-new-nocookie-feature-continues-to-serve-cookies/
44 lines
1.2 KiB
Ruby
44 lines
1.2 KiB
Ruby
require "rails_helper"
|
|
|
|
describe Shared::EmbeddedVideoComponent do
|
|
describe "src attribute" do
|
|
before do
|
|
dummy_class = Class.new do
|
|
include ActiveModel::Model
|
|
attr_accessor :title, :video_url
|
|
|
|
include Videoable
|
|
end
|
|
|
|
stub_const("DummyClass", dummy_class)
|
|
end
|
|
|
|
let(:record) { DummyClass.new(title: "Dummy Video", video_url: "") }
|
|
let(:component) { Shared::EmbeddedVideoComponent.new(record) }
|
|
|
|
it "does not render anything for empty URls" do
|
|
render_inline component
|
|
|
|
expect(page).not_to be_rendered
|
|
end
|
|
|
|
it "embeds a youtube video for youtube URLs" do
|
|
allow(record).to receive(:video_url).and_return "http://www.youtube.com/watch?v=a7UFm6ErMPU"
|
|
embed_url = "https://www.youtube-nocookie.com/embed/a7UFm6ErMPU"
|
|
|
|
render_inline component
|
|
|
|
expect(page).to have_css "[data-video-code*='src=\"#{embed_url}\"']"
|
|
end
|
|
|
|
it "embeds a vimeo video for vimeo URLs" do
|
|
allow(record).to receive(:video_url).and_return "https://vimeo.com/7232823"
|
|
embed_url = "https://player.vimeo.com/video/7232823"
|
|
|
|
render_inline component
|
|
|
|
expect(page).to have_css "[data-video-code*='src=\"#{embed_url}\"']"
|
|
end
|
|
end
|
|
end
|