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
destroy dependent account objects #493
destroy dependent account objects #493
Conversation
account = create(:account) | ||
create(:folder, account: account) | ||
|
||
expect { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using {...}
for multi-line blocks.
@tf your input is appreciated ... the test fails likely because i added a default theming name. however it's a required field and without a valid theming name |
The failing test submits an account form without theme_name as an example of invalid attributes. The default value turns that into a valid request. I checked out your branch and your added tests also passed without this line since the default theming created in the account factory already has a theme name or am I missing something? Two minor nitpicks:
EDIT: Feel free to ignore the rest of this comment There is one bigger issue which I just came to realize: Admins can change entries to use a theming that is associated with a different account. While it has been handy in the past to test new themes without moving entries between accounts, it is something we have to be aware of now when we are deleting themings. For accounts we prevent deletion as long as entries or users are associated. We could do something similar for themings. That would probably require some hints in the UI. All other solutions I can think of seem counter intuitive to me:
The optimal solution from my point of view would be to display a disabled delete button with some sort of tooltip explaining why the account cannot be removed yet, instead of simply hiding the button the way we do at the moment. What do you think? Sorry for turning this into a much bigger thing. I'll be happy to help once we've settled on a solution. |
On second thought, maybe all of this makes things too complicated. The main use case for changing an entry's theming instead of its account has been to change its theme while still giving the same group of users access. This will become much easier when I start working on allowing users to be members of multiple accounts next week. So as long as there is no real support for multiple themings per account, we should probably simply remove the theming drop down from the entry form. So for the sake of this PR, we can simply assume that there are no more entries using an account's themings once the account is deleted. That way there will only be errors if you configured entries in special way instead of every time you delete an account. Sorry for the wall of text. |
I feel safer with
Updated! With regards to the rest of your comment, I agree it should be done in principle but if you're already planning on working this in the short term, I suppose it's a lot of work for not a lot of gain. And then keeping the scope of this PR small makes me happier; especially since it will plug a known usability issue. PR updated. |
Agreed! Please squash the commits and we're good to merge. |
Could you take a second look at the commit message. It still talks about default theme naming etc... |
Account destroy did not get rid of the associated theming. There is no dependent: :destroy on the relation. This is problematic because in the Edit Entry screen, a list of themings is needed for the theming dropdown. When a theming does not have a corresponding account, line 23 raises undefined method 'name' for nil:NilClass. The same holds for an account's folders. fixes #476
@tf all done |
…destroy destroy dependent account objects
👍 |
themings and folders must not be orphaned, because they will break the UI in some ways.
I don't know if you like this spec style, I can do it differently, but this is what I usually do.