2019-03-30 03:23:56 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-03-15 09:18:44 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 02:09:01 -04:00
|
|
|
RSpec.describe SystemNoteMetadata do
|
2017-03-15 09:18:44 -04:00
|
|
|
describe 'associations' do
|
|
|
|
it { is_expected.to belong_to(:note) }
|
2019-10-18 07:11:44 -04:00
|
|
|
it { is_expected.to belong_to(:description_version) }
|
2017-03-15 09:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'validation' do
|
|
|
|
it { is_expected.to validate_presence_of(:note) }
|
|
|
|
|
2017-03-15 09:19:45 -04:00
|
|
|
context 'when action type is invalid' do
|
2017-03-15 09:18:44 -04:00
|
|
|
subject do
|
2020-11-23 16:09:19 -05:00
|
|
|
build(:system_note_metadata, note: build(:note), action: 'invalid_type')
|
2017-03-15 09:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to be_invalid }
|
|
|
|
end
|
|
|
|
|
2017-03-15 09:19:45 -04:00
|
|
|
context 'when action type is valid' do
|
2017-03-15 09:18:44 -04:00
|
|
|
subject do
|
2020-11-23 16:09:19 -05:00
|
|
|
build(:system_note_metadata, note: build(:note), action: 'merge')
|
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to be_valid }
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when importing' do
|
|
|
|
subject do
|
|
|
|
build(:system_note_metadata, note: nil, action: 'merge', importing: true)
|
2017-03-15 09:18:44 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
it { is_expected.to be_valid }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|