Skip to content

Commit

Permalink
Add is_mine parameter to listThread service
Browse files Browse the repository at this point in the history
  • Loading branch information
GeoffreyHuck committed Apr 11, 2023
1 parent 8663507 commit e69a78c
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 87 deletions.
103 changes: 67 additions & 36 deletions app/api/threads/list_threads.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,42 @@ Feature: List threads
| BaptisteCanViewContent1 | Baptiste | | content | |
| BaptisteCanViewContent2 | Baptiste | | content | |
| BaptisteCanViewContentWithDescendants | Baptiste | | content_with_descendants | |
| EtienneKleinHasValidated1 | EtienneKlein | 1 | | |
| EtienneKleinHasValidated2 | EtienneKlein | 1 | | |
| EtienneKleinHasValidated3 | EtienneKlein | 1 | | |
| EtienneKleinHasValidated4 | EtienneKlein | 1 | | |
| EtienneKleinHasValidated5 | EtienneKlein | 1 | | |
| EtienneKleinHasValidated6 | EtienneKlein | 1 | | |
| EtienneKleinHasNotValidated | EtienneKlein | | | answer |
| EtienneKleinCanWatchAnswer1 | EtienneKlein | | | answer |
| EtienneKleinCanWatchAnswer2 | EtienneKlein | | | answer |
| EtienneKleinCanWatchAnswer3 | EtienneKlein | | | answer |
| EtienneKleinCanWatchAnswer4 | EtienneKlein | | | answer |
| EtienneKleinHasValidated1 | EtienneKlein | 1 | info | |
| EtienneKleinHasValidated2 | EtienneKlein | 1 | info | |
| EtienneKleinHasValidated3 | EtienneKlein | 1 | info | |
| EtienneKleinHasValidated4 | EtienneKlein | 1 | info | |
| EtienneKleinHasValidated5 | EtienneKlein | 1 | info | |
| EtienneKleinHasValidated6 | EtienneKlein | 1 | info | |
| EtienneKleinHasNotValidated | EtienneKlein | | info | |
| EtienneKleinCanWatchAnswer1 | EtienneKlein | | info | answer |
| EtienneKleinCanWatchAnswer2 | EtienneKlein | | info | answer |
| EtienneKleinCanWatchAnswer3 | EtienneKlein | | info | answer |
| EtienneKleinCanWatchAnswer4 | EtienneKlein | | info | answer |
| EtienneKleinCanWatchAnswer5 | EtienneKlein | | info | answer |
| EtienneKleinCanWatchAnswer6 | EtienneKlein | | none | answer |
Given there are the following threads:
| participant | item | helper_group | status | latest_update_at | comment |
| ConsortiumPresident | | | | | |
| UniversityPresident | | | | | |
| Mary | | | | | |
| EtienneKlein | EtienneKleinCanWatchAnswer1 | | | | EtienneKlein is_mine=0 -> notok: must not be the participant |
| Charlotte | EtienneKleinHasValidated1 | PremièreAnnée | waiting_for_trainer | | EtienneKlein is_mine=0 -> List thread notok: not part of helper group |
| Charlotte | EtienneKleinHasNotValidated | Université | waiting_for_trainer | | EtienneKlein is_mine=0 -> List thread notok: Has not validated |
| Charlotte | EtienneKleinHasValidated2 | Université | waiting_for_trainer | | EtienneKlein is_mine=0 -> List thread ok: part of helper group, open thread and validated item |
| Charlotte | EtienneKleinHasValidated3 | UniversityConsortium | waiting_for_trainer | | EtienneKlein is_mine=0 -> List thread ok: part of helper group, open thread and validated item |
| Charlotte | EtienneKleinCanWatchAnswer2 | Université | waiting_for_trainer | | EtienneKlein is_mine=0 -> List thread ok: can_watch >= answer |
| Charlotte | EtienneKleinHasValidated4 | Université | waiting_for_participant | | EtienneKlein is_mine=0 -> List thread ok: part of helper group, open thread and validated item |
| Charlotte | EtienneKleinCanWatchAnswer3 | Université | waiting_for_participant | | EtienneKlein is_mine=0 -> List thread ok: can_watch >= answer |
| Charlotte | EtienneKleinHasValidated5 | Université | closed | 2021-12-20T00:00:00Z | EtienneKlein is_mine=0 -> List thread ok: part of helper group, closed thread for less than 2 weeks and validated item |
| Charlotte | EtienneKleinCanWatchAnswer4 | Université | closed | 2021-12-20T00:00:00Z | EtienneKlein is_mine=0 -> List thread ok: can_watch >= answer |
| Charlotte | EtienneKleinHasValidated6 | Université | closed | 2021-11-00T00:00:00Z | EtienneKlein is_mine=0 -> List thread notok: closed for more than 2 weeks |
| Charlotte | EtienneKleinCanWatchAnswer5 | Université | closed | 2021-11-00T00:00:00Z | EtienneKlein is_mine=0 -> List thread ok: can_watch >= answer |
| Baptiste | BaptisteCanViewInfo | | | | Baptiste is_mine=1 -> notok: can_view < content |
| Baptiste | BaptisteCanViewContent1 | | | | Baptiste is_mine=1 -> ok: can_view >= content |
| Thibaut | BaptisteCanViewContent2 | | | | Baptiste is_mine=1 -> notok: not the participant |
| Baptiste | BaptisteCanViewContentWithDescendants | | | | Baptiste is_mine=1 -> ok: can_view >= content |
| DavidBowie | | | | | |
| participant | item | helper_group | status | latest_update_at | message_count | comment |
| ConsortiumPresident | | | | | 0 | |
| UniversityPresident | | | | | 1 | |
| Mary | | | | | 2 | |
| EtienneKlein | EtienneKleinCanWatchAnswer1 | | | | 3 | EtienneKlein is_mine=0 -> notok: must not be the participant |
| Charlotte | EtienneKleinHasValidated1 | PremièreAnnée | waiting_for_trainer | | 4 | EtienneKlein is_mine=0 -> List thread notok: not part of helper group |
| Charlotte | EtienneKleinHasNotValidated | Université | waiting_for_trainer | | 5 | EtienneKlein is_mine=0 -> List thread notok: Has not validated, and not can_watch >= answer |
| Charlotte | EtienneKleinHasValidated2 | Université | waiting_for_trainer | | 6 | EtienneKlein is_mine=0 -> List thread ok: part of helper group, open thread and validated item |
| Charlotte | EtienneKleinHasValidated3 | UniversityConsortium | waiting_for_trainer | | 7 | EtienneKlein is_mine=0 -> List thread ok: part of helper group, open thread and validated item |
| Charlotte | EtienneKleinCanWatchAnswer2 | Université | waiting_for_trainer | | 8 | EtienneKlein is_mine=0 -> List thread ok: can_watch >= answer |
| Charlotte | EtienneKleinHasValidated4 | Université | waiting_for_participant | | 9 | EtienneKlein is_mine=0 -> List thread ok: part of helper group, open thread and validated item |
| Charlotte | EtienneKleinCanWatchAnswer3 | Université | waiting_for_participant | | 10 | EtienneKlein is_mine=0 -> List thread ok: can_watch >= answer |
| Charlotte | EtienneKleinCanWatchAnswer6 | Université | waiting_for_participant | | 11 | EtienneKlein is_mine=0 -> List thread notok: cannot view the item |
| Charlotte | EtienneKleinHasValidated5 | Université | closed | 2021-12-20 00:00:00 | 12 | EtienneKlein is_mine=0 -> List thread ok: part of helper group, closed thread for less than 2 weeks and validated item |
| Charlotte | EtienneKleinCanWatchAnswer4 | Université | closed | 2021-12-20 00:00:00 | 13 | EtienneKlein is_mine=0 -> List thread ok: can_watch >= answer |
| Charlotte | EtienneKleinHasValidated6 | Université | closed | 2021-11-01 00:00:00 | 14 | EtienneKlein is_mine=0 -> List thread notok: closed for more than 2 weeks |
| Charlotte | EtienneKleinCanWatchAnswer5 | Université | closed | 2021-11-01 00:00:00 | 15 | EtienneKlein is_mine=0 -> List thread ok: can_watch >= answer, even if thread is closed for more than 2 weeks |
| Baptiste | BaptisteCanViewInfo | | | | 16 | Baptiste is_mine=1 -> notok: can_view < content |
| Baptiste | BaptisteCanViewContent1 | | | | 17 | Baptiste is_mine=1 -> ok: can_view >= content |
| Thibaut | BaptisteCanViewContent2 | | | | 18 | Baptiste is_mine=1 -> notok: not the participant |
| Baptiste | BaptisteCanViewContentWithDescendants | | | | 19 | Baptiste is_mine=1 -> ok: can_view >= content |
| DavidBowie | | | | | 20 | |
And the time now is "2022-01-01T00:00:00Z"

