|
1 |
# frozen_string_literal: true
|
|
2 |
|
|
3 |
# Redmine - project management software
|
|
4 |
# Copyright (C) 2006-2022 Jean-Philippe Lang
|
|
5 |
#
|
|
6 |
# This program is free software; you can redistribute it and/or
|
|
7 |
# modify it under the terms of the GNU General Public License
|
|
8 |
# as published by the Free Software Foundation; either version 2
|
|
9 |
# of the License, or (at your option) any later version.
|
|
10 |
#
|
|
11 |
# This program is distributed in the hope that it will be useful,
|
|
12 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
# GNU General Public License for more details.
|
|
15 |
#
|
|
16 |
# You should have received a copy of the GNU General Public License
|
|
17 |
# along with this program; if not, write to the Free Software
|
|
18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
19 |
|
|
20 |
require File.expand_path('../../../test_helper', __FILE__)
|
|
21 |
|
|
22 |
class Redmine::ApiTest::JournalTest < Redmine::ApiTest::Base
|
|
23 |
fixtures :projects, :issues, :issue_statuses, :journals, :journal_details,
|
|
24 |
:issue_relations, :workflows,
|
|
25 |
:users, :members, :member_roles, :roles, :enabled_modules,
|
|
26 |
:groups_users, :email_addresses,
|
|
27 |
:enumerations,
|
|
28 |
:projects_trackers, :trackers, :custom_fields
|
|
29 |
|
|
30 |
test "PUT /journals/:id.xml with valid parameters should update the journal notes" do
|
|
31 |
put(
|
|
32 |
'/journals/1.xml',
|
|
33 |
params: {
|
|
34 |
journal: { notes: 'changed notes' }
|
|
35 |
},
|
|
36 |
headers: credentials('admin')
|
|
37 |
)
|
|
38 |
|
|
39 |
assert_response :no_content
|
|
40 |
assert_equal '', @response.body
|
|
41 |
|
|
42 |
journal = Journal.find(1)
|
|
43 |
assert_equal 'changed notes', journal.notes
|
|
44 |
end
|
|
45 |
|
|
46 |
test "PUT /journals/:id.json with valid parameters should update the journal notes" do
|
|
47 |
put(
|
|
48 |
'/journals/1.json',
|
|
49 |
params: {
|
|
50 |
journal: { notes: 'changed notes' }
|
|
51 |
},
|
|
52 |
headers: credentials('admin')
|
|
53 |
)
|
|
54 |
|
|
55 |
assert_response :no_content
|
|
56 |
assert_equal '', @response.body
|
|
57 |
|
|
58 |
journal = Journal.find(1)
|
|
59 |
assert_equal 'changed notes', journal.notes
|
|
60 |
end
|
|
61 |
|
|
62 |
test "PUT /journals/:id.xml without journal details should destroy journal" do
|
|
63 |
journal = Journal.find(5)
|
|
64 |
assert_equal [], journal.details
|
|
65 |
assert_difference('Journal.count', -1) do
|
|
66 |
put(
|
|
67 |
"/journals/#{journal.id}.xml",
|
|
68 |
params: {
|
|
69 |
journal: { notes: '' }
|
|
70 |
},
|
|
71 |
headers: credentials('admin')
|
|
72 |
)
|
|
73 |
end
|
|
74 |
assert_response :no_content
|
|
75 |
assert_equal '', @response.body
|
|
76 |
assert_nil Journal.find_by(id: 5)
|
|
77 |
end
|
|
78 |
|
|
79 |
test "PUT /journals/:id.json without journal details should destroy journal" do
|
|
80 |
journal = Journal.find(5)
|
|
81 |
assert_equal [], journal.details
|
|
82 |
assert_difference('Journal.count', -1) do
|
|
83 |
put(
|
|
84 |
"/journals/#{journal.id}.json",
|
|
85 |
params: {
|
|
86 |
journal: { notes: '' }
|
|
87 |
},
|
|
88 |
headers: credentials('admin')
|
|
89 |
)
|
|
90 |
end
|
|
91 |
assert_response :no_content
|
|
92 |
assert_equal '', @response.body
|
|
93 |
assert_nil Journal.find_by(id: 5)
|
|
94 |
end
|
|
95 |
end
|