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