Replaced remaining #assert_tag with #assert_select.

git-svn-id: http://svn.redmine.org/redmine/trunk@13624 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2014-11-22 09:38:21 +00:00
parent 3602cd637c
commit f3e573b5f8
52 changed files with 443 additions and 951 deletions

View File

@@ -40,19 +40,10 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
get '/attachments/7.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'attachment',
:child => {
:tag => 'id',
:content => '7',
:sibling => {
:tag => 'filename',
:content => 'archive.zip',
:sibling => {
:tag => 'content_url',
:content => 'http://www.example.com/attachments/download/7/archive.zip'
}
}
}
assert_select 'attachment id:content(7)' do
assert_select '~ filename', :text => 'archive.zip'
assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/7/archive.zip'
end
end
test "GET /attachments/:id.xml should deny access without credentials" do
@@ -142,7 +133,7 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
assert_no_difference 'Attachment.count' do
post '/uploads.xml', ('x' * 2048), {"CONTENT_TYPE" => 'application/octet-stream'}.merge(credentials('jsmith'))
assert_response 422
assert_tag 'error', :content => /exceeds the maximum allowed file size/
assert_select 'error', :text => /exceeds the maximum allowed file size/
end
end
end

View File

@@ -32,16 +32,14 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
get '/projects/1/issue_categories.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'issue_categories',
:child => {:tag => 'issue_category', :child => {:tag => 'id', :content => '2'}}
assert_select 'issue_categories issue_category id', :text => '2'
end
test "GET /issue_categories/:id.xml should return the issue category" do
get '/issue_categories/2.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'issue_category',
:child => {:tag => 'id', :content => '2'}
assert_select 'issue_category id', :text => '2'
end
test "POST /projects/:project_id/issue_categories.xml should return create issue category" do
@@ -63,7 +61,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
assert_select 'errors error', :text => "Name can't be blank"
end
test "PUT /issue_categories/:id.xml with valid parameters should update the issue category" do
@@ -82,7 +80,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
assert_select 'errors error', :text => "Name can't be blank"
end
test "DELETE /issue_categories/:id.xml should destroy the issue category" do

View File

@@ -37,15 +37,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'relations',
:attributes => { :type => 'array' },
:child => {
:tag => 'relation',
:child => {
:tag => 'id',
:content => '1'
}
}
assert_select 'relations[type=array] relation id', :text => '1'
end
test "POST /issues/:issue_id/relations.xml should create the relation" do
@@ -60,7 +52,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
assert_tag 'relation', :child => {:tag => 'id', :content => relation.id.to_s}
assert_select 'relation id', :text => relation.id.to_s
end
test "POST /issues/:issue_id/relations.xml with failure should return errors" do
@@ -69,7 +61,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
end
assert_response :unprocessable_entity
assert_tag :errors, :child => {:tag => 'error', :content => /relation_type is not included in the list/}
assert_select 'errors error', :text => /relation_type is not included in the list/
end
test "GET /relations/:id.xml should return the relation" do
@@ -77,7 +69,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag 'relation', :child => {:tag => 'id', :content => '2'}
assert_select 'relation id', :text => '2'
end
test "DELETE /relations/:id.xml should delete the relation" do

View File

@@ -29,18 +29,8 @@ class Redmine::ApiTest::IssueStatusesTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'issue_statuses',
:attributes => {:type => 'array'},
:child => {
:tag => 'issue_status',
:child => {
:tag => 'id',
:content => '2',
:sibling => {
:tag => 'name',
:content => 'Assigned'
}
}
}
assert_select 'issue_statuses[type=array] issue_status id:content(2)' do
assert_select '~ name', :text => 'Assigned'
end
end
end

View File

