Mercurial > hg > soundsoftware-site
comparison .svn/pristine/f8/f8e3393c3af527d599685daf189e7b5311a95a64.svn-base @ 1298:4f746d8966dd redmine_2.3_integration
Merge from redmine-2.3 branch to create new branch redmine-2.3-integration
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:28:30 +0100 |
parents | 622f24f53b42 |
children |
comparison
equal
deleted
inserted
replaced
1297:0a574315af3e | 1298:4f746d8966dd |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2013 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
18 require File.expand_path('../../../test_helper', __FILE__) | |
19 | |
20 class Redmine::ApiTest::JsonpTest < Redmine::ApiTest::Base | |
21 fixtures :trackers | |
22 | |
23 def test_should_ignore_jsonp_callback_with_jsonp_disabled | |
24 with_settings :jsonp_enabled => '0' do | |
25 get '/trackers.json?jsonp=handler' | |
26 end | |
27 | |
28 assert_response :success | |
29 assert_match %r{^\{"trackers":.+\}$}, response.body | |
30 assert_equal 'application/json; charset=utf-8', response.headers['Content-Type'] | |
31 end | |
32 | |
33 def test_jsonp_should_accept_callback_param | |
34 with_settings :jsonp_enabled => '1' do | |
35 get '/trackers.json?callback=handler' | |
36 end | |
37 | |
38 assert_response :success | |
39 assert_match %r{^handler\(\{"trackers":.+\}\)$}, response.body | |
40 assert_equal 'application/javascript; charset=utf-8', response.headers['Content-Type'] | |
41 end | |
42 | |
43 def test_jsonp_should_accept_jsonp_param | |
44 with_settings :jsonp_enabled => '1' do | |
45 get '/trackers.json?jsonp=handler' | |
46 end | |
47 | |
48 assert_response :success | |
49 assert_match %r{^handler\(\{"trackers":.+\}\)$}, response.body | |
50 assert_equal 'application/javascript; charset=utf-8', response.headers['Content-Type'] | |
51 end | |
52 | |
53 def test_jsonp_should_strip_invalid_characters_from_callback | |
54 with_settings :jsonp_enabled => '1' do | |
55 get '/trackers.json?callback=+-aA$1_' | |
56 end | |
57 | |
58 assert_response :success | |
59 assert_match %r{^aA1_\(\{"trackers":.+\}\)$}, response.body | |
60 assert_equal 'application/javascript; charset=utf-8', response.headers['Content-Type'] | |
61 end | |
62 | |
63 def test_jsonp_without_callback_should_return_json | |
64 with_settings :jsonp_enabled => '1' do | |
65 get '/trackers.json?callback=' | |
66 end | |
67 | |
68 assert_response :success | |
69 assert_match %r{^\{"trackers":.+\}$}, response.body | |
70 assert_equal 'application/json; charset=utf-8', response.headers['Content-Type'] | |
71 end | |
72 end |