Scenario: Should have all the fields properly set, including first_name and last_name when the access is approved
Expand Down Expand Up @@ -123,6 +126,7 @@ Feature: List threads
And the user UniversityPresident is referenced by @UniversityPresident
And the group University is referenced by @University
When I send a GET request to "/threads?watched_group_id=@University"
Then the response code should be 200
And it should be a JSON array with 2 entries
And the response at $[*].participant.id should be:
| @UniversityPresident |
Expand All @@ -133,13 +137,40 @@ Feature: List threads
And I can watch the group University
And the user Mary is referenced by @Mary
When I send a GET request to "/threads?watched_group_id=@Mary"
Then the response code should be 200
And it should be a JSON array with 1 entries
And the response at $[0].participant.id should be "@Mary"

Scenario: Should return only the threads in which the participant is the current user and the item is visible when is_mine=1
# Baptiste can see BaptisteCanViewContent and BaptisteCanViewContentWithDescendants
# Waiting for implementation of is_mine
Given I am Baptiste
And the item BaptisteCanViewContent1 is referenced by @BaptisteCanViewContent1
And the item BaptisteCanViewContentWithDescendants is referenced by @BaptisteCanViewContentWithDescendants
When I send a GET request to "/threads?is_mine=1"
Then the response code should be 200
And it should be a JSON array with 2 entries
And the response at $[*].item.id should be:
| @BaptisteCanViewContent1 |
| @BaptisteCanViewContentWithDescendants |

