-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #325 from wearefuturegov/feature/fix-organisation-…
…name-requirement-bug Fix organisation name requirement bug
- Loading branch information
Showing
3 changed files
with
24 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,24 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Organisation, type: :model do | ||
it { should validate_presence_of :name } | ||
it { should validate_uniqueness_of :name } | ||
it { should allow_value(nil).for(:name) } | ||
it { should allow_value('Some Name').for(:name) } | ||
it { should validate_uniqueness_of(:name) } | ||
it { should validate_length_of(:name).is_at_least(2).is_at_most(100).allow_nil } | ||
|
||
# This tests the behavior that multiple organisations can have a nil name. | ||
it 'allows nil names' do | ||
first = Organisation.create!(name: nil) | ||
second = Organisation.new(name: nil) | ||
|
||
expect(second).to be_valid | ||
end | ||
|
||
|
||
it 'Does not allow duplicate names' do | ||
first = Organisation.create!(name: "Organisation 1") | ||
second = Organisation.new(name: "Organisation 1") | ||
|
||
expect(second).to be_invalid | ||
end | ||
end |