42 lines
1.2 KiB
Ruby
42 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require 'spec_helper'
|
|
|
|
RSpec.describe ResourceStateEvent, type: :model do
|
|
subject { build(:resource_state_event, issue: issue) }
|
|
|
|
let(:issue) { create(:issue) }
|
|
let(:merge_request) { create(:merge_request) }
|
|
|
|
it_behaves_like 'a resource event'
|
|
it_behaves_like 'a resource event for issues'
|
|
it_behaves_like 'a resource event for merge requests'
|
|
|
|
describe 'validations' do
|
|
describe 'Issuable validation' do
|
|
it 'is valid if an issue is set' do
|
|
subject.attributes = { issue: build_stubbed(:issue), merge_request: nil }
|
|
|
|
expect(subject).to be_valid
|
|
end
|
|
|
|
it 'is valid if a merge request is set' do
|
|
subject.attributes = { issue: nil, merge_request: build_stubbed(:merge_request) }
|
|
|
|
expect(subject).to be_valid
|
|
end
|
|
|
|
it 'is invalid if both issue and merge request are set' do
|
|
subject.attributes = { issue: build_stubbed(:issue), merge_request: build_stubbed(:merge_request) }
|
|
|
|
expect(subject).not_to be_valid
|
|
end
|
|
|
|
it 'is invalid if there is no issuable set' do
|
|
subject.attributes = { issue: nil, merge_request: nil }
|
|
|
|
expect(subject).not_to be_valid
|
|
end
|
|
end
|
|
end
|
|
end
|