-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add Drafting phase to Budgets #2285
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We need to check if the budget is in drafting phase to avoid showing it to the users, unless the current user is an administrator.
Why: Non-admin users shouldn't be able to access, or know of the existence of a non-published Budget. How: Raising an ActionController::RoutingError (404 error) to simulate the same behaviour as accesing a non-existing Budget. We could have used CanCanCan abilities for this but then an user could be aware of existing but not published Budgets by trying different urls
Why: Non-admins shouldn't be aware of non-published Budgets How: Using the budget_published? helper method
MariaCheca
approved these changes
Jan 8, 2018
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.
Wonderful 🌈
voodoorai2000
approved these changes
Jan 9, 2018
clairezed
pushed a commit
to CDJ11/CDJ
that referenced
this pull request
Jun 26, 2018
…et_draft_phase Feature/2278#budget draft phase
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Where
What
Adds "Drafting" phase to Budgets. Budgets in drafting phase can only be listed/viewed by admins.
How
Adding
description_drafting
& drafting phase to Budget model d0937d7 & f9803ceCreating a
budget_published?
helper method at BudgetHelper 03f4fce to use it on both BudgetController to raise a 404 error 76e05d5 and at public budget lists 4916f9a to decide if it should be accessible or not by current user.Screenshots
A Gif is worth a thousand Screenshots!
In this gif we:
Test
Created a "Drafting phase" scenario for Budget feature spec that checks guest/verified/admin user listing & accessing a Drafting Budget 2026f53
Increased both admin budget spec 63694b5 and budget model spec 1f0eb49 with drafting phase scenarios
Deployment
As usual
Warnings
We could have gone with CanCanCan to prevent non-admin's from accessing Budgets in drafting phase but... from my point of view that's a leak of information. Users could know there's an ongoing/drafting Budget by trying different url's until finding one that returns a "You cannot access this Budget" error instead of a 404 error. By imitating the same 404 behaviour as a non-existing budget url we are consistent in the behaviour, although I agree the disadvantage is that the "ability" is not represented in plain sight under
app/model/abilities/*
files :/