@@ -56,13 +56,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "contain metadata" do
get '/issues.xml'
assert_tag :tag => 'issues',
:attributes => {
:type => 'array',
:total_count => assigns(:issue_count),
:limit => 25,
:offset => 0
}
assert_select 'issues[type=array][total_count=?][limit="25"][offset="0"]', assigns(:issue_count).to_s
end
context "with offset and limit" do
@@ -71,7 +65,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
assert_equal 3, assigns(:limit)
assert_equal 2, assigns(:offset)
assert_tag :tag => 'issues', :children => {:count => 3, :only => {:tag => 'issue'}}
assert_select 'issues issue', 3
end
end
@@ -79,13 +73,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "not contain metadata" do
get '/issues.xml?nometa=1'
assert_tag :tag => 'issues',
:attributes => {
:type => 'array',
:total_count => nil,
:limit => nil,
:offset => nil
}
assert_select 'issues[type=array]:not([total_count]):not([limit]):not([offset])'
end
end
@@ -93,13 +81,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "not contain metadata" do
get '/issues.xml', {}, {'X-Redmine-Nometa' => '1'}
assert_tag :tag => 'issues',
:attributes => {
:type => 'array',
:total_count => nil,
:limit => nil,
:offset => nil
}
assert_select 'issues[type=array]:not([total_count]):not([limit]):not([offset])'
end
end
@@ -109,17 +91,16 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag 'relations',
:parent => {:tag => 'issue', :child => {:tag => 'id', :content => '3'}},
:children => {:count => 1},
:child => {
:tag => 'relation',
:attributes => {:id => '2', :issue_id => '2', :issue_to_id => '3',
:relation_type => 'relates'}
}
assert_tag 'relations',
:parent => {:tag => 'issue', :child => {:tag => 'id', :content => '1'}},
:children => {:count => 0}
assert_select 'issue id:content(3)' do
assert_select '~ relations relation', 1
assert_select '~ relations relation[id="2"][issue_id="2"][issue_to_id="3"][relation_type=relates]'
end
assert_select 'issue id:content(1)' do
assert_select '~ relations'
assert_select '~ relations relation', 0
end
end
end
@@ -129,7 +110,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => "Start date can't be blank"}
assert_select 'errors error', :text => "Start date can't be blank"
end
end
@@ -233,31 +214,16 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "display journals" do
get '/issues/1.xml?include=journals'
assert_tag :tag => 'issue',
:child => {
:tag => 'journals',
:attributes => { :type => 'array' },
:child => {
:tag => 'journal',
:attributes => { :id => '1'},
:child => {
:tag => 'details',
:attributes => { :type => 'array' },
:child => {
:tag => 'detail',
:attributes => { :name => 'status_id' },
:child => {
:tag => 'old_value',
:content => '1',
:sibling => {
:tag => 'new_value',
:content => '2'
}
}
}
}
}
}
assert_select 'issue journals[type=array]' do
assert_select 'journal[id="1"]' do
assert_select 'details[type=array]' do
assert_select 'detail[name=status_id]' do
assert_select 'old_value', :text => '1'
assert_select 'new_value', :text => '2'
end
end
end
end
end
end
end
@@ -267,19 +233,11 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "display custom fields" do
get '/issues/3.xml'
assert_tag :tag => 'issue',
:child => {
:tag => 'custom_fields',
:attributes => { :type => 'array' },
:child => {
:tag => 'custom_field',
:attributes => { :id => '1'},
:child => {
:tag => 'value',
:content => 'MySQL'
}
}
}
assert_select 'issue custom_fields[type=array]' do
assert_select 'custom_field[id="1"]' do
assert_select 'value', :text => 'MySQL'
end
end
assert_nothing_raised do
Hash.from_xml(response.body).to_xml
@@ -301,20 +259,12 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "display custom fields" do
get '/issues/3.xml'
assert_response :success
assert_tag :tag => 'issue',
:child => {
:tag => 'custom_fields',
:attributes => { :type => 'array' },
:child => {
:tag => 'custom_field',
:attributes => { :id => '1'},
:child => {
:tag => 'value',
:attributes => { :type => 'array' },
:children => { :count => 2 }
}
}
}
assert_select 'issue custom_fields[type=array]' do
assert_select 'custom_field[id="1"]' do
assert_select 'value[type=array] value', 2
end
end
xml = Hash.from_xml(response.body)
custom_fields = xml['issue']['custom_fields']
@@ -351,21 +301,12 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
context ".xml" do
should "display custom fields" do
get '/issues/3.xml'
assert_response :success
assert_tag :tag => 'issue',
:child => {
:tag => 'custom_fields',
:attributes => { :type => 'array' },
:child => {
:tag => 'custom_field',
:attributes => { :id => '1'},
:child => {
:tag => 'value',
:attributes => { :type => 'array' },
:children => { :count => 0 }
}
}
}
assert_select 'issue custom_fields[type=array]' do
assert_select 'custom_field[id="1"]' do
assert_select 'value[type=array]:empty'
end
end
xml = Hash.from_xml(response.body)
custom_fields = xml['issue']['custom_fields']
@@ -395,22 +336,13 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "display attachments" do
get '/issues/3.xml?include=attachments'
assert_tag :tag => 'issue',
:child => {
:tag => 'attachments',
:children => {:count => 5},
:child => {
:tag => 'attachment',
:child => {
:tag => 'filename',
:content => 'source.rb',
:sibling => {
:tag => 'content_url',
:content => 'http://www.example.com/attachments/download/4/source.rb'
}
}
}
}
assert_select 'issue attachments[type=array]' do
assert_select 'attachment', 5
assert_select 'attachment id:content(4)' do
assert_select '~ filename', :text => 'source.rb'
assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/4/source.rb'
end
end
end
end
end
@@ -438,27 +370,15 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "display children" do
get '/issues/1.xml?include=children'
assert_tag :tag => 'issue',
:child => {
:tag => 'children',
:children => {:count => 2},
:child => {
:tag => 'issue',
:attributes => {:id => @c1.id.to_s},
:child => {
:tag => 'subject',
:content => 'child c1',
:sibling => {
:tag => 'children',
:children => {:count => 1},
:child => {
:tag => 'issue',
:attributes => {:id => @c3.id.to_s}
}
}
}
}
}
assert_select 'issue children[type=array]' do
assert_select 'issue', 2
assert_select 'issue[id=?]', @c1.id.to_s do
assert_select 'subject', :text => 'child c1'
assert_select 'children' do
assert_select 'issue[id=?]', @c3.id.to_s
end
end
end
end
context ".json" do
@@ -522,7 +442,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
assert_tag 'issue', :child => {:tag => 'id', :content => issue.id.to_s}
assert_select 'issue > id', :text => issue.id.to_s
end
end
@@ -544,7 +464,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
post '/issues.xml', {:issue => {:project_id => 1}}, credentials('jsmith')
end
assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
assert_select 'errors error', :text => "Subject can't be blank"
end
end
@@ -698,7 +618,7 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
should "have an errors tag" do
put '/issues/6.xml', @parameters, credentials('jsmith')
assert_tag :errors, :child => {:tag => 'error', :content => "Subject can't be blank"}
assert_select 'errors error', :text => "Subject can't be blank"
end
end

