To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / .svn / pristine / 42 / 4222efb8f989394cbc29df18dfb204374b8d5e79.svn-base @ 1298:4f746d8966dd
History | View | Annotate | Download (2.77 KB)
| 1 | 1295:622f24f53b42 | Chris | # 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::NewsTest < Redmine::ApiTest::Base |
||
| 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 | :news |
||
| 29 | |||
| 30 | def setup |
||
| 31 | Setting.rest_api_enabled = '1' |
||
| 32 | end |
||
| 33 | |||
| 34 | context "GET /news" do |
||
| 35 | context ".xml" do |
||
| 36 | should "return news" do |
||
| 37 | get '/news.xml' |
||
| 38 | |||
| 39 | assert_tag :tag => 'news', |
||
| 40 | :attributes => {:type => 'array'},
|
||
| 41 | :child => {
|
||
| 42 | :tag => 'news', |
||
| 43 | :child => {
|
||
| 44 | :tag => 'id', |
||
| 45 | :content => '2' |
||
| 46 | } |
||
| 47 | } |
||
| 48 | end |
||
| 49 | end |
||
| 50 | |||
| 51 | context ".json" do |
||
| 52 | should "return news" do |
||
| 53 | get '/news.json' |
||
| 54 | |||
| 55 | json = ActiveSupport::JSON.decode(response.body) |
||
| 56 | assert_kind_of Hash, json |
||
| 57 | assert_kind_of Array, json['news'] |
||
| 58 | assert_kind_of Hash, json['news'].first |
||
| 59 | assert_equal 2, json['news'].first['id'] |
||
| 60 | end |
||
| 61 | end |
||
| 62 | end |
||
| 63 | |||
| 64 | context "GET /projects/:project_id/news" do |
||
| 65 | context ".xml" do |
||
| 66 | should_allow_api_authentication(:get, "/projects/onlinestore/news.xml") |
||
| 67 | |||
| 68 | should "return news" do |
||
| 69 | get '/projects/ecookbook/news.xml' |
||
| 70 | |||
| 71 | assert_tag :tag => 'news', |
||
| 72 | :attributes => {:type => 'array'},
|
||
| 73 | :child => {
|
||
| 74 | :tag => 'news', |
||
| 75 | :child => {
|
||
| 76 | :tag => 'id', |
||
| 77 | :content => '2' |
||
| 78 | } |
||
| 79 | } |
||
| 80 | end |
||
| 81 | end |
||
| 82 | |||
| 83 | context ".json" do |
||
| 84 | should_allow_api_authentication(:get, "/projects/onlinestore/news.json") |
||
| 85 | |||
| 86 | should "return news" do |
||
| 87 | get '/projects/ecookbook/news.json' |
||
| 88 | |||
| 89 | json = ActiveSupport::JSON.decode(response.body) |
||
| 90 | assert_kind_of Hash, json |
||
| 91 | assert_kind_of Array, json['news'] |
||
| 92 | assert_kind_of Hash, json['news'].first |
||
| 93 | assert_equal 2, json['news'].first['id'] |
||
| 94 | end |
||
| 95 | end |
||
| 96 | end |
||
| 97 | end |