mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 03:53:38 +08:00
493d437e79
* Remove outdated option
04078317ba
* Use the non-globally exposed RSpec syntax
https://github.com/rspec/rspec-core/pull/2803
* Use the non-globally exposed RSpec syntax, cont
https://github.com/rspec/rspec-core/pull/2803
* Comply to strict predicate matchers
See:
- https://github.com/rspec/rspec-expectations/pull/1195
- https://github.com/rspec/rspec-expectations/pull/1196
- https://github.com/rspec/rspec-expectations/pull/1277
39 lines
1.3 KiB
Ruby
39 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Onebox::Engine::AnimatedImageOnebox do
|
|
let(:giphy) { "http://gph.is/15bRbWf" }
|
|
let(:direct_gif) { "https://media4.giphy.com/media/Zatyu5LBO2zCyhiAAs/giphy.gif" }
|
|
let(:tenor) { "https://tenor.com/bb3fQ.gif" }
|
|
|
|
before do
|
|
@previous_options = Onebox.options.to_h
|
|
Onebox.options = { redirect_limit: 0 }
|
|
stub_request(:get, giphy).to_return(status: 200, body: onebox_response("giphy"))
|
|
stub_request(:get, direct_gif).to_return(status: 200, body: file_from_fixtures("animated.webp"))
|
|
stub_request(:get, tenor).to_return(status: 200, body: onebox_response("tenor"))
|
|
end
|
|
|
|
after do
|
|
Onebox.options = @previous_options
|
|
end
|
|
|
|
it "works for giphy short URLs" do
|
|
html = described_class.new(giphy).to_html
|
|
expect(html).to include("img")
|
|
expect(html).to include("class='animated onebox'")
|
|
end
|
|
|
|
it "works when the response is the image asset itself" do
|
|
html = described_class.new(direct_gif).to_html
|
|
expect(html).to include("img")
|
|
expect(html).to include("src='#{direct_gif}'")
|
|
expect(html).to include("class='animated onebox'")
|
|
end
|
|
|
|
it "works for tenor URLs" do
|
|
html = described_class.new(tenor).to_html
|
|
expect(html).to include("img")
|
|
expect(html).to include("class='animated onebox'")
|
|
end
|
|
end
|