From a20ac20302f14e8cd14cd1abd6d02ddf528b58f5 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Thu, 31 Oct 2024 09:27:47 -0400 Subject: [PATCH] Add model spec for `Tombstone` (#32697) --- app/models/tombstone.rb | 2 ++ spec/fabricators/tombstone_fabricator.rb | 6 ++++++ spec/models/tombstone_spec.rb | 15 +++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 spec/fabricators/tombstone_fabricator.rb create mode 100644 spec/models/tombstone_spec.rb diff --git a/app/models/tombstone.rb b/app/models/tombstone.rb index bf666c43ac..92eddfc626 100644 --- a/app/models/tombstone.rb +++ b/app/models/tombstone.rb @@ -14,4 +14,6 @@ class Tombstone < ApplicationRecord belongs_to :account + + validates :uri, presence: true end diff --git a/spec/fabricators/tombstone_fabricator.rb b/spec/fabricators/tombstone_fabricator.rb new file mode 100644 index 0000000000..b4cab086af --- /dev/null +++ b/spec/fabricators/tombstone_fabricator.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +Fabricator(:tombstone) do + account + uri { sequence(:uri) { |i| "https://host.example/value/#{i}" } } +end diff --git a/spec/models/tombstone_spec.rb b/spec/models/tombstone_spec.rb new file mode 100644 index 0000000000..ba0603fe3d --- /dev/null +++ b/spec/models/tombstone_spec.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'rails_helper' + +RSpec.describe Tombstone do + describe 'Associations' do + it { is_expected.to belong_to(:account).required } + end + + describe 'Validations' do + subject { Fabricate.build :tombstone } + + it { is_expected.to validate_presence_of(:uri) } + end +end