debian-mirror-gitlab/spec/models/system_note_metadata_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
965 B
Ruby
Raw Normal View History

2019-07-07 11:18:12 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe SystemNoteMetadata do
2017-08-17 22:00:37 +05:30
describe 'associations' do
it { is_expected.to belong_to(:note) }
2019-12-21 20:55:43 +05:30
it { is_expected.to belong_to(:description_version) }
2017-08-17 22:00:37 +05:30
end
describe 'validation' do
it { is_expected.to validate_presence_of(:note) }
context 'when action type is invalid' do
subject do
2021-02-22 17:27:13 +05:30
build(:system_note_metadata, note: build(:note), action: 'invalid_type')
2017-08-17 22:00:37 +05:30
end
it { is_expected.to be_invalid }
end
2022-07-16 23:28:13 +05:30
%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
2021-02-22 17:27:13 +05:30
2022-07-16 23:28:13 +05:30
it { is_expected.to be_valid }
end
2021-02-22 17:27:13 +05:30
end
context 'when importing' do
subject do
build(:system_note_metadata, note: nil, action: 'merge', importing: true)
2017-08-17 22:00:37 +05:30
end
it { is_expected.to be_valid }
end
end
end