View File

@@ -29,26 +29,10 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'memberships',
:attributes => {:type => 'array'},
:child => {
:tag => 'membership',
:child => {
:tag => 'id',
:content => '2',
:sibling => {
:tag => 'user',
:attributes => {:id => '3', :name => 'Dave Lopper'},
:sibling => {
:tag => 'roles',
:child => {
:tag => 'role',
:attributes => {:id => '2', :name => 'Developer'}
}
}
}
}
}
assert_select 'memberships[type=array] membership id:content(2)' do
assert_select '~ user[id=3][name=Dave Lopper]'
assert_select '~ roles role[id=2][name=Developer]'
end
end
test "GET /projects/:project_id/memberships.json should return memberships" do
@@ -105,7 +89,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => "Principal can't be blank"}
assert_select 'errors error', :text => "Principal can't be blank"
end
end
@@ -114,22 +98,10 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'membership',
:child => {
:tag => 'id',
:content => '2',
:sibling => {
:tag => 'user',
:attributes => {:id => '3', :name => 'Dave Lopper'},
:sibling => {
:tag => 'roles',
:child => {
:tag => 'role',
:attributes => {:id => '2', :name => 'Developer'}
}
}
}
}
assert_select 'membership id:content(2)' do
assert_select '~ user[id=3][name=Dave Lopper]'
assert_select '~ roles role[id=2][name=Developer]'
end
end
test "GET /memberships/:id.json should return the membership" do
@@ -165,7 +137,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => /role can't be empty/i}
assert_select 'errors error', :text => "Role can't be empty"
end
test "DELETE /memberships/:id.xml should destroy the membership" do

