##// END OF EJS Templates
Missing "next" pagination link when looking at yesterday's activity (#18399)....
Jean-Philippe Lang -
r15755:84732abd0ad7
parent child
Show More
@@ -1,72 +1,72
1 <h2><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></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 <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
8 <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
9 <dt class="<%= e.event_type %> icon icon-<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
9 <dt class="<%= e.event_type %> icon icon-<%= e.event_type %> <%= "grouped" if in_group %> <%= 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', e.project, :class => 'project') if @project.nil? || @project != e.project %>
12 <%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
13 <%= link_to format_activity_title(e.event_title), e.event_url %>
13 <%= link_to format_activity_title(e.event_title), e.event_url %>
14 </dt>
14 </dt>
15 <dd class="<%= "grouped" if in_group %>"><span class="description"><%= format_activity_description(e.event_description) %></span>
15 <dd class="<%= "grouped" if in_group %>"><span class="description"><%= format_activity_description(e.event_description) %></span>
16 <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd>
16 <span class="author"><%= link_to_user(e.event_author) if e.respond_to?(:event_author) %></span></dd>
17 <% end -%>
17 <% end -%>
18 </dl>
18 </dl>
19 <% end -%>
19 <% end -%>
20 </div>
20 </div>
21
21
22 <%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
22 <%= content_tag('p', l(:label_no_data), :class => 'nodata') if @events_by_day.empty? %>
23
23
24 <span class="pagination">
24 <span class="pagination">
25 <ul class="pages">
25 <ul class="pages">
26 <li class="previous page">
26 <li class="previous page">
27 <%= link_to("\xc2\xab " + l(:label_previous),
27 <%= link_to("\xc2\xab " + l(:label_previous),
28 {:params => request.query_parameters.merge(:from => @date_to - @days - 1)},
28 {:params => request.query_parameters.merge(:from => @date_to - @days - 1)},
29 :title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1)),
29 :title => l(:label_date_from_to, :start => format_date(@date_to - 2*@days), :end => format_date(@date_to - @days - 1)),
30 :accesskey => accesskey(:previous)) %>
30 :accesskey => accesskey(:previous)) %>
31 </li><% unless @date_to >= User.current.today %><li class="next page">
31 </li><% unless @date_to > User.current.today %><li class="next page">
32 <%= link_to(l(:label_next) + " \xc2\xbb",
32 <%= link_to(l(:label_next) + " \xc2\xbb",
33 {:params => request.query_parameters.merge(:from => @date_to + @days - 1)},
33 {:params => request.query_parameters.merge(:from => @date_to + @days - 1)},
34 :title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1)),
34 :title => l(:label_date_from_to, :start => format_date(@date_to), :end => format_date(@date_to + @days - 1)),
35 :accesskey => accesskey(:next)) %><% end %>
35 :accesskey => accesskey(:next)) %><% end %>
36 </li>
36 </li>
37 </ul>
37 </ul>
38 </span>
38 </span>
39 &nbsp;
39 &nbsp;
40 <% other_formats_links do |f| %>
40 <% other_formats_links do |f| %>
41 <%= f.link_to_with_query_parameters 'Atom', 'from' => nil, :key => User.current.rss_key %>
41 <%= f.link_to_with_query_parameters 'Atom', 'from' => nil, :key => User.current.rss_key %>
42 <% end %>
42 <% end %>
43
43
44 <% content_for :header_tags do %>
44 <% content_for :header_tags do %>
45 <%= auto_discovery_link_tag(:atom, :params => request.query_parameters.merge(:from => nil, :key => User.current.rss_key), :format => 'atom') %>
45 <%= auto_discovery_link_tag(:atom, :params => request.query_parameters.merge(:from => nil, :key => User.current.rss_key), :format => 'atom') %>
46 <% end %>
46 <% end %>
47
47
48 <% content_for :sidebar do %>
48 <% content_for :sidebar do %>
49 <%= form_tag({}, :method => :get, :id => 'activity_scope_form') do %>
49 <%= form_tag({}, :method => :get, :id => 'activity_scope_form') do %>
50 <h3><%= l(:label_activity) %></h3>
50 <h3><%= l(:label_activity) %></h3>
51 <ul>
51 <ul>
52 <% @activity.event_types.each do |t| %>
52 <% @activity.event_types.each do |t| %>
53 <li>
53 <li>
54 <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
54 <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %>
55 <label for="show_<%=t%>">
55 <label for="show_<%=t%>">
56 <%= link_to(l("label_#{t.singularize}_plural"),
56 <%= link_to(l("label_#{t.singularize}_plural"),
57 {"show_#{t}" => 1, :user_id => params[:user_id], :from => params[:from]})%>
57 {"show_#{t}" => 1, :user_id => params[:user_id], :from => params[:from]})%>
58 </label>
58 </label>
59 </li>
59 </li>
60 <% end %>
60 <% end %>
61 </ul>
61 </ul>
62 <% if @project && @project.descendants.active.any? %>
62 <% if @project && @project.descendants.active.any? %>
63 <%= hidden_field_tag 'with_subprojects', 0, :id => nil %>
63 <%= hidden_field_tag 'with_subprojects', 0, :id => nil %>
64 <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
64 <p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
65 <% end %>
65 <% end %>
66 <%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %>
66 <%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %>
67 <%= hidden_field_tag('from', params[:from]) unless params[:from].blank? %>
67 <%= hidden_field_tag('from', params[:from]) unless params[:from].blank? %>
68 <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => 'submit' %></p>
68 <p><%= submit_tag l(:button_apply), :class => 'button-small', :name => 'submit' %></p>
69 <% end %>
69 <% end %>
70 <% end %>
70 <% end %>
71
71
72 <% html_title(l(:label_activity), @author) -%>
72 <% html_title(l(:label_activity), @author) -%>
@@ -1,172 +1,190
1 # Redmine - project management software
1 # Redmine - project management software
2 # Copyright (C) 2006-2016 Jean-Philippe Lang
2 # Copyright (C) 2006-2016 Jean-Philippe Lang
3 #
3 #
4 # This program is free software; you can redistribute it and/or
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License
5 # modify it under the terms of the GNU General Public License
6 # as published by the Free Software Foundation; either version 2
6 # as published by the Free Software Foundation; either version 2
7 # of the License, or (at your option) any later version.
7 # of the License, or (at your option) any later version.
8 #
8 #
9 # This program is distributed in the hope that it will be useful,
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
12 # GNU General Public License for more details.
13 #
13 #
14 # You should have received a copy of the GNU General Public License
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
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.
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
17
18 require File.expand_path('../../test_helper', __FILE__)
18 require File.expand_path('../../test_helper', __FILE__)
19
19
20 class ActivitiesControllerTest < Redmine::ControllerTest
20 class ActivitiesControllerTest < Redmine::ControllerTest
21 fixtures :projects, :trackers, :issue_statuses, :issues,
21 fixtures :projects, :trackers, :issue_statuses, :issues,
22 :enumerations, :users, :issue_categories,
22 :enumerations, :users, :issue_categories,
23 :projects_trackers,
23 :projects_trackers,
24 :roles,
24 :roles,
25 :member_roles,
25 :member_roles,
26 :members,
26 :members,
27 :groups_users,
27 :groups_users,
28 :enabled_modules,
28 :enabled_modules,
29 :journals, :journal_details
29 :journals, :journal_details
30
30
31
31
32 def test_project_index
32 def test_project_index
33 get :index, :id => 1, :with_subprojects => 0
33 get :index, :id => 1, :with_subprojects => 0
34 assert_response :success
34 assert_response :success
35
35
36 assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
36 assert_select 'h3', :text => /#{2.days.ago.to_date.day}/
37 assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
37 assert_select 'dl dt.issue-edit a', :text => /(#{IssueStatus.find(2).name})/
38 end
38 end
39
39
40 def test_project_index_with_invalid_project_id_should_respond_404
40 def test_project_index_with_invalid_project_id_should_respond_404
41 get :index, :id => 299
41 get :index, :id => 299
42 assert_response 404
42 assert_response 404
43 end
43 end
44
44
45 def test_previous_project_index
45 def test_previous_project_index
46 get :index, :id => 1, :from => 2.days.ago.to_date
46 get :index, :id => 1, :from => 2.days.ago.to_date
47 assert_response :success
47 assert_response :success
48
48
49 assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
49 assert_select 'h3', :text => /#{3.days.ago.to_date.day}/
50 assert_select 'dl dt.issue a', :text => /Cannot print recipes/
50 assert_select 'dl dt.issue a', :text => /Cannot print recipes/
51 end
51 end
52
52
53 def test_global_index
53 def test_global_index
54 @request.session[:user_id] = 1
54 @request.session[:user_id] = 1
55 get :index
55 get :index
56 assert_response :success
56 assert_response :success
57
57
58 i5 = Issue.find(5)
58 i5 = Issue.find(5)
59 d5 = User.find(1).time_to_date(i5.created_on)
59 d5 = User.find(1).time_to_date(i5.created_on)
60
60
61 assert_select 'h3', :text => /#{d5.day}/
61 assert_select 'h3', :text => /#{d5.day}/
62 assert_select 'dl dt.issue a', :text => /Subproject issue/
62 assert_select 'dl dt.issue a', :text => /Subproject issue/
63 end
63 end
64
64
65 def test_user_index
65 def test_user_index
66 @request.session[:user_id] = 1
66 @request.session[:user_id] = 1
67 get :index, :user_id => 2
67 get :index, :user_id => 2
68 assert_response :success
68 assert_response :success
69
69
70 assert_select 'h2 a[href="/users/2"]', :text => 'John Smith'
70 assert_select 'h2 a[href="/users/2"]', :text => 'John Smith'
71
71
72 i1 = Issue.find(1)
72 i1 = Issue.find(1)
73 d1 = User.find(1).time_to_date(i1.created_on)
73 d1 = User.find(1).time_to_date(i1.created_on)
74
74
75 assert_select 'h3', :text => /#{d1.day}/
75 assert_select 'h3', :text => /#{d1.day}/
76 assert_select 'dl dt.issue a', :text => /Cannot print recipes/
76 assert_select 'dl dt.issue a', :text => /Cannot print recipes/
77 end
77 end
78
78
79 def test_user_index_with_invalid_user_id_should_respond_404
79 def test_user_index_with_invalid_user_id_should_respond_404
80 get :index, :user_id => 299
80 get :index, :user_id => 299
81 assert_response 404
81 assert_response 404
82 end
82 end
83
83
84 def test_index_atom_feed
84 def test_index_atom_feed
85 get :index, :format => 'atom', :with_subprojects => 0
85 get :index, :format => 'atom', :with_subprojects => 0
86 assert_response :success
86 assert_response :success
87
87
88 assert_select 'feed' do
88 assert_select 'feed' do
89 assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
89 assert_select 'link[rel=self][href=?]', 'http://test.host/activity.atom?with_subprojects=0'
90 assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
90 assert_select 'link[rel=alternate][href=?]', 'http://test.host/activity?with_subprojects=0'
91 assert_select 'entry' do
91 assert_select 'entry' do
92 assert_select 'link[href=?]', 'http://test.host/issues/11'
92 assert_select 'link[href=?]', 'http://test.host/issues/11'
93 end
93 end
94 end
94 end
95 end
95 end
96
96
97 def test_index_atom_feed_with_explicit_selection
97 def test_index_atom_feed_with_explicit_selection
98 get :index, :format => 'atom', :with_subprojects => 0,
98 get :index, :format => 'atom', :with_subprojects => 0,
99 :show_changesets => 1,
99 :show_changesets => 1,
100 :show_documents => 1,
100 :show_documents => 1,
101 :show_files => 1,
101 :show_files => 1,
102 :show_issues => 1,
102 :show_issues => 1,
103 :show_messages => 1,
103 :show_messages => 1,
104 :show_news => 1,
104 :show_news => 1,
105 :show_time_entries => 1,
105 :show_time_entries => 1,
106 :show_wiki_edits => 1
106 :show_wiki_edits => 1
107
107
108 assert_response :success
108 assert_response :success
109
109
110 assert_select 'feed' do
110 assert_select 'feed' do
111 assert_select 'link[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'
111 assert_select 'link[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'
112 assert_select 'link[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'
112 assert_select 'link[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'
113 assert_select 'entry' do
113 assert_select 'entry' do
114 assert_select 'link[href=?]', 'http://test.host/issues/11'
114 assert_select 'link[href=?]', 'http://test.host/issues/11'
115 end
115 end
116 end
116 end
117 end
117 end
118
118
119 def test_index_atom_feed_with_one_item_type
119 def test_index_atom_feed_with_one_item_type
120 with_settings :default_language => 'en' do
120 with_settings :default_language => 'en' do
121 get :index, :format => 'atom', :show_issues => '1'
121 get :index, :format => 'atom', :show_issues => '1'
122 assert_response :success
122 assert_response :success
123
123
124 assert_select 'title', :text => /Issues/
124 assert_select 'title', :text => /Issues/
125 end
125 end
126 end
126 end
127
127
128 def test_index_atom_feed_with_user
128 def test_index_atom_feed_with_user
129 get :index, :user_id => 2, :format => 'atom'
129 get :index, :user_id => 2, :format => 'atom'
130
130
131 assert_response :success
131 assert_response :success
132 assert_select 'title', :text => "Redmine: #{User.find(2).name}"
132 assert_select 'title', :text => "Redmine: #{User.find(2).name}"
133 end
133 end
134
134
135 def test_index_should_show_private_notes_with_permission_only
135 def test_index_should_show_private_notes_with_permission_only
136 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes', :private_notes => true)
136 journal = Journal.create!(:journalized => Issue.find(2), :notes => 'Private notes', :private_notes => true)
137 @request.session[:user_id] = 2
137 @request.session[:user_id] = 2
138
138
139 get :index
139 get :index
140 assert_response :success
140 assert_response :success
141 assert_select 'dl', :text => /Private notes/
141 assert_select 'dl', :text => /Private notes/
142
142
143 Role.find(1).remove_permission! :view_private_notes
143 Role.find(1).remove_permission! :view_private_notes
144 get :index
144 get :index
145 assert_response :success
145 assert_response :success
146 assert_select 'dl', :text => /Private notes/, :count => 0
146 assert_select 'dl', :text => /Private notes/, :count => 0
147 end
147 end
148
148
149 def test_index_with_submitted_scope_should_save_as_preference
149 def test_index_with_submitted_scope_should_save_as_preference
150 @request.session[:user_id] = 2
150 @request.session[:user_id] = 2
151
151
152 get :index, :show_issues => '1', :show_messages => '1', :submit => 'Apply'
152 get :index, :show_issues => '1', :show_messages => '1', :submit => 'Apply'
153 assert_response :success
153 assert_response :success
154 assert_equal %w(issues messages), User.find(2).pref.activity_scope.sort
154 assert_equal %w(issues messages), User.find(2).pref.activity_scope.sort
155 end
155 end
156
156
157 def test_index_scope_should_default_to_user_preference
157 def test_index_scope_should_default_to_user_preference
158 pref = User.find(2).pref
158 pref = User.find(2).pref
159 pref.activity_scope = %w(issues news)
159 pref.activity_scope = %w(issues news)
160 pref.save!
160 pref.save!
161 @request.session[:user_id] = 2
161 @request.session[:user_id] = 2
162
162
163 get :index
163 get :index
164 assert_response :success
164 assert_response :success
165
165
166 assert_select '#activity_scope_form' do
166 assert_select '#activity_scope_form' do
167 assert_select 'input[checked=checked]', 2
167 assert_select 'input[checked=checked]', 2
168 assert_select 'input[name=show_issues][checked=checked]'
168 assert_select 'input[name=show_issues][checked=checked]'
169 assert_select 'input[name=show_news][checked=checked]'
169 assert_select 'input[name=show_news][checked=checked]'
170 end
170 end
171 end
171 end
172
173 def test_index_should_not_show_next_page_link
174 @request.session[:user_id] = 2
175
176 get :index
177 assert_response :success
178 assert_select '.pagination a', :text => /Previous/
179 assert_select '.pagination a', :text => /Next/, :count => 0
180 end
181
182 def test_index_up_to_yesterday_should_show_next_page_link
183 @request.session[:user_id] = 2
184
185 get :index, :from => (User.find(2).today-1)
186 assert_response :success
187 assert_select '.pagination a', :text => /Previous/
188 assert_select '.pagination a', :text => /Next/
189 end
172 end
190 end
General Comments 0
You need to be logged in to leave comments. Login now