-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds data constraints in package model.
- Loading branch information
1 parent
aa7ec8d
commit 4591920
Showing
5 changed files
with
106 additions
and
9 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
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe Package, type: :model do | ||
before do | ||
@package = FactoryBot.create(:package) | ||
end | ||
it 'has a valid factory' do | ||
expect(@package).to be_valid | ||
end | ||
it 'has an immutable package_id' do | ||
@package.update(package_id: 'id') | ||
expect { @package.save! }.to raise_error(ActiveRecord::RecordInvalid) | ||
end | ||
it 'adds an error when afs_path is not present for AFS data_pickup_type' do | ||
@package.update(afs_path: '') | ||
expect { @package.save! }.to raise_error(ActiveRecord::RecordInvalid) | ||
expect(@package).to_not be_valid | ||
end | ||
it 'adds an error when FTP information is not present for FTP data_pickup_type' do | ||
@package.update(data_pickup_type: 'FTP') | ||
@package.update(ftp_server: '') | ||
expect { @package.save! }.to raise_error(ActiveRecord::RecordInvalid) | ||
end | ||
it 'adds an error when AFS and FTP information is not present for FTP to AFS data_pickup_type' do | ||
@package.update(data_pickup_type: 'FTP to AFS') | ||
@package.update(afs_path: '') | ||
@package.update(ftp_server: '') | ||
expect { @package.save! }.to raise_error(ActiveRecord::RecordInvalid) | ||
end | ||
it 'adds an error when FTP to AFS download directory path is not present for FTP to AFS data_pickup_type' do | ||
@package.update(data_pickup_type: 'FTP to AFS') | ||
@package.update(put_file_loc: '') | ||
expect { @package.save! }.to raise_error(ActiveRecord::RecordInvalid) | ||
end | ||
it 'adds an error when match_opts is empty but proc_type is newmerge or mergeonly' do | ||
@package.update(match_opts: nil) | ||
expect { @package.save! }.to raise_error(ActiveRecord::RecordInvalid) | ||
end | ||
end |