Skip to content

Commit

Permalink
SiteSetting subtitle_text validations
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcwood committed Jul 22, 2020
1 parent a364c58 commit b11eea0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/site_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ class SiteSetting < ApplicationRecord

validates :header_text,
length: { maximum: 255, too_long: 'Header text cannot be longer than 255 charaters' }

validates :subtitle_text,
length: { maximum: 255, too_long: 'Subtitle text cannot be longer than 255 charaters' }

def update_required?(key, value)
self[key] != value
Expand Down
10 changes: 10 additions & 0 deletions spec/models/site_setting_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
end
end

describe 'Subtitle_text validations' do
it 'Max length' do
site_setting.subtitle_text = '0' * 256
expect(site_setting).to_not be_valid
expect(site_setting.errors.messages[:subtitle_text]).to eq(['Subtitle text cannot be longer than 255 charaters'])
site_setting.subtitle_text = '0' * 255
expect(site_setting).to be_valid
end
end

describe '#update_required?' do
it 'No update required' do
original_name = site_setting.name
Expand Down

0 comments on commit b11eea0

Please sign in to comment.