View File

@@ -37,15 +37,7 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
test "GET /news.xml should return news" do
get '/news.xml'
assert_tag :tag => 'news',
:attributes => {:type => 'array'},
:child => {
:tag => 'news',
:child => {
:tag => 'id',
:content => '2'
}
}
assert_select 'news[type=array] news id', :text => '2'
end
test "GET /news.json should return news" do
@@ -61,15 +53,7 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
test "GET /projects/:project_id/news.xml should return news" do
get '/projects/ecookbook/news.xml'
assert_tag :tag => 'news',
:attributes => {:type => 'array'},
:child => {
:tag => 'news',
:child => {
:tag => 'id',
:content => '2'
}
}
assert_select 'news[type=array] news id', :text => '2'
end
test "GET /projects/:project_id/news.json should return news" do

View File

@@ -71,15 +71,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag 'issue_categories',
:attributes => {:type => 'array'},
:child => {
:tag => 'issue_category',
:attributes => {
:id => '2',
:name => 'Recipes'
}
}
assert_select 'issue_categories[type=array] issue_category[id=2][name=Recipes]'
end
test "GET /projects.xml with include=trackers should return trackers" do
@@ -87,15 +79,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag 'trackers',
:attributes => {:type => 'array'},
:child => {
:tag => 'tracker',
:attributes => {
:id => '2',
:name => 'Feature request'
}
}
assert_select 'trackers[type=array] tracker[id=2][name=Feature request]'
end
test "GET /projects.xml with include=enabled_modules should return enabled modules" do
@@ -103,14 +87,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag 'enabled_modules',
:attributes => {:type => 'array'},
:child => {
:tag => 'enabled_module',
:attributes => {
:name => 'issue_tracking'
}
}
assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]'
end
test "GET /projects/:id.xml should return the project" do
@@ -123,8 +100,8 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_select 'project>is_public', :text => 'true'
assert_select 'custom_field[name=Development status]', :text => 'Stable'
assert_no_tag 'trackers'
assert_no_tag 'issue_categories'
assert_select 'trackers', 0
assert_select 'issue_categories', 0
end
test "GET /projects/:id.json should return the project" do
@@ -143,8 +120,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_no_tag 'custom_field',
:attributes => {:name => 'Development status'}
assert_select 'custom_field[name=?]', 'Development status', 0
end
test "GET /projects/:id.xml with include=issue_categories should return categories" do
@@ -152,15 +128,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag 'issue_categories',
:attributes => {:type => 'array'},
:child => {
:tag => 'issue_category',
:attributes => {
:id => '2',
:name => 'Recipes'
}
}
assert_select 'issue_categories[type=array] issue_category[id=2][name=Recipes]'
end
test "GET /projects/:id.xml with include=trackers should return trackers" do
@@ -168,15 +136,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag 'trackers',
:attributes => {:type => 'array'},
:child => {
:tag => 'tracker',
:attributes => {
:id => '2',
:name => 'Feature request'
}
}
assert_select 'trackers[type=array] tracker[id=2][name=Feature request]'
end
test "GET /projects/:id.xml with include=enabled_modules should return enabled modules" do
@@ -184,14 +144,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag 'enabled_modules',
:attributes => {:type => 'array'},
:child => {
:tag => 'enabled_module',
:attributes => {
:name => 'issue_tracking'
}
}
assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]'
end
test "POST /projects.xml with valid parameters should create the project" do
@@ -211,7 +164,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
assert_tag 'project', :child => {:tag => 'id', :content => project.id.to_s}
assert_select 'project id', :text => project.id.to_s
end
test "POST /projects.xml should accept enabled_module_names attribute" do
@@ -243,7 +196,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => "Identifier can't be blank"}
assert_select 'errors error', :text => "Identifier can't be blank"
end
test "PUT /projects/:id.xml with valid parameters should update the project" do
@@ -284,7 +237,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
assert_select 'errors error', :text => "Name can't be blank"
end
test "DELETE /projects/:id.xml should delete the project" do

