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

Use Rails native AR patterns to control the user scope #982

Merged
merged 4 commits into from
Mar 14, 2024
Merged

Conversation

epugh
Copy link
Member

@epugh epugh commented Mar 14, 2024

Description

Go back to using more native rails code for #979 .....

@reid-rigo can you give this a quick once over?

Motivation and Context

How Has This Been Tested?

Screenshots or GIFs (if appropriate):

Types of changes

  • [] Bug fix (non-breaking change which fixes an issue)
  • [] Improvement (non-breaking change which improves existing functionality)
  • [] New feature (non-breaking change which adds new functionality)
  • [] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • [] My code follows the code style of this project.
  • [] My change requires a change to the documentation.
  • [] I have updated the documentation accordingly.
  • [] I have read the CONTRIBUTING document.
  • [] I have added tests to cover my changes.
  • [] All new and existing tests passed.

@epugh epugh changed the title Alternate fix Use Rails native AR patterns to control the user scope Mar 14, 2024
@reid-rigo
Copy link
Contributor

Looks good. I think adding a test case makes sense here. This one catches the issue:

it 'returns distinct cases' do
  case_ids = Case.for_user(users(:random)).pluck(:id)
  assert_equal case_ids, case_ids.uniq
end

@epugh
Copy link
Member Author

epugh commented Mar 14, 2024

Looks good. I think adding a test case makes sense here. This one catches the issue:

it 'returns distinct cases' do
  case_ids = Case.for_user(users(:random)).pluck(:id)
  assert_equal case_ids, case_ids.uniq
end

Nice simple test case! I tend to a lot of setup and verbosity that isn't actually needed!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like all of these else cases need the select, right? Since they're all looking at last_viewed_at

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thansk for the check, this led me to wondering who used the method and discovering that the code was added on the backend, but we never quite the front end JS to properly work... So removed the code.

@epugh epugh merged commit 05f687c into main Mar 14, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants