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

Add Drafting phase to Budgets #2285

Merged
merged 14 commits into from
Jan 9, 2018
Merged

Conversation

bertocq
Copy link
Collaborator

@bertocq bertocq commented Jan 8, 2018

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 & f9803ce

  • Creating 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:

  • Create a Drafting Budget & check as admins that its listed & accesible
  • Check that its not listed neither accessible as guests or verified users
  • Change phase to Accepting and re-check as guests & users its listed & accessible as it should

drafting_budgets

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 :/

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
Copy link
Contributor

@MariaCheca MariaCheca left a comment

Choose a reason for hiding this comment

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

Wonderful 🌈

@bertocq bertocq merged commit bcec5f7 into master Jan 9, 2018
@bertocq bertocq deleted the feature/2278#budget_draft_phase branch January 9, 2018 09:50
@bertocq bertocq changed the title Feature/2278#budget draft phase Add Drafting phase to Budgets 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants