Skip to content

Commit

Permalink
Hide API-only app permissions on users page
Browse files Browse the repository at this point in the history
Joseph spotted that I missed this in #2452. Now fixed!
  • Loading branch information
floehopper committed Oct 26, 2023
1 parent 3d04057 commit f76d0ca
Show file tree
Hide file tree
Showing 2 changed files with 15 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
14 changes: 14 additions & 0 deletions test/models/users_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,20 @@ class UsersFilterTest < ActiveSupport::TestCase
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 f76d0ca

Please sign in to comment.