From 60d2ee1cec709a23a035deef4395fede3b7e0bea Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Sat, 19 Oct 2024 23:03:35 +0200 Subject: [PATCH] Use fixed time for start_at and end_at in suggest_spec.rb --- .app_version | 2 +- CHANGELOG.md | 6 ++++++ config/initializers/00_random.rb | 10 ++++------ spec/services/visits/suggest_spec.rb | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/.app_version b/.app_version index c6193945..3b1c7940 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.15.6 +0.15.7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 9027b0ff..0f86ceac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +# 0.15.7 - 2024-10-19 + +### Fixed + +- A bug where "RuntimeError: failed to get urandom" was being raised upon importing attempt on Synology. + # 0.15.6 - 2024-10-19 ### Fixed diff --git a/config/initializers/00_random.rb b/config/initializers/00_random.rb index b23a879e..fc8947d1 100644 --- a/config/initializers/00_random.rb +++ b/config/initializers/00_random.rb @@ -1,17 +1,15 @@ -# -*- coding: us-ascii -*- # frozen_string_literal: true +# This code fixes failed to get urandom for running Ruby on Docker for Synology. class Random - class << self - private - + # :stopdoc: # Implementation using OpenSSL def gen_random_openssl(n) - return OpenSSL::Random.random_bytes(n) + OpenSSL::Random.random_bytes(n) end begin @@ -21,7 +19,7 @@ def gen_random_openssl(n) begin require 'openssl' rescue NoMethodError - raise NotImplementedError, "No random device" + raise NotImplementedError, 'No random device' else alias urandom gen_random_openssl end diff --git a/spec/services/visits/suggest_spec.rb b/spec/services/visits/suggest_spec.rb index c4bf3d30..00c20c81 100644 --- a/spec/services/visits/suggest_spec.rb +++ b/spec/services/visits/suggest_spec.rb @@ -5,8 +5,8 @@ RSpec.describe Visits::Suggest do describe '#call' do let!(:user) { create(:user) } - let(:start_at) { 1.week.ago } - let(:end_at) { Time.current } + let(:start_at) { Time.new(2020, 1, 1, 0, 0, 0) } + let(:end_at) { Time.new(2020, 1, 1, 2, 0, 0) } let!(:points) do [