Skip to content

Commit

Permalink
Fixed 404 on room join
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad committed Sep 17, 2020
1 parent a278847 commit 8760e0a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def show

# GET /rooms
def cant_create_rooms
return redirect_to root_path unless current_user
shared_rooms = current_user.shared_rooms

if current_user.shared_rooms.empty?
Expand Down Expand Up @@ -156,11 +157,8 @@ def destroy
def join_specific_room
room_uid = params[:join_room][:url].split('/').last

begin
@room = Room.find_by!(uid: room_uid)
rescue ActiveRecord::RecordNotFound
return redirect_to current_user.main_room, alert: I18n.t("room.no_room.invalid_room_uid")
end
@room = Room.find_by(uid: room_uid)
return redirect_to cant_create_rooms_path, alert: I18n.t("room.no_room.invalid_room_uid") unless @room

redirect_to room_path(@room)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/rooms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ def random_valid_room_params
post :join_specific_room, params: { join_room: { url: "abc" } }

expect(flash[:alert]).to eq(I18n.t("room.no_room.invalid_room_uid"))
expect(response).to redirect_to room_path(@user.main_room)
expect(response).to redirect_to cant_create_rooms_path
end

it "should redirect the user to the room uid they supplied" do
Expand Down

0 comments on commit 8760e0a

Please sign in to comment.