##// END OF EJS Templates
Pull up #setup and #teardown in API tests....
Jean-Philippe Lang -
r13297:d22029083c48
parent child
Show More
@@ -20,10 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::ApiTest < Redmine::ApiTest::Base
21 21 fixtures :users
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 23 def test_api_should_work_with_protect_from_forgery
28 24 ActionController::Base.allow_forgery_protection = true
29 25 assert_difference('User.count') do
@@ -28,11 +28,12 class Redmine::ApiTest::AttachmentsTest < Redmine::ApiTest::Base
28 28 :attachments
29 29
30 30 def setup
31 Setting.rest_api_enabled = '1'
31 super
32 32 set_fixtures_attachments_directory
33 33 end
34 34
35 35 def teardown
36 super
36 37 set_tmp_attachments_directory
37 38 end
38 39
@@ -20,14 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::AuthenticationTest < Redmine::ApiTest::Base
21 21 fixtures :users
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 def teardown
28 Setting.rest_api_enabled = '0'
29 end
30
31 23 def test_api_should_deny_without_credentials
32 24 get '/users/current.xml', {}
33 25 assert_response 401
@@ -20,10 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::CustomFieldsAttributeTest < Redmine::ApiTest::Base
21 21 fixtures :users
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 23 def test_integer_custom_fields_should_accept_strings
28 24 field = GroupCustomField.generate!(:field_format => 'int')
29 25
@@ -20,10 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::CustomFieldsTest < Redmine::ApiTest::Base
21 21 fixtures :users, :custom_fields
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 23 test "GET /custom_fields.xml should return custom fields" do
28 24 get '/custom_fields.xml', {}, credentials('admin')
29 25 assert_response :success
@@ -20,10 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::EnumerationsTest < Redmine::ApiTest::Base
21 21 fixtures :enumerations
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 23 test "GET /enumerations/issue_priorities.xml should return priorities" do
28 24 get '/enumerations/issue_priorities.xml'
29 25 assert_response :success
@@ -20,10 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::GroupsTest < Redmine::ApiTest::Base
21 21 fixtures :users, :groups_users
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 23 test "GET /groups.xml should require authentication" do
28 24 get '/groups.xml'
29 25 assert_response 401
@@ -24,10 +24,6 class Redmine::ApiTest::IssueCategoriesTest < Redmine::ApiTest::Base
24 24 :members,
25 25 :enabled_modules
26 26
27 def setup
28 Setting.rest_api_enabled = '1'
29 end
30
31 27 test "GET /projects/:project_id/issue_categories.xml should return the issue categories" do
32 28 get '/projects/1/issue_categories.xml', {}, credentials('jsmith')
33 29 assert_response :success
@@ -27,10 +27,6 class Redmine::ApiTest::IssueRelationsTest < Redmine::ApiTest::Base
27 27 :enabled_modules,
28 28 :issue_relations
29 29
30 def setup
31 Setting.rest_api_enabled = '1'
32 end
33
34 30 test "GET /issues/:issue_id/relations.xml should return issue relations" do
35 31 get '/issues/9/relations.xml', {}, credentials('jsmith')
36 32
@@ -20,10 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::IssueStatusesTest < Redmine::ApiTest::Base
21 21 fixtures :issue_statuses
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 23 test "GET /issue_statuses.xml should return issue statuses" do
28 24 get '/issue_statuses.xml'
29 25
@@ -44,10 +44,6 class Redmine::ApiTest::IssuesTest < Redmine::ApiTest::Base
44 44 :queries,
45 45 :attachments
46 46
47 def setup
48 Setting.rest_api_enabled = '1'
49 end
50
51 47 test "GET /issues.xml should contain metadata" do
52 48 get '/issues.xml'
53 49 assert_select 'issues[type=array][total_count=?][limit="25"][offset="0"]',
@@ -20,10 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::MembershipsTest < Redmine::ApiTest::Base
21 21 fixtures :projects, :users, :roles, :members, :member_roles
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 23 test "GET /projects/:project_id/memberships.xml should return memberships" do
28 24 get '/projects/1/memberships.xml', {}, credentials('jsmith')
29 25
@@ -27,10 +27,6 class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
27 27 :enabled_modules,
28 28 :news
29 29
30 def setup
31 Setting.rest_api_enabled = '1'
32 end
33
34 30 test "GET /news.xml should return news" do
35 31 get '/news.xml'
36 32
@@ -23,7 +23,7 class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
23 23 :attachments, :custom_fields, :custom_values, :time_entries, :issue_categories
24 24
25 25 def setup
26 Setting.rest_api_enabled = '1'
26 super
27 27 set_tmp_attachments_directory
28 28 end
29 29
@@ -27,10 +27,6 class Redmine::ApiTest::QueriesTest < Redmine::ApiTest::Base
27 27 :enabled_modules,
28 28 :queries
29 29
30 def setup
31 Setting.rest_api_enabled = '1'
32 end
33
34 30 test "GET /queries.xml should return queries" do
35 31 get '/queries.xml'
36 32
@@ -20,10 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::RolesTest < Redmine::ApiTest::Base
21 21 fixtures :roles
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 23 test "GET /roles.xml should return the roles" do
28 24 get '/roles.xml'
29 25
@@ -27,10 +27,6 class Redmine::ApiTest::TimeEntriesTest < Redmine::ApiTest::Base
27 27 :enabled_modules,
28 28 :time_entries
29 29
30 def setup
31 Setting.rest_api_enabled = '1'
32 end
33
34 30 test "GET /time_entries.xml should return time entries" do
35 31 get '/time_entries.xml', {}, credentials('jsmith')
36 32 assert_response :success
@@ -20,10 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::TrackersTest < Redmine::ApiTest::Base
21 21 fixtures :trackers
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 23 test "GET /trackers.xml should return trackers" do
28 24 get '/trackers.xml'
29 25
@@ -20,10 +20,6 require File.expand_path('../../../test_helper', __FILE__)
20 20 class Redmine::ApiTest::UsersTest < Redmine::ApiTest::Base
21 21 fixtures :users, :members, :member_roles, :roles, :projects
22 22
23 def setup
24 Setting.rest_api_enabled = '1'
25 end
26
27 23 test "GET /users/:id.xml should return the user" do
28 24 get '/users/2.xml'
29 25
@@ -27,10 +27,6 class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
27 27 :enabled_modules,
28 28 :versions
29 29
30 def setup
31 Setting.rest_api_enabled = '1'
32 end
33
34 30 test "GET /projects/:project_id/versions.xml should return project versions" do
35 31 get '/projects/1/versions.xml'
36 32
@@ -22,10 +22,6 class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base
22 22 :enabled_modules, :wikis, :wiki_pages, :wiki_contents,
23 23 :wiki_content_versions, :attachments
24 24
25 def setup
26 Setting.rest_api_enabled = '1'
27 end
28
29 25 test "GET /projects/:project_id/wiki/index.xml should return wiki pages" do
30 26 get '/projects/ecookbook/wiki/index.xml'
31 27 assert_response 200
@@ -253,6 +253,13 module Redmine
253 253
254 254 # Base class for API tests
255 255 class Base < ActionDispatch::IntegrationTest
256 def setup
257 Setting.rest_api_enabled = '1'
258 end
259
260 def teardown
261 Setting.rest_api_enabled = '0'
262 end
256 263 end
257 264
258 265 class Routing < Redmine::RoutingTest
General Comments 0
You need to be logged in to leave comments. Login now