app.kluk.fr/spec/requests/home_spec.rb
Christophe Robillard 279a31f7ce
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run
add OpenGraph tags and a share image
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 20:04:56 +02:00

23 lines
972 B
Ruby
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

require 'rails_helper'
describe "Home", type: :request do
describe "GET / on a public user's subdomain" do
let(:user) { create(:user, username: "alice", public: true) }
before { host! "#{user.username}.example.com" }
it "exposes OpenGraph tags for sharing" do
get root_path, params: { day: "2026-01-15" }
expect(response).to have_http_status(:ok)
page = Nokogiri::HTML(response.body)
meta = ->(attr, name) { page.at_css("meta[#{attr}='#{name}']")&.[]("content") }
expect(meta.("property", "og:title")).to eq("Comment ça Kluk chez alice\u202F?")
expect(meta.("property", "og:description")).to start_with("Les humeurs d’alice")
expect(meta.("property", "og:url")).to eq("http://alice.example.com/")
expect(meta.("property", "og:image")).to match(%r{\Ahttp://alice\.example\.com/assets/charte/partage-\h+\.png\z})
expect(meta.("name", "twitter:card")).to eq("summary_large_image")
end
end
end