File: process_assignees_spec.rb

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (96 lines) | stat: -rw-r--r-- 2,908 bytes parent folder | download
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe Issuable::ProcessAssignees, feature_category: :team_planning do
  describe '#execute' do
    it 'returns assignee_ids when add_assignee_ids and remove_assignee_ids are not specified' do
      process = described_class.new(
        assignee_ids: %w[5 7 9],
        add_assignee_ids: nil,
        remove_assignee_ids: nil,
        existing_assignee_ids: %w[1 3 9],
        extra_assignee_ids: %w[2 5 12]
      )
      result = process.execute

      expect(result).to contain_exactly(5, 7, 9)
    end

    it 'combines other ids when assignee_ids is nil' do
      process = described_class.new(
        assignee_ids: nil,
        add_assignee_ids: nil,
        remove_assignee_ids: nil,
        existing_assignee_ids: %w[1 3 11],
        extra_assignee_ids: %w[2 5 12]
      )
      result = process.execute

      expect(result).to contain_exactly(1, 2, 3, 5, 11, 12)
    end

    it 'combines other ids when both add_assignee_ids and remove_assignee_ids are not empty' do
      process = described_class.new(
        assignee_ids: %w[5 7 9],
        add_assignee_ids: %w[2 4 6],
        remove_assignee_ids: %w[4 7 11],
        existing_assignee_ids: %w[1 3 11],
        extra_assignee_ids: %w[2 5 12]
      )
      result = process.execute

      expect(result).to contain_exactly(1, 2, 3, 5, 6, 12)
    end

    it 'combines other ids when remove_assignee_ids is not empty' do
      process = described_class.new(
        assignee_ids: %w[5 7 9],
        add_assignee_ids: nil,
        remove_assignee_ids: %w[4 7 11],
        existing_assignee_ids: %w[1 3 11],
        extra_assignee_ids: %w[2 5 12]
      )
      result = process.execute

      expect(result).to contain_exactly(1, 2, 3, 5, 12)
    end

    it 'combines other ids when add_assignee_ids is not empty' do
      process = described_class.new(
        assignee_ids: %w[5 7 9],
        add_assignee_ids: %w[2 4 6],
        remove_assignee_ids: nil,
        existing_assignee_ids: %w[1 3 11],
        extra_assignee_ids: %w[2 5 12]
      )
      result = process.execute

      expect(result).to contain_exactly(1, 2, 4, 3, 5, 6, 11, 12)
    end

    it 'combines ids when existing_assignee_ids and extra_assignee_ids are omitted' do
      process = described_class.new(
        assignee_ids: %w[5 7 9],
        add_assignee_ids: %w[2 4 6],
        remove_assignee_ids: %w[4 7 11]
      )
      result = process.execute

      expect(result.sort).to eq([2, 6].sort)
    end

    it 'handles mixed string and integer arrays' do
      process = described_class.new(
        assignee_ids: %w[5 7 9],
        add_assignee_ids: [2, 4, 6],
        remove_assignee_ids: %w[4 7 11],
        existing_assignee_ids: [1, 3, 11],
        extra_assignee_ids: %w[2 5 12]
      )
      result = process.execute

      expect(result).to contain_exactly(1, 2, 3, 5, 6, 12)
    end
  end
end