mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-04 11:46:25 +08:00
fix sample types
This commit is contained in:
parent
dfd488fa96
commit
cd7ababab0
3 changed files with 23 additions and 1 deletions
5
spec/factories/sample_types.rb
Normal file
5
spec/factories/sample_types.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
FactoryGirl.define do
|
||||
factory :sample_type do
|
||||
name 'Sample type'
|
||||
end
|
||||
end
|
5
spec/factories/samples.rb
Normal file
5
spec/factories/samples.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
FactoryGirl.define do
|
||||
factory :sample do
|
||||
name 'Sample'
|
||||
end
|
||||
end
|
|
@ -22,11 +22,23 @@ describe SampleType, type: :model do
|
|||
end
|
||||
|
||||
describe 'Should be a valid object' do
|
||||
let(:team) { create :team }
|
||||
let!(:test_type) { create :sample_type, name: 'Sample one', team: team }
|
||||
|
||||
it { should validate_presence_of :name }
|
||||
it { should validate_presence_of :team }
|
||||
it do
|
||||
should validate_length_of(:name).is_at_most(Constants::NAME_MAX_LENGTH)
|
||||
end
|
||||
it { should validate_uniqueness_of(:name).scoped_to(:team).case_insensitive }
|
||||
|
||||
it 'should have uniq name scoped to team' do
|
||||
new_type = build :sample_type, name: 'Sample one', team: team
|
||||
expect(new_type).to_not be_valid
|
||||
end
|
||||
|
||||
it 'should not be case sensitive' do
|
||||
new_type = build :sample_type, name: 'SAMPLE ONE', team: team
|
||||
expect(new_type).to be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue