-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refacto : on sépare les API internes full calendar dans un autre namespace #4805
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion
2
...llers/admin/agenda/absences_controller.rb → ...s/admin/api/agenda/absences_controller.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
2 changes: 1 addition & 1 deletion
2
...min/agenda/plage_ouvertures_controller.rb → ...api/agenda/plage_ouvertures_controller.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
2 changes: 1 addition & 1 deletion
2
...ntrollers/admin/agenda/rdvs_controller.rb → ...llers/admin/api/agenda/rdvs_controller.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
2 changes: 1 addition & 1 deletion
2
...ntrollers/admin/agenda/base_controller.rb → app/controllers/admin/api/base_controller.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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 was deleted.
Oops, something went wrong.
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
104 changes: 104 additions & 0 deletions
104
spec/controllers/admin/api/agenda/rdvs_controller_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,104 @@ | ||
RSpec.describe Admin::Api::Agenda::RdvsController, type: :controller do | ||
render_views | ||
|
||
# Semaine du lundi 8 avril 2024 au vendredi 12 avril 2024. | ||
# On note que FullCalendar utilise des dates naïves (sans timezone). | ||
let(:fullcalendar_time_range_params) do | ||
{ | ||
start: "2024-04-08T00:00:00", | ||
end: "2024-04-13T00:00:00", # FullCalendar utilise cette valeur pour indiquer "jusqu'au vendredi 12 inclus" | ||
} | ||
end | ||
let(:aujourdhui_lundi_15h) { Time.zone.parse("2024-04-08 15:00:00") } | ||
let(:mercredi_15h) { Time.zone.parse("2024-04-10 15:00:00") } | ||
|
||
let(:organisation) { create(:organisation) } | ||
|
||
context "with a signed in agent" do | ||
before { sign_in current_agent } | ||
|
||
describe "displaying RDVs across organisations" do | ||
let(:other_organisation) { create(:organisation) } | ||
let(:current_agent) { create(:agent, admin_role_in_organisations: [organisation, other_organisation]) } | ||
|
||
it "returns rdvs of given agent across organisations" do | ||
travel_to(aujourdhui_lundi_15h) | ||
given_agent = create(:agent, basic_role_in_organisations: [organisation], service: current_agent.services.first) | ||
create(:rdv, agents: [current_agent]) | ||
rdv = create(:rdv, agents: [given_agent], organisation: organisation, starts_at: mercredi_15h) | ||
rdv_from_other_organisation = create(:rdv, agents: [given_agent], organisation: other_organisation, starts_at: mercredi_15h) | ||
get :index, params: fullcalendar_time_range_params.merge(agent_id: given_agent.id, organisation_id: organisation.id, format: :json) | ||
expect(response).to be_successful | ||
|
||
returns_rdvs = response.parsed_body | ||
expect(returns_rdvs.pluck("id")).to contain_exactly(rdv.id, rdv_from_other_organisation.id) | ||
|
||
# Les RDVs des autres orgas sont affichés en gris | ||
expect(returns_rdvs.find { _1["id"] == rdv_from_other_organisation.id }["backgroundColor"]).to eq("#757575") | ||
end | ||
end | ||
|
||
describe "respecting the time range" do | ||
let(:samedi_15h) { Time.zone.parse("2024-04-13 15:00:00") } | ||
let(:mardi_en_huit_15h) { Time.zone.parse("2024-04-16 15:00:00") } | ||
let(:vendredi_dernier_15h) { Time.zone.parse("2024-04-05 15:00:00") } | ||
|
||
let(:current_agent) { create(:agent, basic_role_in_organisations: [organisation]) } | ||
|
||
it "returns rdvs of given agent from start to end" do | ||
travel_to(aujourdhui_lundi_15h) | ||
create(:rdv, agents: [current_agent], organisation: organisation, starts_at: vendredi_dernier_15h) | ||
rdv = create(:rdv, agents: [current_agent], organisation: organisation, starts_at: mercredi_15h) | ||
create(:rdv, agents: [current_agent], organisation: organisation, starts_at: samedi_15h) | ||
create(:rdv, agents: [current_agent], organisation: organisation, starts_at: mardi_en_huit_15h) | ||
|
||
get :index, params: fullcalendar_time_range_params.merge(agent_id: current_agent.id, organisation_id: organisation.id, format: :json) | ||
expect(response.parsed_body.pluck("id")).to eq([rdv.id]) | ||
end | ||
end | ||
|
||
describe "showing RDVs without details" do | ||
describe "showing an agent's RDVs for a service in which I am not" do | ||
let(:current_agent) { create(:agent, basic_role_in_organisations: [organisation]) } | ||
|
||
it "does not show any info about the RDV and does not provide a link" do | ||
other_service = create(:service) | ||
given_agent = create(:agent, basic_role_in_organisations: [organisation], service: current_agent.services.first) | ||
rdv_of_another_service = create(:rdv, agents: [given_agent], organisation: organisation, starts_at: mercredi_15h, motif: create(:motif, service: other_service)) | ||
get :index, params: fullcalendar_time_range_params.merge(agent_id: given_agent.id, organisation_id: organisation.id, format: :json) | ||
expect(response.parsed_body.size).to eq(1) | ||
expect(response.parsed_body[0].keys).to eq(%w[start end title textColor backgroundColor extendedProps]) | ||
expect(response.parsed_body[0]["title"]).to eq("Occupé⋅e (en RDV)") | ||
expect(Time.zone.parse(response.parsed_body[0]["start"])).to eq(rdv_of_another_service.starts_at) | ||
expect(Time.zone.parse(response.parsed_body[0]["end"])).to eq(rdv_of_another_service.ends_at) | ||
expect(response.parsed_body[0]["extendedProps"]["unauthorizedRdvExplanation"]).to include("Vous n'avez pas accès à ce RDV") | ||
end | ||
end | ||
|
||
describe "showing an agent's RDVs for an organisation where I don't belongs" do | ||
let(:current_agent) { create(:agent, basic_role_in_organisations: [organisation]) } | ||
|
||
it "does not show any info about the RDV and does not provide a link" do | ||
other_org = create(:organisation) | ||
given_agent = create(:agent, basic_role_in_organisations: [organisation, other_org], service: current_agent.services.first) | ||
motif_of_other_org = create(:motif, organisation: other_org, service: current_agent.services.first) | ||
rdv_of_another_org_same_service = create(:rdv, agents: [given_agent], organisation: other_org, starts_at: aujourdhui_lundi_15h, motif: motif_of_other_org) | ||
get :index, params: fullcalendar_time_range_params.merge(agent_id: given_agent.id, organisation_id: organisation.id, format: :json) | ||
expect(response.parsed_body.size).to eq(1) | ||
expect(response.parsed_body[0].keys).to eq(%w[start end title textColor backgroundColor extendedProps]) | ||
expect(response.parsed_body[0]["title"]).to eq("Occupé⋅e (en RDV)") | ||
expect(Time.zone.parse(response.parsed_body[0]["start"])).to eq(rdv_of_another_org_same_service.starts_at) | ||
expect(Time.zone.parse(response.parsed_body[0]["end"])).to eq(rdv_of_another_org_same_service.ends_at) | ||
expect(response.parsed_body[0]["extendedProps"]["unauthorizedRdvExplanation"]).to include("Vous n'avez pas accès à ce RDV") | ||
end | ||
end | ||
end | ||
end | ||
|
||
context "when agent is not login" do | ||
it "returns unauthorized" do | ||
get :index, params: { agent_id: 1, organisation_id: 1, start: "2019-08-12", end: "2019-08-19", format: :json } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. J'apprécie beaucoup que cette spec ne reprenne pas tous les |
||
expect(response).to be_unauthorized | ||
end | ||
end | ||
end |
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.
Ici j’ai juste rajouté ce contexte pour pouvoir rajouter le cas où l’agent n’est pas connecté