gitlab-org--gitlab-foss/spec/serializers/issue_board_entity_spec.rb

43 lines
1.5 KiB
Ruby
Raw Normal View History

2018-12-03 10:23:38 -05:00
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe IssueBoardEntity do
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') }
let(:request) { double('request', current_user: user) }
2018-12-03 10:23:38 -05:00
subject { described_class.new(resource, request: request).as_json }
it 'has basic attributes' do
expect(subject).to include(:id, :iid, :title, :confidential, :due_date, :project_id, :relative_position,
2018-12-13 12:47:50 -05:00
:labels, :assignees, project: hash_including(:id, :path))
2018-12-03 10:23:38 -05:00
end
it 'has path and endpoints' do
expect(subject).to include(:reference_path, :real_path, :issue_sidebar_endpoint,
:toggle_subscription_endpoint, :assignable_labels_endpoint)
end
2018-12-13 12:47:50 -05:00
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
2018-12-03 10:23:38 -05:00
end