Commit 146184f7 authored by jplang's avatar jplang

Pull up #setup and #teardown in API tests.

git-svn-id: https://svn.redmine.org/redmine/trunk@13679 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 25d04e65
......@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::ApiTest < Redmine::ApiTest::Base
fixtures :users
def setup
Setting.rest_api_enabled = '1'
end
def test_api_should_work_with_protect_from_forgery
ActionController::Base.allow_forgery_protection = true
assert_difference('User.count') do
......
......@@ -28,11 +28,12 @@ class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
:attachments
def setup
Setting.rest_api_enabled = '1'
super
set_fixtures_attachments_directory
end
def teardown
super
set_tmp_attachments_directory
end
......
......@@ -20,14 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base
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
get '/users/current.xml', {}
assert_response 401
......
......@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base
fixtures :users
def setup
Setting.rest_api_enabled = '1'
end
def test_integer_custom_fields_should_accept_strings
field = GroupCustomField.generate!(:field_format => 'int')
......
......@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::CustomFieldsTest < Redmine::ApiTest::Base
fixtures :users, :custom_fields
def setup
Setting.rest_api_enabled = '1'
end
test "GET /custom_fields.xml should return custom fields" do
get '/custom_fields.xml', {}, credentials('admin')
assert_response :success
......
......@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::EnumerationsTest < Redmine::ApiTest::Base
fixtures :enumerations
def setup
Setting.rest_api_enabled = '1'
end
test "GET /enumerations/issue_priorities.xml should return priorities" do
get '/enumerations/issue_priorities.xml'
assert_response :success
......
......@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
fixtures :users, :groups_users
def setup
Setting.rest_api_enabled = '1'
end
test "GET /groups.xml should require authentication" do
get '/groups.xml'
assert_response 401
......
......@@ -24,10 +24,6 @@ class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
:members,
:enabled_modules
def setup
Setting.rest_api_enabled = '1'
end
test "GET /projects/:project_id/issue_categories.xml should return the issue categories" do
get '/projects/1/issue_categories.xml', {}, credentials('jsmith')
assert_response :success
......
......@@ -27,10 +27,6 @@ class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
:enabled_modules,
:issue_relations
def setup
Setting.rest_api_enabled = '1'
end
test "GET /issues/:issue_id/relations.xml should return issue relations" do
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
fixtures :issue_statuses
def setup
Setting.rest_api_enabled = '1'
end
test "GET /issue_statuses.xml should return issue statuses" do
get '/issue_statuses.xml'
......
......@@ -44,10 +44,6 @@ class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
:queries,
:attachments
def setup
Setting.rest_api_enabled = '1'
end
test "GET /issues.xml should contain metadata" do
get '/issues.xml'
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
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
get '/projects/1/memberships.xml', {}, credentials('jsmith')
......
......@@ -27,10 +27,6 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
:enabled_modules,
:news
def setup
Setting.rest_api_enabled = '1'
end
test "GET /news.xml should return news" do
get '/news.xml'
......
......@@ -23,7 +23,7 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
:attachments, :custom_fields, :custom_values, :time_entries, :issue_categories
def setup
Setting.rest_api_enabled = '1'
super
set_tmp_attachments_directory
end
......
......@@ -27,10 +27,6 @@ class Redmine::ApiTest::QueriesTest < Redmine::ApiTest::Base
:enabled_modules,
:queries
def setup
Setting.rest_api_enabled = '1'
end
test "GET /queries.xml should return queries" do
get '/queries.xml'
......
......@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base
fixtures :roles
def setup
Setting.rest_api_enabled = '1'
end
test "GET /roles.xml should return the roles" do
get '/roles.xml'
......
......@@ -27,10 +27,6 @@ class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
:enabled_modules,
:time_entries
def setup
Setting.rest_api_enabled = '1'
end
test "GET /time_entries.xml should return time entries" do
get '/time_entries.xml', {}, credentials('jsmith')
assert_response :success
......
......@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::TrackersTest < Redmine::ApiTest::Base
fixtures :trackers
def setup
Setting.rest_api_enabled = '1'
end
test "GET /trackers.xml should return trackers" do
get '/trackers.xml'
......
......@@ -20,10 +20,6 @@ require File.expand_path('../../../test_helper', __FILE__)
class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
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
get '/users/2.xml'
......
......@@ -27,10 +27,6 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
:enabled_modules,
:versions
def setup
Setting.rest_api_enabled = '1'
end
test "GET /projects/:project_id/versions.xml should return project versions" do
get '/projects/1/versions.xml'
......
......@@ -22,10 +22,6 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base
:enabled_modules, :wikis, :wiki_pages, :wiki_contents,
: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
get '/projects/ecookbook/wiki/index.xml'
assert_response 200
......
......@@ -253,6 +253,13 @@ module Redmine
# Base class for API tests
class Base < ActionDispatch::IntegrationTest
def setup
Setting.rest_api_enabled = '1'
end
def teardown
Setting.rest_api_enabled = '0'
end
end
class Routing < Redmine::RoutingTest
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment