summaryrefslogtreecommitdiff
path: root/spec/models/description_version_spec.rb
blob: 7c094f7a0a0aa09febf72fa33ab30253d1b357fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe DescriptionVersion do
  describe 'associations' do
    it { is_expected.to belong_to :issue }
    it { is_expected.to belong_to :merge_request }
  end

  describe 'validations' do
    describe 'exactly_one_issuable' do
      using RSpec::Parameterized::TableSyntax

      subject { described_class.new(issue_id: issue_id, merge_request_id: merge_request_id).valid? }

      where(:issue_id, :merge_request_id, :valid?) do
        nil | 1   | true
        1   | nil | true
        nil | nil | false
        1   | 1   | false
      end

      with_them do
        it { is_expected.to eq(valid?) }
      end
    end
  end
end