diff options
author | Go MAEDA <maeda@farend.jp> | 2019-09-09 08:55:43 +0000 |
---|---|---|
committer | Go MAEDA <maeda@farend.jp> | 2019-09-09 08:55:43 +0000 |
commit | 3ca75647dfbc3c41f11f202b436a1463cca8236c (patch) | |
tree | 115e02908886644aaa31d5f593141ce0c90f15bc /test/integration | |
parent | c22469838d33250a1615352accaa0ff9d4e59d04 (diff) | |
download | redmine-3ca75647dfbc3c41f11f202b436a1463cca8236c.tar.gz redmine-3ca75647dfbc3c41f11f202b436a1463cca8236c.zip |
REST API for retrieving news (#13468).
Patch by Takenori TAKAKI.
git-svn-id: http://svn.redmine.org/redmine/trunk@18441 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'test/integration')
-rw-r--r-- | test/integration/api_test/news_test.rb | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/test/integration/api_test/news_test.rb b/test/integration/api_test/news_test.rb index b1b436ad0..48a0b1025 100644 --- a/test/integration/api_test/news_test.rb +++ b/test/integration/api_test/news_test.rb @@ -27,7 +27,8 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base :member_roles, :members, :enabled_modules, - :news + :news, + :comments test "GET /news.xml should return news" do get '/news.xml' @@ -61,6 +62,60 @@ class Redmine::ApiTest::NewsTest < Redmine::ApiTest::Base assert_equal 2, json['news'].first['id'] end + test "GET /news/:id.xml" do + get "/news/1.xml" + assert_response :success + assert_equal 'application/xml', response.content_type + assert_select 'news' do + assert_select 'id', 1 + assert_select "project[id=1][name=\"eCookbook\"]" + assert_select "author[id=2][name=\"John Smith\"]" + assert_select 'title', 'eCookbook first release !' + assert_select 'summary', 'First version was released...' + assert_select 'description', "eCookbook 1.0 has been released.\n\nVisit http://ecookbook.somenet.foo/" + iso_date = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/ + assert_select 'news>created_on', :text => iso_date + end + end + + test "GET /news/:id.json" do + get "/news/1.json" + assert_response :success + assert_equal 'application/json', response.content_type + json = ActiveSupport::JSON.decode(response.body) + assert_equal 1, json['news']['id'] + end + + test "GET /news/:id.xml with attachments" do + news = News.find(1) + attachment = Attachment.first + attachment.container = news + attachment.save! + + get "/news/1.xml?include=attachments" + assert_select 'news attachments[type=array]' do + assert_select 'attachment id', :text => '1' do + assert_select '~ filename', :text => 'error281.txt' + assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/1/error281.txt' + end + end + end + + test "GET /news/:id.xml with comments" do + get "/news/1.xml?include=comments" + assert_select 'news comments[type=array]' do + assert_select 'comment', 2 + assert_select 'comment[id=1]' do + assert_select 'author[id=1][name="Redmine Admin"]' + assert_select 'content', :text => 'my first comment' + end + assert_select 'comment[id=2]' do + assert_select 'author[id=2][name="John Smith"]' + assert_select 'content', :text => 'This is an other comment' + end + end + end + test "POST /project/:project_id/news.xml should create a news with the attributes" do payload = <<~XML <?xml version="1.0" encoding="UTF-8" ?> |