mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-01 02:03:22 +00:00
Limit size to 20 char for the custom tab title
This commit is contained in:
@@ -3,5 +3,5 @@
|
||||
class CustomTab < ApplicationRecord
|
||||
belongs_to :enterprise, optional: false
|
||||
|
||||
validates :title, presence: true
|
||||
validates :title, presence: true, length: { maximum: 20 }
|
||||
end
|
||||
|
||||
@@ -9,5 +9,7 @@ describe CustomTab do
|
||||
|
||||
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
|
||||
|
||||
@@ -753,6 +753,15 @@ describe '
|
||||
expect(page).to have_content("Custom tab title can't be blank")
|
||||
expect(distributor1.reload.custom_tab).to be_nil
|
||||
end
|
||||
|
||||
it "can't save custom tab fields if title is too long" do
|
||||
fill_in "enterprise_custom_tab_attributes_title", with: "a" * 21
|
||||
fill_in_trix_editor "custom_tab_content", with: "Custom tab content"
|
||||
click_button 'Update'
|
||||
expect(page).
|
||||
to have_content("Custom tab title is too long (maximum is 20 characters)")
|
||||
expect(distributor1.reload.custom_tab).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context "when custom tab is already created" do
|
||||
|
||||
Reference in New Issue
Block a user