View File

@@ -36,18 +36,8 @@ class Redmine::ApiTest::QueriesTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'queries',
:attributes => {:type => 'array'},
:child => {
:tag => 'query',
:child => {
:tag => 'id',
:content => '4',
:sibling => {
:tag => 'name',
:content => 'Public query for all projects'
}
}
}
assert_select 'queries[type=array] query id:content(4)' do
assert_select '~ name', :text => 'Public query for all projects'
end
end
end

View File

@@ -31,19 +31,9 @@ class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base
assert_equal 'application/xml', @response.content_type
assert_equal 3, assigns(:roles).size
assert_tag :tag => 'roles',
:attributes => {:type => 'array'},
:child => {
:tag => 'role',
:child => {
:tag => 'id',
:content => '2',
:sibling => {
:tag => 'name',
:content => 'Developer'
}
}
}
assert_select 'roles[type=array] role id:content(2)' do
assert_select '~ name', :text => 'Developer'
end
end
test "GET /roles.json should return the roles" do

View File

@@ -35,24 +35,21 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
get '/time_entries.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'time_entries',
:child => {:tag => 'time_entry', :child => {:tag => 'id', :content => '2'}}
assert_select 'time_entries[type=array] time_entry id', :text => '2'
end
test "GET /time_entries.xml with limit should return limited results" do
get '/time_entries.xml?limit=2', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'time_entries',
:children => {:count => 2}
assert_select 'time_entries[type=array] time_entry', 2
end
test "GET /time_entries/:id.xml should return the time entry" do
get '/time_entries/2.xml', {}, credentials('jsmith')
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'time_entry',
:child => {:tag => 'id', :content => '2'}
assert_select 'time_entry id', :text => '2'
end
test "POST /time_entries.xml with issue_id should create time entry" do
@@ -109,7 +106,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => "Hours can't be blank"}
assert_select 'errors error', :text => "Hours can't be blank"
end
test "PUT /time_entries/:id.xml with valid parameters should update time entry" do
@@ -128,7 +125,7 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {:tag => 'error', :content => "Hours can't be blank"}
assert_select 'errors error', :text => "Hours can't be blank"
end
test "DELETE /time_entries/:id.xml should destroy time entry" do

View File

@@ -29,18 +29,9 @@ class Redmine::ApiTest::TrackersTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'trackers',
:attributes => {:type => 'array'},
:child => {
:tag => 'tracker',
:child => {
:tag => 'id',
:content => '2',
:sibling => {
:tag => 'name',
:content => 'Feature request'
}
}
}
assert_select 'trackers[type=array] tracker id:content(2)' do
assert_select '~ name', :text => 'Feature request'
end
end
end

View File

