Feature #29482 » 0002-Filter-after-projects.patch
| app/models/project_query.rb | ||
|---|---|---|
|
class ProjectQuery < Query
|
||
|
self.queried_class = Project
|
||
|
self.view_permission = :search_project
|
||
|
self.available_columns = []
|
||
| ... | ... | |
|
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",
|
||
| app/models/query.rb | ||
|---|---|---|
|
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
|
||
| test/functional/projects_controller_test.rb | ||
|---|---|---|
|
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',
|
||