2018-05-07 16:47:29 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
2017-02-06 16:11:22 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
|
|
describe Resource do
|
|
|
|
|
let(:conference) { create(:conference) }
|
|
|
|
|
let(:resource) { create :resource }
|
|
|
|
|
|
2017-03-21 16:46:09 +05:30
|
|
|
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) }
|
|
|
|
|
|
2017-02-06 16:11:22 +05:30
|
|
|
it 'is not valid with used greater than quantity' do
|
|
|
|
|
resource.used = resource.quantity + 1
|
2022-03-30 12:39:01 +02:00
|
|
|
expect(resource.valid?).to be false
|
2017-02-06 16:11:22 +05:30
|
|
|
end
|
|
|
|
|
end
|