@@ -67,8 +67,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
get '/users/2.xml'
assert_response :success
assert_tag :tag => 'user',
:child => {:tag => 'id', :content => '2'}
assert_select 'user id', :text => '2'
end
test "GET /users/:id.json should return the user" do
@@ -85,9 +84,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
get '/users/2.xml?include=memberships'
assert_response :success
assert_tag :tag => 'memberships',
:parent => {:tag => 'user'},
:children => {:count => 1}
assert_select 'user memberships', 1
end
test "GET /users/:id.json with include=memberships should include memberships" do
@@ -112,44 +109,43 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
test "GET /users/current.xml should return current user" do
get '/users/current.xml', {}, credentials('jsmith')
assert_tag :tag => 'user',
:child => {:tag => 'id', :content => '2'}
assert_select 'user id', :text => '2'
end
test "GET /users/:id should not return login for other user" do
get '/users/3.xml', {}, credentials('jsmith')
assert_response :success
assert_no_tag 'user', :child => {:tag => 'login'}
assert_select 'user login', 0
end
test "GET /users/:id should return login for current user" do
get '/users/2.xml', {}, credentials('jsmith')
assert_response :success
assert_tag 'user', :child => {:tag => 'login', :content => 'jsmith'}
assert_select 'user login', :text => 'jsmith'
end
test "GET /users/:id should not return api_key for other user" do
get '/users/3.xml', {}, credentials('jsmith')
assert_response :success
assert_no_tag 'user', :child => {:tag => 'api_key'}
assert_select 'user api_key', 0
end
test "GET /users/:id should return api_key for current user" do
get '/users/2.xml', {}, credentials('jsmith')
assert_response :success
assert_tag 'user', :child => {:tag => 'api_key', :content => User.find(2).api_key}
assert_select 'user api_key', :text => User.find(2).api_key
end
test "GET /users/:id should not return status for standard user" do
get '/users/3.xml', {}, credentials('jsmith')
assert_response :success
assert_no_tag 'user', :child => {:tag => 'status'}
assert_select 'user status', 0
end
test "GET /users/:id should return status for administrators" do
get '/users/2.xml', {}, credentials('admin')
assert_response :success
assert_tag 'user', :child => {:tag => 'status', :content => User.find(1).status.to_s}
assert_select 'user status', :text => User.find(1).status.to_s
end
test "POST /users.xml with valid parameters should create the user" do
@@ -174,7 +170,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
assert_tag 'user', :child => {:tag => 'id', :content => user.id.to_s}
assert_select 'user id', :text => user.id.to_s
end
test "POST /users.json with valid parameters should create the user" do
@@ -210,10 +206,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {
:tag => 'error',
:content => "First name can't be blank"
}
assert_select 'errors error', :text => "First name can't be blank"
end
test "POST /users.json with with invalid parameters should return errors" do
@@ -283,10 +276,7 @@ class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
assert_response :unprocessable_entity
assert_equal 'application/xml', @response.content_type
assert_tag 'errors', :child => {
:tag => 'error',
:content => "First name can't be blank"
}
assert_select 'errors error', :text => "First name can't be blank"
end
test "PUT /users/:id.json with invalid parameters" do

View File

@@ -36,19 +36,10 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_tag :tag => 'versions',
:attributes => {:type => 'array'},
:child => {
:tag => 'version',
:child => {
:tag => 'id',
:content => '2',
:sibling => {
:tag => 'name',
:content => '1.0'
}
}
}
assert_select 'versions[type=array] version id:content(2)' do
assert_select '~ name', :text => '1.0'
end
end
test "POST /projects/:project_id/versions.xml should create the version" do
@@ -61,7 +52,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
assert_select 'version id', :text => version.id.to_s
end
test "POST /projects/:project_id/versions.xml should create the version with due date" do
@@ -75,7 +66,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
assert_response :created
assert_equal 'application/xml', @response.content_type
assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
assert_select 'version id', :text => version.id.to_s
end
test "POST /projects/:project_id/versions.xml should create the version with custom fields" do
@@ -107,7 +98,7 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
end
assert_response :unprocessable_entity
assert_tag :errors, :child => {:tag => 'error', :content => "Name can't be blank"}
assert_select 'errors error', :text => "Name can't be blank"
end
test "GET /versions/:id.xml should return the version" do