docbrown/spec/requests/universal_links_spec.rb
Mac Siri 842e6880b8
Routine rubocop fix on /spec (#19217)
* Softrun rubocop

* Hardrun rubocop (-A)

* Change a rubocop rule

* Add missing cops

* Undo & redo rubocop -A
2023-03-21 09:55:26 -04:00

58 lines
2.2 KiB
Ruby

require "rails_helper"
RSpec.describe "Universal Links (Apple)" do
let(:aasa_route) { "/.well-known/apple-app-site-association" }
let(:forem_app_id) { "R9SWHSQNV8.com.forem.app" }
let(:expected_paths) { ["/*", "NOT /users/auth/*"] }
describe "returns a valid Apple App Site Association file" do
context "with multiple ConsumerApps" do
it "responds with applinks support for iOS apps only" do
# This iOS ConsumerApp should appear in the results
ios_app = create(:consumer_app, platform: Device::IOS)
# This Android ConsumerApp shouldn't appear in the results
create(:consumer_app, platform: Device::ANDROID)
get aasa_route
json_response = response.parsed_body
both_app_ids = [forem_app_id, ios_app.app_bundle]
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(expected_paths)
end
end
end
context "without any custom ConsumerApps" do
it "responds with applinks support for Forem app" do
get aasa_route
json_response = response.parsed_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(expected_paths)
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 = response.parsed_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(expected_paths)
end
end
end
end
end