To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / .svn / pristine / 20 / 20f8dff24ed27f7604eb718009f2a8bf899ab23c.svn-base @ 1298:4f746d8966dd

History | View | Annotate | Download (2.8 KB)

1
# Redmine - project management software
2
# Copyright (C) 2006-2012  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
require 'pp'
20
class ApiTest::NewsTest < ActionController::IntegrationTest
21
  fixtures :projects, :trackers, :issue_statuses, :issues,
22
           :enumerations, :users, :issue_categories,
23
           :projects_trackers,
24
           :roles,
25
           :member_roles,
26
           :members,
27
           :enabled_modules,
28
           :workflows,
29
           :news
30

    
31
  def setup
32
    Setting.rest_api_enabled = '1'
33
  end
34

    
35
  context "GET /news" do
36
    context ".xml" do
37
      should "return news" do
38
        get '/news.xml'
39

    
40
        assert_tag :tag => 'news',
41
          :attributes => {:type => 'array'},
42
          :child => {
43
            :tag => 'news',
44
            :child => {
45
              :tag => 'id',
46
              :content => '2'
47
            }
48
          }
49
      end
50
    end
51

    
52
    context ".json" do
53
      should "return news" do
54
        get '/news.json'
55

    
56
        json = ActiveSupport::JSON.decode(response.body)
57
        assert_kind_of Hash, json
58
        assert_kind_of Array, json['news']
59
        assert_kind_of Hash, json['news'].first
60
        assert_equal 2, json['news'].first['id']
61
      end
62
    end
63
  end
64

    
65
  context "GET /projects/:project_id/news" do
66
    context ".xml" do
67
      should_allow_api_authentication(:get, "/projects/onlinestore/news.xml")
68

    
69
      should "return news" do
70
        get '/projects/ecookbook/news.xml'
71

    
72
        assert_tag :tag => 'news',
73
          :attributes => {:type => 'array'},
74
          :child => {
75
            :tag => 'news',
76
            :child => {
77
              :tag => 'id',
78
              :content => '2'
79
            }
80
          }
81
      end
82
    end
83

    
84
    context ".json" do
85
      should_allow_api_authentication(:get, "/projects/onlinestore/news.json")
86

    
87
      should "return news" do
88
        get '/projects/ecookbook/news.json'
89

    
90
        json = ActiveSupport::JSON.decode(response.body)
91
        assert_kind_of Hash, json
92
        assert_kind_of Array, json['news']
93
        assert_kind_of Hash, json['news'].first
94
        assert_equal 2, json['news'].first['id']
95
      end
96
    end
97
  end
98
end