summaryrefslogtreecommitdiffstats
path: root/test/integration
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration')
-rw-r--r--test/integration/account_test.rb8
-rw-r--r--test/integration/api_test/attachments_test.rb19
-rw-r--r--test/integration/api_test/issue_categories_test.rb10
-rw-r--r--test/integration/api_test/issue_relations_test.rb16
-rw-r--r--test/integration/api_test/issue_statuses_test.rb16
-rw-r--r--test/integration/api_test/issues_test.rb202
-rw-r--r--test/integration/api_test/memberships_test.rb48
-rw-r--r--test/integration/api_test/news_test.rb20
-rw-r--r--test/integration/api_test/projects_test.rb71
-rw-r--r--test/integration/api_test/queries_test.rb16
-rw-r--r--test/integration/api_test/roles_test.rb16
-rw-r--r--test/integration/api_test/time_entries_test.rb13
-rw-r--r--test/integration/api_test/trackers_test.rb17
-rw-r--r--test/integration/api_test/users_test.rb34
-rw-r--r--test/integration/api_test/versions_test.rb23
-rw-r--r--test/integration/application_test.rb6
-rw-r--r--test/integration/issues_test.rb54
-rw-r--r--test/integration/layout_test.rb4
-rw-r--r--test/integration/lib/redmine/hook_test.rb3
-rw-r--r--test/integration/lib/redmine/menu_manager_test.rb30
20 files changed, 168 insertions, 458 deletions
diff --git a/test/integration/account_test.rb b/test/integration/account_test.rb
index c822cc38a..8d8444a9d 100644
--- a/test/integration/account_test.rb
+++ b/test/integration/account_test.rb
@@ -229,10 +229,10 @@ class AccountTest < ActionDispatch::IntegrationTest
post '/login', :username => 'foo', :password => 'bar'
assert_response :success
assert_template 'account/register'
- assert_tag :input, :attributes => { :name => 'user[firstname]', :value => '' }
- assert_tag :input, :attributes => { :name => 'user[lastname]', :value => 'Smith' }
- assert_no_tag :input, :attributes => { :name => 'user[login]' }
- assert_no_tag :input, :attributes => { :name => 'user[password]' }
+ assert_select 'input[name=?][value=""]', 'user[firstname]'
+ assert_select 'input[name=?][value=Smith]', 'user[lastname]'
+ assert_select 'input[name=?]', 'user[login]', 0
+ assert_select 'input[name=?]', 'user[password]', 0
post 'account/register',
:user => {:firstname => 'Foo', :lastname => 'Smith', :mail => 'foo@bar.com'}
diff --git a/test/integration/api_test/attachments_test.rb b/test/integration/api_test/attachments_test.rb
index e1dc2cf89..5a80f5cc7 100644
--- a/test/integration/api_test/attachments_test.rb
+++ b/test/integration/api_test/attachments_test.rb
@@ -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
diff --git a/test/integration/api_test/issue_categories_test.rb b/test/integration/api_test/issue_categories_test.rb
index 2c1ea8a30..712cfb0d1 100644
--- a/test/integration/api_test/issue_categories_test.rb
+++ b/test/integration/api_test/issue_categories_test.rb
@@ -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
diff --git a/test/integration/api_test/issue_relations_test.rb b/test/integration/api_test/issue_relations_test.rb
index 5b9f11e8a..601e96067 100644
--- a/test/integration/api_test/issue_relations_test.rb
+++ b/test/integration/api_test/issue_relations_test.rb
@@ -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
diff --git a/test/integration/api_test/issue_statuses_test.rb b/test/integration/api_test/issue_statuses_test.rb
index 03b94c7d0..14a7f2d4d 100644
--- a/test/integration/api_test/issue_statuses_test.rb
+++ b/test/integration/api_test/issue_statuses_test.rb
@@ -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
diff --git a/test/integration/api_test/issues_test.rb b/test/integration/api_test/issues_test.rb
index f6e458e99..d9525b963 100644
--- a/test/integration/api_test/issues_test.rb
+++ b/test/integration/api_test/issues_test.rb
@@ -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
diff --git a/test/integration/api_test/memberships_test.rb b/test/integration/api_test/memberships_test.rb
index 2493c797d..9f8ac24e8 100644
--- a/test/integration/api_test/memberships_test.rb
+++ b/test/integration/api_test/memberships_test.rb
@@ -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
diff --git a/test/integration/api_test/news_test.rb b/test/integration/api_test/news_test.rb
index a60fe94c8..67984e70f 100644
--- a/test/integration/api_test/news_test.rb
+++ b/test/integration/api_test/news_test.rb
@@ -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
diff --git a/test/integration/api_test/projects_test.rb b/test/integration/api_test/projects_test.rb
index a345f5822..16c556dde 100644
--- a/test/integration/api_test/projects_test.rb
+++ b/test/integration/api_test/projects_test.rb
@@ -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
diff --git a/test/integration/api_test/queries_test.rb b/test/integration/api_test/queries_test.rb
index afaed3090..72e9ed5e2 100644
--- a/test/integration/api_test/queries_test.rb
+++ b/test/integration/api_test/queries_test.rb
@@ -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
diff --git a/test/integration/api_test/roles_test.rb b/test/integration/api_test/roles_test.rb
index 59dd12fbf..4f04b4b25 100644
--- a/test/integration/api_test/roles_test.rb
+++ b/test/integration/api_test/roles_test.rb
@@ -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
diff --git a/test/integration/api_test/time_entries_test.rb b/test/integration/api_test/time_entries_test.rb
index 93c42e675..9fa93cd27 100644
--- a/test/integration/api_test/time_entries_test.rb
+++ b/test/integration/api_test/time_entries_test.rb
@@ -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
diff --git a/test/integration/api_test/trackers_test.rb b/test/integration/api_test/trackers_test.rb
index 80188a3de..d85e2a4c3 100644
--- a/test/integration/api_test/trackers_test.rb
+++ b/test/integration/api_test/trackers_test.rb
@@ -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
diff --git a/test/integration/api_test/users_test.rb b/test/integration/api_test/users_test.rb
index 2fab3f80c..f44948c54 100644
--- a/test/integration/api_test/users_test.rb
+++ b/test/integration/api_test/users_test.rb
@@ -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
diff --git a/test/integration/api_test/versions_test.rb b/test/integration/api_test/versions_test.rb
index 2e217d9b1..77fd2c0e5 100644
--- a/test/integration/api_test/versions_test.rb
+++ b/test/integration/api_test/versions_test.rb
@@ -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
diff --git a/test/integration/application_test.rb b/test/integration/application_test.rb
index ced1783e5..e70277a2e 100644
--- a/test/integration/application_test.rb
+++ b/test/integration/application_test.rb
@@ -34,21 +34,21 @@ class ApplicationTest < ActionDispatch::IntegrationTest
# a french user
get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
assert_response :success
- assert_tag :tag => 'h2', :content => 'Projets'
+ assert_select 'h2', :text => 'Projets'
assert_equal :fr, current_language
assert_select "html[lang=?]", "fr"
# then an italien user
get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'it;q=0.8,en-us;q=0.5,en;q=0.3'
assert_response :success
- assert_tag :tag => 'h2', :content => 'Progetti'
+ assert_select 'h2', :text => 'Progetti'
assert_equal :it, current_language
assert_select "html[lang=?]", "it"
# not a supported language: default language should be used
get 'projects', { }, 'HTTP_ACCEPT_LANGUAGE' => 'zz'
assert_response :success
- assert_tag :tag => 'h2', :content => 'Projects'
+ assert_select 'h2', :text => 'Projects'
assert_select "html[lang=?]", "en"
end
diff --git a/test/integration/issues_test.rb b/test/integration/issues_test.rb
index 1e7efde7a..1f30acc8a 100644
--- a/test/integration/issues_test.rb
+++ b/test/integration/issues_test.rb
@@ -115,9 +115,7 @@ class IssuesTest < ActionDispatch::IntegrationTest
get '/projects/ecookbook/issues'
%w(Atom PDF CSV).each do |format|
- assert_tag :a, :content => format,
- :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
- :rel => 'nofollow' }
+ assert_select 'a[rel=nofollow][href=?]', "/projects/ecookbook/issues.#{format.downcase}", :text => format
end
end
@@ -125,9 +123,7 @@ class IssuesTest < ActionDispatch::IntegrationTest
get '/issues', :project_id => 'ecookbook'
%w(Atom PDF CSV).each do |format|
- assert_tag :a, :content => format,
- :attributes => { :href => "/projects/ecookbook/issues.#{format.downcase}",
- :rel => 'nofollow' }
+ assert_select 'a[rel=nofollow][href=?]', "/projects/ecookbook/issues.#{format.downcase}", :text => format
end
end
@@ -135,8 +131,7 @@ class IssuesTest < ActionDispatch::IntegrationTest
with_settings :per_page_options => '2' do
get '/projects/ecookbook/issues'
- assert_tag :a, :content => '2',
- :attributes => { :href => '/projects/ecookbook/issues?page=2' }
+ assert_select 'a[href=?]', '/projects/ecookbook/issues?page=2', :text => '2'
end
end
@@ -144,8 +139,7 @@ class IssuesTest < ActionDispatch::IntegrationTest
with_settings :per_page_options => '2' do
get '/issues', :project_id => 'ecookbook'
- assert_tag :a, :content => '2',
- :attributes => { :href => '/projects/ecookbook/issues?page=2' }
+ assert_select 'a[href=?]', '/projects/ecookbook/issues?page=2', :text => '2'
end
end
@@ -158,14 +152,10 @@ class IssuesTest < ActionDispatch::IntegrationTest
# Issue form
get '/projects/ecookbook/issues/new'
assert_response :success
- assert_tag :select,
- :attributes => {:name => "issue[custom_field_values][#{@field.id}]"},
- :children => {:count => (users.size + 1)}, # +1 for blank value
- :child => {
- :tag => 'option',
- :attributes => {:value => tester.id.to_s},
- :content => tester.name
- }
+ assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
+ assert_select 'option', users.size + 1 # +1 for blank value
+ assert_select 'option[value=?]', tester.id.to_s, :text => tester.name
+ end
# Create issue
assert_difference 'Issue.count' do
@@ -182,20 +172,11 @@ class IssuesTest < ActionDispatch::IntegrationTest
# Issue view
follow_redirect!
- assert_tag :th,
- :content => /Tester/,
- :sibling => {
- :tag => 'td',
- :content => tester.name
- }
- assert_tag :select,
- :attributes => {:name => "issue[custom_field_values][#{@field.id}]"},
- :children => {:count => (users.size + 1)}, # +1 for blank value
- :child => {
- :tag => 'option',
- :attributes => {:value => tester.id.to_s, :selected => 'selected'},
- :content => tester.name
- }
+ assert_select 'th:content(Tester:) + td', :text => tester.name
+ assert_select 'select[name=?]', "issue[custom_field_values][#{@field.id}]" do
+ assert_select 'option', users.size + 1 # +1 for blank value
+ assert_select 'option[value=?][selected=selected]', tester.id.to_s, :text => tester.name
+ end
# Update issue
new_tester = users[1]
@@ -210,14 +191,7 @@ class IssuesTest < ActionDispatch::IntegrationTest
# Issue view
follow_redirect!
- assert_tag :content => 'Tester',
- :ancestor => {:tag => 'ul', :attributes => {:class => /details/}},
- :sibling => {
- :content => tester.name,
- :sibling => {
- :content => new_tester.name
- }
- }
+ assert_select 'ul.details li', :text => "Tester changed from #{tester} to #{new_tester}"
end
def test_update_using_invalid_http_verbs
diff --git a/test/integration/layout_test.rb b/test/integration/layout_test.rb
index 0e6fa24e8..fd9ddc28e 100644
--- a/test/integration/layout_test.rb
+++ b/test/integration/layout_test.rb
@@ -65,9 +65,7 @@ class LayoutTest < ActionDispatch::IntegrationTest
Role.anonymous.add_permission! :add_issues
get '/projects/ecookbook/issues/new'
- assert_tag :script,
- :attributes => {:src => %r{^/javascripts/jstoolbar/jstoolbar-textile.min.js}},
- :parent => {:tag => 'head'}
+ assert_select 'head script[src=?]', '/javascripts/jstoolbar/jstoolbar-textile.min.js'
end
def test_calendar_header_tags
diff --git a/test/integration/lib/redmine/hook_test.rb b/test/integration/lib/redmine/hook_test.rb
index f0520b58e..9e5c5bbb1 100644
--- a/test/integration/lib/redmine/hook_test.rb
+++ b/test/integration/lib/redmine/hook_test.rb
@@ -76,8 +76,7 @@ VIEW
Redmine::Hook.add_listener(ProjectBasedTemplate)
get '/projects/ecookbook'
- assert_tag :tag => 'link', :attributes => {:href => '/stylesheets/ecookbook.css'},
- :parent => {:tag => 'head'}
+ assert_select 'head link[href=?]', '/stylesheets/ecookbook.css'
end
def test_empty_sidebar_should_be_hidden
diff --git a/test/integration/lib/redmine/menu_manager_test.rb b/test/integration/lib/redmine/menu_manager_test.rb
index 5d3826a23..bc4fbf017 100644
--- a/test/integration/lib/redmine/menu_manager_test.rb
+++ b/test/integration/lib/redmine/menu_manager_test.rb
@@ -31,14 +31,10 @@ class MenuManagerTest < ActionDispatch::IntegrationTest
def test_project_menu_with_specific_locale
get 'projects/ecookbook/issues', { }, 'HTTP_ACCEPT_LANGUAGE' => 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3'
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_activity),
- :attributes => { :href => '/projects/ecookbook/activity',
- :class => 'activity' } } }
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => ll('fr', :label_issue_plural),
- :attributes => { :href => '/projects/ecookbook/issues',
- :class => 'issues selected' } } }
+ assert_select 'div#main-menu' do
+ assert_select 'li a.activity[href=?]', '/projects/ecookbook/activity', :text => ll('fr', :label_activity)
+ assert_select 'li a.issues.selected[href=?]', '/projects/ecookbook/issues', :text => ll('fr', :label_issue_plural)
+ end
end
def test_project_menu_with_additional_menu_items
@@ -51,19 +47,13 @@ class MenuManagerTest < ActionDispatch::IntegrationTest
end
get 'projects/ecookbook'
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Foo',
- :attributes => { :class => 'foo' } } }
-
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'Bar',
- :attributes => { :class => 'bar' } },
- :before => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK' } } }
- assert_tag :div, :attributes => { :id => 'main-menu' },
- :descendant => { :tag => 'li', :child => { :tag => 'a', :content => 'ECOOKBOOK',
- :attributes => { :class => 'hello' } },
- :before => { :tag => 'li', :child => { :tag => 'a', :content => 'Activity' } } }
+ assert_select 'div#main-menu ul' do
+ assert_select 'li:last-child a.foo[href=?]', '/projects/ecookbook', :text => 'Foo'
+ assert_select 'li:nth-child(2) a.bar[href=?]', '/projects/ecookbook', :text => 'Bar'
+ assert_select 'li:nth-child(3) a.hello[href=?]', '/projects/ecookbook', :text => 'ECOOKBOOK'
+ assert_select 'li:nth-child(4) a', :text => 'Activity'
+ end
# Remove the menu items
Redmine::MenuManager.map :project_menu do |menu|