Return NotFound error if ChatChannelMembership is not found (#5806)
This commit is contained in:
parent
7270d5ab4c
commit
28440d1fa1
2 changed files with 9 additions and 1 deletions
|
|
@ -2,7 +2,7 @@ class ChatChannelMembershipsController < ApplicationController
|
|||
after_action :verify_authorized
|
||||
|
||||
def find_by_chat_channel_id
|
||||
@membership = ChatChannelMembership.where(chat_channel_id: params[:chat_channel_id], user_id: current_user.id).first
|
||||
@membership = ChatChannelMembership.where(chat_channel_id: params[:chat_channel_id], user_id: current_user.id).first!
|
||||
authorize @membership
|
||||
render json: @membership.to_json(
|
||||
only: %i[id status viewable_by chat_channel_id last_opened_at],
|
||||
|
|
|
|||
|
|
@ -88,4 +88,12 @@ RSpec.describe "ChatChannelMemberships", type: :request do
|
|||
expect(ChatChannelMembership.find(membership.id).status).to eq("left_channel")
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /chat_channel_memberships/find_by_chat_channel_id" do
|
||||
it "renders not_found" do
|
||||
expect do
|
||||
get "/chat_channel_memberships/find_by_chat_channel_id", params: {}
|
||||
end.to raise_error(ActiveRecord::RecordNotFound)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue