Skip to content

Commit

Permalink
WIP: failing tests to reproduce bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chrislo committed Oct 3, 2023
1 parent bda0668 commit d076882
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/models/user_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,16 @@ def setup
specified_permissions = [app1.signin_permission, app2.signin_permission]
assert_equal [user1, user2], User.with_permission(specified_permissions.map(&:to_param))
end

should "only return a user once even when they have two permissions for the same app" do
app = create(:application)

permission = create(:supported_permission, application: app)
create(:user, supported_permissions: [app.signin_permission, permission])

specified_permissions = [app.signin_permission, permission]
assert_equal 1, User.with_permission(specified_permissions.map(&:to_param)).count
end
end

context ".with_organisation" do
Expand Down
11 changes: 11 additions & 0 deletions test/models/users_filter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ class UsersFilterTest < ActiveSupport::TestCase

assert_equal %w[user1 user3], filter.users.map(&:name)
end

should "return a user once if they have multiple selected permissions for the same app" do
app = create(:application, name: "App 1")
permission = create(:supported_permission, application: app, name: "Permission 1")

create(:user, name: "user", supported_permissions: [app.signin_permission, permission])

filter = UsersFilter.new(User.all, @current_user, permissions: [app.signin_permission, permission].map(&:to_param))

assert_equal %w[user], filter.users.map(&:name)
end
end

context "#permission_option_select_options" do
Expand Down

0 comments on commit d076882

Please sign in to comment.