Feature #8160 » Add_filter_value_of_watcher_v2.patch
| app/models/issue_query.rb | ||
|---|---|---|
|
if User.current.logged?
|
||
|
add_available_filter "watcher_id",
|
||
|
:type => :list, :values => [["<< #{l(:label_me)} >>", "me"]]
|
||
|
:type => :list, :values => lambda { watcher_values }
|
||
|
end
|
||
|
add_available_filter("updated_by",
|
||
| app/models/query.rb | ||
|---|---|---|
|
statuses.collect{|s| [s.name, s.id.to_s]}
|
||
|
end
|
||
|
def watcher_values
|
||
|
watcher_values = [["<< #{l(:label_me)} >>", "me"]]
|
||
|
watcher_values += users.sort_by(&:status).collect{|s| [s.name, s.id.to_s, l("status_#{User::LABEL_BY_STATUS[s.status]}")] } if User.current.allowed_to?(:view_issue_watchers, self.project)
|
||
|
watcher_values
|
||
|
end
|
||
|
# Returns a scope of issue custom fields that are available as columns or filters
|
||
|
def issue_custom_fields
|
||
|
if project
|
||
| test/functional/queries_controller_test.rb | ||
|---|---|---|
|
assert_include ["Dave Lopper", "3", "active"], json
|
||
|
assert_include ["Dave2 Lopper2", "5", "locked"], json
|
||
|
end
|
||
|
def test_watcher_filter_without_view_issue_watchers_should_return_filter_values
|
||
|
# A user who does not belong to any project
|
||
|
# Don't have view_issue_watcher permission
|
||
|
@request.session[:user_id] = 7
|
||
|
get :filter, :params => {
|
||
|
:project_id => 1,
|
||
|
:type => 'IssueQuery',
|
||
|
:name => 'watcher_id'
|
||
|
}
|
||
|
assert_response :success
|
||
|
assert_equal 'application/json', response.content_type
|
||
|
json = ActiveSupport::JSON.decode(response.body)
|
||
|
assert_equal [["<< me >>", "me"]], json
|
||
|
end
|
||
|
def test_watcher_filter_with_view_issue_watchers_should_return_filter_values
|
||
|
# This user has view_issue_watcher permission
|
||
|
@request.session[:user_id] = 1
|
||
|
get :filter, :params => {
|
||
|
:project_id => 1,
|
||
|
:type => 'IssueQuery',
|
||
|
:name => 'watcher_id'
|
||
|
}
|
||
|
assert_response :success
|
||
|
assert_equal 'application/json', response.content_type
|
||
|
json = ActiveSupport::JSON.decode(response.body)
|
||
|
assert_equal 6, json.count
|
||
|
# "me" value should not be grouped
|
||
|
assert_include ["<< me >>", "me"], json
|
||
|
assert_include ["Dave Lopper", "3", "active"], json
|
||
|
assert_include ["Dave2 Lopper2", "5", "locked"], json
|
||
|
end
|
||
|
end
|
||
- « Previous
- 1
- 2
- Next »