remove trailing white-spaces from test/integration/api_test/issues_test.rb.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6945 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-09-01 00:49:30 +00:00
parent 54ae8de42b
commit d51cc908fe

View File

@ -5,12 +5,12 @@
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -51,10 +51,10 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
# Use a private project to make sure auth is really working and not just # Use a private project to make sure auth is really working and not just
# only showing public issues. # only showing public issues.
should_allow_api_authentication(:get, "/projects/private-child/issues.xml") should_allow_api_authentication(:get, "/projects/private-child/issues.xml")
should "contain metadata" do should "contain metadata" do
get '/issues.xml' get '/issues.xml'
assert_tag :tag => 'issues', assert_tag :tag => 'issues',
:attributes => { :attributes => {
:type => 'array', :type => 'array',
@ -63,11 +63,11 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
:offset => 0 :offset => 0
} }
end end
context "with offset and limit" do context "with offset and limit" do
should "use the params" do should "use the params" do
get '/issues.xml?offset=2&limit=3' get '/issues.xml?offset=2&limit=3'
assert_equal 3, assigns(:limit) assert_equal 3, assigns(:limit)
assert_equal 2, assigns(:offset) assert_equal 2, assigns(:offset)
assert_tag :tag => 'issues', :children => {:count => 3, :only => {:tag => 'issue'}} assert_tag :tag => 'issues', :children => {:count => 3, :only => {:tag => 'issue'}}
@ -77,7 +77,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
context "with nometa param" do context "with nometa param" do
should "not contain metadata" do should "not contain metadata" do
get '/issues.xml?nometa=1' get '/issues.xml?nometa=1'
assert_tag :tag => 'issues', assert_tag :tag => 'issues',
:attributes => { :attributes => {
:type => 'array', :type => 'array',
@ -91,7 +91,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
context "with nometa header" do context "with nometa header" do
should "not contain metadata" do should "not contain metadata" do
get '/issues.xml', {}, {'X-Redmine-Nometa' => '1'} get '/issues.xml', {}, {'X-Redmine-Nometa' => '1'}
assert_tag :tag => 'issues', assert_tag :tag => 'issues',
:attributes => { :attributes => {
:type => 'array', :type => 'array',
@ -101,11 +101,11 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
} }
end end
end end
context "with relations" do context "with relations" do
should "display relations" do should "display relations" do
get '/issues.xml?include=relations' get '/issues.xml?include=relations'
assert_response :success assert_response :success
assert_equal 'application/xml', @response.content_type assert_equal 'application/xml', @response.content_type
assert_tag 'relations', assert_tag 'relations',
@ -120,11 +120,11 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
:children => {:count => 0} :children => {:count => 0}
end end
end end
context "with invalid query params" do context "with invalid query params" do
should "return errors" do should "return errors" do
get '/issues.xml', {:f => ['start_date'], :op => {:start_date => '='}} get '/issues.xml', {:f => ['start_date'], :op => {:start_date => '='}}
assert_response :unprocessable_entity assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => "Start date can't be blank"} assert_tag 'errors', :child => {:tag => 'error', :content => "Start date can't be blank"}
@ -140,7 +140,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
should "show only issues with the status_id" do should "show only issues with the status_id" do
get '/issues.xml?status_id=5' get '/issues.xml?status_id=5'
assert_tag :tag => 'issues', assert_tag :tag => 'issues',
:children => { :count => Issue.visible.count(:conditions => {:status_id => 5}), :children => { :count => Issue.visible.count(:conditions => {:status_id => 5}),
:only => { :tag => 'issue' } } :only => { :tag => 'issue' } }
end end
end end
@ -165,13 +165,13 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
context "/issues/6.json" do context "/issues/6.json" do
should_allow_api_authentication(:get, "/issues/6.json") should_allow_api_authentication(:get, "/issues/6.json")
end end
context "GET /issues/:id" do context "GET /issues/:id" do
context "with journals" do context "with journals" do
context ".xml" do context ".xml" do
should "display journals" do should "display journals" do
get '/issues/1.xml?include=journals' get '/issues/1.xml?include=journals'
assert_tag :tag => 'issue', assert_tag :tag => 'issue',
:child => { :child => {
:tag => 'journals', :tag => 'journals',
@ -200,13 +200,13 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
end end
end end
end end
context "with custom fields" do context "with custom fields" do
context ".xml" do context ".xml" do
should "display custom fields" do should "display custom fields" do
get '/issues/3.xml' get '/issues/3.xml'
assert_tag :tag => 'issue', assert_tag :tag => 'issue',
:child => { :child => {
:tag => 'custom_fields', :tag => 'custom_fields',
:attributes => { :type => 'array' }, :attributes => { :type => 'array' },
@ -219,19 +219,19 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
} }
} }
} }
assert_nothing_raised do assert_nothing_raised do
Hash.from_xml(response.body).to_xml Hash.from_xml(response.body).to_xml
end end
end end
end end
end end
context "with attachments" do context "with attachments" do
context ".xml" do context ".xml" do
should "display attachments" do should "display attachments" do
get '/issues/3.xml?include=attachments' get '/issues/3.xml?include=attachments'
assert_tag :tag => 'issue', assert_tag :tag => 'issue',
:child => { :child => {
:tag => 'attachments', :tag => 'attachments',
@ -251,19 +251,19 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
end end
end end
end end
context "with subtasks" do context "with subtasks" do
setup do setup do
@c1 = Issue.generate!(:status_id => 1, :subject => "child c1", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1) @c1 = Issue.generate!(:status_id => 1, :subject => "child c1", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1)
@c2 = Issue.generate!(:status_id => 1, :subject => "child c2", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1) @c2 = Issue.generate!(:status_id => 1, :subject => "child c2", :tracker_id => 1, :project_id => 1, :parent_issue_id => 1)
@c3 = Issue.generate!(:status_id => 1, :subject => "child c3", :tracker_id => 1, :project_id => 1, :parent_issue_id => @c1.id) @c3 = Issue.generate!(:status_id => 1, :subject => "child c3", :tracker_id => 1, :project_id => 1, :parent_issue_id => @c1.id)
end end
context ".xml" do context ".xml" do
should "display children" do should "display children" do
get '/issues/1.xml?include=children' get '/issues/1.xml?include=children'
assert_tag :tag => 'issue', assert_tag :tag => 'issue',
:child => { :child => {
:tag => 'children', :tag => 'children',
:children => {:count => 2}, :children => {:count => 2},
@ -285,11 +285,11 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
} }
} }
end end
context ".json" do context ".json" do
should "display children" do should "display children" do
get '/issues/1.json?include=children' get '/issues/1.json?include=children'
json = ActiveSupport::JSON.decode(response.body) json = ActiveSupport::JSON.decode(response.body)
assert_equal([ assert_equal([
{ {
@ -315,19 +315,19 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
assert_difference('Issue.count') do assert_difference('Issue.count') do
post '/issues.xml', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, :authorization => credentials('jsmith') post '/issues.xml', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, :authorization => credentials('jsmith')
end end
issue = Issue.first(:order => 'id DESC') issue = Issue.first(:order => 'id DESC')
assert_equal 1, issue.project_id assert_equal 1, issue.project_id
assert_equal 2, issue.tracker_id assert_equal 2, issue.tracker_id
assert_equal 3, issue.status_id assert_equal 3, issue.status_id
assert_equal 'API test', issue.subject assert_equal 'API test', issue.subject
assert_response :created assert_response :created
assert_equal 'application/xml', @response.content_type assert_equal 'application/xml', @response.content_type
assert_tag 'issue', :child => {:tag => 'id', :content => issue.id.to_s} assert_tag 'issue', :child => {:tag => 'id', :content => issue.id.to_s}
end end
end end
context "POST /issues.xml with failure" do context "POST /issues.xml with failure" do
should "have an errors tag" do should "have an errors tag" do
assert_no_difference('Issue.count') do assert_no_difference('Issue.count') do
@ -348,16 +348,16 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
assert_difference('Issue.count') do assert_difference('Issue.count') do
post '/issues.json', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, :authorization => credentials('jsmith') post '/issues.json', {:issue => {:project_id => 1, :subject => 'API test', :tracker_id => 2, :status_id => 3}}, :authorization => credentials('jsmith')
end end
issue = Issue.first(:order => 'id DESC') issue = Issue.first(:order => 'id DESC')
assert_equal 1, issue.project_id assert_equal 1, issue.project_id
assert_equal 2, issue.tracker_id assert_equal 2, issue.tracker_id
assert_equal 3, issue.status_id assert_equal 3, issue.status_id
assert_equal 'API test', issue.subject assert_equal 'API test', issue.subject
end end
end end
context "POST /issues.json with failure" do context "POST /issues.json with failure" do
should "have an errors element" do should "have an errors element" do
assert_no_difference('Issue.count') do assert_no_difference('Issue.count') do
@ -375,7 +375,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
@parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}} @parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}}
@headers = { :authorization => credentials('jsmith') } @headers = { :authorization => credentials('jsmith') }
end end
should_allow_api_authentication(:put, should_allow_api_authentication(:put,
'/issues/6.xml', '/issues/6.xml',
{:issue => {:subject => 'API update', :notes => 'A new note'}}, {:issue => {:subject => 'API update', :notes => 'A new note'}},
@ -395,37 +395,37 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
should "add the note to the journal" do should "add the note to the journal" do
put '/issues/6.xml', @parameters, @headers put '/issues/6.xml', @parameters, @headers
journal = Journal.last journal = Journal.last
assert_equal "A new note", journal.notes assert_equal "A new note", journal.notes
end end
should "update the issue" do should "update the issue" do
put '/issues/6.xml', @parameters, @headers put '/issues/6.xml', @parameters, @headers
issue = Issue.find(6) issue = Issue.find(6)
assert_equal "API update", issue.subject assert_equal "API update", issue.subject
end end
end end
context "PUT /issues/3.xml with custom fields" do context "PUT /issues/3.xml with custom fields" do
setup do setup do
@parameters = {:issue => {:custom_fields => [{'id' => '1', 'value' => 'PostgreSQL' }, {'id' => '2', 'value' => '150'}]}} @parameters = {:issue => {:custom_fields => [{'id' => '1', 'value' => 'PostgreSQL' }, {'id' => '2', 'value' => '150'}]}}
@headers = { :authorization => credentials('jsmith') } @headers = { :authorization => credentials('jsmith') }
end end
should "update custom fields" do should "update custom fields" do
assert_no_difference('Issue.count') do assert_no_difference('Issue.count') do
put '/issues/3.xml', @parameters, @headers put '/issues/3.xml', @parameters, @headers
end end
issue = Issue.find(3) issue = Issue.find(3)
assert_equal '150', issue.custom_value_for(2).value assert_equal '150', issue.custom_value_for(2).value
assert_equal 'PostgreSQL', issue.custom_value_for(1).value assert_equal 'PostgreSQL', issue.custom_value_for(1).value
end end
end end
context "PUT /issues/6.xml with failed update" do context "PUT /issues/6.xml with failed update" do
setup do setup do
@parameters = {:issue => {:subject => ''}} @parameters = {:issue => {:subject => ''}}
@ -456,7 +456,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
@parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}} @parameters = {:issue => {:subject => 'API update', :notes => 'A new note'}}
@headers = { :authorization => credentials('jsmith') } @headers = { :authorization => credentials('jsmith') }
end end
should_allow_api_authentication(:put, should_allow_api_authentication(:put,
'/issues/6.json', '/issues/6.json',
{:issue => {:subject => 'API update', :notes => 'A new note'}}, {:issue => {:subject => 'API update', :notes => 'A new note'}},
@ -476,20 +476,20 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
should "add the note to the journal" do should "add the note to the journal" do
put '/issues/6.json', @parameters, @headers put '/issues/6.json', @parameters, @headers
journal = Journal.last journal = Journal.last
assert_equal "A new note", journal.notes assert_equal "A new note", journal.notes
end end
should "update the issue" do should "update the issue" do
put '/issues/6.json', @parameters, @headers put '/issues/6.json', @parameters, @headers
issue = Issue.find(6) issue = Issue.find(6)
assert_equal "API update", issue.subject assert_equal "API update", issue.subject
end end
end end
context "PUT /issues/6.json with failed update" do context "PUT /issues/6.json with failed update" do
setup do setup do
@parameters = {:issue => {:subject => ''}} @parameters = {:issue => {:subject => ''}}
@ -526,7 +526,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
assert_difference('Issue.count',-1) do assert_difference('Issue.count',-1) do
delete '/issues/6.xml', {}, :authorization => credentials('jsmith') delete '/issues/6.xml', {}, :authorization => credentials('jsmith')
end end
assert_nil Issue.find_by_id(6) assert_nil Issue.find_by_id(6)
end end
end end
@ -541,7 +541,7 @@ class ApiTest::IssuesTest < ActionController::IntegrationTest
assert_difference('Issue.count',-1) do assert_difference('Issue.count',-1) do
delete '/issues/6.json', {}, :authorization => credentials('jsmith') delete '/issues/6.json', {}, :authorization => credentials('jsmith')
end end
assert_nil Issue.find_by_id(6) assert_nil Issue.find_by_id(6)
end end
end end