Chris@119
|
1 # Redmine - project management software
|
Chris@1295
|
2 # Copyright (C) 2006-2013 Jean-Philippe Lang
|
Chris@119
|
3 #
|
Chris@119
|
4 # This program is free software; you can redistribute it and/or
|
Chris@119
|
5 # modify it under the terms of the GNU General Public License
|
Chris@119
|
6 # as published by the Free Software Foundation; either version 2
|
Chris@119
|
7 # of the License, or (at your option) any later version.
|
Chris@909
|
8 #
|
Chris@119
|
9 # This program is distributed in the hope that it will be useful,
|
Chris@119
|
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@119
|
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@119
|
12 # GNU General Public License for more details.
|
Chris@909
|
13 #
|
Chris@119
|
14 # You should have received a copy of the GNU General Public License
|
Chris@119
|
15 # along with this program; if not, write to the Free Software
|
Chris@119
|
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
Chris@119
|
17
|
Chris@119
|
18 require File.expand_path('../../../test_helper', __FILE__)
|
Chris@1295
|
19
|
Chris@1295
|
20 class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base
|
Chris@909
|
21 fixtures :projects, :trackers, :issue_statuses, :issues,
|
Chris@909
|
22 :enumerations, :users, :issue_categories,
|
Chris@909
|
23 :projects_trackers,
|
Chris@909
|
24 :roles,
|
Chris@909
|
25 :member_roles,
|
Chris@909
|
26 :members,
|
Chris@909
|
27 :enabled_modules,
|
Chris@909
|
28 :news
|
Chris@119
|
29
|
Chris@119
|
30 def setup
|
Chris@119
|
31 Setting.rest_api_enabled = '1'
|
Chris@119
|
32 end
|
Chris@119
|
33
|
Chris@119
|
34 context "GET /news" do
|
Chris@119
|
35 context ".xml" do
|
Chris@119
|
36 should "return news" do
|
Chris@119
|
37 get '/news.xml'
|
Chris@909
|
38
|
Chris@119
|
39 assert_tag :tag => 'news',
|
Chris@119
|
40 :attributes => {:type => 'array'},
|
Chris@119
|
41 :child => {
|
Chris@119
|
42 :tag => 'news',
|
Chris@119
|
43 :child => {
|
Chris@119
|
44 :tag => 'id',
|
Chris@119
|
45 :content => '2'
|
Chris@119
|
46 }
|
Chris@119
|
47 }
|
Chris@119
|
48 end
|
Chris@119
|
49 end
|
Chris@909
|
50
|
Chris@119
|
51 context ".json" do
|
Chris@119
|
52 should "return news" do
|
Chris@119
|
53 get '/news.json'
|
Chris@909
|
54
|
Chris@119
|
55 json = ActiveSupport::JSON.decode(response.body)
|
Chris@119
|
56 assert_kind_of Hash, json
|
Chris@119
|
57 assert_kind_of Array, json['news']
|
Chris@119
|
58 assert_kind_of Hash, json['news'].first
|
Chris@119
|
59 assert_equal 2, json['news'].first['id']
|
Chris@119
|
60 end
|
Chris@119
|
61 end
|
Chris@119
|
62 end
|
Chris@119
|
63
|
Chris@119
|
64 context "GET /projects/:project_id/news" do
|
Chris@119
|
65 context ".xml" do
|
Chris@119
|
66 should_allow_api_authentication(:get, "/projects/onlinestore/news.xml")
|
Chris@909
|
67
|
Chris@119
|
68 should "return news" do
|
Chris@119
|
69 get '/projects/ecookbook/news.xml'
|
Chris@909
|
70
|
Chris@119
|
71 assert_tag :tag => 'news',
|
Chris@119
|
72 :attributes => {:type => 'array'},
|
Chris@119
|
73 :child => {
|
Chris@119
|
74 :tag => 'news',
|
Chris@119
|
75 :child => {
|
Chris@119
|
76 :tag => 'id',
|
Chris@119
|
77 :content => '2'
|
Chris@119
|
78 }
|
Chris@119
|
79 }
|
Chris@119
|
80 end
|
Chris@119
|
81 end
|
Chris@909
|
82
|
Chris@119
|
83 context ".json" do
|
Chris@119
|
84 should_allow_api_authentication(:get, "/projects/onlinestore/news.json")
|
Chris@909
|
85
|
Chris@119
|
86 should "return news" do
|
Chris@119
|
87 get '/projects/ecookbook/news.json'
|
Chris@909
|
88
|
Chris@119
|
89 json = ActiveSupport::JSON.decode(response.body)
|
Chris@119
|
90 assert_kind_of Hash, json
|
Chris@119
|
91 assert_kind_of Array, json['news']
|
Chris@119
|
92 assert_kind_of Hash, json['news'].first
|
Chris@119
|
93 assert_equal 2, json['news'].first['id']
|
Chris@119
|
94 end
|
Chris@119
|
95 end
|
Chris@119
|
96 end
|
Chris@119
|
97 end
|