gitlab-org--gitlab-foss/spec/models/system_note_metadata_spec.rb

41 lines
965 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2017-03-15 09:18:44 -04:00
require 'spec_helper'
RSpec.describe SystemNoteMetadata do
2017-03-15 09:18:44 -04:00
describe 'associations' do
it { is_expected.to belong_to(:note) }
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) }
context 'when action type is invalid' do
2017-03-15 09:18:44 -04:00
subject do
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
%i[merge timeline_event].each do |action|
context 'when action type is valid' do
subject do
build(:system_note_metadata, note: build(:note), action: action)
end
it { is_expected.to be_valid }
end
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