Use fixed time for start_at and end_at in suggest_spec.rb

This commit is contained in:
Eugene Burmakin 2024-10-19 23:03:35 +02:00
parent 5accd16deb
commit 60d2ee1cec
4 changed files with 13 additions and 9 deletions

View file

@ -1 +1 @@
0.15.6 0.15.7

View file

@ -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/) The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). 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 # 0.15.6 - 2024-10-19
### Fixed ### Fixed

View file

@ -1,17 +1,15 @@
# -*- coding: us-ascii -*-
# frozen_string_literal: true # frozen_string_literal: true
# This code fixes failed to get urandom for running Ruby on Docker for Synology.
class Random class Random
class << self class << self
private private
# :stopdoc: # :stopdoc:
# Implementation using OpenSSL # Implementation using OpenSSL
def gen_random_openssl(n) def gen_random_openssl(n)
return OpenSSL::Random.random_bytes(n) OpenSSL::Random.random_bytes(n)
end end
begin begin
@ -21,7 +19,7 @@ class Random
begin begin
require 'openssl' require 'openssl'
rescue NoMethodError rescue NoMethodError
raise NotImplementedError, "No random device" raise NotImplementedError, 'No random device'
else else
alias urandom gen_random_openssl alias urandom gen_random_openssl
end end

View file

@ -5,8 +5,8 @@ require 'rails_helper'
RSpec.describe Visits::Suggest do RSpec.describe Visits::Suggest do
describe '#call' do describe '#call' do
let!(:user) { create(:user) } let!(:user) { create(:user) }
let(:start_at) { 1.week.ago } let(:start_at) { Time.new(2020, 1, 1, 0, 0, 0) }
let(:end_at) { Time.current } let(:end_at) { Time.new(2020, 1, 1, 2, 0, 0) }
let!(:points) do let!(:points) do
[ [