27 |
27 |
:member_roles,
|
28 |
28 |
:members,
|
29 |
29 |
:enabled_modules,
|
30 |
|
:news
|
|
30 |
:news,
|
|
31 |
:comments
|
31 |
32 |
|
32 |
33 |
test "GET /news.xml should return news" do
|
33 |
34 |
get '/news.xml'
|
... | ... | |
61 |
62 |
assert_equal 2, json['news'].first['id']
|
62 |
63 |
end
|
63 |
64 |
|
|
65 |
test "GET /news/:id.xml" do
|
|
66 |
get "/news/1.xml"
|
|
67 |
assert_response :success
|
|
68 |
assert_equal 'application/xml', response.content_type
|
|
69 |
assert_select 'news' do
|
|
70 |
assert_select 'id', 1
|
|
71 |
assert_select "project[id=1][name=\"eCookbook\"]"
|
|
72 |
assert_select "author[id=2][name=\"John Smith\"]"
|
|
73 |
assert_select 'title', 'eCookbook first release !'
|
|
74 |
assert_select 'summary', 'First version was released...'
|
|
75 |
assert_select 'description', "eCookbook 1.0 has been released.\n\nVisit http://ecookbook.somenet.foo/"
|
|
76 |
iso_date = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/
|
|
77 |
assert_select 'news>created_on', :text => iso_date
|
|
78 |
end
|
|
79 |
end
|
|
80 |
|
|
81 |
test "GET /news/:id.json" do
|
|
82 |
get "/news/1.json"
|
|
83 |
assert_response :success
|
|
84 |
assert_equal 'application/json', response.content_type
|
|
85 |
json = ActiveSupport::JSON.decode(response.body)
|
|
86 |
assert_equal 1, json['news']['id']
|
|
87 |
end
|
|
88 |
|
|
89 |
test "GET /news/:id.xml with attachments" do
|
|
90 |
news = News.find(1)
|
|
91 |
attachment = Attachment.first
|
|
92 |
attachment.container = news
|
|
93 |
attachment.save!
|
|
94 |
|
|
95 |
get "/news/1.xml?include=attachments"
|
|
96 |
assert_select 'news attachments[type=array]' do
|
|
97 |
assert_select 'attachment id', :text => '1' do
|
|
98 |
assert_select '~ filename', :text => 'error281.txt'
|
|
99 |
assert_select '~ content_url', :text => 'http://www.example.com/attachments/download/1/error281.txt'
|
|
100 |
end
|
|
101 |
end
|
|
102 |
end
|
|
103 |
|
|
104 |
test "GET /news/:id.xml with comments" do
|
|
105 |
get "/news/1.xml?include=comments"
|
|
106 |
assert_select 'news comments[type=array]' do
|
|
107 |
assert_select 'comment', 2
|
|
108 |
assert_select 'comment[id=1]' do
|
|
109 |
assert_select 'author[id=1][name="Redmine Admin"]'
|
|
110 |
assert_select 'content', :text => 'my first comment'
|
|
111 |
end
|
|
112 |
assert_select 'comment[id=2]' do
|
|
113 |
assert_select 'author[id=2][name="John Smith"]'
|
|
114 |
assert_select 'content', :text => 'This is an other comment'
|
|
115 |
end
|
|
116 |
end
|
|
117 |
end
|
|
118 |
|
64 |
119 |
test "POST /project/:project_id/news.xml should create a news with the attributes" do
|
65 |
120 |
payload = <<-XML
|
66 |
121 |
<?xml version="1.0" encoding="UTF-8" ?>
|