-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat(rgpd): partition motifs by org type #2540
Open
Michaelvilleneuve
wants to merge
8
commits into
staging
Choose a base branch
from
feat/partition-motifs-by-organisation-type
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b6e399f
participation motifs by org type
Michaelvilleneuve f8559b0
fix minor issues
Michaelvilleneuve b854e2b
fix validation issue
Michaelvilleneuve 0937c49
fix spec
Michaelvilleneuve d44e108
minor refacto
Michaelvilleneuve 0b5a686
minor refacto
Michaelvilleneuve cd0ba52
moved validation to service
Michaelvilleneuve d1ad48c
extract unit
Michaelvilleneuve File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class MotifCategoryPolicy < ApplicationPolicy | ||
RSA_RELATED_TYPES = %w[rsa_orientation rsa_accompagnement].freeze | ||
|
||
def self.authorized_for_organisation(organisation) | ||
if organisation.rsa_related? | ||
MotifCategory.where(motif_category_type: RSA_RELATED_TYPES) | ||
else | ||
MotifCategory.where(motif_category_type: organisation.organisation_type) | ||
end | ||
end | ||
|
||
# We need a dedicated method on top of the class method because we may be validating on a new object | ||
# which the scope is not yet aware of | ||
def authorized_for_organisation?(organisation) | ||
return RSA_RELATED_TYPES.include?(record.motif_category_type) if organisation.rsa_related? | ||
|
||
organisation.organisation_type == record.motif_category_type | ||
end | ||
end |
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
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
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
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
63 changes: 63 additions & 0 deletions
63
spec/features/agent_can_create_category_configuration_spec.rb
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
describe "Agents can edit category configuration", :js do | ||
let!(:agent) { create(:agent) } | ||
let!(:organisation) { create(:organisation, organisation_type: "delegataire_rsa") } | ||
let!(:agent_role) { create(:agent_role, organisation: organisation, agent: agent, access_level: "admin") } | ||
let!(:motif_category) do | ||
create( | ||
:motif_category, | ||
name: "RSA Follow up", | ||
short_name: "rsa_follow_up", | ||
motif_category_type: "rsa_accompagnement" | ||
) | ||
end | ||
|
||
let!(:category_configuration) { create(:category_configuration, organisation:, file_configuration:) } | ||
let(:file_configuration) { create(:file_configuration) } | ||
|
||
before do | ||
stub_rdv_solidarites_activate_motif_category_territories( | ||
organisation.rdv_solidarites_organisation_id, | ||
motif_category.short_name | ||
) | ||
setup_agent_session(agent) | ||
end | ||
|
||
context "category configuration edit" do | ||
it "allows to create category configuration" do | ||
visit new_organisation_category_configuration_path(organisation) | ||
|
||
fill_in "category_configuration_phone_number", with: "3234" | ||
fill_in "category_configuration_email_to_notify_rdv_changes", with: "[email protected]" | ||
fill_in "category_configuration_email_to_notify_no_available_slots", with: "[email protected]" | ||
|
||
select "RSA Follow up", from: "category_configuration[motif_category_id]" | ||
|
||
find("input[name=\"category_configuration[file_configuration_id]\"]").click | ||
|
||
click_button "Enregistrer" | ||
|
||
expect(page).to have_content("3234") | ||
expect(page).to have_content("[email protected]") | ||
|
||
new_category_configuration = CategoryConfiguration.last | ||
expect(new_category_configuration.reload.phone_number).to eq("3234") | ||
expect(new_category_configuration.email_to_notify_rdv_changes).to eq("[email protected]") | ||
expect(new_category_configuration.email_to_notify_no_available_slots).to eq("[email protected]") | ||
end | ||
|
||
context "motif category selection" do | ||
let!(:motif_category2) do | ||
create(:motif_category, name: "Autre", short_name: "autre", motif_category_type: "autre") | ||
end | ||
|
||
it "allows to select authorized motif categories" do | ||
visit new_organisation_category_configuration_path(organisation) | ||
|
||
expect(page).to have_select( | ||
"category_configuration[motif_category_id]", options: ["-", "RSA Follow up", | ||
category_configuration.motif_category.name] | ||
) | ||
end | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
it "allows to edit category configuration" do | ||
visit edit_organisation_category_configuration_path(organisation, organisation.category_configurations.first) | ||
|
||
fill_in "category_configuration_phone_number", with: "3234" | ||
fill_in "category_configuration_phone_number", with: "3234" | ||
fill_in "category_configuration_email_to_notify_rdv_changes", with: "[email protected]" | ||
fill_in "category_configuration_email_to_notify_no_available_slots", with: "[email protected]" | ||
|
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
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
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
Oops, something went wrong.
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.
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.
ce serait bien d'avoir un test qui vérifie qu'on ne puisse pas créer une config sur une catégorie non autorisée
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.
Je pense pas que ce soit utile ce serait redondant avec le TU