Skip to content
This repository has been archived by the owner on May 14, 2022. It is now read-only.

Commit

Permalink
Merge pull request #85 from pulibrary/relax-code-validations
Browse files Browse the repository at this point in the history
Relax code format validation
  • Loading branch information
hackartisan committed Jan 21, 2021
2 parents 334da3b + dd75cd4 commit 8c6fe6e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 0 additions & 2 deletions app/models/concerns/locations/coded.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ module Coded
friendly_id :code
validates :code, presence: true
validates :code, uniqueness: true
validates_format_of :code, with: /\A[a-z][a-z0-9]{0,13}\Z/,
message: 'must be at least one character, all lowercase letters or numbers, and may not start with a number'
end
end
end
12 changes: 8 additions & 4 deletions spec/models/locations/library_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,20 @@ module Locations
end

describe 'code must follow naming conventions' do
it 'may not have spaces' do
# TODO: Update this test when gem is updated.
xit 'may not have spaces' do
expect {
FactoryGirl.create(:library, code: 'my code')
}.to raise_error ActiveRecord::RecordInvalid
end
it 'may not have capital letters' do
# TODO: Update this test when gem is updated.
xit 'may not have capital letters' do
expect {
FactoryGirl.create(:library, code: 'myCode')
}.to raise_error ActiveRecord::RecordInvalid
end
it 'may not start with a number' do
# TODO: Update this test when gem is updated.
xit 'may not start with a number' do
expect {
FactoryGirl.create(:library, code: '42mycode')
}.to raise_error ActiveRecord::RecordInvalid
Expand All @@ -60,7 +63,8 @@ module Locations
FactoryGirl.create(:library, code: 'cotsenresearch')
}.to_not raise_error
end
it 'code may not be more than 14 characters' do
# TODO: Update this test when gem is updated.
xit 'code may not be more than 14 characters' do
expect {
FactoryGirl.create(:library, code: 'thiscodeistooloong')
}.to raise_error ActiveRecord::RecordInvalid
Expand Down

0 comments on commit 8c6fe6e

Please sign in to comment.