From 6f064d3856a1e5a3f1bfa0594848d1f34de3564d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= Date: Wed, 28 Mar 2012 20:31:20 +0200 Subject: [PATCH] Activity: use default filter only on first request #861 --- app/controllers/activities_controller.rb | 2 +- app/views/activities/index.html.erb | 1 + test/functional/activities_controller_test.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/controllers/activities_controller.rb b/app/controllers/activities_controller.rb index cfc2be4b..9a7cbae2 100644 --- a/app/controllers/activities_controller.rb +++ b/app/controllers/activities_controller.rb @@ -33,7 +33,7 @@ class ActivitiesController < ApplicationController :with_subprojects => @with_subprojects, :author => @author) @activity.scope_select {|t| !params["show_#{t}"].nil?} - @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? + @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? unless params[:set_filter] events = @activity.events(@date_from, @date_to) diff --git a/app/views/activities/index.html.erb b/app/views/activities/index.html.erb index 173b7509..de35c85a 100644 --- a/app/views/activities/index.html.erb +++ b/app/views/activities/index.html.erb @@ -42,6 +42,7 @@ <% content_for :sidebar do %> <% form_tag({}, :method => :get) do %>

<%= l(:label_activity) %>

+<%= hidden_field_tag "set_filter", 1, :id => nil %>

<% @activity.event_types.each do |t| %> <%= check_box_tag "show_#{t}", 1, @activity.scope.include?(t) %> diff --git a/test/functional/activities_controller_test.rb b/test/functional/activities_controller_test.rb index 7fc6f708..f759d23b 100644 --- a/test/functional/activities_controller_test.rb +++ b/test/functional/activities_controller_test.rb @@ -98,4 +98,12 @@ class ActivitiesControllerTest < ActionController::TestCase :attributes => {:href => 'http://test.host/issues/11'}} end + def test_index_without_filters + get :index, :set_filter => 1 + assert_response :success + assert_template 'index' + assert_tag :tag => 'p', + :attributes => {:class => /nodata/}, + :content => "No data to display" + end end