Removed some shoulda context.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11862 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
5b29964512
commit
0d4bb7558f
|
@ -24,12 +24,8 @@ class Redmine::ApiTest::EnumerationsTest < Redmine::ApiTest::Base
|
||||||
Setting.rest_api_enabled = '1'
|
Setting.rest_api_enabled = '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "/enumerations/issue_priorities" do
|
test "GET /enumerations/issue_priorities.xml should return priorities" do
|
||||||
context "GET" do
|
|
||||||
|
|
||||||
should "return priorities" do
|
|
||||||
get '/enumerations/issue_priorities.xml'
|
get '/enumerations/issue_priorities.xml'
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/xml', response.content_type
|
assert_equal 'application/xml', response.content_type
|
||||||
assert_select 'issue_priorities[type=array]' do
|
assert_select 'issue_priorities[type=array]' do
|
||||||
|
@ -40,5 +36,3 @@ class Redmine::ApiTest::EnumerationsTest < Redmine::ApiTest::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -24,14 +24,12 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
Setting.rest_api_enabled = '1'
|
Setting.rest_api_enabled = '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "GET /groups" do
|
test "GET /groups.xml should require authentication" do
|
||||||
context ".xml" do
|
|
||||||
should "require authentication" do
|
|
||||||
get '/groups.xml'
|
get '/groups.xml'
|
||||||
assert_response 401
|
assert_response 401
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return groups" do
|
test "GET /groups.xml should return groups" do
|
||||||
get '/groups.xml', {}, credentials('admin')
|
get '/groups.xml', {}, credentials('admin')
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/xml', response.content_type
|
assert_equal 'application/xml', response.content_type
|
||||||
|
@ -43,15 +41,13 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context ".json" do
|
test "GET /groups.json should require authentication" do
|
||||||
should "require authentication" do
|
|
||||||
get '/groups.json'
|
get '/groups.json'
|
||||||
assert_response 401
|
assert_response 401
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return groups" do
|
test "GET /groups.json should return groups" do
|
||||||
get '/groups.json', {}, credentials('admin')
|
get '/groups.json', {}, credentials('admin')
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/json', response.content_type
|
assert_equal 'application/json', response.content_type
|
||||||
|
@ -63,12 +59,8 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
assert_not_nil group
|
assert_not_nil group
|
||||||
assert_equal({'id' => 10, 'name' => 'A Team'}, group)
|
assert_equal({'id' => 10, 'name' => 'A Team'}, group)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "GET /groups/:id" do
|
test "GET /groups/:id.xml should return the group with its users" do
|
||||||
context ".xml" do
|
|
||||||
should "return the group with its users" do
|
|
||||||
get '/groups/10.xml', {}, credentials('admin')
|
get '/groups/10.xml', {}, credentials('admin')
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/xml', response.content_type
|
assert_equal 'application/xml', response.content_type
|
||||||
|
@ -79,7 +71,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "include users if requested" do
|
test "GET /groups/:id.xml should include users if requested" do
|
||||||
get '/groups/10.xml?include=users', {}, credentials('admin')
|
get '/groups/10.xml?include=users', {}, credentials('admin')
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/xml', response.content_type
|
assert_equal 'application/xml', response.content_type
|
||||||
|
@ -92,7 +84,7 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "include memberships if requested" do
|
test "GET /groups/:id.xml include memberships if requested" do
|
||||||
get '/groups/10.xml?include=memberships', {}, credentials('admin')
|
get '/groups/10.xml?include=memberships', {}, credentials('admin')
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/xml', response.content_type
|
assert_equal 'application/xml', response.content_type
|
||||||
|
@ -101,13 +93,8 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
assert_select 'memberships'
|
assert_select 'memberships'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "POST /groups" do
|
test "POST /groups.xml with valid parameters should create the group" do
|
||||||
context "with valid parameters" do
|
|
||||||
context ".xml" do
|
|
||||||
should "create groups" do
|
|
||||||
assert_difference('Group.count') do
|
assert_difference('Group.count') do
|
||||||
post '/groups.xml', {:group => {:name => 'Test', :user_ids => [2, 3]}}, credentials('admin')
|
post '/groups.xml', {:group => {:name => 'Test', :user_ids => [2, 3]}}, credentials('admin')
|
||||||
assert_response :created
|
assert_response :created
|
||||||
|
@ -122,12 +109,8 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
assert_select 'name', :text => 'Test'
|
assert_select 'name', :text => 'Test'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with invalid parameters" do
|
test "POST /groups.xml with invalid parameters should return errors" do
|
||||||
context ".xml" do
|
|
||||||
should "return errors" do
|
|
||||||
assert_no_difference('Group.count') do
|
assert_no_difference('Group.count') do
|
||||||
post '/groups.xml', {:group => {:name => ''}}, credentials('admin')
|
post '/groups.xml', {:group => {:name => ''}}, credentials('admin')
|
||||||
end
|
end
|
||||||
|
@ -138,14 +121,8 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
assert_select 'error', :text => /Name can't be blank/
|
assert_select 'error', :text => /Name can't be blank/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "PUT /groups/:id" do
|
test "PUT /groups/:id.xml with valid parameters should update the group" do
|
||||||
context "with valid parameters" do
|
|
||||||
context ".xml" do
|
|
||||||
should "update the group" do
|
|
||||||
put '/groups/10.xml', {:group => {:name => 'New name', :user_ids => [2, 3]}}, credentials('admin')
|
put '/groups/10.xml', {:group => {:name => 'New name', :user_ids => [2, 3]}}, credentials('admin')
|
||||||
assert_response :ok
|
assert_response :ok
|
||||||
assert_equal '', @response.body
|
assert_equal '', @response.body
|
||||||
|
@ -154,12 +131,8 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
assert_equal 'New name', group.name
|
assert_equal 'New name', group.name
|
||||||
assert_equal [2, 3], group.users.map(&:id).sort
|
assert_equal [2, 3], group.users.map(&:id).sort
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "with invalid parameters" do
|
test "PUT /groups/:id.xml with invalid parameters should return errors" do
|
||||||
context ".xml" do
|
|
||||||
should "return errors" do
|
|
||||||
put '/groups/10.xml', {:group => {:name => ''}}, credentials('admin')
|
put '/groups/10.xml', {:group => {:name => ''}}, credentials('admin')
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_entity
|
||||||
assert_equal 'application/xml', response.content_type
|
assert_equal 'application/xml', response.content_type
|
||||||
|
@ -168,25 +141,16 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
assert_select 'error', :text => /Name can't be blank/
|
assert_select 'error', :text => /Name can't be blank/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "DELETE /groups/:id" do
|
test "DELETE /groups/:id.xml should delete the group" do
|
||||||
context ".xml" do
|
|
||||||
should "delete the group" do
|
|
||||||
assert_difference 'Group.count', -1 do
|
assert_difference 'Group.count', -1 do
|
||||||
delete '/groups/10.xml', {}, credentials('admin')
|
delete '/groups/10.xml', {}, credentials('admin')
|
||||||
assert_response :ok
|
assert_response :ok
|
||||||
assert_equal '', @response.body
|
assert_equal '', @response.body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "POST /groups/:id/users" do
|
test "POST /groups/:id/users.xml should add user to the group" do
|
||||||
context ".xml" do
|
|
||||||
should "add user to the group" do
|
|
||||||
assert_difference 'Group.find(10).users.count' do
|
assert_difference 'Group.find(10).users.count' do
|
||||||
post '/groups/10/users.xml', {:user_id => 5}, credentials('admin')
|
post '/groups/10/users.xml', {:user_id => 5}, credentials('admin')
|
||||||
assert_response :ok
|
assert_response :ok
|
||||||
|
@ -194,12 +158,8 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
end
|
end
|
||||||
assert_include User.find(5), Group.find(10).users
|
assert_include User.find(5), Group.find(10).users
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "DELETE /groups/:id/users/:user_id" do
|
test "DELETE /groups/:id/users/:user_id.xml should remove user from the group" do
|
||||||
context ".xml" do
|
|
||||||
should "remove user from the group" do
|
|
||||||
assert_difference 'Group.find(10).users.count', -1 do
|
assert_difference 'Group.find(10).users.count', -1 do
|
||||||
delete '/groups/10/users/8.xml', {}, credentials('admin')
|
delete '/groups/10/users/8.xml', {}, credentials('admin')
|
||||||
assert_response :ok
|
assert_response :ok
|
||||||
|
@ -208,5 +168,3 @@ class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
assert_not_include User.find(8), Group.find(10).users
|
assert_not_include User.find(8), Group.find(10).users
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -28,28 +28,23 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
||||||
Setting.rest_api_enabled = '1'
|
Setting.rest_api_enabled = '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "GET /projects/:project_id/issue_categories.xml" do
|
test "GET /projects/:project_id/issue_categories.xml should return the issue categories" do
|
||||||
should "return issue categories" do
|
|
||||||
get '/projects/1/issue_categories.xml', {}, credentials('jsmith')
|
get '/projects/1/issue_categories.xml', {}, credentials('jsmith')
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/xml', @response.content_type
|
assert_equal 'application/xml', @response.content_type
|
||||||
assert_tag :tag => 'issue_categories',
|
assert_tag :tag => 'issue_categories',
|
||||||
:child => {:tag => 'issue_category', :child => {:tag => 'id', :content => '2'}}
|
:child => {:tag => 'issue_category', :child => {:tag => 'id', :content => '2'}}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context "GET /issue_categories/2.xml" do
|
test "GET /issue_categories/:id.xml should return the issue category" do
|
||||||
should "return requested issue category" do
|
|
||||||
get '/issue_categories/2.xml', {}, credentials('jsmith')
|
get '/issue_categories/2.xml', {}, credentials('jsmith')
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/xml', @response.content_type
|
assert_equal 'application/xml', @response.content_type
|
||||||
assert_tag :tag => 'issue_category',
|
assert_tag :tag => 'issue_category',
|
||||||
:child => {:tag => 'id', :content => '2'}
|
:child => {:tag => 'id', :content => '2'}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context "POST /projects/:project_id/issue_categories.xml" do
|
test "POST /projects/:project_id/issue_categories.xml should return create issue category" do
|
||||||
should "return create issue category" do
|
|
||||||
assert_difference 'IssueCategory.count' do
|
assert_difference 'IssueCategory.count' do
|
||||||
post '/projects/1/issue_categories.xml', {:issue_category => {:name => 'API'}}, credentials('jsmith')
|
post '/projects/1/issue_categories.xml', {:issue_category => {:name => 'API'}}, credentials('jsmith')
|
||||||
end
|
end
|
||||||
|
@ -61,8 +56,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
||||||
assert_equal 1, category.project_id
|
assert_equal 1, category.project_id
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with invalid parameters" do
|
test "POST /projects/:project_id/issue_categories.xml with invalid parameters should return errors" do
|
||||||
should "return errors" do
|
|
||||||
assert_no_difference 'IssueCategory.count' do
|
assert_no_difference 'IssueCategory.count' do
|
||||||
post '/projects/1/issue_categories.xml', {:issue_category => {:name => ''}}, credentials('jsmith')
|
post '/projects/1/issue_categories.xml', {:issue_category => {:name => ''}}, credentials('jsmith')
|
||||||
end
|
end
|
||||||
|
@ -71,12 +65,8 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
||||||
|
|
||||||
assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
|
assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "PUT /issue_categories/2.xml" do
|
test "PUT /issue_categories/:id.xml with valid parameters should update the issue category" do
|
||||||
context "with valid parameters" do
|
|
||||||
should "update issue category" do
|
|
||||||
assert_no_difference 'IssueCategory.count' do
|
assert_no_difference 'IssueCategory.count' do
|
||||||
put '/issue_categories/2.xml', {:issue_category => {:name => 'API Update'}}, credentials('jsmith')
|
put '/issue_categories/2.xml', {:issue_category => {:name => 'API Update'}}, credentials('jsmith')
|
||||||
end
|
end
|
||||||
|
@ -84,10 +74,8 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
||||||
assert_equal '', @response.body
|
assert_equal '', @response.body
|
||||||
assert_equal 'API Update', IssueCategory.find(2).name
|
assert_equal 'API Update', IssueCategory.find(2).name
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context "with invalid parameters" do
|
test "PUT /issue_categories/:id.xml with invalid parameters should return errors" do
|
||||||
should "return errors" do
|
|
||||||
assert_no_difference 'IssueCategory.count' do
|
assert_no_difference 'IssueCategory.count' do
|
||||||
put '/issue_categories/2.xml', {:issue_category => {:name => ''}}, credentials('jsmith')
|
put '/issue_categories/2.xml', {:issue_category => {:name => ''}}, credentials('jsmith')
|
||||||
end
|
end
|
||||||
|
@ -96,11 +84,8 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
||||||
|
|
||||||
assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
|
assert_tag 'errors', :child => {:tag => 'error', :content => "Name can't be blank"}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "DELETE /issue_categories/1.xml" do
|
test "DELETE /issue_categories/:id.xml should destroy the issue category" do
|
||||||
should "destroy issue categories" do
|
|
||||||
assert_difference 'IssueCategory.count', -1 do
|
assert_difference 'IssueCategory.count', -1 do
|
||||||
delete '/issue_categories/1.xml', {}, credentials('jsmith')
|
delete '/issue_categories/1.xml', {}, credentials('jsmith')
|
||||||
end
|
end
|
||||||
|
@ -109,7 +94,7 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
||||||
assert_nil IssueCategory.find_by_id(1)
|
assert_nil IssueCategory.find_by_id(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "reassign issues with :reassign_to_id param" do
|
test "DELETE /issue_categories/:id.xml should reassign issues with :reassign_to_id param" do
|
||||||
issue_count = Issue.count(:conditions => {:category_id => 1})
|
issue_count = Issue.count(:conditions => {:category_id => 1})
|
||||||
assert issue_count > 0
|
assert issue_count > 0
|
||||||
|
|
||||||
|
@ -123,4 +108,3 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
||||||
assert_nil IssueCategory.find_by_id(1)
|
assert_nil IssueCategory.find_by_id(1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
|
@ -31,9 +31,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
|
||||||
Setting.rest_api_enabled = '1'
|
Setting.rest_api_enabled = '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "/issues/:issue_id/relations" do
|
test "GET /issues/:issue_id/relations.xml should return issue relations" do
|
||||||
context "GET" do
|
|
||||||
should "return issue relations" do
|
|
||||||
get '/issues/9/relations.xml', {}, credentials('jsmith')
|
get '/issues/9/relations.xml', {}, credentials('jsmith')
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -49,10 +47,8 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context "POST" do
|
test "POST /issues/:issue_id/relations.xml should create the relation" do
|
||||||
should "create a relation" do
|
|
||||||
assert_difference('IssueRelation.count') do
|
assert_difference('IssueRelation.count') do
|
||||||
post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'relates'}}, credentials('jsmith')
|
post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'relates'}}, credentials('jsmith')
|
||||||
end
|
end
|
||||||
|
@ -67,8 +63,7 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
|
||||||
assert_tag 'relation', :child => {:tag => 'id', :content => relation.id.to_s}
|
assert_tag 'relation', :child => {:tag => 'id', :content => relation.id.to_s}
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with failure" do
|
test "POST /issues/:issue_id/relations.xml with failure should return errors" do
|
||||||
should "return the errors" do
|
|
||||||
assert_no_difference('IssueRelation.count') do
|
assert_no_difference('IssueRelation.count') do
|
||||||
post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'foo'}}, credentials('jsmith')
|
post '/issues/2/relations.xml', {:relation => {:issue_to_id => 7, :relation_type => 'foo'}}, credentials('jsmith')
|
||||||
end
|
end
|
||||||
|
@ -76,23 +71,16 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
|
||||||
assert_response :unprocessable_entity
|
assert_response :unprocessable_entity
|
||||||
assert_tag :errors, :child => {:tag => 'error', :content => /relation_type is not included in the list/}
|
assert_tag :errors, :child => {:tag => 'error', :content => /relation_type is not included in the list/}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "/relations/:id" do
|
test "GET /relations/:id.xml should return the relation" do
|
||||||
context "GET" do
|
|
||||||
should "return the relation" do
|
|
||||||
get '/relations/2.xml', {}, credentials('jsmith')
|
get '/relations/2.xml', {}, credentials('jsmith')
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_equal 'application/xml', @response.content_type
|
assert_equal 'application/xml', @response.content_type
|
||||||
assert_tag 'relation', :child => {:tag => 'id', :content => '2'}
|
assert_tag 'relation', :child => {:tag => 'id', :content => '2'}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context "DELETE" do
|
test "DELETE /relations/:id.xml should delete the relation" do
|
||||||
should "delete the relation" do
|
|
||||||
assert_difference('IssueRelation.count', -1) do
|
assert_difference('IssueRelation.count', -1) do
|
||||||
delete '/relations/2.xml', {}, credentials('jsmith')
|
delete '/relations/2.xml', {}, credentials('jsmith')
|
||||||
end
|
end
|
||||||
|
@ -102,5 +90,3 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
|
||||||
assert_nil IssueRelation.find_by_id(2)
|
assert_nil IssueRelation.find_by_id(2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -24,10 +24,7 @@ class Redmine::ApiTest::IssueStatusesTest < Redmine::ApiTest::Base
|
||||||
Setting.rest_api_enabled = '1'
|
Setting.rest_api_enabled = '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "/issue_statuses" do
|
test "GET /issue_statuses.xml should return issue statuses" do
|
||||||
context "GET" do
|
|
||||||
|
|
||||||
should "return issue statuses" do
|
|
||||||
get '/issue_statuses.xml'
|
get '/issue_statuses.xml'
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -47,5 +44,3 @@ class Redmine::ApiTest::IssueStatusesTest < Redmine::ApiTest::Base
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -24,10 +24,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
Setting.rest_api_enabled = '1'
|
Setting.rest_api_enabled = '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "/projects/:project_id/memberships" do
|
test "GET /projects/:project_id/memberships.xml should return memberships" do
|
||||||
context "GET" do
|
|
||||||
context "xml" do
|
|
||||||
should "return memberships" do
|
|
||||||
get '/projects/1/memberships.xml', {}, credentials('jsmith')
|
get '/projects/1/memberships.xml', {}, credentials('jsmith')
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -53,10 +50,8 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context "json" do
|
test "GET /projects/:project_id/memberships.json should return memberships" do
|
||||||
should "return memberships" do
|
|
||||||
get '/projects/1/memberships.json', {}, credentials('jsmith')
|
get '/projects/1/memberships.json', {}, credentials('jsmith')
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -77,12 +72,8 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
"offset" => 0},
|
"offset" => 0},
|
||||||
json)
|
json)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "POST" do
|
test "POST /projects/:project_id/memberships.xml should create the membership" do
|
||||||
context "xml" do
|
|
||||||
should "create membership" do
|
|
||||||
assert_difference 'Member.count' do
|
assert_difference 'Member.count' do
|
||||||
post '/projects/1/memberships.xml', {:membership => {:user_id => 7, :role_ids => [2,3]}}, credentials('jsmith')
|
post '/projects/1/memberships.xml', {:membership => {:user_id => 7, :role_ids => [2,3]}}, credentials('jsmith')
|
||||||
|
|
||||||
|
@ -90,7 +81,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return errors on failure" do
|
test "POST /projects/:project_id/memberships.xml with invalid parameters should return errors" do
|
||||||
assert_no_difference 'Member.count' do
|
assert_no_difference 'Member.count' do
|
||||||
post '/projects/1/memberships.xml', {:membership => {:role_ids => [2,3]}}, credentials('jsmith')
|
post '/projects/1/memberships.xml', {:membership => {:role_ids => [2,3]}}, credentials('jsmith')
|
||||||
|
|
||||||
|
@ -99,14 +90,8 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
assert_tag 'errors', :child => {:tag => 'error', :content => "Principal can't be blank"}
|
assert_tag 'errors', :child => {:tag => 'error', :content => "Principal can't be blank"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "/memberships/:id" do
|
test "GET /memberships/:id.xml should return the membership" do
|
||||||
context "GET" do
|
|
||||||
context "xml" do
|
|
||||||
should "return the membership" do
|
|
||||||
get '/memberships/2.xml', {}, credentials('jsmith')
|
get '/memberships/2.xml', {}, credentials('jsmith')
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -128,10 +113,8 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context "json" do
|
test "GET /memberships/:id.json should return the membership" do
|
||||||
should "return the membership" do
|
|
||||||
get '/memberships/2.json', {}, credentials('jsmith')
|
get '/memberships/2.json', {}, credentials('jsmith')
|
||||||
|
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
@ -146,12 +129,8 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
},
|
},
|
||||||
json)
|
json)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "PUT" do
|
test "PUT /memberships/:id.xml should update the membership" do
|
||||||
context "xml" do
|
|
||||||
should "update membership" do
|
|
||||||
assert_not_equal [1,2], Member.find(2).role_ids.sort
|
assert_not_equal [1,2], Member.find(2).role_ids.sort
|
||||||
assert_no_difference 'Member.count' do
|
assert_no_difference 'Member.count' do
|
||||||
put '/memberships/2.xml', {:membership => {:user_id => 3, :role_ids => [1,2]}}, credentials('jsmith')
|
put '/memberships/2.xml', {:membership => {:user_id => 3, :role_ids => [1,2]}}, credentials('jsmith')
|
||||||
|
@ -163,19 +142,15 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
assert_equal [1,2], member.role_ids.sort
|
assert_equal [1,2], member.role_ids.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return errors on failure" do
|
test "PUT /memberships/:id.xml with invalid parameters should return errors" do
|
||||||
put '/memberships/2.xml', {:membership => {:user_id => 3, :role_ids => [99]}}, credentials('jsmith')
|
put '/memberships/2.xml', {:membership => {:user_id => 3, :role_ids => [99]}}, credentials('jsmith')
|
||||||
|
|
||||||
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 => /member_roles is invalid/}
|
assert_tag 'errors', :child => {:tag => 'error', :content => /member_roles is invalid/}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "DELETE" do
|
test "DELETE /memberships/:id.xml should destroy the membership" do
|
||||||
context "xml" do
|
|
||||||
should "destroy membership" do
|
|
||||||
assert_difference 'Member.count', -1 do
|
assert_difference 'Member.count', -1 do
|
||||||
delete '/memberships/2.xml', {}, credentials('jsmith')
|
delete '/memberships/2.xml', {}, credentials('jsmith')
|
||||||
|
|
||||||
|
@ -185,7 +160,7 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
assert_nil Member.find_by_id(2)
|
assert_nil Member.find_by_id(2)
|
||||||
end
|
end
|
||||||
|
|
||||||
should "respond with 422 on failure" do
|
test "DELETE /memberships/:id.xml should respond with 422 on failure" do
|
||||||
assert_no_difference 'Member.count' do
|
assert_no_difference 'Member.count' do
|
||||||
# A membership with an inherited role can't be deleted
|
# A membership with an inherited role can't be deleted
|
||||||
Member.find(2).member_roles.first.update_attribute :inherited_from, 99
|
Member.find(2).member_roles.first.update_attribute :inherited_from, 99
|
||||||
|
@ -195,6 +170,3 @@ class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -31,9 +31,10 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
|
||||||
Setting.rest_api_enabled = '1'
|
Setting.rest_api_enabled = '1'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "GET /news" do
|
should_allow_api_authentication(:get, "/projects/onlinestore/news.xml")
|
||||||
context ".xml" do
|
should_allow_api_authentication(:get, "/projects/onlinestore/news.json")
|
||||||
should "return news" do
|
|
||||||
|
test "GET /news.xml should return news" do
|
||||||
get '/news.xml'
|
get '/news.xml'
|
||||||
|
|
||||||
assert_tag :tag => 'news',
|
assert_tag :tag => 'news',
|
||||||
|
@ -46,10 +47,8 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context ".json" do
|
test "GET /news.json should return news" do
|
||||||
should "return news" do
|
|
||||||
get '/news.json'
|
get '/news.json'
|
||||||
|
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
|
@ -58,14 +57,8 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
|
||||||
assert_kind_of Hash, json['news'].first
|
assert_kind_of Hash, json['news'].first
|
||||||
assert_equal 2, json['news'].first['id']
|
assert_equal 2, json['news'].first['id']
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context "GET /projects/:project_id/news" do
|
test "GET /projects/:project_id/news.xml should return news" do
|
||||||
context ".xml" do
|
|
||||||
should_allow_api_authentication(:get, "/projects/onlinestore/news.xml")
|
|
||||||
|
|
||||||
should "return news" do
|
|
||||||
get '/projects/ecookbook/news.xml'
|
get '/projects/ecookbook/news.xml'
|
||||||
|
|
||||||
assert_tag :tag => 'news',
|
assert_tag :tag => 'news',
|
||||||
|
@ -78,12 +71,8 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
context ".json" do
|
test "GET /projects/:project_id/news.json should return news" do
|
||||||
should_allow_api_authentication(:get, "/projects/onlinestore/news.json")
|
|
||||||
|
|
||||||
should "return news" do
|
|
||||||
get '/projects/ecookbook/news.json'
|
get '/projects/ecookbook/news.json'
|
||||||
|
|
||||||
json = ActiveSupport::JSON.decode(response.body)
|
json = ActiveSupport::JSON.decode(response.body)
|
||||||
|
@ -93,5 +82,3 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
|
||||||
assert_equal 2, json['news'].first['id']
|
assert_equal 2, json['news'].first['id']
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
Loading…
Reference in New Issue