Browse Source

Filter after projects (#29482).

Patch by Marius BALTEANU.

git-svn-id: http://svn.redmine.org/redmine/trunk@18762 e93f8b46-1217-0410-a6f0-8f06a7374b81
tags/4.1.0
Jean-Philippe Lang 4 years ago
parent
commit
80844362db
3 changed files with 24 additions and 1 deletions
  1. 4
    0
      app/models/project_query.rb
  2. 1
    1
      app/models/query.rb
  3. 19
    0
      test/functional/projects_controller_test.rb

+ 4
- 0
app/models/project_query.rb View File

@@ -20,6 +20,7 @@
class ProjectQuery < Query

self.queried_class = Project
self.view_permission = :search_project

self.available_columns = []

@@ -31,6 +32,9 @@ class ProjectQuery < Query
def initialize_available_filters
add_available_filter "status",
:type => :list, :values => lambda { project_statuses_values }
add_available_filter("id",
:type => :list, :values => lambda { project_values }, :label => :field_project
)
add_available_filter "name", :type => :text
add_available_filter "description", :type => :text
add_available_filter "is_public",

+ 1
- 1
app/models/query.rb View File

@@ -905,7 +905,7 @@ class Query < ActiveRecord::Base
end
end

if field == 'project_id'
if field == 'project_id' || (self.type == 'ProjectQuery' && field == 'id')
if v.delete('mine')
v += User.current.memberships.map(&:project_id).map(&:to_s)
end

+ 19
- 0
test/functional/projects_controller_test.rb View File

@@ -56,6 +56,25 @@ class ProjectsControllerTest < Redmine::ControllerTest
assert_select 'feed>entry', :count => Project.visible(User.current).count
end

def test_index_with_project_filter_is_my_projects
@request.session[:user_id] = 2

get :index, :params => {
:f => ['id'],
:op => {'id' => '='},
:v => {'id' => ['mine']}
}

assert_response :success

assert_select 'div#projects-index ul' do
assert_select 'a.project', 3
assert_select 'a', :text => 'eCookbook'
assert_select 'a', :text => 'OnlineStore'
assert_select 'a', :text => 'Private child of eCookbook'
end
end

def test_autocomplete_js
get :autocomplete, :params => {
:format => 'js',

Loading…
Cancel
Save