mirror of
https://github.com/redmine/redmine.git
synced 2025-11-05 04:45:57 +01:00
Pull up #setup and #teardown in API tests.
git-svn-id: http://svn.redmine.org/redmine/trunk@13679 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::ApiTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::ApiTest < Redmine::ApiTest::Base
|
||||||
fixtures :users
|
fixtures :users
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_api_should_work_with_protect_from_forgery
|
def test_api_should_work_with_protect_from_forgery
|
||||||
ActionController::Base.allow_forgery_protection = true
|
ActionController::Base.allow_forgery_protection = true
|
||||||
assert_difference('User.count') do
|
assert_difference('User.count') do
|
||||||
|
|||||||
@@ -28,11 +28,12 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
|
|||||||
:attachments
|
:attachments
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Setting.rest_api_enabled = '1'
|
super
|
||||||
set_fixtures_attachments_directory
|
set_fixtures_attachments_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
def teardown
|
def teardown
|
||||||
|
super
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -20,14 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base
|
||||||
fixtures :users
|
fixtures :users
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
def teardown
|
|
||||||
Setting.rest_api_enabled = '0'
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_api_should_deny_without_credentials
|
def test_api_should_deny_without_credentials
|
||||||
get '/users/current.xml', {}
|
get '/users/current.xml', {}
|
||||||
assert_response 401
|
assert_response 401
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base
|
||||||
fixtures :users
|
fixtures :users
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_integer_custom_fields_should_accept_strings
|
def test_integer_custom_fields_should_accept_strings
|
||||||
field = GroupCustomField.generate!(:field_format => 'int')
|
field = GroupCustomField.generate!(:field_format => 'int')
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::CustomFieldsTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::CustomFieldsTest < Redmine::ApiTest::Base
|
||||||
fixtures :users, :custom_fields
|
fixtures :users, :custom_fields
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /custom_fields.xml should return custom fields" do
|
test "GET /custom_fields.xml should return custom fields" do
|
||||||
get '/custom_fields.xml', {}, credentials('admin')
|
get '/custom_fields.xml', {}, credentials('admin')
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::EnumerationsTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::EnumerationsTest < Redmine::ApiTest::Base
|
||||||
fixtures :enumerations
|
fixtures :enumerations
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /enumerations/issue_priorities.xml should return priorities" do
|
test "GET /enumerations/issue_priorities.xml should return priorities" do
|
||||||
get '/enumerations/issue_priorities.xml'
|
get '/enumerations/issue_priorities.xml'
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
|
||||||
fixtures :users, :groups_users
|
fixtures :users, :groups_users
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /groups.xml should require authentication" do
|
test "GET /groups.xml should require authentication" do
|
||||||
get '/groups.xml'
|
get '/groups.xml'
|
||||||
assert_response 401
|
assert_response 401
|
||||||
|
|||||||
@@ -24,10 +24,6 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
|
|||||||
:members,
|
:members,
|
||||||
:enabled_modules
|
:enabled_modules
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /projects/:project_id/issue_categories.xml should return the issue categories" do
|
test "GET /projects/:project_id/issue_categories.xml should return the 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
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
|
|||||||
:enabled_modules,
|
:enabled_modules,
|
||||||
:issue_relations
|
:issue_relations
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /issues/:issue_id/relations.xml should return issue relations" do
|
test "GET /issues/:issue_id/relations.xml should return issue relations" do
|
||||||
get '/issues/9/relations.xml', {}, credentials('jsmith')
|
get '/issues/9/relations.xml', {}, credentials('jsmith')
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::IssueStatusesTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::IssueStatusesTest < Redmine::ApiTest::Base
|
||||||
fixtures :issue_statuses
|
fixtures :issue_statuses
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /issue_statuses.xml should return issue statuses" do
|
test "GET /issue_statuses.xml should return issue statuses" do
|
||||||
get '/issue_statuses.xml'
|
get '/issue_statuses.xml'
|
||||||
|
|
||||||
|
|||||||
@@ -44,10 +44,6 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
|
|||||||
:queries,
|
:queries,
|
||||||
:attachments
|
:attachments
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /issues.xml should contain metadata" do
|
test "GET /issues.xml should contain metadata" do
|
||||||
get '/issues.xml'
|
get '/issues.xml'
|
||||||
assert_select 'issues[type=array][total_count=?][limit="25"][offset="0"]',
|
assert_select 'issues[type=array][total_count=?][limit="25"][offset="0"]',
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
|
||||||
fixtures :projects, :users, :roles, :members, :member_roles
|
fixtures :projects, :users, :roles, :members, :member_roles
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /projects/:project_id/memberships.xml should return memberships" do
|
test "GET /projects/:project_id/memberships.xml should return memberships" do
|
||||||
get '/projects/1/memberships.xml', {}, credentials('jsmith')
|
get '/projects/1/memberships.xml', {}, credentials('jsmith')
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
|
|||||||
:enabled_modules,
|
:enabled_modules,
|
||||||
:news
|
:news
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /news.xml should return news" do
|
test "GET /news.xml should return news" do
|
||||||
get '/news.xml'
|
get '/news.xml'
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
|
|||||||
:attachments, :custom_fields, :custom_values, :time_entries, :issue_categories
|
:attachments, :custom_fields, :custom_values, :time_entries, :issue_categories
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Setting.rest_api_enabled = '1'
|
super
|
||||||
set_tmp_attachments_directory
|
set_tmp_attachments_directory
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ class Redmine::ApiTest::QueriesTest < Redmine::ApiTest::Base
|
|||||||
:enabled_modules,
|
:enabled_modules,
|
||||||
:queries
|
:queries
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /queries.xml should return queries" do
|
test "GET /queries.xml should return queries" do
|
||||||
get '/queries.xml'
|
get '/queries.xml'
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base
|
||||||
fixtures :roles
|
fixtures :roles
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /roles.xml should return the roles" do
|
test "GET /roles.xml should return the roles" do
|
||||||
get '/roles.xml'
|
get '/roles.xml'
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
|
|||||||
:enabled_modules,
|
:enabled_modules,
|
||||||
:time_entries
|
:time_entries
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /time_entries.xml should return time entries" do
|
test "GET /time_entries.xml should return time entries" do
|
||||||
get '/time_entries.xml', {}, credentials('jsmith')
|
get '/time_entries.xml', {}, credentials('jsmith')
|
||||||
assert_response :success
|
assert_response :success
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::TrackersTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::TrackersTest < Redmine::ApiTest::Base
|
||||||
fixtures :trackers
|
fixtures :trackers
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /trackers.xml should return trackers" do
|
test "GET /trackers.xml should return trackers" do
|
||||||
get '/trackers.xml'
|
get '/trackers.xml'
|
||||||
|
|
||||||
|
|||||||
@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
|
|||||||
class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
|
class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
|
||||||
fixtures :users, :members, :member_roles, :roles, :projects
|
fixtures :users, :members, :member_roles, :roles, :projects
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /users/:id.xml should return the user" do
|
test "GET /users/:id.xml should return the user" do
|
||||||
get '/users/2.xml'
|
get '/users/2.xml'
|
||||||
|
|
||||||
|
|||||||
@@ -27,10 +27,6 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
|
|||||||
:enabled_modules,
|
:enabled_modules,
|
||||||
:versions
|
:versions
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /projects/:project_id/versions.xml should return project versions" do
|
test "GET /projects/:project_id/versions.xml should return project versions" do
|
||||||
get '/projects/1/versions.xml'
|
get '/projects/1/versions.xml'
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,6 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base
|
|||||||
:enabled_modules, :wikis, :wiki_pages, :wiki_contents,
|
:enabled_modules, :wikis, :wiki_pages, :wiki_contents,
|
||||||
:wiki_content_versions, :attachments
|
:wiki_content_versions, :attachments
|
||||||
|
|
||||||
def setup
|
|
||||||
Setting.rest_api_enabled = '1'
|
|
||||||
end
|
|
||||||
|
|
||||||
test "GET /projects/:project_id/wiki/index.xml should return wiki pages" do
|
test "GET /projects/:project_id/wiki/index.xml should return wiki pages" do
|
||||||
get '/projects/ecookbook/wiki/index.xml'
|
get '/projects/ecookbook/wiki/index.xml'
|
||||||
assert_response 200
|
assert_response 200
|
||||||
|
|||||||
@@ -253,6 +253,13 @@ module Redmine
|
|||||||
|
|
||||||
# Base class for API tests
|
# Base class for API tests
|
||||||
class Base < ActionDispatch::IntegrationTest
|
class Base < ActionDispatch::IntegrationTest
|
||||||
|
def setup
|
||||||
|
Setting.rest_api_enabled = '1'
|
||||||
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
Setting.rest_api_enabled = '0'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class Routing < Redmine::RoutingTest
|
class Routing < Redmine::RoutingTest
|
||||||
|
|||||||
Reference in New Issue
Block a user