@@ -1,59 +1,59 | |||||
1 | <h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)) %></h2> |
|
1 | <h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h2> | |
2 | <p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p> |
|
2 | <p class="subtitle"><%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %></p> | |
3 |
|
3 | |||
4 | <div id="activity"> |
|
4 | <div id="activity"> | |
5 | <% @events_by_day.keys.sort.reverse.each do |day| %> |
|
5 | <% @events_by_day.keys.sort.reverse.each do |day| %> | |
6 | <h3><%= format_activity_day(day) %></h3> |
|
6 | <h3><%= format_activity_day(day) %></h3> | |
7 | <dl> |
|
7 | <dl> | |
8 | <% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> |
|
8 | <% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> | |
9 | <dt class="<%= e.event_type %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>"> |
|
9 | <dt class="<%= e.event_type %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>"> | |
10 | <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %> |
|
10 | <%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %> | |
11 | <span class="time"><%= format_time(e.event_datetime, false) %></span> |
|
11 | <span class="time"><%= format_time(e.event_datetime, false) %></span> | |
12 | <%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %> |
|
12 | <%= content_tag('span', h(e.project), :class => 'project') if @project.nil? || @project != e.project %> | |
13 | <%= link_to format_activity_title(e.event_title), e.event_url %></dt> |
|
13 | <%= link_to format_activity_title(e.event_title), e.event_url %></dt> | |
14 | <dd><span class="description"><%= format_activity_description(e.event_description) %></span> |
|
14 | <dd><span class="description"><%= format_activity_description(e.event_description) %></span> | |
15 | <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd> |
|
15 | <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd> | |
16 | <% end -%> |
|
16 | <% end -%> | |
17 | </dl> |
|
17 | </dl> | |
18 | <% end -%> |
|
18 | <% end -%> | |
19 | </div> |
|
19 | </div> | |
20 |
|
20 | |||
21 | <%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %> |
|
21 | <%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %> | |
22 |
|
22 | |||
23 | <div style="float:left;"> |
|
23 | <div style="float:left;"> | |
24 | <%= link_to_content_update("\xc2\xab " + l(:label_previous), |
|
24 | <%= link_to_content_update("\xc2\xab " + l(:label_previous), | |
25 | params.merge(:from => @date_to - @days - 1), |
|
25 | params.merge(:from => @date_to - @days - 1), | |
26 | :title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1))) %> |
|
26 | :title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1))) %> | |
27 | </div> |
|
27 | </div> | |
28 | <div style="float:right;"> |
|
28 | <div style="float:right;"> | |
29 | <%= link_to_content_update(l(:label_next) + " \xc2\xbb", |
|
29 | <%= link_to_content_update(l(:label_next) + " \xc2\xbb", | |
30 | params.merge(:from => @date_to + @days - 1), |
|
30 | params.merge(:from => @date_to + @days - 1), | |
31 | :title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1))) unless @date_to >= Date.today %> |
|
31 | :title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1))) unless @date_to >= Date.today %> | |
32 | </div> |
|
32 | </div> | |
33 | |
|
33 | | |
34 | <% other_formats_links do |f| %> |
|
34 | <% other_formats_links do |f| %> | |
35 | <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %> |
|
35 | <%= f.link_to 'Atom', :url => params.merge(:from => nil, :key => User.current.rss_key) %> | |
36 | <% end %> |
|
36 | <% end %> | |
37 |
|
37 | |||
38 | <% content_for :header_tags do %> |
|
38 | <% content_for :header_tags do %> | |
39 | <%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %> |
|
39 | <%= auto_discovery_link_tag(:atom, params.merge(:format => 'atom', :from => nil, :key => User.current.rss_key)) %> | |
40 | <% end %> |
|
40 | <% end %> | |
41 |
|
41 | |||
42 | <% content_for :sidebar do %> |
|
42 | <% content_for :sidebar do %> | |
43 | <%= form_tag({}, :method => :get) do %> |
|
43 | <%= form_tag({}, :method => :get) do %> | |
44 | <h3><%= l(:label_activity) %></h3> |
|
44 | <h3><%= l(:label_activity) %></h3> | |
45 | <p><% @activity.event_types.each do |t| %> |
|
45 | <p><% @activity.event_types.each do |t| %> | |
46 | <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %> |
|
46 | <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %> | |
47 | <label for="show_<%=t%>"><%= link_to(l("label_#{t.singularize}_plural"), {"show_#{t}" => 1, :user_id => params[:user_id]})%></label> |
|
47 | <label for="show_<%=t%>"><%= link_to(l("label_#{t.singularize}_plural"), {"show_#{t}" => 1, :user_id => params[:user_id]})%></label> | |
48 | <br /> |
|
48 | <br /> | |
49 | <% end %></p> |
|
49 | <% end %></p> | |
50 | <% if @project && @project.descendants.active.any? %> |
|
50 | <% if @project && @project.descendants.active.any? %> | |
51 | <%= hidden_field_tag 'with_subprojects', 0 %> |
|
51 | <%= hidden_field_tag 'with_subprojects', 0 %> | |
52 | <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p> |
|
52 | <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p> | |
53 | <% end %> |
|
53 | <% end %> | |
54 | <%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %> |
|
54 | <%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %> | |
55 | <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p> |
|
55 | <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p> | |
56 | <% end %> |
|
56 | <% end %> | |
57 | <% end %> |
|
57 | <% end %> | |
58 |
|
58 | |||
59 | <% html_title(l(:label_activity), @author) -%> |
|
59 | <% html_title(l(:label_activity), @author) -%> |
@@ -1,143 +1,145 | |||||
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 | :journals, :journal_details |
|
13 | :journals, :journal_details | |
14 |
|
14 | |||
15 |
|
15 | |||
16 | def test_project_index |
|
16 | def test_project_index | |
17 | get :index, :id => 1, :with_subprojects => 0 |
|
17 | get :index, :id => 1, :with_subprojects => 0 | |
18 | assert_response :success |
|
18 | assert_response :success | |
19 | assert_template 'index' |
|
19 | assert_template 'index' | |
20 | assert_not_nil assigns(:events_by_day) |
|
20 | assert_not_nil assigns(:events_by_day) | |
21 |
|
21 | |||
22 | assert_tag :tag => "h3", |
|
22 | assert_tag :tag => "h3", | |
23 | :content => /#{2.days.ago.to_date.day}/, |
|
23 | :content => /#{2.days.ago.to_date.day}/, | |
24 | :sibling => { :tag => "dl", |
|
24 | :sibling => { :tag => "dl", | |
25 | :child => { :tag => "dt", |
|
25 | :child => { :tag => "dt", | |
26 | :attributes => { :class => /issue-edit/ }, |
|
26 | :attributes => { :class => /issue-edit/ }, | |
27 | :child => { :tag => "a", |
|
27 | :child => { :tag => "a", | |
28 | :content => /(#{IssueStatus.find(2).name})/, |
|
28 | :content => /(#{IssueStatus.find(2).name})/, | |
29 | } |
|
29 | } | |
30 | } |
|
30 | } | |
31 | } |
|
31 | } | |
32 | end |
|
32 | end | |
33 |
|
33 | |||
34 | def test_project_index_with_invalid_project_id_should_respond_404 |
|
34 | def test_project_index_with_invalid_project_id_should_respond_404 | |
35 | get :index, :id => 299 |
|
35 | get :index, :id => 299 | |
36 | assert_response 404 |
|
36 | assert_response 404 | |
37 | end |
|
37 | end | |
38 |
|
38 | |||
39 | def test_previous_project_index |
|
39 | def test_previous_project_index | |
40 | get :index, :id => 1, :from => 3.days.ago.to_date |
|
40 | get :index, :id => 1, :from => 3.days.ago.to_date | |
41 | assert_response :success |
|
41 | assert_response :success | |
42 | assert_template 'index' |
|
42 | assert_template 'index' | |
43 | assert_not_nil assigns(:events_by_day) |
|
43 | assert_not_nil assigns(:events_by_day) | |
44 |
|
44 | |||
45 | assert_tag :tag => "h3", |
|
45 | assert_tag :tag => "h3", | |
46 | :content => /#{3.day.ago.to_date.day}/, |
|
46 | :content => /#{3.day.ago.to_date.day}/, | |
47 | :sibling => { :tag => "dl", |
|
47 | :sibling => { :tag => "dl", | |
48 | :child => { :tag => "dt", |
|
48 | :child => { :tag => "dt", | |
49 | :attributes => { :class => /issue/ }, |
|
49 | :attributes => { :class => /issue/ }, | |
50 | :child => { :tag => "a", |
|
50 | :child => { :tag => "a", | |
51 | :content => /#{Issue.find(1).subject}/, |
|
51 | :content => /#{Issue.find(1).subject}/, | |
52 | } |
|
52 | } | |
53 | } |
|
53 | } | |
54 | } |
|
54 | } | |
55 | end |
|
55 | end | |
56 |
|
56 | |||
57 | def test_global_index |
|
57 | def test_global_index | |
58 | get :index |
|
58 | get :index | |
59 | assert_response :success |
|
59 | assert_response :success | |
60 | assert_template 'index' |
|
60 | assert_template 'index' | |
61 | assert_not_nil assigns(:events_by_day) |
|
61 | assert_not_nil assigns(:events_by_day) | |
62 |
|
62 | |||
63 | assert_tag :tag => "h3", |
|
63 | assert_tag :tag => "h3", | |
64 | :content => /#{5.day.ago.to_date.day}/, |
|
64 | :content => /#{5.day.ago.to_date.day}/, | |
65 | :sibling => { :tag => "dl", |
|
65 | :sibling => { :tag => "dl", | |
66 | :child => { :tag => "dt", |
|
66 | :child => { :tag => "dt", | |
67 | :attributes => { :class => /issue/ }, |
|
67 | :attributes => { :class => /issue/ }, | |
68 | :child => { :tag => "a", |
|
68 | :child => { :tag => "a", | |
69 | :content => /#{Issue.find(5).subject}/, |
|
69 | :content => /#{Issue.find(5).subject}/, | |
70 | } |
|
70 | } | |
71 | } |
|
71 | } | |
72 | } |
|
72 | } | |
73 | end |
|
73 | end | |
74 |
|
74 | |||
75 | def test_user_index |
|
75 | def test_user_index | |
76 | get :index, :user_id => 2 |
|
76 | get :index, :user_id => 2 | |
77 | assert_response :success |
|
77 | assert_response :success | |
78 | assert_template 'index' |
|
78 | assert_template 'index' | |
79 | assert_not_nil assigns(:events_by_day) |
|
79 | assert_not_nil assigns(:events_by_day) | |
80 |
|
80 | |||
|
81 | assert_select 'h2 a[href=/users/2]', :text => 'John Smith' | |||
|
82 | ||||
81 | assert_tag :tag => "h3", |
|
83 | assert_tag :tag => "h3", | |
82 | :content => /#{3.day.ago.to_date.day}/, |
|
84 | :content => /#{3.day.ago.to_date.day}/, | |
83 | :sibling => { :tag => "dl", |
|
85 | :sibling => { :tag => "dl", | |
84 | :child => { :tag => "dt", |
|
86 | :child => { :tag => "dt", | |
85 | :attributes => { :class => /issue/ }, |
|
87 | :attributes => { :class => /issue/ }, | |
86 | :child => { :tag => "a", |
|
88 | :child => { :tag => "a", | |
87 | :content => /#{Issue.find(1).subject}/, |
|
89 | :content => /#{Issue.find(1).subject}/, | |
88 | } |
|
90 | } | |
89 | } |
|
91 | } | |
90 | } |
|
92 | } | |
91 | end |
|
93 | end | |
92 |
|
94 | |||
93 | def test_user_index_with_invalid_user_id_should_respond_404 |
|
95 | def test_user_index_with_invalid_user_id_should_respond_404 | |
94 | get :index, :user_id => 299 |
|
96 | get :index, :user_id => 299 | |
95 | assert_response 404 |
|
97 | assert_response 404 | |
96 | end |
|
98 | end | |
97 |
|
99 | |||
98 | def test_index_atom_feed |
|
100 | def test_index_atom_feed | |
99 | get :index, :format => 'atom', :with_subprojects => 0 |
|
101 | get :index, :format => 'atom', :with_subprojects => 0 | |
100 | assert_response :success |
|
102 | assert_response :success | |
101 | assert_template 'common/feed' |
|
103 | assert_template 'common/feed' | |
102 |
|
104 | |||
103 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, |
|
105 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | |
104 | :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?with_subprojects=0'} |
|
106 | :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?with_subprojects=0'} | |
105 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, |
|
107 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | |
106 | :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?with_subprojects=0'} |
|
108 | :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?with_subprojects=0'} | |
107 |
|
109 | |||
108 | assert_tag :tag => 'entry', :child => { |
|
110 | assert_tag :tag => 'entry', :child => { | |
109 | :tag => 'link', |
|
111 | :tag => 'link', | |
110 | :attributes => {:href => 'http://test.host/issues/11'}} |
|
112 | :attributes => {:href => 'http://test.host/issues/11'}} | |
111 | end |
|
113 | end | |
112 |
|
114 | |||
113 | def test_index_atom_feed_with_explicit_selection |
|
115 | def test_index_atom_feed_with_explicit_selection | |
114 | get :index, :format => 'atom', :with_subprojects => 0, |
|
116 | get :index, :format => 'atom', :with_subprojects => 0, | |
115 | :show_changesets => 1, |
|
117 | :show_changesets => 1, | |
116 | :show_documents => 1, |
|
118 | :show_documents => 1, | |
117 | :show_files => 1, |
|
119 | :show_files => 1, | |
118 | :show_issues => 1, |
|
120 | :show_issues => 1, | |
119 | :show_messages => 1, |
|
121 | :show_messages => 1, | |
120 | :show_news => 1, |
|
122 | :show_news => 1, | |
121 | :show_time_entries => 1, |
|
123 | :show_time_entries => 1, | |
122 | :show_wiki_edits => 1 |
|
124 | :show_wiki_edits => 1 | |
123 |
|
125 | |||
124 | assert_response :success |
|
126 | assert_response :success | |
125 | assert_template 'common/feed' |
|
127 | assert_template 'common/feed' | |
126 |
|
128 | |||
127 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, |
|
129 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | |
128 | :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'} |
|
130 | :attributes => {:rel => 'self', :href => 'http://test.host/activity.atom?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'} | |
129 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, |
|
131 | assert_tag :tag => 'link', :parent => {:tag => 'feed', :parent => nil }, | |
130 | :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'} |
|
132 | :attributes => {:rel => 'alternate', :href => 'http://test.host/activity?show_changesets=1&show_documents=1&show_files=1&show_issues=1&show_messages=1&show_news=1&show_time_entries=1&show_wiki_edits=1&with_subprojects=0'} | |
131 |
|
133 | |||
132 | assert_tag :tag => 'entry', :child => { |
|
134 | assert_tag :tag => 'entry', :child => { | |
133 | :tag => 'link', |
|
135 | :tag => 'link', | |
134 | :attributes => {:href => 'http://test.host/issues/11'}} |
|
136 | :attributes => {:href => 'http://test.host/issues/11'}} | |
135 | end |
|
137 | end | |
136 |
|
138 | |||
137 | def test_index_atom_feed_with_one_item_type |
|
139 | def test_index_atom_feed_with_one_item_type | |
138 | get :index, :format => 'atom', :show_issues => '1' |
|
140 | get :index, :format => 'atom', :show_issues => '1' | |
139 | assert_response :success |
|
141 | assert_response :success | |
140 | assert_template 'common/feed' |
|
142 | assert_template 'common/feed' | |
141 | assert_tag :tag => 'title', :content => /Issues/ |
|
143 | assert_tag :tag => 'title', :content => /Issues/ | |
142 | end |
|
144 | end | |
143 | end |
|
145 | end |
General Comments 0
You need to be logged in to leave comments.
Login now