Feature #37674 » 0004-adds-column-and-filter-for-authentication-mode-to-ad.patch
| app/models/user_query.rb | ||
|---|---|---|
|
QueryColumn.new(:updated_on, :sortable => "#{User.table_name}.updated_on"),
|
||
|
QueryColumn.new(:last_login_on, :sortable => "#{User.table_name}.last_login_on"),
|
||
|
QueryColumn.new(:passwd_changed_on, :sortable => "#{User.table_name}.passwd_changed_on"),
|
||
|
QueryColumn.new(:status, sortable: "#{User.table_name}.status")
|
||
|
QueryColumn.new(:status, sortable: "#{User.table_name}.status"),
|
||
|
QueryAssociationColumn.new(:auth_source, :name, caption: :field_auth_source, sortable: "#{AuthSource.table_name}.name")
|
||
|
]
|
||
|
def initialize(attributes=nil, *args)
|
||
| ... | ... | |
|
def initialize_available_filters
|
||
|
add_available_filter "status",
|
||
|
type: :list, values: ->{ user_statuses_values }
|
||
|
add_available_filter "auth_source_id",
|
||
|
type: :list_optional, values: ->{ auth_sources_values }
|
||
|
add_available_filter "is_member_of_group",
|
||
|
type: :list_optional,
|
||
|
values: ->{ Group.givable.visible.map {|g| [g.name, g.id.to_s] } }
|
||
| ... | ... | |
|
add_custom_fields_filters(user_custom_fields)
|
||
|
end
|
||
|
def auth_sources_values
|
||
|
AuthSource.order(name: :asc).to_a.map do |auth_source|
|
||
|
[auth_source.name, auth_source.id]
|
||
|
end
|
||
|
end
|
||
|
def user_statuses_values
|
||
|
[
|
||
|
[l(:status_active), User::STATUS_ACTIVE.to_s],
|
||
| test/functional/users_controller_test.rb | ||
|---|---|---|
|
end
|
||
|
end
|
||
|
def test_index_filter_by_auth_source_none
|
||
|
user = User.find(1)
|
||
|
user.update_column :auth_source_id, 1
|
||
|
get :index, params: {
|
||
|
set_filter: 1,
|
||
|
f: ['auth_source_id'], op: {auth_source_id: '!*'}
|
||
|
}
|
||
|
assert_response :success
|
||
|
assert_select 'tr.user'
|
||
|
assert_select 'tr#user-1', 0
|
||
|
end
|
||
|
def test_index_filter_by_auth_source
|
||
|
user = User.find(1)
|
||
|
user.update_column :auth_source_id, 1
|
||
|
get :index, params: {
|
||
|
set_filter: 1,
|
||
|
f: ['auth_source_id'], op: {auth_source_id: '='}, v: {auth_source_id: ['1']}
|
||
|
}
|
||
|
assert_response :success
|
||
|
assert_select 'tr#user-1', 1
|
||
|
assert_select "select#add_filter_select" do
|
||
|
assert_select "option[value=auth_source_id]"
|
||
|
end
|
||
|
assert_select "select#available_c" do
|
||
|
assert_select "option[value='auth_source.name']"
|
||
|
end
|
||
|
end
|
||
|
def test_index_csv
|
||
|
with_settings :default_language => 'en' do
|
||
|
user = User.logged.status(1).first
|
||