forked from External/greenlight
Added setting for admin to limit the number of rooms for the user (#607)
This commit is contained in:
committed by
Jesus Federico
parent
4f2b190239
commit
e4f50026f1
@ -247,7 +247,9 @@ describe AdminsController, type: :controller do
|
||||
expect(response).to redirect_to(admins_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "Site Settings" do
|
||||
context "POST #registration_method" do
|
||||
it "changes the registration method for the given context" do
|
||||
allow(Rails.configuration).to receive(:enable_email_verification).and_return(true)
|
||||
@ -294,5 +296,21 @@ describe AdminsController, type: :controller do
|
||||
expect(response).to redirect_to(admins_path)
|
||||
end
|
||||
end
|
||||
|
||||
context "POST #room_limit" do
|
||||
it "changes the room limit setting" do
|
||||
allow(Rails.configuration).to receive(:loadbalanced_configuration).and_return(true)
|
||||
allow_any_instance_of(User).to receive(:greenlight_account?).and_return(true)
|
||||
|
||||
@request.session[:user_id] = @admin.id
|
||||
|
||||
post :room_limit, params: { limit: 5 }
|
||||
|
||||
feature = Setting.find_by(provider: "provider1").features.find_by(name: "Room Limit")
|
||||
|
||||
expect(feature[:value]).to eq("5")
|
||||
expect(response).to redirect_to(admins_path)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -129,7 +129,7 @@ describe RoomsController, type: :controller do
|
||||
expect(response).to redirect_to(r)
|
||||
end
|
||||
|
||||
it "it should redirect to root if not logged in" do
|
||||
it "should redirect to root if not logged in" do
|
||||
expect do
|
||||
name = Faker::Games::Pokemon.name
|
||||
post :create, params: { room: { name: name } }
|
||||
@ -138,7 +138,7 @@ describe RoomsController, type: :controller do
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
|
||||
it "it should redirect back to main room with error if it fails" do
|
||||
it "should redirect back to main room with error if it fails" do
|
||||
@request.session[:user_id] = @owner.id
|
||||
|
||||
room_params = { name: "", "client": "html5", "mute_on_join": "1" }
|
||||
@ -148,6 +148,19 @@ describe RoomsController, type: :controller do
|
||||
expect(flash[:alert]).to be_present
|
||||
expect(response).to redirect_to(@owner.main_room)
|
||||
end
|
||||
|
||||
it "redirects to main room if room limit is reached" do
|
||||
allow_any_instance_of(Setting).to receive(:get_value).and_return(1)
|
||||
|
||||
@request.session[:user_id] = @owner.id
|
||||
|
||||
room_params = { name: Faker::Games::Pokemon.name, "client": "html5", "mute_on_join": "1" }
|
||||
|
||||
post :create, params: { room: room_params }
|
||||
|
||||
expect(flash[:alert]).to be_present
|
||||
expect(response).to redirect_to(@owner.main_room)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #join" do
|
||||
|
Reference in New Issue
Block a user