Project

General

Profile

« Previous | Next » 

Revision 7c019498

Added by Shlomi Zadok over 8 years ago

Fixes #11401 - Add scoped search to auth_source on name

View differences:

app/controllers/api/v2/auth_source_ldaps_controller.rb
before_filter :find_resource, :only => %w{show update destroy}
api :GET, "/auth_source_ldaps/", N_("List all LDAP authentication sources")
param_group :pagination, ::Api::V2::BaseController
param_group :search_and_pagination, ::Api::V2::BaseController
def index
@auth_source_ldaps = resource_scope.paginate(paginate_options)
@auth_source_ldaps = resource_scope_for_index
end
api :GET, "/auth_source_ldaps/:id/", N_("Show an LDAP authentication source")
app/models/auth_source.rb
scope :non_internal, -> { where("type NOT IN (?)", ['AuthSourceInternal', 'AuthSourceHidden']) }
scope :except_hidden, -> { where('type <> ?', 'AuthSourceHidden') }
scoped_search :on => :name, :complete_value => :true
def authenticate(login, password)
end
test/unit/auth_source_test.rb
@auth_source.update_attributes(:type => AuthSourceHidden.name)
end
end
test "should return search results if search free text is auth source name" do
@auth_source.name = 'remote'
@auth_source.save
results = AuthSource.search_for('remote')
assert_equal(1, results.count)
end
test "should return search results for name = auth source name" do
@auth_source.name = 'my_ldap'
@auth_source.save
results = AuthSource.search_for('name = my_ldap')
assert_equal(1, results.count)
assert_equal 'my_ldap', results.first.name
end
end

Also available in: Unified diff