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

Resync fixes (#4066)

* Resync fixes

* rspec
parent 7c194d7e
Branches
Tags
No related merge requests found
...@@ -19,6 +19,7 @@ class Room < ApplicationRecord ...@@ -19,6 +19,7 @@ class Room < ApplicationRecord
size: { less_than: 30.megabytes } size: { less_than: 30.megabytes }
validates :name, length: { minimum: 2, maximum: 255 } validates :name, length: { minimum: 2, maximum: 255 }
validates :recordings_processing, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
before_validation :set_friendly_id, :set_meeting_id, on: :create before_validation :set_friendly_id, :set_meeting_id, on: :create
after_create :create_meeting_options after_create :create_meeting_options
......
...@@ -12,5 +12,6 @@ class RecordingsSync ...@@ -12,5 +12,6 @@ class RecordingsSync
recordings[:recordings].each do |recording| recordings[:recordings].each do |recording|
RecordingCreator.new(recording:).call RecordingCreator.new(recording:).call
end end
@room.update(recordings_processing: 0)
end end
end end
...@@ -12,6 +12,7 @@ RSpec.describe Room, type: :model do ...@@ -12,6 +12,7 @@ RSpec.describe Room, type: :model do
it { is_expected.to have_many(:recordings).dependent(:destroy) } it { is_expected.to have_many(:recordings).dependent(:destroy) }
it { is_expected.to validate_presence_of(:name) } it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_length_of(:name).is_at_least(2).is_at_most(255) } it { is_expected.to validate_length_of(:name).is_at_least(2).is_at_most(255) }
it { is_expected.to validate_numericality_of(:recordings_processing).only_integer.is_greater_than_or_equal_to(0) }
# Can't test validation on friendly_id and meeting_id due to before_validations # Can't test validation on friendly_id and meeting_id due to before_validations
......
...@@ -4,7 +4,7 @@ require 'rails_helper' ...@@ -4,7 +4,7 @@ require 'rails_helper'
describe RecordingsSync, type: :service do describe RecordingsSync, type: :service do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:room) { create(:room, user:) } let(:room) { create(:room, user:, recordings_processing: 5) }
let(:service) { described_class.new(room:) } let(:service) { described_class.new(room:) }
describe '#call' do describe '#call' do
...@@ -47,6 +47,10 @@ describe RecordingsSync, type: :service do ...@@ -47,6 +47,10 @@ describe RecordingsSync, type: :service do
service.call service.call
expect(Recording.where(id: other_recordings.pluck(:id))).to eq(other_recordings) expect(Recording.where(id: other_recordings.pluck(:id))).to eq(other_recordings)
end end
it 'resets the recordings processing value for the room' do
expect { service.call }.to change(room, :recordings_processing).from(5).to(0)
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