From 9abbdbad2a4fc64bf76bdf7661c4a70c20165ee6 Mon Sep 17 00:00:00 2001 From: Chris Doyle Date: Mon, 23 May 2022 13:40:33 -0400 Subject: [PATCH] Require description --- Gemfile | 1 + Gemfile.lock | 3 +++ app/models/finding_aid.rb | 1 + spec/models/finding_aid_spec.rb | 5 ++++- spec/rails_helper.rb | 7 +++++++ 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 4959dbff5..a87d8b60b 100644 --- a/Gemfile +++ b/Gemfile @@ -96,4 +96,5 @@ group :test do gem "simplecov-lcov" gem "webmock" gem "launchy" + gem "shoulda-matchers", "~> 5.1" end diff --git a/Gemfile.lock b/Gemfile.lock index a9d2d4e3b..72c502838 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -512,6 +512,8 @@ GEM rubyzip (>= 1.2.2) semantic_range (3.0.0) shellany (0.0.1) + shoulda-matchers (5.1.0) + activesupport (>= 5.2.0) signet (0.16.1) addressable (~> 2.8) faraday (>= 0.17.5, < 3.0) @@ -660,6 +662,7 @@ DEPENDENCIES rubocop-rspec sass-rails (~> 6.0) selenium-webdriver + shoulda-matchers (~> 5.1) simple_form simplecov simplecov-lcov diff --git a/app/models/finding_aid.rb b/app/models/finding_aid.rb index 7ad2505a7..28840b39b 100644 --- a/app/models/finding_aid.rb +++ b/app/models/finding_aid.rb @@ -19,6 +19,7 @@ class FindingAid < ApplicationRecord has_rich_text :draft_description has_rich_text :covid_alert validates :collection_id, collection_or_subject: true + validates :description, presence: true scope :has_subjects, -> { where.not(subject: []) } scope :has_collections, -> { where.not(collections: []) } diff --git a/spec/models/finding_aid_spec.rb b/spec/models/finding_aid_spec.rb index 3c2497cfd..80baeed77 100644 --- a/spec/models/finding_aid_spec.rb +++ b/spec/models/finding_aid_spec.rb @@ -4,6 +4,10 @@ RSpec.describe FindingAid, type: :model do + describe "validations" do + it { should validate_presence_of(:description) } + end + describe "version all fields", :skip do # [TODO] create factory with default collection fields = { @@ -44,7 +48,6 @@ end end - describe "Scope" do describe ":with_subject" do before do diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 1432617ae..c909ebc85 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -93,4 +93,11 @@ end config.include ActionText::SystemTestHelper, type: :system + + Shoulda::Matchers.configure do |config| + config.integrate do |with| + with.test_framework :rspec + with.library :rails + end + end end