@activity = Redmine::Activity::Fetcher.new(User.current, :project => @project,
:with_subprojects => @with_subprojects,
:author => @author)
+ pref = User.current.pref
@activity.scope_select {|t| !params["show_#{t}"].nil?}
- @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty?
+ if @activity.scope.present?
+ if params[:submit].present?
+ pref.activity_scope = @activity.scope
+ pref.save
+ end
+ else
+ if @author.nil?
+ scope = pref.activity_scope & @activity.event_types
+ @activity.scope = scope.present? ? scope : :default
+ else
+ @activity.scope = :all
+ end
+ end
events = @activity.events(@date_from, @date_to)
def no_self_notified; (self[:no_self_notified] == true || self[:no_self_notified] == '1'); end
def no_self_notified=(value); self[:no_self_notified]=value; end
+
+ def activity_scope; Array(self[:activity_scope]) ; end
+ def activity_scope=(value); self[:activity_scope]=value ; end
end
<p><label><%= check_box_tag 'with_subprojects', 1, @with_subprojects %> <%=l(:label_subproject_plural)%></label></p>
<% end %>
<%= hidden_field_tag('user_id', params[:user_id]) unless params[:user_id].blank? %>
-<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %></p>
+<p><%= submit_tag l(:button_apply), :class => 'button-small', :name => 'submit' %></p>
<% end %>
<% end %>
assert_response :success
assert_not_include journal, assigns(:events_by_day).values.flatten
end
+
+ def test_index_with_submitted_scope_should_save_as_preference
+ @request.session[:user_id] = 2
+
+ get :index, :show_issues => '1', :show_messages => '1', :submit => 'Apply'
+ assert_response :success
+ assert_equal %w(issues messages), User.find(2).pref.activity_scope.sort
+ end
+
+ def test_index_scope_should_default_to_user_preference
+ pref = User.find(2).pref
+ pref.activity_scope = %w(issues news)
+ pref.save!
+ @request.session[:user_id] = 2
+
+ get :index
+ assert_response :success
+ assert_equal %w(issues news), assigns(:activity).scope
+ end
end