Skip to content
Snippets Groups Projects
Unverified Commit 16bf14f9 authored by Ahmad Farhat's avatar Ahmad Farhat Committed by GitHub
Browse files

Fix CI (#5432)

* Fix Greenlight CI

* Rubocop fixes
parent e7ba4e0c
No related branches found
No related tags found
No related merge requests found
Showing
with 84 additions and 81 deletions
...@@ -9,6 +9,8 @@ on: ...@@ -9,6 +9,8 @@ on:
- v2 - v2
- v3 - v3
- translations* - translations*
- snyk*
- dependabot*
jobs: jobs:
main: main:
......
...@@ -95,3 +95,6 @@ Rails/Output: ...@@ -95,3 +95,6 @@ Rails/Output:
Rails/RootPathnameMethods: Rails/RootPathnameMethods:
Enabled: false Enabled: false
Rails/ThreeStateBooleanColumn:
Enabled: false
...@@ -36,7 +36,7 @@ module Api ...@@ -36,7 +36,7 @@ module Api
pagy, paged_rooms = pagy(rooms) pagy, paged_rooms = pagy(rooms)
RunningMeetingChecker.new(rooms: paged_rooms.select(&:online)).call if paged_rooms.select(&:online).any? RunningMeetingChecker.new(rooms: paged_rooms.select(&:online)).call if paged_rooms.any?(&:online)
render_data data: paged_rooms, meta: pagy_metadata(pagy), serializer: ServerRoomSerializer, status: :ok render_data data: paged_rooms, meta: pagy_metadata(pagy), serializer: ServerRoomSerializer, status: :ok
end end
......
...@@ -45,7 +45,7 @@ module Api ...@@ -45,7 +45,7 @@ module Api
render_data data: config_value, status: :ok render_data data: config_value, status: :ok
rescue StandardError rescue StandardError
return render_error status: :not_found unless config_value render_error status: :not_found unless config_value
end end
end end
end end
......
...@@ -51,7 +51,7 @@ module Api ...@@ -51,7 +51,7 @@ module Api
room.shared = true if room.user_id != current_user.id room.shared = true if room.user_id != current_user.id
end end
RunningMeetingChecker.new(rooms: rooms.select(&:online)).call if rooms.select(&:online).any? RunningMeetingChecker.new(rooms: rooms.select(&:online)).call if rooms.any?(&:online)
render_data data: rooms, status: :ok render_data data: rooms, status: :ok
end end
......
...@@ -62,7 +62,7 @@ module Api ...@@ -62,7 +62,7 @@ module Api
return render_error status: :bad_request unless params[:user] return render_error status: :bad_request unless params[:user]
@user = User.find_by id: params[:user][:id] @user = User.find_by id: params[:user][:id]
return render_data status: :ok unless @user && !@user.verified? render_data status: :ok unless @user && !@user.verified?
end end
end end
end end
......
...@@ -21,17 +21,17 @@ module Authorizable ...@@ -21,17 +21,17 @@ module Authorizable
# Unless the request format is explicitly json Rails will mitigate the responsibility to CSR to handle it. # Unless the request format is explicitly json Rails will mitigate the responsibility to CSR to handle it.
def ensure_valid_request def ensure_valid_request
return render 'components/index' if !Rails.env.development? && !valid_api_request? render 'components/index' if !Rails.env.development? && !valid_api_request?
end end
# Ensures that the user is logged in # Ensures that the user is logged in
def ensure_authenticated def ensure_authenticated
return render_error status: :unauthorized unless current_user render_error status: :unauthorized unless current_user
end end
# PermissionsChecker service will return a true or false depending on whether the current_user's role has the provided permission_name # PermissionsChecker service will return a true or false depending on whether the current_user's role has the provided permission_name
def ensure_authorized(permission_names, user_id: nil, friendly_id: nil, record_id: nil) def ensure_authorized(permission_names, user_id: nil, friendly_id: nil, record_id: nil)
return render_error status: :forbidden unless PermissionsChecker.new( render_error status: :forbidden unless PermissionsChecker.new(
current_user:, current_user:,
permission_names:, permission_names:,
user_id:, user_id:,
...@@ -42,7 +42,7 @@ module Authorizable ...@@ -42,7 +42,7 @@ module Authorizable
end end
def ensure_super_admin def ensure_super_admin
return render_error status: :forbidden unless current_user.super_admin? render_error status: :forbidden unless current_user.super_admin?
end end
private private
......
...@@ -20,7 +20,7 @@ module Presentable ...@@ -20,7 +20,7 @@ module Presentable
extend ActiveSupport::Concern extend ActiveSupport::Concern
def presentation_file_name(room) def presentation_file_name(room)
return room.presentation.filename if room.presentation.attached? room.presentation.filename if room.presentation.attached?
end end
def presentation_thumbnail(room) def presentation_thumbnail(room)
......
...@@ -7,7 +7,7 @@ class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] ...@@ -7,7 +7,7 @@ class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0]
# Use Active Record's configured type for primary key # Use Active Record's configured type for primary key
create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| # rubocop:disable Rails/CreateTableWithTimestamps create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t|
t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type
t.string :variation_digest, null: false t.string :variation_digest, null: false
......
...@@ -46,7 +46,6 @@ namespace :poller do ...@@ -46,7 +46,6 @@ namespace :poller do
online_meetings = Room.includes(:user).where(online: true) online_meetings = Room.includes(:user).where(online: true)
RunningMeetingChecker.new(rooms: online_meetings).call RunningMeetingChecker.new(rooms: online_meetings).call
rescue StandardError => e rescue StandardError => e
err "Unable to poll meetings. Error: #{e}" err "Unable to poll meetings. Error: #{e}"
end end
...@@ -72,7 +71,6 @@ namespace :poller do ...@@ -72,7 +71,6 @@ namespace :poller do
end end
RecordingCreator.new(recording:).call RecordingCreator.new(recording:).call
rescue StandardError => e rescue StandardError => e
err "Unable to poll Recording:\nRecordID: #{recording[:recordID]}\nError: #{e}" err "Unable to poll Recording:\nRecordID: #{recording[:recordID]}\nError: #{e}"
next next
......
...@@ -39,7 +39,7 @@ RSpec.describe Api::V1::Admin::InvitationsController, type: :controller do ...@@ -39,7 +39,7 @@ RSpec.describe Api::V1::Admin::InvitationsController, type: :controller do
get :index get :index
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data'].pluck('email')).to match_array(invitations.pluck(:email)) expect(response.parsed_body['data'].pluck('email')).to match_array(invitations.pluck(:email))
end end
it 'returns the invitations according to the query' do it 'returns the invitations according to the query' do
...@@ -52,7 +52,7 @@ RSpec.describe Api::V1::Admin::InvitationsController, type: :controller do ...@@ -52,7 +52,7 @@ RSpec.describe Api::V1::Admin::InvitationsController, type: :controller do
get :index, params: { search: 'test.com' } get :index, params: { search: 'test.com' }
expect(JSON.parse(response.body)['data'].pluck('email')).to match_array(invitations.pluck(:email)) expect(response.parsed_body['data'].pluck('email')).to match_array(invitations.pluck(:email))
end end
context 'user without ManageUsers permission' do context 'user without ManageUsers permission' do
...@@ -74,7 +74,7 @@ RSpec.describe Api::V1::Admin::InvitationsController, type: :controller do ...@@ -74,7 +74,7 @@ RSpec.describe Api::V1::Admin::InvitationsController, type: :controller do
expect { post :create, params: { invitations: valid_params } }.to change(Invitation, :count).by(3) expect { post :create, params: { invitations: valid_params } }.to change(Invitation, :count).by(3)
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['errors']).to be_nil expect(response.parsed_body['errors']).to be_nil
end end
it 'emails the invitations to the invited user' do it 'emails the invitations to the invited user' do
......
...@@ -32,10 +32,10 @@ RSpec.describe Api::V1::Admin::RolePermissionsController, type: :controller do ...@@ -32,10 +32,10 @@ RSpec.describe Api::V1::Admin::RolePermissionsController, type: :controller do
get :index, params: { role_id: user_with_manage_roles_permission.role_id } get :index, params: { role_id: user_with_manage_roles_permission.role_id }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']['CreateRoom']).to eq('true') expect(response.parsed_body['data']['CreateRoom']).to eq('true')
expect(JSON.parse(response.body)['data']['RoomLimit']).to eq('100') expect(response.parsed_body['data']['RoomLimit']).to eq('100')
expect(JSON.parse(response.body)['data']['SharedList']).to eq('true') expect(response.parsed_body['data']['SharedList']).to eq('true')
expect(JSON.parse(response.body)['data']['ManageRoles']).to eq('true') expect(response.parsed_body['data']['ManageRoles']).to eq('true')
end end
context 'user without ManageRoles permission' do context 'user without ManageRoles permission' do
......
...@@ -35,7 +35,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do ...@@ -35,7 +35,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do
get :index get :index
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(roles.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(roles.pluck(:id))
end end
it 'returns the roles according to the query' do it 'returns the roles according to the query' do
...@@ -44,14 +44,14 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do ...@@ -44,14 +44,14 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do
create_list(:role, 3) create_list(:role, 3)
get :index, params: { search: 'role' } get :index, params: { search: 'role' }
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(search_roles.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(search_roles.pluck(:id))
end end
it 'returns all roles if the search bar is empty' do it 'returns all roles if the search bar is empty' do
create_list(:role, 5) create_list(:role, 5)
get :index, params: { search: '' } get :index, params: { search: '' }
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(Role.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(Role.pluck(:id))
end end
it 'excludes roles with a different provider' do it 'excludes roles with a different provider' do
...@@ -62,7 +62,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do ...@@ -62,7 +62,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do
get :index get :index
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(greenlight_roles.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(greenlight_roles.pluck(:id))
end end
context 'user with ManageUser permission' do context 'user with ManageUser permission' do
...@@ -79,7 +79,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do ...@@ -79,7 +79,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do
get :index get :index
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(roles.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(roles.pluck(:id))
end end
end end
...@@ -108,14 +108,14 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do ...@@ -108,14 +108,14 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
# Order is important match_array isn't adequate for this test. # Order is important match_array isn't adequate for this test.
expect(JSON.parse(response.body)['data'].pluck('name')).to eq(roles.sort.reverse) expect(response.parsed_body['data'].pluck('name')).to eq(roles.sort.reverse)
end end
it 'orders the roles list by column and direction ASC' do it 'orders the roles list by column and direction ASC' do
get :index, params: { sort: { column: 'name', direction: 'ASC' } } get :index, params: { sort: { column: 'name', direction: 'ASC' } }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
# Order is important match_array isn't adequate for this test. # Order is important match_array isn't adequate for this test.
expect(JSON.parse(response.body)['data'].pluck('name')).to eq(roles.sort) expect(response.parsed_body['data'].pluck('name')).to eq(roles.sort)
end end
end end
end end
...@@ -125,14 +125,14 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do ...@@ -125,14 +125,14 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do
valid_params = { name: 'CrazyRole' } valid_params = { name: 'CrazyRole' }
expect { post :create, params: { role: valid_params } }.to change(Role, :count).by(1) expect { post :create, params: { role: valid_params } }.to change(Role, :count).by(1)
expect(response).to have_http_status(:created) expect(response).to have_http_status(:created)
expect(JSON.parse(response.body)['errors']).to be_nil expect(response.parsed_body['errors']).to be_nil
end end
it 'returns :bad_request for invalid params' do it 'returns :bad_request for invalid params' do
invalid_params = { name: '' } invalid_params = { name: '' }
post :create, params: { not_role: invalid_params } post :create, params: { not_role: invalid_params }
expect(response).to have_http_status(:bad_request) expect(response).to have_http_status(:bad_request)
expect(JSON.parse(response.body)['errors']).not_to be_empty expect(response.parsed_body['errors']).not_to be_empty
end end
it 'calls create_role_permissions on role' do it 'calls create_role_permissions on role' do
...@@ -161,7 +161,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do ...@@ -161,7 +161,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do
post :update, params: { id: role.id, role: valid_params } post :update, params: { id: role.id, role: valid_params }
expect(role.reload.name).to eq(valid_params[:name]) expect(role.reload.name).to eq(valid_params[:name])
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['errors']).to be_nil expect(response.parsed_body['errors']).to be_nil
end end
it 'returns :not_found for unfound roles' do it 'returns :not_found for unfound roles' do
...@@ -174,7 +174,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do ...@@ -174,7 +174,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do
invalid_params = { name: '' } invalid_params = { name: '' }
post :update, params: { id: role.id, not_role: invalid_params } post :update, params: { id: role.id, not_role: invalid_params }
expect(response).to have_http_status(:bad_request) expect(response).to have_http_status(:bad_request)
expect(JSON.parse(response.body)['errors']).not_to be_empty expect(response.parsed_body['errors']).not_to be_empty
end end
context 'user without ManageRoles permission' do context 'user without ManageRoles permission' do
...@@ -196,7 +196,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do ...@@ -196,7 +196,7 @@ RSpec.describe Api::V1::Admin::RolesController, type: :controller do
role = create(:role) role = create(:role)
get :show, params: { id: role.id } get :show, params: { id: role.id }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']['id']).to eq(role.id) expect(response.parsed_body['data']['id']).to eq(role.id)
end end
it 'returns :not_found for unfound roles' do it 'returns :not_found for unfound roles' do
......
...@@ -35,7 +35,7 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do ...@@ -35,7 +35,7 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do
get :index get :index
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(recordings.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(recordings.pluck(:id))
end end
it 'returns the recordings according to the query' do it 'returns the recordings according to the query' do
...@@ -43,7 +43,7 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do ...@@ -43,7 +43,7 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do
get :index, params: { search: 'recording' } get :index, params: { search: 'recording' }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(search_recordings.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(search_recordings.pluck(:id))
end end
it 'returns all recordings if the search query is empty' do it 'returns all recordings if the search query is empty' do
...@@ -51,7 +51,7 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do ...@@ -51,7 +51,7 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do
get :index, params: { search: '' } get :index, params: { search: '' }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(recordings.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(recordings.pluck(:id))
end end
it 'excludes rooms whose owners have a different provider' do it 'excludes rooms whose owners have a different provider' do
...@@ -64,7 +64,7 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do ...@@ -64,7 +64,7 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do
get :index get :index
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(recs.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(recs.pluck(:id))
end end
context 'SuperAdmin accessing recordings for provider other than current provider' do context 'SuperAdmin accessing recordings for provider other than current provider' do
...@@ -79,7 +79,7 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do ...@@ -79,7 +79,7 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do
get :index get :index
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(recordings.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(recordings.pluck(:id))
end end
end end
...@@ -105,14 +105,14 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do ...@@ -105,14 +105,14 @@ RSpec.describe Api::V1::Admin::ServerRecordingsController, type: :controller do
get :index, params: { sort: { column: 'name', direction: 'DESC' } } get :index, params: { sort: { column: 'name', direction: 'DESC' } }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
# Order is important match_array isn't adequate for this test. # Order is important match_array isn't adequate for this test.
expect(JSON.parse(response.body)['data'].pluck('name')).to eq(%w[P O O]) expect(response.parsed_body['data'].pluck('name')).to eq(%w[P O O])
end end
it 'orders the recordings list by column and direction ASC' do it 'orders the recordings list by column and direction ASC' do
get :index, params: { sort: { column: 'name', direction: 'ASC' } } get :index, params: { sort: { column: 'name', direction: 'ASC' } }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
# Order is important match_array isn't adequate for this test. # Order is important match_array isn't adequate for this test.
expect(JSON.parse(response.body)['data'].pluck('name')).to eq(%w[O O P]) expect(response.parsed_body['data'].pluck('name')).to eq(%w[O O P])
end end
end end
end end
......
...@@ -37,7 +37,7 @@ RSpec.describe Api::V1::Admin::ServerRoomsController, type: :controller do ...@@ -37,7 +37,7 @@ RSpec.describe Api::V1::Admin::ServerRoomsController, type: :controller do
create_list(:room, 2, user_id: user_two.id) create_list(:room, 2, user_id: user_two.id)
get :index get :index
expect(JSON.parse(response.body)['data'].pluck('friendly_id')) expect(response.parsed_body['data'].pluck('friendly_id'))
.to match_array(Room.all.pluck(:friendly_id)) .to match_array(Room.all.pluck(:friendly_id))
end end
...@@ -56,7 +56,7 @@ RSpec.describe Api::V1::Admin::ServerRoomsController, type: :controller do ...@@ -56,7 +56,7 @@ RSpec.describe Api::V1::Admin::ServerRoomsController, type: :controller do
create_list(:room, 2, user_id: user_two.id) create_list(:room, 2, user_id: user_two.id)
get :index get :index
expect(JSON.parse(response.body)['data'].pluck('friendly_id')) expect(response.parsed_body['data'].pluck('friendly_id'))
.to match_array(Room.all.pluck(:friendly_id)) .to match_array(Room.all.pluck(:friendly_id))
end end
end end
...@@ -69,7 +69,7 @@ RSpec.describe Api::V1::Admin::ServerRoomsController, type: :controller do ...@@ -69,7 +69,7 @@ RSpec.describe Api::V1::Admin::ServerRoomsController, type: :controller do
create_list(:room, 2, user: user2) create_list(:room, 2, user: user2)
get :index get :index
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(rooms.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(rooms.pluck(:id))
end end
context 'user without ManageRooms permission' do context 'user without ManageRooms permission' do
......
...@@ -36,7 +36,7 @@ RSpec.describe Api::V1::Admin::SiteSettingsController, type: :controller do ...@@ -36,7 +36,7 @@ RSpec.describe Api::V1::Admin::SiteSettingsController, type: :controller do
get :index, params: { names: %w[settingA settingB] } get :index, params: { names: %w[settingA settingB] }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']).to eq({ expect(response.parsed_body['data']).to eq({
'settingA' => 'valueA', 'settingA' => 'valueA',
'settingB' => 'valueB' 'settingB' => 'valueB'
}) })
......
...@@ -32,7 +32,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do ...@@ -32,7 +32,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do
users = create_list(:user, 3, status: 'active') + [user, user_with_manage_users_permission] users = create_list(:user, 3, status: 'active') + [user, user_with_manage_users_permission]
get :verified get :verified
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
response_user_ids = JSON.parse(response.body)['data'].pluck('id') response_user_ids = response.parsed_body['data'].pluck('id')
expect(response_user_ids).to match_array(users.pluck(:id)) expect(response_user_ids).to match_array(users.pluck(:id))
end end
...@@ -43,7 +43,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do ...@@ -43,7 +43,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do
get :verified get :verified
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(greenlight_users.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(greenlight_users.pluck(:id))
end end
end end
...@@ -53,7 +53,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do ...@@ -53,7 +53,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do
get :pending get :pending
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(users.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(users.pluck(:id))
end end
context 'user without ManageUsers permission' do context 'user without ManageUsers permission' do
...@@ -74,7 +74,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do ...@@ -74,7 +74,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do
get :banned get :banned
expect(JSON.parse(response.body)['data'].pluck('id')).to match_array(users.pluck(:id)) expect(response.parsed_body['data'].pluck('id')).to match_array(users.pluck(:id))
end end
context 'user without ManageUsers permission' do context 'user without ManageUsers permission' do
...@@ -101,7 +101,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do ...@@ -101,7 +101,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do
users = create_list(:user, 3, status: 'active') + [user, user_with_manage_users_permission] users = create_list(:user, 3, status: 'active') + [user, user_with_manage_users_permission]
get :verified get :verified
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
response_user_ids = JSON.parse(response.body)['data'].pluck('id') response_user_ids = response.parsed_body['data'].pluck('id')
expect(response_user_ids).to match_array(users.pluck(:id)) expect(response_user_ids).to match_array(users.pluck(:id))
end end
...@@ -109,7 +109,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do ...@@ -109,7 +109,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do
users = create_list(:user, 3, status: 'pending') users = create_list(:user, 3, status: 'pending')
get :pending get :pending
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
response_user_ids = JSON.parse(response.body)['data'].pluck('id') response_user_ids = response.parsed_body['data'].pluck('id')
expect(response_user_ids).to match_array(users.pluck(:id)) expect(response_user_ids).to match_array(users.pluck(:id))
end end
...@@ -117,7 +117,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do ...@@ -117,7 +117,7 @@ RSpec.describe Api::V1::Admin::UsersController, type: :controller do
users = create_list(:user, 3, status: 'banned') users = create_list(:user, 3, status: 'banned')
get :banned get :banned
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
response_user_ids = JSON.parse(response.body)['data'].pluck('id') response_user_ids = response.parsed_body['data'].pluck('id')
expect(response_user_ids).to match_array(users.pluck(:id)) expect(response_user_ids).to match_array(users.pluck(:id))
end end
end end
......
...@@ -389,7 +389,7 @@ RSpec.describe ExternalController, type: :controller do ...@@ -389,7 +389,7 @@ RSpec.describe ExternalController, type: :controller do
expect(room.reload.online).to be(false) expect(room.reload.online).to be(false)
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)).to eq({}) expect(response.parsed_body).to eq({})
end end
it 'increments a rooms recordings processing value if the meeting was recorded' do it 'increments a rooms recordings processing value if the meeting was recorded' do
...@@ -409,7 +409,7 @@ RSpec.describe ExternalController, type: :controller do ...@@ -409,7 +409,7 @@ RSpec.describe ExternalController, type: :controller do
expect(room.online).to be(false) expect(room.online).to be(false)
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)).to eq({}) expect(response.parsed_body).to eq({})
end end
end end
...@@ -418,7 +418,7 @@ RSpec.describe ExternalController, type: :controller do ...@@ -418,7 +418,7 @@ RSpec.describe ExternalController, type: :controller do
get :meeting_ended, params: { meetingID: '404', recordingmarks: 'false' } get :meeting_ended, params: { meetingID: '404', recordingmarks: 'false' }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)).to eq({}) expect(response.parsed_body).to eq({})
end end
end end
end end
......
...@@ -48,7 +48,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do ...@@ -48,7 +48,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
post :start, params: { friendly_id: room.friendly_id } post :start, params: { friendly_id: room.friendly_id }
expect(response).to have_http_status(:created) expect(response).to have_http_status(:created)
expect(JSON.parse(response.body)['data']).to eq('JOIN_URL') expect(response.parsed_body['data']).to eq('JOIN_URL')
end end
it 'cannot make call to MeetingStarter service for another room' do it 'cannot make call to MeetingStarter service for another room' do
...@@ -81,7 +81,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do ...@@ -81,7 +81,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
post :start, params: { friendly_id: room.friendly_id } post :start, params: { friendly_id: room.friendly_id }
expect(response).to have_http_status(:created) expect(response).to have_http_status(:created)
expect(JSON.parse(response.body)['data']).to eq('JOIN_URL') expect(response.parsed_body['data']).to eq('JOIN_URL')
end end
it 'returns an error if the user is not logged in' do it 'returns an error if the user is not logged in' do
...@@ -104,7 +104,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do ...@@ -104,7 +104,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
post :start, params: { friendly_id: room.friendly_id } post :start, params: { friendly_id: room.friendly_id }
expect(response).to have_http_status(:created) expect(response).to have_http_status(:created)
expect(JSON.parse(response.body)['data']).to eq('JOIN_URL') expect(response.parsed_body['data']).to eq('JOIN_URL')
end end
end end
...@@ -134,7 +134,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do ...@@ -134,7 +134,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
post :start, params: { friendly_id: room.friendly_id } post :start, params: { friendly_id: room.friendly_id }
expect(response).to have_http_status(:created) expect(response).to have_http_status(:created)
expect(JSON.parse(response.body)['data']).to eq('JOIN_URL') expect(response.parsed_body['data']).to eq('JOIN_URL')
end end
end end
end end
...@@ -146,7 +146,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do ...@@ -146,7 +146,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
post :status, params: { friendly_id: test_room.friendly_id, name: user.name } post :status, params: { friendly_id: test_room.friendly_id, name: user.name }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']).to eq({ 'joinUrl' => 'JOIN_URL', 'status' => true }) expect(response.parsed_body['data']).to eq({ 'joinUrl' => 'JOIN_URL', 'status' => true })
end end
it 'returns status false if the meeting is NOT running and the user is NOT authorized to start the meeting' do it 'returns status false if the meeting is NOT running and the user is NOT authorized to start the meeting' do
...@@ -156,7 +156,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do ...@@ -156,7 +156,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
post :status, params: { friendly_id: test_room.friendly_id, name: user.name } post :status, params: { friendly_id: test_room.friendly_id, name: user.name }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']).to eq({ 'status' => false }) expect(response.parsed_body['data']).to eq({ 'status' => false })
end end
it 'joins as viewer if no access code is required nor provided' do it 'joins as viewer if no access code is required nor provided' do
...@@ -192,7 +192,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do ...@@ -192,7 +192,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
post :status, params: { friendly_id: room.friendly_id, name: user.name } post :status, params: { friendly_id: room.friendly_id, name: user.name }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']).to eq({ 'joinUrl' => 'JOIN_URL', 'status' => true }) expect(response.parsed_body['data']).to eq({ 'joinUrl' => 'JOIN_URL', 'status' => true })
end end
context 'user is joining a shared room' do context 'user is joining a shared room' do
...@@ -360,7 +360,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do ...@@ -360,7 +360,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
post :status, params: { friendly_id: room.friendly_id, name: user.name } post :status, params: { friendly_id: room.friendly_id, name: user.name }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']).to eq({ 'joinUrl' => 'JOIN_URL', 'status' => true }) expect(response.parsed_body['data']).to eq({ 'joinUrl' => 'JOIN_URL', 'status' => true })
end end
it 'doesnt start the meeting if its already running' do it 'doesnt start the meeting if its already running' do
...@@ -373,7 +373,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do ...@@ -373,7 +373,7 @@ RSpec.describe Api::V1::MeetingsController, type: :controller do
post :status, params: { friendly_id: room.friendly_id, name: user.name } post :status, params: { friendly_id: room.friendly_id, name: user.name }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']).to eq({ 'joinUrl' => 'JOIN_URL', 'status' => true }) expect(response.parsed_body['data']).to eq({ 'joinUrl' => 'JOIN_URL', 'status' => true })
end end
end end
......
...@@ -34,7 +34,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -34,7 +34,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
get :index get :index
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
response_recording_ids = JSON.parse(response.body)['data'].pluck('id') response_recording_ids = response.parsed_body['data'].pluck('id')
expect(response_recording_ids).to match_array(recordings.pluck(:id)) expect(response_recording_ids).to match_array(recordings.pluck(:id))
end end
...@@ -43,7 +43,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -43,7 +43,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
get :index get :index
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']).to be_empty expect(response.parsed_body['data']).to be_empty
end end
it 'returns the recordings according to the query' do it 'returns the recordings according to the query' do
...@@ -56,7 +56,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -56,7 +56,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
create_list(:recording, 10) create_list(:recording, 10)
get :index, params: { search: 'greenlight' } get :index, params: { search: 'greenlight' }
response_recording_ids = JSON.parse(response.body)['data'].pluck('id') response_recording_ids = response.parsed_body['data'].pluck('id')
expect(response_recording_ids).to match_array(recordings.pluck(:id)) expect(response_recording_ids).to match_array(recordings.pluck(:id))
end end
...@@ -70,7 +70,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -70,7 +70,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
create_list(:recording, 10) create_list(:recording, 10)
get :index, params: { search: 'presentation' } get :index, params: { search: 'presentation' }
response_recording_ids = JSON.parse(response.body)['data'].pluck('id') response_recording_ids = response.parsed_body['data'].pluck('id')
expect(response_recording_ids).to match_array(recordings.pluck(:id)) expect(response_recording_ids).to match_array(recordings.pluck(:id))
end end
...@@ -84,7 +84,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -84,7 +84,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
create_list(:recording, 10) create_list(:recording, 10)
get :index, params: { search: 'unpublished' } get :index, params: { search: 'unpublished' }
response_recording_ids = JSON.parse(response.body)['data'].pluck('id') response_recording_ids = response.parsed_body['data'].pluck('id')
expect(response_recording_ids).to match_array(recordings.pluck(:id)) expect(response_recording_ids).to match_array(recordings.pluck(:id))
end end
...@@ -93,7 +93,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -93,7 +93,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
create(:room, user:, recordings:) create(:room, user:, recordings:)
get :index, params: { search: '' } get :index, params: { search: '' }
response_recording_ids = JSON.parse(response.body)['data'].pluck('id') response_recording_ids = response.parsed_body['data'].pluck('id')
expect(response_recording_ids).to match_array(recordings.pluck(:id)) expect(response_recording_ids).to match_array(recordings.pluck(:id))
end end
...@@ -108,14 +108,14 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -108,14 +108,14 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
get :index, params: { sort: { column: 'name', direction: 'DESC' } } get :index, params: { sort: { column: 'name', direction: 'DESC' } }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
# Order is important match_array isn't adequate for this test. # Order is important match_array isn't adequate for this test.
expect(JSON.parse(response.body)['data'].pluck('name')).to eq(%w[C B A]) expect(response.parsed_body['data'].pluck('name')).to eq(%w[C B A])
end end
it 'orders the recordings list by column and direction ASC' do it 'orders the recordings list by column and direction ASC' do
get :index, params: { sort: { column: 'name', direction: 'ASC' } } get :index, params: { sort: { column: 'name', direction: 'ASC' } }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
# Order is important match_array isn't adequate for this test. # Order is important match_array isn't adequate for this test.
expect(JSON.parse(response.body)['data'].pluck('name')).to eq(%w[A B C]) expect(response.parsed_body['data'].pluck('name')).to eq(%w[A B C])
end end
end end
end end
...@@ -287,7 +287,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -287,7 +287,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
create_list(:room, 5, user:, recordings:) create_list(:room, 5, user:, recordings:)
get :recordings_count get :recordings_count
expect(JSON.parse(response.body)['data']).to be(5) expect(response.parsed_body['data']).to be(5)
end end
end end
...@@ -314,7 +314,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -314,7 +314,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
post :recording_url, params: { id: recording.record_id } post :recording_url, params: { id: recording.record_id }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)).to match_array ['https://test.com/screenshare', 'https://test.com/video'] expect(response.parsed_body).to match_array ['https://test.com/screenshare', 'https://test.com/video']
end end
context 'Single playback format' do context 'Single playback format' do
...@@ -328,7 +328,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -328,7 +328,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
post :recording_url, params: { id: recording.record_id } post :recording_url, params: { id: recording.record_id }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)).to eq ['https://test.com/screenshare'] expect(response.parsed_body).to eq ['https://test.com/screenshare']
end end
end end
end end
...@@ -349,7 +349,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -349,7 +349,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
post :recording_url, params: { id: recording.record_id } post :recording_url, params: { id: recording.record_id }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)).to match_array recording.formats.pluck(:url) expect(response.parsed_body).to match_array recording.formats.pluck(:url)
end end
end end
end end
...@@ -370,7 +370,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -370,7 +370,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
post :recording_url, params: { id: recording.record_id, recording_format: 'screenshare' } post :recording_url, params: { id: recording.record_id, recording_format: 'screenshare' }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']).to eq 'https://test.com/screenshare' expect(response.parsed_body['data']).to eq 'https://test.com/screenshare'
end end
context 'Single playback format' do context 'Single playback format' do
...@@ -384,7 +384,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -384,7 +384,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
post :recording_url, params: { id: recording.record_id, recording_format: 'screenshare' } post :recording_url, params: { id: recording.record_id, recording_format: 'screenshare' }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']).to eq 'https://test.com/screenshare/solo' expect(response.parsed_body['data']).to eq 'https://test.com/screenshare/solo'
end end
end end
...@@ -393,7 +393,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -393,7 +393,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
post :recording_url, params: { id: recording.record_id, recording_format: '404' } post :recording_url, params: { id: recording.record_id, recording_format: '404' }
expect(response).to have_http_status(:not_found) expect(response).to have_http_status(:not_found)
expect(JSON.parse(response.body)['data']).to be_blank expect(response.parsed_body['data']).to be_blank
end end
end end
end end
...@@ -416,7 +416,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -416,7 +416,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
post :recording_url, params: { id: recording.record_id, recording_format: target_format.recording_type } post :recording_url, params: { id: recording.record_id, recording_format: target_format.recording_type }
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(JSON.parse(response.body)['data']).to eq target_format.url expect(response.parsed_body['data']).to eq target_format.url
end end
context 'Inexistent format' do context 'Inexistent format' do
...@@ -424,7 +424,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do ...@@ -424,7 +424,7 @@ RSpec.describe Api::V1::RecordingsController, type: :controller do
post :recording_url, params: { id: recording.record_id, recording_format: '404' } post :recording_url, params: { id: recording.record_id, recording_format: '404' }
expect(response).to have_http_status(:not_found) expect(response).to have_http_status(:not_found)
expect(JSON.parse(response.body)['data']).to be_blank expect(response.parsed_body['data']).to be_blank
end end
end end
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment