describe'#perform'dosubject{described_class.new.perform}beforedoallow(ActiveRecord::Base.connection).toreceive(:transaction_open?).and_return(false)endcontext'when successful'doit'create an users statistics entry'doexpect{subject}.tochange{UsersStatistics.count}.from(0).to(1)endendcontext'when unsuccessful'doit'logs an error'dousers_statistics=build(:users_statistics)users_statistics.errors.add(:base,'This is an error')exception=ActiveRecord::RecordInvalid.new(users_statistics)allow(UsersStatistics).toreceive(:create_current_stats!).and_raise(exception)expect(Gitlab::ErrorTracking).toreceive(:track_exception).with(exception).and_call_originalsubjectendendendend