diff options
author | Thibaut Girka <thib@sitedethib.com> | 2019-01-16 14:20:07 +0100 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2019-01-16 14:20:07 +0100 |
commit | dbe311f0e97a79f7530c7fe10bcee8b9c70b9904 (patch) | |
tree | eb42d152d7204d4f109aee195037d82afd842b16 /spec | |
parent | 077639c27409f897e87522dd18a51801b6cbc40d (diff) | |
parent | 5363c724fc33e441cd4be22ba0e757b1ac4fd401 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: - config/locales/simple_form.pl.yml
Diffstat (limited to 'spec')
-rw-r--r-- | spec/fixtures/requests/oembed_json_empty.html | 7 | ||||
-rw-r--r-- | spec/rails_helper.rb | 1 | ||||
-rw-r--r-- | spec/services/fetch_oembed_service_spec.rb | 18 |
3 files changed, 25 insertions, 1 deletions
diff --git a/spec/fixtures/requests/oembed_json_empty.html b/spec/fixtures/requests/oembed_json_empty.html new file mode 100644 index 000000000..4b02413aa --- /dev/null +++ b/spec/fixtures/requests/oembed_json_empty.html @@ -0,0 +1,7 @@ +<!DOCTYPE html> +<html> + <head> + <link href='https://host.test/empty_provider.json' rel='alternate' type='application/json+oembed'> + </head> + <body></body> +</html> diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 1ded751ab..3a5e7491e 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -29,7 +29,6 @@ Devise::Test::ControllerHelpers.module_eval do value: resource.activate_session(warden.request), expires: 1.year.from_now, httponly: true, - same_site: :lax, } end end diff --git a/spec/services/fetch_oembed_service_spec.rb b/spec/services/fetch_oembed_service_spec.rb index 706eb3f2a..5789fb53b 100644 --- a/spec/services/fetch_oembed_service_spec.rb +++ b/spec/services/fetch_oembed_service_spec.rb @@ -8,6 +8,7 @@ describe FetchOEmbedService, type: :service do before do stub_request(:get, "https://host.test/provider.json").to_return(status: 404) stub_request(:get, "https://host.test/provider.xml").to_return(status: 404) + stub_request(:get, "https://host.test/empty_provider.json").to_return(status: 200) end describe 'discover_provider' do @@ -93,6 +94,23 @@ describe FetchOEmbedService, type: :service do expect(subject.call('https://host.test/oembed.html')).to be_nil end end + + context 'Empty JSON provider is discoverable' do + before do + stub_request(:get, 'https://host.test/oembed.html').to_return( + status: 200, + headers: { 'Content-Type': 'text/html' }, + body: request_fixture('oembed_json_empty.html') + ) + end + + it 'returns new OEmbed::Provider for JSON provider' do + subject.call('https://host.test/oembed.html') + expect(subject.endpoint_url).to eq 'https://host.test/empty_provider.json' + expect(subject.format).to eq :json + end + end + end context 'when status code is not 200' do |