File: column_test.rb

package info (click to toggle)
redmine-plugin-redhopper 2.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 300 kB
  • sloc: ruby: 709; javascript: 76; makefile: 2
file content (94 lines) | stat: -rw-r--r-- 2,602 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
#
# Redhopper - Kanban boards for Redmine, inspired by Jira Agile (formerly known as
# Greenhopper), but following its own path.
# Copyright (C) 2015-2019 infoPiiaf <contact@infopiiaf.fr>
#
# This file is part of Redhopper.
#
# Redhopper is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# Redhopper is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Redhopper.  If not, see <http://www.gnu.org/licenses/>.
#
require File.expand_path('../../test_helper', __FILE__)

class ColumnTest < ActiveSupport::TestCase
  fixtures :issues

  setup do
    # Given
    @issue_status = IssueStatus.new name: 'To do'
    @column = Column.new @issue_status
  end

  test ".initialize with issue status" do
    # Then
    assert_not_nil @column
  end

  test ".issue_status returns the status from initialization" do
    # Given
    expected = @issue_status
    # When
    result = @column.issue_status
    # Then
    assert_equal expected, result
  end

  test ".unsorted_issues returns an empty array after initialization" do
    # Given
    expected = []
    # When
    result = @column.unsorted_issues
    # Then
    assert_equal expected, result
  end

  test ".sorted_issues returns an empty array after initialization" do
    # Given
    expected = []
    # When
    result = @column.sorted_issues
    # Then
    assert_equal expected, result
  end

  test ".<< adds Redhopper issues to unsorted section" do
    # Given
    kanban = RedhopperIssue.new
    expected = [kanban]
    # When
    @column << kanban && result = @column.unsorted_issues
    # Then
    assert_equal expected, result
  end

  test ".<< adds sortable Redhopper issues to sorted section" do
    # Given
    kanban = RedhopperIssue.create issue: Issue.first
    expected = [kanban]
    # When
    @column << kanban && result = @column.sorted_issues
    # Then
    assert_equal expected, result
  end

  test ".work_in_progress returns the count of issues in both sections" do
    # Given
    @column << RedhopperIssue.new
    @column << RedhopperIssue.create(issue: Issue.first)
    # When
    result = @column.work_in_progress
    # Then
    assert_equal 2, result
  end

end