mirror of
https://github.com/manyfold3d/manyfold.git
synced 2026-10-22 03:32:18 -05:00
If we do need to link between models, we will do it with proper relationships.
16 lines
574 B
Ruby
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
|