Scenario: Should return only the threads that the current-user can list and in which he is not the participant when is_mine=0
# EtienneKlein can see EtienneKleinHasValidated2, EtienneKleinHasValidated3, EtienneKleinCanWatchAnswer2, EtienneKleinHasValidated4, EtienneKleinCanWatchAnswer3, EtienneKleinHasValidated5, EtienneKleinCanWatchAnswer4, EtienneKleinCanWatchAnswer5
# Waiting for implementation of is_mine
Given I am EtienneKlein
And the item EtienneKleinHasValidated2 is referenced by @EtienneKleinHasValidated2
And the item EtienneKleinHasValidated3 is referenced by @EtienneKleinHasValidated3
And the item EtienneKleinCanWatchAnswer2 is referenced by @EtienneKleinCanWatchAnswer2
And the item EtienneKleinHasValidated4 is referenced by @EtienneKleinHasValidated4
And the item EtienneKleinCanWatchAnswer3 is referenced by @EtienneKleinCanWatchAnswer3
And the item EtienneKleinHasValidated5 is referenced by @EtienneKleinHasValidated5
And the item EtienneKleinCanWatchAnswer4 is referenced by @EtienneKleinCanWatchAnswer4
And the item EtienneKleinCanWatchAnswer5 is referenced by @EtienneKleinCanWatchAnswer5
When I send a GET request to "/threads?is_mine=0"
Then the response code should be 200
And it should be a JSON array with 8 entries
And the response at $[*].item.id should be:
| @EtienneKleinHasValidated2 |
| @EtienneKleinHasValidated3 |
| @EtienneKleinCanWatchAnswer2 |
| @EtienneKleinHasValidated4 |
| @EtienneKleinCanWatchAnswer3 |
| @EtienneKleinHasValidated5 |
| @EtienneKleinCanWatchAnswer4 |
| @EtienneKleinCanWatchAnswer5 |
Loading

0 comments on commit e69a78c

Please sign in to comment.