docbrown/spec/requests/universal_links_spec.rb
Michael Kohl 6dfabd578f
Rename SiteConfig to Settings::General (#13573)
* Rename SiteConfig

* More renaming

* Update spec

* Update mandatory settings mapping

* More renaming

* e2e test fixes

* You have a rename, and you have a rename

* Spec fix

* More changes

* Temporarily disable specs

* After-merge update

* Undo rename for migration

* undo rename of DUS

* Fix DUS

* Fix merge problem

* Remove redundant DUS

* Fix specs

* Remove unused code

* Change wrong class name

* More cleanup

* Re-add missing values to constant

* Fix constant

* Fix spec

* Remove obsolete fields

* Add accidentally removed field

* Update spec

* Move methods from Settings::General to ForemInstance

* Remove unneeded model

* Change mentions of 'site config'
2021-05-21 14:45:37 +02:00

54 lines
2 KiB
Ruby

require "rails_helper"
RSpec.describe "Universal Links (Apple)", type: :request do
let(:aasa_route) { "/.well-known/apple-app-site-association" }
let(:forem_app_id) { "R9SWHSQNV8.com.forem.app" }
let(:dev_app_id) { "R9SWHSQNV8.to.dev.ios" }
describe "returns a valid Apple App Site Association file" do
context "with DEV app backwards compatibility" do
it "responds with applinks support for both" do
allow(ForemInstance).to receive(:dev_to?).and_return(true)
get aasa_route
json_response = JSON.parse(response.body)
both_app_ids = [forem_app_id, dev_app_id]
expect(response).to have_http_status(:ok)
expect(json_response.dig("applinks", "apps")).to be_empty
json_response.dig("applinks", "details").each do |hash|
expect(both_app_ids).to include(hash["appID"])
expect(hash["paths"]).to match_array(["/*"])
end
end
end
context "when non-DEV Forem instance" do
it "responds with applinks support for Forem app" do
get aasa_route
json_response = JSON.parse(response.body)
expect(response).to have_http_status(:ok)
expect(json_response.dig("applinks", "apps")).to be_empty
json_response.dig("applinks", "details").each do |hash|
expect(hash["appID"]).to eq(forem_app_id)
expect(hash["paths"]).to match_array(["/*"])
end
end
end
context "when non-public Forem instance" do
it "responds with applinks support for Forem app", :aggregate_failures do
allow(Settings::UserExperience).to receive(:public).and_return(false)
get aasa_route
json_response = JSON.parse(response.body)
expect(response).to have_http_status(:ok)
expect(json_response.dig("applinks", "apps")).to be_empty
json_response.dig("applinks", "details").each do |hash|
expect(hash["appID"]).to eq(forem_app_id)
expect(hash["paths"]).to match_array(["/*"])
end
end
end
end
end