Skip to content

Commit

Permalink
Enrollments#update no longer works with migrated target API
Browse files Browse the repository at this point in the history
  • Loading branch information
skelz0r committed May 21, 2024
1 parent 30b7aaa commit 0a83797
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/app/policies/enrollment_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ def create?
end

def update?
(record.status_draft? || record.status_changes_requested?) &&
record.class.migrated_target_apis.exclude?(record.target_api) &&
(record.status_draft? || record.status_changes_requested?) &&
user.belongs_to_organization?(record) &&
user.is_demandeur?(record)
end
Expand Down
7 changes: 7 additions & 0 deletions backend/spec/controllers/enrollments/update_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,12 @@
}.to change { api_r2p_enrollment.reload.additional_content }.to(api_r2p_attributes[:additional_content].transform_keys(&:to_s))
end
end

context "when updating migrated target api" do
let(:target_enrollment) { create(:enrollment, :api_entreprise, user: enrollment_creator) }
let(:target_enrollment_attributes) { {} }

it { is_expected.to have_http_status(:forbidden) }
end
end
end

0 comments on commit 0a83797

Please sign in to comment.