Return not_found error if org is not found (#5179) [deploy]
This commit is contained in:
parent
36aed0458e
commit
ac8e5b4fb0
2 changed files with 8 additions and 0 deletions
|
|
@ -79,6 +79,7 @@ class OrganizationsController < ApplicationController
|
|||
|
||||
def set_organization
|
||||
@organization = Organization.find_by(id: organization_params[:id])
|
||||
not_found unless @organization
|
||||
authorize @organization
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,4 +30,11 @@ RSpec.describe "OrganizationsUpdate", type: :request do
|
|||
put "/organizations/#{org_id}", params: { organization: { id: org_id, text_color_hex: "#111111" } }
|
||||
expect(Organization.last.profile_updated_at).to be > 2.minutes.ago
|
||||
end
|
||||
|
||||
it "returns not_found if organization is missing" do
|
||||
invalid_id = org_id + 100
|
||||
expect do
|
||||
put "/organizations/#{invalid_id}", params: { organization: { id: invalid_id, text_color_hex: "#111111" } }
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue