mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 06:26:15 +02:00
Merge pull request #2709 from internetee/fix-failed-tests
fixed tests: updated gems; improve company register status job and te…
This commit is contained in:
commit
b655d93e61
6 changed files with 119 additions and 37 deletions
88
Dockerfile
88
Dockerfile
|
@ -1,13 +1,67 @@
|
|||
FROM internetee/ruby:3.0-buster
|
||||
FROM --platform=linux/amd64 ruby:3.0.3-slim-buster
|
||||
|
||||
# # RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4EB27DB2A3B88B8B
|
||||
# RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
# git \
|
||||
# postgresql-client \
|
||||
# && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends > /dev/null \
|
||||
build-essential=* \
|
||||
imagemagick=* \
|
||||
curl \
|
||||
wget \
|
||||
gnupg2 \
|
||||
git \
|
||||
apt-utils \
|
||||
&& apt-get dist-upgrade -yf\
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y locales
|
||||
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
|
||||
RUN sed -i -e 's/# et_EE.UTF-8 UTF-8/et_EE.UTF-8 UTF-8/' /etc/locale.gen && \
|
||||
dpkg-reconfigure --frontend=noninteractive locales && \
|
||||
update-locale LANG=et_EE.UTF-8
|
||||
|
||||
ENV LANG et_EE.UTF-8
|
||||
RUN curl https://www.postgresql.org/media/keys/ACCC4CF8.asc -s | apt-key add -
|
||||
RUN sh -c 'echo "deb https://apt-archive.postgresql.org/pub/repos/apt bionic-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
RUN apt-get update > /dev/null && apt-get install -y --no-install-recommends > /dev/null \
|
||||
postgresql-client-13=* \
|
||||
libpq-dev \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# add repository for Node.js in the LTS version
|
||||
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash -
|
||||
|
||||
RUN apt-get install -y --no-install-recommends > /dev/null \
|
||||
nodejs=* \
|
||||
qt5-default=* \
|
||||
libqt5webkit5-dev=* \
|
||||
gstreamer1.0-plugins-base=* \
|
||||
libappindicator3-1=* \
|
||||
gstreamer1.0-tools=* \
|
||||
qtdeclarative5-dev=* \
|
||||
fonts-liberation=* \
|
||||
gstreamer1.0-x=* \
|
||||
libasound2=* \
|
||||
libnspr4=* \
|
||||
libnss3=* \
|
||||
libxss1=* \
|
||||
libxtst6=* \
|
||||
xdg-utils=* \
|
||||
qtdeclarative5-dev=* \
|
||||
fonts-liberation=* \
|
||||
gstreamer1.0-x=* \
|
||||
wkhtmltopdf \
|
||||
libxslt1-dev \
|
||||
libxml2-dev \
|
||||
python-dev \
|
||||
unzip \
|
||||
# libc6-i386 \
|
||||
# lib32gcc-s1 \
|
||||
wkhtmltopdf \
|
||||
xvfb \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN apt-get remove -y google-chrome-stable
|
||||
RUN apt-get purge -y google-chrome-stable
|
||||
RUN apt-get autoremove -y && apt-get clean
|
||||
|
||||
ENV CHROME_VERSION="128.0.6613.137"
|
||||
|
@ -21,6 +75,8 @@ RUN wget -q "https://storage.googleapis.com/chrome-for-testing-public/${CHROME_V
|
|||
&& mv /opt/chromedriver-linux64/chromedriver /usr/local/bin/ \
|
||||
&& rm -rf chromedriver-linux64.zip /opt/chromedriver-linux64
|
||||
|
||||
RUN npm install --global yarn
|
||||
|
||||
RUN mkdir -p /opt/webapps/app/tmp/pids
|
||||
WORKDIR /opt/webapps/app
|
||||
COPY Gemfile Gemfile.lock ./
|
||||
|
@ -29,4 +85,18 @@ RUN gem install bundler && bundle install --jobs 20 --retry 5
|
|||
|
||||
ENV PATH="/opt/chrome-linux64:${PATH}"
|
||||
|
||||
EXPOSE 3000
|
||||
# RUN apt-get update && apt-get install -y --no-install-recommends > /dev/null \
|
||||
# libc6-i386 \
|
||||
# lib32gcc-s1 \
|
||||
# wkhtmltopdf \
|
||||
# xvfb \
|
||||
# && apt-get clean \
|
||||
# && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
RUN ln -s /lib/ld-linux.so.2 /lib/ld-linux.so.2 || true
|
||||
|
||||
# Обертка для wkhtmltopdf с xvfb
|
||||
RUN echo '#!/bin/bash\nxvfb-run -a --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf "$@"' > /usr/local/bin/wkhtmltopdf \
|
||||
&& chmod +x /usr/local/bin/wkhtmltopdf
|
||||
|
||||
EXPOSE 3000
|
4
Gemfile
4
Gemfile
|
@ -86,11 +86,11 @@ group :development, :test do
|
|||
end
|
||||
|
||||
group :test do
|
||||
gem 'capybara'
|
||||
gem 'capybara', '~> 3.40.0'
|
||||
gem 'database_cleaner'
|
||||
gem 'minitest', '~> 5.17'
|
||||
gem 'minitest-stub_any_instance'
|
||||
gem 'selenium-webdriver'
|
||||
gem 'selenium-webdriver', '~> 4.26'
|
||||
# gem 'webdrivers'
|
||||
gem 'simplecov', '0.17.1', require: false # CC last supported v0.17
|
||||
gem 'spy'
|
||||
|
|
27
Gemfile.lock
27
Gemfile.lock
|
@ -179,15 +179,15 @@ GEM
|
|||
sassc (>= 2.0.0)
|
||||
builder (3.3.0)
|
||||
cancancan (3.3.0)
|
||||
capybara (3.35.3)
|
||||
capybara (3.40.0)
|
||||
addressable
|
||||
matrix
|
||||
mini_mime (>= 0.1.3)
|
||||
nokogiri (~> 1.8)
|
||||
nokogiri (~> 1.11)
|
||||
rack (>= 1.6.0)
|
||||
rack-test (>= 0.6.3)
|
||||
regexp_parser (>= 1.5, < 3.0)
|
||||
xpath (~> 3.2)
|
||||
childprocess (3.0.0)
|
||||
chronic (0.10.2)
|
||||
coderay (1.1.3)
|
||||
coffee-rails (5.0.0)
|
||||
|
@ -308,6 +308,7 @@ GEM
|
|||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (1.0.2)
|
||||
matrix (0.4.2)
|
||||
method_source (1.0.0)
|
||||
mime-types (3.3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
|
@ -329,10 +330,10 @@ GEM
|
|||
money (~> 6.13.2)
|
||||
railties (>= 3.0)
|
||||
msgpack (1.7.2)
|
||||
mutex_m (0.2.0)
|
||||
net-ftp (0.3.7)
|
||||
net-protocol
|
||||
time
|
||||
mutex_m (0.2.0)
|
||||
net-protocol (0.1.3)
|
||||
timeout
|
||||
net-smtp (0.3.3)
|
||||
|
@ -434,7 +435,7 @@ GEM
|
|||
redis-client (>= 0.9.0)
|
||||
redis-client (0.14.1)
|
||||
connection_pool
|
||||
regexp_parser (2.1.1)
|
||||
regexp_parser (2.9.2)
|
||||
request_store (1.5.1)
|
||||
rack (>= 1.4)
|
||||
responders (3.0.1)
|
||||
|
@ -469,9 +470,12 @@ GEM
|
|||
wasabi (>= 3.7, < 6)
|
||||
select2-rails (4.0.13)
|
||||
selectize-rails (0.12.6)
|
||||
selenium-webdriver (3.142.7)
|
||||
childprocess (>= 0.5, < 4.0)
|
||||
rubyzip (>= 1.2.2)
|
||||
selenium-webdriver (4.26.0)
|
||||
base64 (~> 0.2)
|
||||
logger (~> 1.4)
|
||||
rexml (~> 3.2, >= 3.2.5)
|
||||
rubyzip (>= 1.2.2, < 3.0)
|
||||
websocket (~> 1.0)
|
||||
sidekiq (7.1.4)
|
||||
concurrent-ruby (< 2)
|
||||
connection_pool (>= 2.3.0)
|
||||
|
@ -535,6 +539,7 @@ GEM
|
|||
addressable (>= 2.8.0)
|
||||
crack (>= 0.3.2)
|
||||
hashdiff (>= 0.4.0, < 2.0.0)
|
||||
websocket (1.2.11)
|
||||
websocket-driver (0.7.6)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
|
@ -557,7 +562,7 @@ DEPENDENCIES
|
|||
bootsnap (>= 1.1.0)
|
||||
bootstrap-sass (~> 3.4)
|
||||
cancancan
|
||||
capybara
|
||||
capybara (~> 3.40.0)
|
||||
coffee-rails (>= 5.0)
|
||||
company_register!
|
||||
countries
|
||||
|
@ -606,7 +611,7 @@ DEPENDENCIES
|
|||
sass-rails
|
||||
select2-rails (= 4.0.13)
|
||||
selectize-rails (= 0.12.6)
|
||||
selenium-webdriver
|
||||
selenium-webdriver (~> 4.26)
|
||||
sidekiq (~> 7.0)
|
||||
simplecov (= 0.17.1)
|
||||
simpleidn (= 0.2.3)
|
||||
|
@ -620,4 +625,4 @@ DEPENDENCIES
|
|||
wkhtmltopdf-binary (~> 0.12.6.1)
|
||||
|
||||
BUNDLED WITH
|
||||
2.5.19
|
||||
2.5.23
|
||||
|
|
|
@ -7,7 +7,11 @@ class CompanyRegisterStatusJob < ApplicationJob
|
|||
|
||||
def perform(days_interval = 14, spam_time_delay = 1, batch_size = 100)
|
||||
sampling_registrant_contact(days_interval).find_in_batches(batch_size: batch_size) do |contacts|
|
||||
contacts.reject { |contact| whitelisted_company?(contact) }.each { |contact| proceed_company_status(contact, spam_time_delay) }
|
||||
contacts_to_check = contacts.reject { |contact| whitelisted_company?(contact) }
|
||||
|
||||
contacts_to_check.each do |contact|
|
||||
proceed_company_status(contact, spam_time_delay)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -17,13 +21,9 @@ class CompanyRegisterStatusJob < ApplicationJob
|
|||
# avoid spamming company register
|
||||
sleep spam_time_delay
|
||||
|
||||
puts "WHAT YOU GONNA DO WHEN I COME FOR YOU?"
|
||||
|
||||
company_status = contact.return_company_status
|
||||
contact.update!(company_register_status: company_status, checked_company_at: Time.zone.now)
|
||||
|
||||
puts "company id #{contact.id} status: #{company_status}"
|
||||
|
||||
case company_status
|
||||
when Contact::REGISTERED
|
||||
lift_force_delete(contact) if check_for_force_delete(contact)
|
||||
|
@ -44,7 +44,6 @@ class CompanyRegisterStatusJob < ApplicationJob
|
|||
company_register_status IN (?)",
|
||||
Contact::REGISTERED, days_interval.days.ago, [Contact::LIQUIDATED, Contact::BANKRUPT, Contact::DELETED]
|
||||
)
|
||||
|
||||
end
|
||||
|
||||
def update_validation_company_status(contact:, status:)
|
||||
|
@ -66,7 +65,8 @@ class CompanyRegisterStatusJob < ApplicationJob
|
|||
|
||||
def check_for_force_delete(contact)
|
||||
contact.registrant_domains.any? do |domain|
|
||||
domain.status_notes[DomainStatus::FORCE_DELETE].include?("Company no: #{contact.ident}")
|
||||
notes = domain.status_notes[DomainStatus::FORCE_DELETE]
|
||||
notes && notes.include?("Company no: #{contact.ident}")
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -107,9 +107,14 @@ class CompanyRegisterStatusJob < ApplicationJob
|
|||
end
|
||||
|
||||
def whitelisted_companies
|
||||
@whitelisted_companies ||= ENV['whitelist_companies'].split(',')
|
||||
@whitelisted_companies ||= begin
|
||||
raw_list = ENV['whitelist_companies'] || '[]'
|
||||
JSON.parse(raw_list)
|
||||
rescue JSON::ParserError
|
||||
[]
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def whitelisted_company?(contact)
|
||||
whitelisted_companies.include?(contact.ident)
|
||||
end
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
require 'test_helper'
|
||||
require 'minitest/mock'
|
||||
|
||||
class FormHelperTest < ActionView::TestCase
|
||||
def test_legal_document_field
|
||||
meth = MiniTest::Mock.new
|
||||
meth = Minitest::Mock.new
|
||||
returned_legal_document_field = ApplicationController.helpers.legal_document_field('Hello', meth)
|
||||
|
||||
assert returned_legal_document_field.include? 'data-legal-document="true"'
|
||||
assert returned_legal_document_field.include? 'accept=".pdf,.asice,.asics,.sce,.scs,.adoc,.edoc,.bdoc,.zip,.rar,.gz,.tar,.7z,.odt,.doc,.docx"'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -22,9 +22,9 @@ class CompanyRegisterStatusJobTest < ActiveSupport::TestCase
|
|||
def test_if_company_wasn_not_checked_before_it_should_be_checked
|
||||
original_new_method = CompanyRegister::Client.method(:new)
|
||||
CompanyRegister::Client.define_singleton_method(:new) do
|
||||
object = original_new_method.call
|
||||
object = original_new_method.call
|
||||
def object.simple_data(registration_number:)
|
||||
[Company.new('1234567', 'ACME Ltd', REGISTERED)]
|
||||
[Company.new('16752073', 'ACME Ltd', REGISTERED), Company.new('14112620', 'Jack', REGISTERED)]
|
||||
end
|
||||
object
|
||||
end
|
||||
|
@ -43,10 +43,11 @@ class CompanyRegisterStatusJobTest < ActiveSupport::TestCase
|
|||
|
||||
@registrant_acme.reload && @registrant_jack.reload
|
||||
|
||||
assert_not_nil @registrant_acme.checked_company_at
|
||||
assert_not_nil @registrant_acme.company_register_status
|
||||
assert_not_nil @registrant_jack.checked_company_at
|
||||
assert_not_nil @registrant_jack.company_register_status
|
||||
assert_not_nil @registrant_acme.checked_company_at
|
||||
assert_not_nil @registrant_acme.company_register_status
|
||||
|
||||
|
||||
CompanyRegister::Client.define_singleton_method(:new, original_new_method)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue