2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe IssueBoardEntity do
|
2022-07-16 23:28:13 +05:30
|
|
|
include Gitlab::Routing.url_helpers
|
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
let_it_be(:project) { create(:project) }
|
|
|
|
let_it_be(:resource) { create(:issue, project: project) }
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
let_it_be(:milestone) { create(:milestone, project: project) }
|
|
|
|
let_it_be(:label) { create(:label, project: project, title: 'Test Label') }
|
2021-04-29 21:17:54 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
let(:request) { double('request', current_user: user) }
|
2019-02-15 15:39:39 +05:30
|
|
|
|
|
|
|
subject { described_class.new(resource, request: request).as_json }
|
|
|
|
|
|
|
|
it 'has basic attributes' do
|
2023-06-20 00:43:36 +05:30
|
|
|
expect(subject).to include(
|
|
|
|
:id, :iid, :title, :confidential, :due_date, :project_id, :relative_position,
|
|
|
|
:labels, :assignees, project: hash_including(:id, :path, :path_with_namespace)
|
|
|
|
)
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'has path and endpoints' do
|
2023-06-20 00:43:36 +05:30
|
|
|
expect(subject).to include(
|
|
|
|
:reference_path, :real_path, :issue_sidebar_endpoint,
|
|
|
|
:toggle_subscription_endpoint, :assignable_labels_endpoint
|
|
|
|
)
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'has milestone attributes' do
|
|
|
|
resource.milestone = milestone
|
|
|
|
|
|
|
|
expect(subject).to include(milestone: hash_including(:id, :title))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has assignee attributes' do
|
|
|
|
resource.assignees = [user]
|
|
|
|
|
|
|
|
expect(subject).to include(assignees: array_including(hash_including(:id, :name, :username, :avatar_url)))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has label attributes' do
|
|
|
|
resource.labels = [label]
|
|
|
|
|
|
|
|
expect(subject).to include(labels: array_including(hash_including(:id, :title, :color, :description, :text_color, :priority)))
|
|
|
|
end
|
2022-07-16 23:28:13 +05:30
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
describe 'type' do
|
|
|
|
it 'has an issue type' do
|
|
|
|
expect(subject[:type]).to eq('ISSUE')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-07-16 23:28:13 +05:30
|
|
|
describe 'real_path' do
|
|
|
|
it 'has an issue path' do
|
|
|
|
expect(subject[:real_path]).to eq(project_issue_path(project, resource.iid))
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when issue is of type task' do
|
|
|
|
let(:resource) { create(:issue, :task, project: project) }
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'has a work item path with iid' do
|
2023-07-09 08:55:56 +05:30
|
|
|
expect(subject[:real_path]).to eq(project_work_items_path(project, resource.iid))
|
2022-07-16 23:28:13 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-02-15 15:39:39 +05:30
|
|
|
end
|