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

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

42 lines
1.4 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe MergeRequestAssignee do
2022-01-26 12:08:38 +05:30
let(:assignee) { create(:user) }
2020-03-13 15:44:24 +05:30
let(:merge_request) { create(:merge_request) }
2022-01-26 12:08:38 +05:30
subject { merge_request.merge_request_assignees.build(assignee: assignee) }
2020-03-13 15:44:24 +05:30
describe 'associations' do
it { is_expected.to belong_to(:merge_request).class_name('MergeRequest') }
it { is_expected.to belong_to(:assignee).class_name('User') }
end
describe 'validations' do
it { is_expected.to validate_uniqueness_of(:assignee).scoped_to(:merge_request_id) }
end
2020-07-28 23:09:34 +05:30
describe 'scopes' do
let_it_be(:user) { create(:user) }
let_it_be(:project) { create(:project, :repository) }
let_it_be(:project_merge_request) { create(:merge_request, target_project: project, source_project: project, assignee_ids: [user.id]) }
before do
merge_request.update!(assignee_ids: [user.id])
end
context 'in_projects' do
it 'returns issue assignees for given project' do
expect(MergeRequestAssignee.count).to eq 2
assignees = MergeRequestAssignee.in_projects([project])
expect(assignees.count).to eq 1
expect(assignees.first.user_id).to eq project_merge_request.merge_request_assignees.first.user_id
expect(assignees.first.merge_request_id).to eq project_merge_request.merge_request_assignees.first.merge_request_id
end
end
end
2020-03-13 15:44:24 +05:30
end