docbrown/spec/support/embeds_helpers.rb
Arit Amana e4446a778c
Revalidate embedded links that redirect (#17150)
* complete implementation and add specs

* delete irrelevant spec and comment

* refactor validate_link method to return passed-in url

* better naming

* handle NotAllowed status in link validation
2022-04-07 13:32:07 -04:00

22 lines
693 B
Ruby

module EmbedsHelpers
def stub_network_request(url:, method: :head, status_code: 200)
stub_request(method, url)
.with(
headers: {
Accept: "*/*",
"User-Agent": "#{Settings::Community.community_name} (#{URL.url})"
},
).to_return(status: status_code, body: "", headers: {})
end
def stub_metainspector_request(url, status_code = 200)
stub_request(:get, url)
.with(
headers: {
Accept: "*/*",
"Accept-Encoding": "identity",
"User-Agent": "MetaInspector/5.12.0 (+https://github.com/jaimeiniesta/metainspector)"
},
).to_return(status: status_code, body: "", headers: {})
end
end