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

readonly? query method #47

Open
eric-hemasystems opened this issue Mar 21, 2022 · 3 comments
Open

readonly? query method #47

eric-hemasystems opened this issue Mar 21, 2022 · 3 comments

Comments

@eric-hemasystems
Copy link

eric-hemasystems commented Mar 21, 2022

To more fully mock an ActiveRecord object should the mock respond to the readonly? method (similar to the `new_record? query method)?

Use case. We sometimes have a object that enters a final state. To enforce that the record is not updated after that final state we override readonly? to examine the object state to determine if it should be read only or nor. For example:

def readonly?
  super || state == 'complete'
end

Our UI then reads that attribute to know of it needs to present the option to edit that record (via a Pundit policy but that is an impl detail not relevant).

If I use a real ActiveRecord object this all works flawless because readonly? is a built-in method. But if I use a mock from this library that is supposed to be able to replace an ActiveRecord object it does not work.

Seems some way for it to respond to readonly? and return false (mirroring a ActiveRecord object by default) would be good. Bonus points if there was a good way to change the return value for a specific test although that's not a huge need of mine currently.

Wanted to inquire if this was in-scope for this project or just something I need to handle internally (by further mocking what this library returns to more closely mirror an ActiveRecord object myself).

@JonRowe
Copy link
Member

JonRowe commented Mar 22, 2022

If you'd like to add this I'm open to it, I warn you this library will probably need a bit of CI cleanup as its not been updated to github actions

@eric-hemasystems
Copy link
Author

You are wanting to move off Travis CI to use Github Actions? Just trying to understand the scope.

@JonRowe
Copy link
Member

JonRowe commented Mar 22, 2022

Travis is dead, we removed it in the core repos in favour of Github actions, it shouldn't be too arduous to copy there config for this repo

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

No branches or pull requests

2 participants