Skip to content

Commit

Permalink
Merge pull request #2457 from alphagov/hide-permissions-for-api-only-…
Browse files Browse the repository at this point in the history
…apps-on-users-index-page

Hide permissions for API-only apps on users index page
  • Loading branch information
floehopper authored Oct 26, 2023
2 parents aa951aa + f76d0ca commit c6a0fb3
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/users_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def role_option_select_options(aria_controls_id: nil)
end

def permission_option_select_options(aria_controls_id: nil)
Doorkeeper::Application.includes(:supported_permissions).flat_map do |application|
Doorkeeper::Application.not_api_only.includes(:supported_permissions).flat_map do |application|
application.supported_permissions.map do |permission|
{
label: "#{application.name} #{permission.name}",
Expand Down
28 changes: 28 additions & 0 deletions test/models/users_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,34 @@ class UsersFilterTest < ActiveSupport::TestCase
assert_equal expected_options, options
end
end

context "when App 2 is retired" do
setup do
@app2.update!(retired: true)
end

should "return not include options for retired application permissions" do
filter = UsersFilter.new(User.all, @current_user, {})
options = filter.permission_option_select_options

app2_option = options.detect { |o| o[:value] == @app2.signin_permission.to_param }
assert_not app2_option
end
end

context "when App 2 is API-only" do
setup do
@app2.update!(api_only: true)
end

should "return not include options for API-only application permissions" do
filter = UsersFilter.new(User.all, @current_user, {})
options = filter.permission_option_select_options

app2_option = options.detect { |o| o[:value] == @app2.signin_permission.to_param }
assert_not app2_option
end
end
end

context "when filtering by organisation" do
Expand Down

0 comments on commit c6a0fb3

Please sign in to comment.