forked from External/greenlight
GRN2-196: Fixed issues that scrutinizer is complaining about (#765)
* Refactored code to improve scrutinizer score * Bug fixes
This commit is contained in:
@ -50,7 +50,7 @@ describe PasswordResetsController, type: :controller do
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
|
||||
it "reloads the page if no email exists in the database" do
|
||||
it "redirects to root with success flash if email does not exists" do
|
||||
params = {
|
||||
password_reset: {
|
||||
email: nil,
|
||||
@ -58,7 +58,8 @@ describe PasswordResetsController, type: :controller do
|
||||
}
|
||||
|
||||
post :create, params: params
|
||||
expect(response).to redirect_to(new_password_reset_path)
|
||||
expect(flash[:success]).to be_present
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -44,6 +44,19 @@ describe RecordingsController, type: :controller do
|
||||
end
|
||||
end
|
||||
|
||||
context "PATCH #rename" do
|
||||
it "properly updates recording name and redirects to current page" do
|
||||
allow_any_instance_of(BbbServer).to receive(:update_recording).and_return(updated: true)
|
||||
|
||||
@request.session[:user_id] = @user.id
|
||||
name = Faker::Games::Pokemon.name
|
||||
|
||||
patch :rename, params: { meetingID: @room.bbb_id, record_id: Faker::IDNumber.valid, record_name: name }
|
||||
|
||||
expect(response).to redirect_to(@room)
|
||||
end
|
||||
end
|
||||
|
||||
context "DELETE #delete_recording" do
|
||||
it "deletes the recording" do
|
||||
allow_any_instance_of(BbbServer).to receive(:delete_recording).and_return(true)
|
||||
|
@ -366,7 +366,7 @@ describe RoomsController, type: :controller do
|
||||
@request.session[:user_id] = @user.id
|
||||
post :start, params: { room_uid: @other_room }
|
||||
|
||||
expect(response).to redirect_to(@user.main_room)
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
|
||||
it "should bring to root if not authenticated" do
|
||||
@ -405,37 +405,11 @@ describe RoomsController, type: :controller do
|
||||
.from(@secondary_room.room_settings).to(formatted_room_params)
|
||||
expect(response).to redirect_to(@secondary_room)
|
||||
end
|
||||
end
|
||||
|
||||
describe "PATCH #update" do
|
||||
before do
|
||||
@user = create(:user)
|
||||
@secondary_room = create(:room, owner: @user)
|
||||
@editable_room = create(:room, owner: @user)
|
||||
end
|
||||
|
||||
it "properly updates room name through room block and redirects to current page" do
|
||||
@request.session[:user_id] = @user.id
|
||||
|
||||
patch :update, params: { room_uid: @secondary_room, room_block_uid: @editable_room,
|
||||
setting: :rename_block, room_name: :name }
|
||||
|
||||
expect(response).to redirect_to(@secondary_room)
|
||||
end
|
||||
|
||||
it "properly updates room name through room header and redirects to current page" do
|
||||
@request.session[:user_id] = @user.id
|
||||
|
||||
patch :update, params: { room_uid: @secondary_room, setting: :rename_header, room_name: :name }
|
||||
|
||||
expect(response).to redirect_to(@secondary_room)
|
||||
end
|
||||
|
||||
it "properly updates recording name and redirects to current page" do
|
||||
@request.session[:user_id] = @user.id
|
||||
|
||||
patch :update, params: { room_uid: @secondary_room, recordid: :recordid,
|
||||
setting: :rename_recording, record_name: :name }
|
||||
patch :update_settings, params: { room_uid: @secondary_room, setting: :rename_header, room_name: :name }
|
||||
|
||||
expect(response).to redirect_to(@secondary_room)
|
||||
end
|
||||
|
@ -19,6 +19,50 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe SessionsController, type: :controller do
|
||||
describe "GET #new" do
|
||||
it "assigns a blank user to the view" do
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
|
||||
get :new
|
||||
expect(assigns(:user)).to be_a_new(User)
|
||||
end
|
||||
|
||||
it "redirects to root if allow_user_signup is false" do
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(false)
|
||||
|
||||
get :new
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
|
||||
it "rejects the user if they are not invited" do
|
||||
allow_any_instance_of(Registrar).to receive(:invite_registration).and_return(true)
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
|
||||
get :new
|
||||
|
||||
expect(flash[:alert]).to be_present
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #signin" do
|
||||
it "redirects to main room if already authenticated" do
|
||||
user = create(:user)
|
||||
@request.session[:user_id] = user.id
|
||||
|
||||
post :signin
|
||||
expect(response).to redirect_to(room_path(user.main_room))
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #ldap_signin' do
|
||||
it "should render the ldap signin page" do
|
||||
get :ldap_signin
|
||||
|
||||
expect(response).to render_template(:ldap_signin)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #destroy" do
|
||||
before(:each) do
|
||||
user = create(:user, provider: "greenlight")
|
||||
|
@ -46,32 +46,6 @@ describe UsersController, type: :controller do
|
||||
}
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a blank user to the view" do
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(true)
|
||||
|
||||
get :new
|
||||
expect(assigns(:user)).to be_a_new(User)
|
||||
end
|
||||
|
||||
it "redirects to root if allow_user_signup is false" do
|
||||
allow(Rails.configuration).to receive(:allow_user_signup).and_return(false)
|
||||
|
||||
get :new
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #signin" do
|
||||
it "redirects to main room if already authenticated" do
|
||||
user = create(:user)
|
||||
@request.session[:user_id] = user.id
|
||||
|
||||
post :signin
|
||||
expect(response).to redirect_to(room_path(user.main_room))
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "renders the edit template" do
|
||||
user = create(:user)
|
||||
@ -211,13 +185,6 @@ describe UsersController, type: :controller do
|
||||
expect { post :create, params: params }.to change { ActionMailer::Base.deliveries.count }.by(1)
|
||||
end
|
||||
|
||||
it "rejects the user if they are not invited" do
|
||||
get :new
|
||||
|
||||
expect(flash[:alert]).to be_present
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
|
||||
it "allows the user to signup if they are invited" do
|
||||
allow(Rails.configuration).to receive(:enable_email_verification).and_return(false)
|
||||
|
||||
@ -493,12 +460,4 @@ describe UsersController, type: :controller do
|
||||
expect(response).to redirect_to(root_path)
|
||||
end
|
||||
end
|
||||
|
||||
context 'GET #ldap_signin' do
|
||||
it "should render the ldap signin page" do
|
||||
get :ldap_signin
|
||||
|
||||
expect(response).to render_template(:ldap_signin)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user