From 061b69f9628dc6cb3c243a4ef606803c8225c5c8 Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Thu, 5 Sep 2019 15:50:19 -0400 Subject: [PATCH] GRN2-xx: Fixed issue with room join (#779) * Fixed issue with room join * Rspec fix --- app/controllers/rooms_controller.rb | 6 ++++++ config/locales/en.yml | 1 + spec/controllers/rooms_controller_spec.rb | 14 ++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/app/controllers/rooms_controller.rb b/app/controllers/rooms_controller.rb index 227addb2..4771d7de 100644 --- a/app/controllers/rooms_controller.rb +++ b/app/controllers/rooms_controller.rb @@ -72,6 +72,8 @@ class RoomsController < ApplicationController render :cant_create_rooms end else + return redirect_to root_path, flash: { alert: I18n.t("room.invalid_provider") } if incorrect_user_domain + # Get users name @name = if current_user current_user.name @@ -356,4 +358,8 @@ class RoomsController < ApplicationController render :wait end end + + def incorrect_user_domain + Rails.configuration.loadbalanced_configuration && @room.owner.provider != @user_domain + end end diff --git a/config/locales/en.yml b/config/locales/en.yml index aab1e226..9966b463 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -412,6 +412,7 @@ en: create_room_error: There was an error creating the room create_room_success: Room created successfully enter_the_access_code: Enter the room's access code + invalid_provider: You have entered an invalid url. Please check the url and try again. invited: You have been invited to join invite_participants: Invite Participants join: Join diff --git a/spec/controllers/rooms_controller_spec.rb b/spec/controllers/rooms_controller_spec.rb index 001b82c2..1424ab66 100644 --- a/spec/controllers/rooms_controller_spec.rb +++ b/spec/controllers/rooms_controller_spec.rb @@ -121,6 +121,20 @@ describe RoomsController, type: :controller do expect(response).to redirect_to(admins_path) end + + it "redirects to root if the providers dont match" do + allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true) + allow_any_instance_of(Room).to receive(:running?).and_return(false) + + @owner.update_attribute(:provider, "provider1") + @user.update_attribute(:provider, "provider2") + + @request.session[:user_id] = @user.id + get :show, params: { room_uid: @owner.main_room } + + expect(flash[:alert]).to be_present + expect(response).to redirect_to(root_path) + end end describe "POST #create" do