Welcome to mirror list, hosted at ThFree Co, Russian Federation.

issue_board_entity_spec.rb « serializers « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7a6a496912f695222da9fe84e9f306a1c24816a4 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe IssueBoardEntity do
  include Gitlab::Routing.url_helpers

  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) }

  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,
                               :labels, :assignees, project: hash_including(:id, :path, :path_with_namespace))
  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

  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

  describe 'type' do
    it 'has an issue type' do
      expect(subject[:type]).to eq('ISSUE')
    end
  end

  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) }

      it 'has a work item path' do
        expect(subject[:real_path]).to eq(project_work_items_path(project, resource.id))
      end
    end
  end
end