add validation for name, used and quantity
This commit is contained in:
parent
4b72d383ea
commit
e73baa2754
4 changed files with 25 additions and 4 deletions
|
|
@ -4,6 +4,24 @@ describe Resource do
|
|||
let(:conference) { create(:conference) }
|
||||
let(:resource) { create :resource }
|
||||
|
||||
it { is_expected.to validate_presence_of(:name) }
|
||||
|
||||
it { is_expected.to validate_presence_of(:used) }
|
||||
|
||||
it { is_expected.to validate_presence_of(:quantity) }
|
||||
|
||||
it { is_expected.to validate_numericality_of(:used) }
|
||||
|
||||
it { is_expected.to validate_numericality_of(:quantity) }
|
||||
|
||||
it { is_expected.not_to allow_value(-1).for(:used) }
|
||||
|
||||
it { is_expected.to allow_value(0).for(:used) }
|
||||
|
||||
it { is_expected.not_to allow_value(-1).for(:quantity) }
|
||||
|
||||
it { is_expected.to allow_value(0).for(:quantity) }
|
||||
|
||||
it 'has a valid factory' do
|
||||
expect(build(:resource)).to be_valid
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue