##// END OF EJS Templates
Fixed double escaping of Atom feed links....
Etienne Massip -
r8526:54c0b531e127
parent child
Show More
@@ -1,31 +1,31
1 xml.instruct!
1 xml.instruct!
2 xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
2 xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do
3 xml.title truncate_single_line(@title, :length => 100)
3 xml.title truncate_single_line(@title, :length => 100)
4 xml.link "rel" => "self", "href" => url_for(params.merge(:only_path => false))
4 xml.link "rel" => "self", "href" => url_for(params.merge(:only_path => false, :escape => false))
5 xml.link "rel" => "alternate", "href" => url_for(params.merge(:only_path => false, :format => nil, :key => nil))
5 xml.link "rel" => "alternate", "href" => url_for(params.merge(:only_path => false, :format => nil, :key => nil, :escape => false))
6 xml.id url_for(:controller => 'welcome', :only_path => false)
6 xml.id url_for(:controller => 'welcome', :only_path => false)
7 xml.updated((@items.first ? @items.first.event_datetime : Time.now).xmlschema)
7 xml.updated((@items.first ? @items.first.event_datetime : Time.now).xmlschema)
8 xml.author { xml.name "#{Setting.app_title}" }
8 xml.author { xml.name "#{Setting.app_title}" }
9 xml.generator(:uri => Redmine::Info.url) { xml.text! Redmine::Info.app_name; }
9 xml.generator(:uri => Redmine::Info.url) { xml.text! Redmine::Info.app_name; }
10 @items.each do |item|
10 @items.each do |item|
11 xml.entry do
11 xml.entry do
12 url = url_for(item.event_url(:only_path => false))
12 url = url_for(item.event_url(:only_path => false))
13 if @project
13 if @project
14 xml.title truncate_single_line(item.event_title, :length => 100)
14 xml.title truncate_single_line(item.event_title, :length => 100)
15 else
15 else
16 xml.title truncate_single_line("#{item.project} - #{item.event_title}", :length => 100)
16 xml.title truncate_single_line("#{item.project} - #{item.event_title}", :length => 100)
17 end
17 end
18 xml.link "rel" => "alternate", "href" => url
18 xml.link "rel" => "alternate", "href" => url
19 xml.id url
19 xml.id url
20 xml.updated item.event_datetime.xmlschema
20 xml.updated item.event_datetime.xmlschema
21 author = item.event_author if item.respond_to?(:event_author)
21 author = item.event_author if item.respond_to?(:event_author)
22 xml.author do
22 xml.author do
23 xml.name(author)
23 xml.name(author)
24 xml.email(author.mail) if author.is_a?(User) && !author.mail.blank? && !author.pref.hide_mail
24 xml.email(author.mail) if author.is_a?(User) && !author.mail.blank? && !author.pref.hide_mail
25 end if author
25 end if author
26 xml.content "type" => "html" do
26 xml.content "type" => "html" do
27 xml.text! textilizable(item, :event_description, :only_path => false)
27 xml.text! textilizable(item, :event_description, :only_path => false)
28 end
28 end
29 end
29 end
30 end
30 end
31 end
31 end
@@ -1,114 +1,144
1 require File.expand_path('../../test_helper', __FILE__)
1 require File.expand_path('../../test_helper', __FILE__)
2
2
3 class ActivitiesControllerTest < ActionController::TestCase
3 class ActivitiesControllerTest < ActionController::TestCase
4 fixtures :projects, :trackers, :issue_statuses, :issues,
4 fixtures :projects, :trackers, :issue_statuses, :issues,
5 :enumerations, :users, :issue_categories,
5 :enumerations, :users, :issue_categories,
6 :projects_trackers,
6 :projects_trackers,
7 :roles,
7 :roles,
8 :member_roles,
8 :member_roles,
9 :members,
9 :members,
10 :groups_users,
10 :groups_users,
11 :enabled_modules,
11 :enabled_modules,
12 :workflows,
12 :workflows,
13 :auth_sources,
13 :auth_sources,
14 :journals, :journal_details
14 :journals, :journal_details
15
15
16
16
17 def test_project_index
17 def test_project_index
18 get :index, :id => 1, :with_subprojects => 0
18 get :index, :id => 1, :with_subprojects => 0
19 assert_response :success
19 assert_response :success
20 assert_template 'index'
20 assert_template 'index'
21 assert_not_nil assigns(:events_by_day)
21 assert_not_nil assigns(:events_by_day)
22
22
23 assert_tag :tag => "h3",
23 assert_tag :tag => "h3",
24 :content => /#{2.days.ago.to_date.day}/,
24 :content => /#{2.days.ago.to_date.day}/,
25 :sibling => { :tag => "dl",
25 :sibling => { :tag => "dl",
26 :child => { :tag => "dt",
26 :child => { :tag => "dt",
27 :attributes => { :class => /issue-edit/ },
27 :attributes => { :class => /issue-edit/ },
28 :child => { :tag => "a",
28 :child => { :tag => "a",
29 :content => /(#{IssueStatus.find(2).name})/,
29 :content => /(#{IssueStatus.find(2).name})/,
30 }
30 }
31 }
31 }
32 }
32 }
33 end
33 end
34
34
35 def test_project_index_with_invalid_project_id_should_respond_404
35 def test_project_index_with_invalid_project_id_should_respond_404
36 get :index, :id => 299
36 get :index, :id => 299
37 assert_response 404
37 assert_response 404
38 end
38 end
39
39
40 def test_previous_project_index
40 def test_previous_project_index
41 get :index, :id => 1, :from => 3.days.ago.to_date
41 get :index, :id => 1, :from => 3.days.ago.to_date
42 assert_response :success
42 assert_response :success
43 assert_template 'index'
43 assert_template 'index'
44 assert_not_nil assigns(:events_by_day)
44 assert_not_nil assigns(:events_by_day)
45
45
46 assert_tag :tag => "h3",
46 assert_tag :tag => "h3",
47 :content => /#{3.day.ago.to_date.day}/,
47 :content => /#{3.day.ago.to_date.day}/,
48 :sibling => { :tag => "dl",
48 :sibling => { :tag => "dl",
49 :child => { :tag => "dt",
49 :child => { :tag => "dt",
50 :attributes => { :class => /issue/ },
50 :attributes => { :class => /issue/ },
51 :child => { :tag => "a",
51 :child => { :tag => "a",
52 :content => /#{Issue.find(1).subject}/,
52 :content => /#{Issue.find(1).subject}/,
53 }
53 }
54 }
54 }
55 }
55 }
56 end
56 end
57
57
58 def test_global_index
58 def test_global_index
59 get :index
59 get :index
60 assert_response :success
60 assert_response :success
61 assert_template 'index'
61 assert_template 'index'
62 assert_not_nil assigns(:events_by_day)
62 assert_not_nil assigns(:events_by_day)
63
63
64 assert_tag :tag => "h3",
64 assert_tag :tag => "h3",
65 :content => /#{5.day.ago.to_date.day}/,
65 :content => /#{5.day.ago.to_date.day}/,
66 :sibling => { :tag => "dl",
66 :sibling => { :tag => "dl",
67 :child => { :tag => "dt",
67 :child => { :tag => "dt",
68 :attributes => { :class => /issue/ },
68 :attributes => { :class => /issue/ },
69 :child => { :tag => "a",
69 :child => { :tag => "a",
70 :content => /#{Issue.find(5).subject}/,
70 :content => /#{Issue.find(5).subject}/,
71 }
71 }
72 }
72 }
73 }
73 }
74 end
74 end
75
75
76 def test_user_index
76 def test_user_index
77 get :index, :user_id => 2
77 get :index, :user_id => 2
78 assert_response :success
78 assert_response :success
79 assert_template 'index'
79 assert_template 'index'
80 assert_not_nil assigns(:events_by_day)
80 assert_not_nil assigns(:events_by_day)
81
81
82 assert_tag :tag => "h3",
82 assert_tag :tag => "h3",
83 :content => /#{3.day.ago.to_date.day}/,
83 :content => /#{3.day.ago.to_date.day}/,
84 :sibling => { :tag => "dl",
84 :sibling => { :tag => "dl",
85 :child => { :tag => "dt",
85 :child => { :tag => "dt",
86 :attributes => { :class => /issue/ },
86 :attributes => { :class => /issue/ },
87 :child => { :tag => "a",
87 :child => { :tag => "a",
88 :content => /#{Issue.find(1).subject}/,
88 :content => /#{Issue.find(1).subject}/,
89 }
89 }
90 }
90 }
91 }
91 }
92 end
92 end
93
93
94 def test_user_index_with_invalid_user_id_should_respond_404
94 def test_user_index_with_invalid_user_id_should_respond_404
95 get :index, :user_id => 299
95 get :index, :user_id => 299
96 assert_response 404
96 assert_response 404
97 end
97 end
98
98
99 def test_index_atom_feed
99 def test_index_atom_feed
100 get :index, :format => 'atom'
100 get :index, :format => 'atom', :with_subprojects => 0
101 assert_response :success
101 assert_response :success
102 assert_template 'common/feed.atom'
102 assert_template 'common/feed.atom'
103
104 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
105 :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?with_subprojects=0'}
106 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
107 :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?with_subprojects=0'}
108
109 assert_tag :tag => 'entry', :child => {
110 :tag => 'link',
111 :attributes => {:href => 'http://test.host/issues/11'}}
112 end
113
114 def test_index_atom_feed_with_explicit_selection
115 get :index, :format => 'atom', :with_subprojects => 0,
116 :show_changesets => 1,
117 :show_documents => 1,
118 :show_files => 1,
119 :show_issues => 1,
120 :show_messages => 1,
121 :show_news => 1,
122 :show_time_entries => 1,
123 :show_wiki_edits => 1
124
125 assert_response :success
126 assert_template 'common/feed.atom'
127
128 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
129 :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'}
130 assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil },
131 :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?show_changesets=1&amp;show_documents=1&amp;show_files=1&amp;show_issues=1&amp;show_messages=1&amp;show_news=1&amp;show_time_entries=1&amp;show_wiki_edits=1&amp;with_subprojects=0'}
132
103 assert_tag :tag => 'entry', :child => {
133 assert_tag :tag => 'entry', :child => {
104 :tag => 'link',
134 :tag => 'link',
105 :attributes => {:href => 'http://test.host/issues/11'}}
135 :attributes => {:href => 'http://test.host/issues/11'}}
106 end
136 end
107
137
108 def test_index_atom_feed_with_one_item_type
138 def test_index_atom_feed_with_one_item_type
109 get :index, :format => 'atom', :show_issues => '1'
139 get :index, :format => 'atom', :show_issues => '1'
110 assert_response :success
140 assert_response :success
111 assert_template 'common/feed.atom'
141 assert_template 'common/feed.atom'
112 assert_tag :tag => 'title', :content => /Issues/
142 assert_tag :tag => 'title', :content => /Issues/
113 end
143 end
114 end
144 end
General Comments 0
You need to be logged in to leave comments. Login now