diff --git a/app/models/custom_tab.rb b/app/models/custom_tab.rb index aee8fab087..22058efcc1 100644 --- a/app/models/custom_tab.rb +++ b/app/models/custom_tab.rb @@ -2,4 +2,6 @@ class CustomTab < ApplicationRecord belongs_to :enterprise, optional: false + + validates :title, presence: true, length: { maximum: 20 } end diff --git a/spec/models/custom_tab_spec.rb b/spec/models/custom_tab_spec.rb index cad60ef8a2..f192068f63 100644 --- a/spec/models/custom_tab_spec.rb +++ b/spec/models/custom_tab_spec.rb @@ -6,4 +6,10 @@ describe CustomTab do describe 'associations' do it { is_expected.to belong_to(:enterprise).required } end + + describe 'validations' do + it { is_expected.to validate_presence_of(:title) } + + it { is_expected.to validate_length_of(:title).is_at_most(20) } + end end diff --git a/spec/system/admin/enterprises_spec.rb b/spec/system/admin/enterprises_spec.rb index 58e68d34f8..7a59620131 100644 --- a/spec/system/admin/enterprises_spec.rb +++ b/spec/system/admin/enterprises_spec.rb @@ -753,6 +753,25 @@ describe ' expect(distributor1.reload.custom_tab.content).to eq("