Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -18,7 +20,8 @@
|
|||
require File.expand_path('../../../test_helper', __FILE__)
|
||||
|
||||
class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
||||
fixtures :projects,
|
||||
fixtures(
|
||||
:projects,
|
||||
:users,
|
||||
:roles,
|
||||
:members,
|
||||
|
@ -42,7 +45,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||
:journals,
|
||||
:journal_details,
|
||||
:queries,
|
||||
:attachments
|
||||
:attachments)
|
||||
|
||||
test "GET /issues.xml should contain metadata" do
|
||||
get '/issues.xml'
|
||||
|
@ -107,14 +110,14 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||
end
|
||||
|
||||
test "GET /issues.xml with custom field filter" do
|
||||
get '/issues.xml',
|
||||
:params => {:set_filter => 1, :f => ['cf_1'], :op => {:cf_1 => '='}, :v => {:cf_1 => ['MySQL']}}
|
||||
|
||||
get(
|
||||
'/issues.xml',
|
||||
:params => {:set_filter => 1, :f => ['cf_1'],
|
||||
:op => {:cf_1 => '='}, :v => {:cf_1 => ['MySQL']}})
|
||||
expected_ids = Issue.visible.
|
||||
joins(:custom_values).
|
||||
where(:custom_values => {:custom_field_id => 1, :value => 'MySQL'}).map(&:id)
|
||||
assert expected_ids.any?
|
||||
|
||||
assert_select 'issues > issue > id', :count => expected_ids.count do |ids|
|
||||
ids.each { |id| assert expected_ids.delete(id.children.first.content.to_i) }
|
||||
end
|
||||
|
@ -209,10 +212,10 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||
test "GET /issues/:id.xml with journals should format timestamps in ISO 8601" do
|
||||
get '/issues/1.xml?include=journals'
|
||||
|
||||
iso_date = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/
|
||||
assert_select 'issue>created_on', :text => iso_date
|
||||
assert_select 'issue>updated_on', :text => iso_date
|
||||
assert_select 'issue journal>created_on', :text => iso_date
|
||||
issue = Issue.find(1)
|
||||
assert_select 'issue>created_on', :text => issue.created_on.iso8601
|
||||
assert_select 'issue>updated_on', :text => issue.updated_on.iso8601
|
||||
assert_select 'issue journal>created_on', :text => issue.journals[0].created_on.iso8601
|
||||
end
|
||||
|
||||
test "GET /issues/:id.xml with custom fields" do
|
||||
|
@ -336,7 +339,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
assert_equal 2, json['issue']['children'].size
|
||||
assert_equal 1, json['issue']['children'].select {|child| child.key?('children')}.size
|
||||
assert_equal 1, json['issue']['children'].count {|child| child.key?('children')}
|
||||
end
|
||||
|
||||
test "GET /issues/:id.json with no spent time should return floats" do
|
||||
|
@ -403,9 +406,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||
parent = Issue.find(3)
|
||||
parent.update_columns :estimated_hours => 2.0
|
||||
child = Issue.generate!(:parent_issue_id => parent.id, :estimated_hours => 3.0)
|
||||
# remove permission!
|
||||
Role.anonymous.remove_permission! :view_time_entries
|
||||
#Role.all.each { |role| role.remove_permission! :view_time_entries }
|
||||
get '/issues/3.xml'
|
||||
|
||||
assert_equal 'application/xml', response.content_type
|
||||
|
@ -454,9 +455,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||
parent = Issue.find(3)
|
||||
parent.update_columns :estimated_hours => 2.0
|
||||
child = Issue.generate!(:parent_issue_id => parent.id, :estimated_hours => 3.0)
|
||||
# remove permission!
|
||||
Role.anonymous.remove_permission! :view_time_entries
|
||||
#Role.all.each { |role| role.remove_permission! :view_time_entries }
|
||||
get '/issues/3.json'
|
||||
|
||||
assert_equal 'application/json', response.content_type
|
||||
|
@ -484,26 +483,27 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||
end
|
||||
|
||||
test "POST /issues.xml should create an issue with the attributes" do
|
||||
|
||||
payload = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<issue>
|
||||
<project_id>1</project_id>
|
||||
<tracker_id>2</tracker_id>
|
||||
<status_id>3</status_id>
|
||||
<subject>API test</subject>
|
||||
</issue>
|
||||
XML
|
||||
|
||||
payload = <<~XML
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<issue>
|
||||
<project_id>1</project_id>
|
||||
<tracker_id>2</tracker_id>
|
||||
<status_id>3</status_id>
|
||||
<category_id>2</category_id>
|
||||
<subject>API test</subject>
|
||||
</issue>
|
||||
XML
|
||||
assert_difference('Issue.count') do
|
||||
post '/issues.xml',
|
||||
post(
|
||||
'/issues.xml',
|
||||
:params => payload,
|
||||
:headers => {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith')))
|
||||
end
|
||||
issue = Issue.order('id DESC').first
|
||||
assert_equal 1, issue.project_id
|
||||
assert_equal 2, issue.tracker_id
|
||||
assert_equal 3, issue.status_id
|
||||
assert_equal 2, issue.category_id
|
||||
assert_equal 'API test', issue.subject
|
||||
|
||||
assert_response :created
|
||||
|
@ -513,14 +513,15 @@ XML
|
|||
|
||||
test "POST /issues.xml with watcher_user_ids should create issue with watchers" do
|
||||
assert_difference('Issue.count') do
|
||||
post '/issues.xml',
|
||||
post(
|
||||
'/issues.xml',
|
||||
:params => {
|
||||
:issue => {
|
||||
:project_id => 1, :subject => 'Watchers',
|
||||
:tracker_id => 2, :status_id => 3, :watcher_user_ids => [3, 1]
|
||||
}
|
||||
},
|
||||
:headers => credentials('jsmith')
|
||||
:headers => credentials('jsmith'))
|
||||
assert_response :created
|
||||
end
|
||||
issue = Issue.order('id desc').first
|
||||
|
@ -530,46 +531,48 @@ XML
|
|||
|
||||
test "POST /issues.xml with failure should return errors" do
|
||||
assert_no_difference('Issue.count') do
|
||||
post '/issues.xml',
|
||||
post(
|
||||
'/issues.xml',
|
||||
:params => {:issue => {:project_id => 1}},
|
||||
:headers => credentials('jsmith')
|
||||
:headers => credentials('jsmith'))
|
||||
end
|
||||
|
||||
assert_select 'errors error', :text => "Subject cannot be blank"
|
||||
end
|
||||
|
||||
test "POST /issues.json should create an issue with the attributes" do
|
||||
|
||||
payload = <<-JSON
|
||||
{
|
||||
"issue": {
|
||||
"project_id": "1",
|
||||
"tracker_id": "2",
|
||||
"status_id": "3",
|
||||
"subject": "API test"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
payload = <<~JSON
|
||||
{
|
||||
"issue": {
|
||||
"project_id": "1",
|
||||
"tracker_id": "2",
|
||||
"status_id": "3",
|
||||
"category_id": "2",
|
||||
"subject": "API test"
|
||||
}
|
||||
}
|
||||
JSON
|
||||
assert_difference('Issue.count') do
|
||||
post '/issues.json',
|
||||
post(
|
||||
'/issues.json',
|
||||
:params => payload,
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith')))
|
||||
end
|
||||
|
||||
issue = Issue.order('id DESC').first
|
||||
assert_equal 1, issue.project_id
|
||||
assert_equal 2, issue.tracker_id
|
||||
assert_equal 3, issue.status_id
|
||||
assert_equal 2, issue.category_id
|
||||
assert_equal 'API test', issue.subject
|
||||
end
|
||||
|
||||
test "POST /issues.json should accept project identifier as project_id" do
|
||||
assert_difference('Issue.count') do
|
||||
post '/issues.json',
|
||||
post(
|
||||
'/issues.json',
|
||||
:params => {:issue => {:project_id => 'subproject1', :tracker_id => 2, :subject => 'Foo'}},
|
||||
:headers => credentials('jsmith')
|
||||
|
||||
:headers => credentials('jsmith'))
|
||||
assert_response :created
|
||||
end
|
||||
end
|
||||
|
@ -583,23 +586,21 @@ JSON
|
|||
:is_for_all => true,
|
||||
:trackers => Tracker.all.to_a
|
||||
)
|
||||
|
||||
payload = <<-JSON
|
||||
{
|
||||
"issue": {
|
||||
"project_id": "1",
|
||||
"subject": "Multivalued custom field",
|
||||
"custom_field_values":{"#{field.id}":["V1","V3"]}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
payload = <<~JSON
|
||||
{
|
||||
"issue": {
|
||||
"project_id": "1",
|
||||
"subject": "Multivalued custom field",
|
||||
"custom_field_values":{"#{field.id}":["V1","V3"]}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
assert_difference('Issue.count') do
|
||||
post '/issues.json',
|
||||
post(
|
||||
'/issues.json',
|
||||
:params => payload,
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith')))
|
||||
end
|
||||
|
||||
assert_response :created
|
||||
issue = Issue.order('id DESC').first
|
||||
assert_equal ["V1", "V3"], issue.custom_field_value(field).sort
|
||||
|
@ -607,51 +608,58 @@ JSON
|
|||
|
||||
test "POST /issues.json with omitted custom field should set default value" do
|
||||
field = IssueCustomField.generate!(:default_value => "Default")
|
||||
|
||||
issue = new_record(Issue) do
|
||||
post '/issues.json',
|
||||
:params => {:issue => {:project_id => 1, :subject => 'API', :custom_field_values => {}}},
|
||||
:headers => credentials('jsmith')
|
||||
post(
|
||||
'/issues.json',
|
||||
:params => {
|
||||
:issue => {:project_id => 1, :subject => 'API',
|
||||
:custom_field_values => {}}
|
||||
},
|
||||
:headers => credentials('jsmith'))
|
||||
end
|
||||
assert_equal "Default", issue.custom_field_value(field)
|
||||
end
|
||||
|
||||
test "POST /issues.json with custom field set to blank should not set default value" do
|
||||
field = IssueCustomField.generate!(:default_value => "Default")
|
||||
|
||||
issue = new_record(Issue) do
|
||||
post '/issues.json',
|
||||
:params => {:issue => {:project_id => 1, :subject => 'API', :custom_field_values => {field.id.to_s => ""}}},
|
||||
:headers => credentials('jsmith')
|
||||
post(
|
||||
'/issues.json',
|
||||
:params => {
|
||||
:issue => {:project_id => 1, :subject => 'API',
|
||||
:custom_field_values => {field.id.to_s => ""}}
|
||||
},
|
||||
:headers => credentials('jsmith'))
|
||||
end
|
||||
assert_equal "", issue.custom_field_value(field)
|
||||
end
|
||||
|
||||
test "POST /issues.json with failure should return errors" do
|
||||
assert_no_difference('Issue.count') do
|
||||
post '/issues.json',
|
||||
post(
|
||||
'/issues.json',
|
||||
:params => {:issue => {:project_id => 1}},
|
||||
:headers => credentials('jsmith')
|
||||
:headers => credentials('jsmith'))
|
||||
end
|
||||
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
assert json['errors'].include?("Subject cannot be blank")
|
||||
end
|
||||
|
||||
test "POST /issues.json with invalid project_id should respond with 422" do
|
||||
post '/issues.json',
|
||||
post(
|
||||
'/issues.json',
|
||||
:params => {:issue => {:project_id => 999, :subject => "API"}},
|
||||
:headers => credentials('jsmith')
|
||||
:headers => credentials('jsmith'))
|
||||
assert_response 422
|
||||
end
|
||||
|
||||
test "PUT /issues/:id.xml" do
|
||||
assert_difference('Journal.count') do
|
||||
put '/issues/6.xml',
|
||||
put(
|
||||
'/issues/6.xml',
|
||||
:params => {:issue => {:subject => 'API update', :notes => 'A new note'}},
|
||||
:headers => credentials('jsmith')
|
||||
:headers => credentials('jsmith'))
|
||||
end
|
||||
|
||||
issue = Issue.find(6)
|
||||
assert_equal "API update", issue.subject
|
||||
journal = Journal.last
|
||||
|
@ -659,14 +667,18 @@ JSON
|
|||
end
|
||||
|
||||
test "PUT /issues/:id.xml with custom fields" do
|
||||
put '/issues/3.xml',
|
||||
:params => {:issue => {:custom_fields => [
|
||||
{'id' => '1', 'value' => 'PostgreSQL' },
|
||||
{'id' => '2', 'value' => '150'}
|
||||
]}
|
||||
},
|
||||
:headers => credentials('jsmith')
|
||||
|
||||
put(
|
||||
'/issues/3.xml',
|
||||
:params =>
|
||||
{
|
||||
:issue => {
|
||||
:custom_fields => [
|
||||
{'id' => '1', 'value' => 'PostgreSQL' },
|
||||
{'id' => '2', 'value' => '150'}
|
||||
]
|
||||
}
|
||||
},
|
||||
:headers => credentials('jsmith'))
|
||||
issue = Issue.find(3)
|
||||
assert_equal '150', issue.custom_value_for(2).value
|
||||
assert_equal 'PostgreSQL', issue.custom_value_for(1).value
|
||||
|
@ -675,25 +687,28 @@ JSON
|
|||
test "PUT /issues/:id.xml with multi custom fields" do
|
||||
field = CustomField.find(1)
|
||||
field.update_attribute :multiple, true
|
||||
|
||||
put '/issues/3.xml',
|
||||
:params => {:issue => {:custom_fields => [
|
||||
{'id' => '1', 'value' => ['MySQL', 'PostgreSQL'] },
|
||||
{'id' => '2', 'value' => '150'}
|
||||
]}
|
||||
},
|
||||
:headers => credentials('jsmith')
|
||||
|
||||
put(
|
||||
'/issues/3.xml',
|
||||
:params =>
|
||||
{
|
||||
:issue => {
|
||||
:custom_fields => [
|
||||
{'id' => '1', 'value' => ['MySQL', 'PostgreSQL']},
|
||||
{'id' => '2', 'value' => '150'}
|
||||
]
|
||||
}
|
||||
},
|
||||
:headers => credentials('jsmith'))
|
||||
issue = Issue.find(3)
|
||||
assert_equal '150', issue.custom_value_for(2).value
|
||||
assert_equal ['MySQL', 'PostgreSQL'], issue.custom_field_value(1).sort
|
||||
end
|
||||
|
||||
test "PUT /issues/:id.xml with project change" do
|
||||
put '/issues/3.xml',
|
||||
put(
|
||||
'/issues/3.xml',
|
||||
:params => {:issue => {:project_id => 2, :subject => 'Project changed'}},
|
||||
:headers => credentials('jsmith')
|
||||
|
||||
:headers => credentials('jsmith'))
|
||||
issue = Issue.find(3)
|
||||
assert_equal 2, issue.project_id
|
||||
assert_equal 'Project changed', issue.subject
|
||||
|
@ -701,11 +716,11 @@ JSON
|
|||
|
||||
test "PUT /issues/:id.xml with notes only" do
|
||||
assert_difference('Journal.count') do
|
||||
put '/issues/6.xml',
|
||||
put(
|
||||
'/issues/6.xml',
|
||||
:params => {:issue => {:notes => 'Notes only'}},
|
||||
:headers => credentials('jsmith')
|
||||
:headers => credentials('jsmith'))
|
||||
end
|
||||
|
||||
journal = Journal.last
|
||||
assert_equal "Notes only", journal.notes
|
||||
end
|
||||
|
@ -714,13 +729,12 @@ JSON
|
|||
field = IssueCustomField.generate!(:default_value => "Default")
|
||||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {field.id.to_s => ""})
|
||||
assert_equal "", issue.reload.custom_field_value(field)
|
||||
|
||||
assert_difference('Journal.count') do
|
||||
put "/issues/#{issue.id}.json",
|
||||
put(
|
||||
"/issues/#{issue.id}.json",
|
||||
:params => {:issue => {:custom_field_values => {}, :notes => 'API'}},
|
||||
:headers => credentials('jsmith')
|
||||
:headers => credentials('jsmith'))
|
||||
end
|
||||
|
||||
assert_equal "", issue.reload.custom_field_value(field)
|
||||
end
|
||||
|
||||
|
@ -728,26 +742,24 @@ JSON
|
|||
field = IssueCustomField.generate!(:default_value => "Default")
|
||||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1, :custom_field_values => {field.id.to_s => ""})
|
||||
assert_equal "", issue.reload.custom_field_value(field)
|
||||
|
||||
assert_difference('Journal.count') do
|
||||
put "/issues/#{issue.id}.json",
|
||||
put(
|
||||
"/issues/#{issue.id}.json",
|
||||
:params => {:issue => {:custom_field_values => {field.id.to_s => ""}, :notes => 'API'}},
|
||||
:headers => credentials('jsmith')
|
||||
:headers => credentials('jsmith'))
|
||||
end
|
||||
|
||||
assert_equal "", issue.reload.custom_field_value(field)
|
||||
end
|
||||
|
||||
test "PUT /issues/:id.json with tracker change and omitted custom field specific to that tracker should set default value" do
|
||||
field = IssueCustomField.generate!(:default_value => "Default", :tracker_ids => [2])
|
||||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1)
|
||||
|
||||
assert_difference('Journal.count') do
|
||||
put "/issues/#{issue.id}.json",
|
||||
put(
|
||||
"/issues/#{issue.id}.json",
|
||||
:params => {:issue => {:tracker_id => 2, :custom_field_values => {}, :notes => 'API'}},
|
||||
:headers => credentials('jsmith')
|
||||
:headers => credentials('jsmith'))
|
||||
end
|
||||
|
||||
assert_equal 2, issue.reload.tracker_id
|
||||
assert_equal "Default", issue.reload.custom_field_value(field)
|
||||
end
|
||||
|
@ -755,43 +767,42 @@ JSON
|
|||
test "PUT /issues/:id.json with tracker change and custom field specific to that tracker set to blank should not set default value" do
|
||||
field = IssueCustomField.generate!(:default_value => "Default", :tracker_ids => [2])
|
||||
issue = Issue.generate!(:project_id => 1, :tracker_id => 1)
|
||||
|
||||
assert_difference('Journal.count') do
|
||||
put "/issues/#{issue.id}.json",
|
||||
put(
|
||||
"/issues/#{issue.id}.json",
|
||||
:params => {:issue => {:tracker_id => 2, :custom_field_values => {field.id.to_s => ""}, :notes => 'API'}},
|
||||
:headers => credentials('jsmith')
|
||||
:headers => credentials('jsmith'))
|
||||
end
|
||||
|
||||
assert_equal 2, issue.reload.tracker_id
|
||||
assert_equal "", issue.reload.custom_field_value(field)
|
||||
end
|
||||
|
||||
test "PUT /issues/:id.xml with failed update" do
|
||||
put '/issues/6.xml',
|
||||
put(
|
||||
'/issues/6.xml',
|
||||
:params => {:issue => {:subject => ''}},
|
||||
:headers => credentials('jsmith')
|
||||
|
||||
:headers => credentials('jsmith'))
|
||||
assert_response :unprocessable_entity
|
||||
assert_select 'errors error', :text => "Subject cannot be blank"
|
||||
end
|
||||
|
||||
test "PUT /issues/:id.xml with invalid assignee should return error" do
|
||||
user = User.generate!
|
||||
put '/issues/6.xml',
|
||||
put(
|
||||
'/issues/6.xml',
|
||||
:params => {:issue => {:assigned_to_id => user.id}},
|
||||
:headers => credentials('jsmith')
|
||||
|
||||
:headers => credentials('jsmith'))
|
||||
assert_response :unprocessable_entity
|
||||
assert_select 'errors error', :text => "Assignee is invalid"
|
||||
end
|
||||
|
||||
test "PUT /issues/:id.json" do
|
||||
assert_difference('Journal.count') do
|
||||
put '/issues/6.json',
|
||||
put(
|
||||
'/issues/6.json',
|
||||
:params => {:issue => {:subject => 'API update', :notes => 'A new note'}},
|
||||
:headers => credentials('jsmith')
|
||||
|
||||
assert_response :ok
|
||||
:headers => credentials('jsmith'))
|
||||
assert_response :no_content
|
||||
assert_equal '', response.body
|
||||
end
|
||||
|
||||
|
@ -802,10 +813,10 @@ JSON
|
|||
end
|
||||
|
||||
test "PUT /issues/:id.json with failed update" do
|
||||
put '/issues/6.json',
|
||||
put(
|
||||
'/issues/6.json',
|
||||
:params => {:issue => {:subject => ''}},
|
||||
:headers => credentials('jsmith')
|
||||
|
||||
:headers => credentials('jsmith'))
|
||||
assert_response :unprocessable_entity
|
||||
json = ActiveSupport::JSON.decode(response.body)
|
||||
assert json['errors'].include?("Subject cannot be blank")
|
||||
|
@ -815,7 +826,7 @@ JSON
|
|||
assert_difference('Issue.count', -1) do
|
||||
delete '/issues/6.xml', :headers => credentials('jsmith')
|
||||
|
||||
assert_response :ok
|
||||
assert_response :no_content
|
||||
assert_equal '', response.body
|
||||
end
|
||||
assert_nil Issue.find_by_id(6)
|
||||
|
@ -825,7 +836,7 @@ JSON
|
|||
assert_difference('Issue.count', -1) do
|
||||
delete '/issues/6.json', :headers => credentials('jsmith')
|
||||
|
||||
assert_response :ok
|
||||
assert_response :no_content
|
||||
assert_equal '', response.body
|
||||
end
|
||||
assert_nil Issue.find_by_id(6)
|
||||
|
@ -833,11 +844,11 @@ JSON
|
|||
|
||||
test "POST /issues/:id/watchers.xml should add watcher" do
|
||||
assert_difference 'Watcher.count' do
|
||||
post '/issues/1/watchers.xml',
|
||||
post(
|
||||
'/issues/1/watchers.xml',
|
||||
:params => {:user_id => 3},
|
||||
:headers => credentials('jsmith')
|
||||
|
||||
assert_response :ok
|
||||
:headers => credentials('jsmith'))
|
||||
assert_response :no_content
|
||||
assert_equal '', response.body
|
||||
end
|
||||
watcher = Watcher.order('id desc').first
|
||||
|
@ -851,7 +862,7 @@ JSON
|
|||
assert_difference 'Watcher.count', -1 do
|
||||
delete '/issues/1/watchers/3.xml', :headers => credentials('jsmith')
|
||||
|
||||
assert_response :ok
|
||||
assert_response :no_content
|
||||
assert_equal '', response.body
|
||||
end
|
||||
assert_equal false, Issue.find(1).watched_by?(User.find(3))
|
||||
|
@ -863,11 +874,14 @@ JSON
|
|||
|
||||
# create the issue with the upload's token
|
||||
assert_difference 'Issue.count' do
|
||||
post '/issues.xml',
|
||||
:params => {:issue => {:project_id => 1, :subject => 'Uploaded file',
|
||||
:uploads => [{:token => token, :filename => 'test.txt',
|
||||
:content_type => 'text/plain'}]}},
|
||||
:headers => credentials('jsmith')
|
||||
post(
|
||||
'/issues.xml',
|
||||
:params =>
|
||||
{:issue =>
|
||||
{:project_id => 1, :subject => 'Uploaded file',
|
||||
:uploads => [{:token => token, :filename => 'test.txt',
|
||||
:content_type => 'text/plain'}]}},
|
||||
:headers => credentials('jsmith'))
|
||||
assert_response :created
|
||||
end
|
||||
issue = Issue.order('id DESC').first
|
||||
|
@ -899,30 +913,29 @@ JSON
|
|||
def test_create_issue_with_multiple_uploaded_files_as_xml
|
||||
token1 = xml_upload('File content 1', credentials('jsmith'))
|
||||
token2 = xml_upload('File content 2', credentials('jsmith'))
|
||||
|
||||
payload = <<-XML
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<issue>
|
||||
<project_id>1</project_id>
|
||||
<tracker_id>1</tracker_id>
|
||||
<subject>Issue with multiple attachments</subject>
|
||||
<uploads type="array">
|
||||
<upload>
|
||||
<token>#{token1}</token>
|
||||
<filename>test1.txt</filename>
|
||||
</upload>
|
||||
<upload>
|
||||
<token>#{token2}</token>
|
||||
<filename>test1.txt</filename>
|
||||
</upload>
|
||||
</uploads>
|
||||
</issue>
|
||||
XML
|
||||
|
||||
payload = <<~XML
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<issue>
|
||||
<project_id>1</project_id>
|
||||
<tracker_id>1</tracker_id>
|
||||
<subject>Issue with multiple attachments</subject>
|
||||
<uploads type="array">
|
||||
<upload>
|
||||
<token>#{token1}</token>
|
||||
<filename>test1.txt</filename>
|
||||
</upload>
|
||||
<upload>
|
||||
<token>#{token2}</token>
|
||||
<filename>test1.txt</filename>
|
||||
</upload>
|
||||
</uploads>
|
||||
</issue>
|
||||
XML
|
||||
assert_difference 'Issue.count' do
|
||||
post '/issues.xml',
|
||||
post(
|
||||
'/issues.xml',
|
||||
:params => payload,
|
||||
:headers => {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/xml'}.merge(credentials('jsmith')))
|
||||
assert_response :created
|
||||
end
|
||||
issue = Issue.order('id DESC').first
|
||||
|
@ -932,25 +945,24 @@ XML
|
|||
def test_create_issue_with_multiple_uploaded_files_as_json
|
||||
token1 = json_upload('File content 1', credentials('jsmith'))
|
||||
token2 = json_upload('File content 2', credentials('jsmith'))
|
||||
|
||||
payload = <<-JSON
|
||||
{
|
||||
"issue": {
|
||||
"project_id": "1",
|
||||
"tracker_id": "1",
|
||||
"subject": "Issue with multiple attachments",
|
||||
"uploads": [
|
||||
{"token": "#{token1}", "filename": "test1.txt"},
|
||||
{"token": "#{token2}", "filename": "test2.txt"}
|
||||
]
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
payload = <<~JSON
|
||||
{
|
||||
"issue": {
|
||||
"project_id": "1",
|
||||
"tracker_id": "1",
|
||||
"subject": "Issue with multiple attachments",
|
||||
"uploads": [
|
||||
{"token": "#{token1}", "filename": "test1.txt"},
|
||||
{"token": "#{token2}", "filename": "test2.txt"}
|
||||
]
|
||||
}
|
||||
}
|
||||
JSON
|
||||
assert_difference 'Issue.count' do
|
||||
post '/issues.json',
|
||||
post(
|
||||
'/issues.json',
|
||||
:params => payload,
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith'))
|
||||
:headers => {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith')))
|
||||
assert_response :created
|
||||
end
|
||||
issue = Issue.order('id DESC').first
|
||||
|
@ -963,12 +975,16 @@ JSON
|
|||
|
||||
# update the issue with the upload's token
|
||||
assert_difference 'Journal.count' do
|
||||
put '/issues/1.xml',
|
||||
:params => {:issue => {:notes => 'Attachment added',
|
||||
:uploads => [{:token => token, :filename => 'test.txt',
|
||||
:content_type => 'text/plain'}]}},
|
||||
:headers => credentials('jsmith')
|
||||
assert_response :ok
|
||||
put(
|
||||
'/issues/1.xml',
|
||||
:params =>
|
||||
{:issue =>
|
||||
{:notes => 'Attachment added',
|
||||
:uploads =>
|
||||
[{:token => token, :filename => 'test.txt',
|
||||
:content_type => 'text/plain'}]}},
|
||||
:headers => credentials('jsmith'))
|
||||
assert_response :no_content
|
||||
assert_equal '', @response.body
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue