Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for Org selection dropdowns #2747

Merged
merged 3 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions app/controllers/orgs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ def shibboleth_ds_passthru
# rubocop:enable Metrics/AbcSize

# POST /orgs (via AJAX from Org Typeaheads ... see below for specific pages)
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def search
args = search_params
# If the search term is greater than 2 characters
if args.present? && args.fetch(:name, "").length > 2
type = args.fetch(:type, "local")
type = params.fetch(:type, "local")

# If we are including external API results
orgs = case type
Expand Down Expand Up @@ -192,7 +192,7 @@ def search

# If we need to restrict the results to funding orgs then
# only return the ones with a valid fundref
if orgs.present? && args.fetch(:funder_only, "false") == true
if orgs.present? && params.fetch(:funder_only, "false") == true
orgs = orgs.select do |org|
org[:fundref].present? && !org[:fundref].blank?
end
Expand All @@ -204,8 +204,7 @@ def search
render json: []
end
end
# rubocop:enable Metrics/MethodLength
# rubocop:enable
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize

private

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/orgs_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,13 @@

it "calls search_externally when query string contains type=external" do
OrgSelection::SearchService.expects(:search_externally).at_least(1)
post :search, params: { org: { name: Faker::Lorem.sentence, type: "external" } },
post :search, params: { org: { name: Faker::Lorem.sentence }, type: "external" },
format: :js
end

it "calls search_combined when query string contains type=combined" do
OrgSelection::SearchService.expects(:search_combined).at_least(1)
post :search, params: { org: { name: Faker::Lorem.sentence, type: "combined" } },
post :search, params: { org: { name: Faker::Lorem.sentence }, type: "combined" },
format: :js
end
end
Expand Down