Files
manyfold/spec/models/concerns/linkable_shared.rb
James Smith 6f55216dd3 Ignore all links to the local hostname
If we do need to link between models, we will do it with proper relationships.
2025-10-15 15:49:24 +01:00

16 lines
574 B
Ruby

shared_examples "Linkable" do
let!(:thing) { create(described_class.to_s.underscore.to_sym, links_attributes: [{url: "https://example.com"}]) }
it "can find by link" do
expect(described_class.linked_to("https://example.com").first).to eq thing
end
it "only matches exact link" do
expect(described_class.linked_to("https://example.com/nope").exists?).to be false
end
it "rejects self-referential links" do
expect { thing.update! links_attributes: [{url: Rails.application.routes.url_helpers.url_for(thing)}] }.not_to change(Link, :count)
end
end