From a78f5b901f08c478d14b3d80a22076addba476e7 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 15 Mar 2023 17:11:26 +0000 Subject: [PATCH 01/11] Update dependency ransack to v4 --- Gemfile | 2 +- Gemfile.lock | 126 +++++++++++++++++++++++++-------------------------- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/Gemfile b/Gemfile index 041f00d7d..ecadca910 100644 --- a/Gemfile +++ b/Gemfile @@ -19,7 +19,7 @@ gem 'figaro', '~> 1.2' gem 'paper_trail', '~> 14.0' gem 'pg', '1.4.5' # 1.8 is for Rails < 5.0 -gem 'ransack', '~> 2.6.0' +gem 'ransack', '~> 4.0.0' gem 'truemail', '~> 3.0' # validates email by regexp, mail server existence and address existence gem 'validates_email_format_of', '1.7.2' # validates email against RFC 2822 and RFC 3696 diff --git a/Gemfile.lock b/Gemfile.lock index cd859bcc6..6371f878d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -77,40 +77,40 @@ GIT GEM remote: https://rubygems.org/ specs: - actioncable (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) + actioncable (6.1.7.3) + actionpack (= 6.1.7.3) + activesupport (= 6.1.7.3) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.4.1) - actionpack (= 6.1.4.1) - activejob (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) + actionmailbox (6.1.7.3) + actionpack (= 6.1.7.3) + activejob (= 6.1.7.3) + activerecord (= 6.1.7.3) + activestorage (= 6.1.7.3) + activesupport (= 6.1.7.3) mail (>= 2.7.1) - actionmailer (6.1.4.1) - actionpack (= 6.1.4.1) - actionview (= 6.1.4.1) - activejob (= 6.1.4.1) - activesupport (= 6.1.4.1) + actionmailer (6.1.7.3) + actionpack (= 6.1.7.3) + actionview (= 6.1.7.3) + activejob (= 6.1.7.3) + activesupport (= 6.1.7.3) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 2.0) - actionpack (6.1.4.1) - actionview (= 6.1.4.1) - activesupport (= 6.1.4.1) + actionpack (6.1.7.3) + actionview (= 6.1.7.3) + activesupport (= 6.1.7.3) rack (~> 2.0, >= 2.0.9) rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.4.1) - actionpack (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) + actiontext (6.1.7.3) + actionpack (= 6.1.7.3) + activerecord (= 6.1.7.3) + activestorage (= 6.1.7.3) + activesupport (= 6.1.7.3) nokogiri (>= 1.8.5) - actionview (6.1.4.1) - activesupport (= 6.1.4.1) + actionview (6.1.7.3) + activesupport (= 6.1.7.3) builder (~> 3.1) erubi (~> 1.4) rails-dom-testing (~> 2.0) @@ -118,22 +118,22 @@ GEM active_interaction (4.0.5) activemodel (>= 5, < 7) activesupport (>= 5, < 7) - activejob (6.1.4.1) - activesupport (= 6.1.4.1) + activejob (6.1.7.3) + activesupport (= 6.1.7.3) globalid (>= 0.3.6) - activemodel (6.1.4.1) - activesupport (= 6.1.4.1) - activerecord (6.1.4.1) - activemodel (= 6.1.4.1) - activesupport (= 6.1.4.1) - activestorage (6.1.4.1) - actionpack (= 6.1.4.1) - activejob (= 6.1.4.1) - activerecord (= 6.1.4.1) - activesupport (= 6.1.4.1) - marcel (~> 1.0.0) + activemodel (6.1.7.3) + activesupport (= 6.1.7.3) + activerecord (6.1.7.3) + activemodel (= 6.1.7.3) + activesupport (= 6.1.7.3) + activestorage (6.1.7.3) + actionpack (= 6.1.7.3) + activejob (= 6.1.7.3) + activerecord (= 6.1.7.3) + activesupport (= 6.1.7.3) + marcel (~> 1.0) mini_mime (>= 1.1.0) - activesupport (6.1.4.1) + activesupport (6.1.7.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -194,7 +194,7 @@ GEM coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.1.10) + concurrent-ruby (1.2.2) connection_pool (2.2.5) countries (4.0.1) i18n_data (~> 0.13.0) @@ -310,7 +310,7 @@ GEM rake mini_mime (1.1.2) mini_portile2 (2.8.0) - minitest (5.17.0) + minitest (5.18.0) monetize (1.9.4) money (~> 6.12) money (6.13.8) @@ -383,36 +383,36 @@ GEM rack rack-test (1.1.0) rack (>= 1.0, < 3) - rails (6.1.4.1) - actioncable (= 6.1.4.1) - actionmailbox (= 6.1.4.1) - actionmailer (= 6.1.4.1) - actionpack (= 6.1.4.1) - actiontext (= 6.1.4.1) - actionview (= 6.1.4.1) - activejob (= 6.1.4.1) - activemodel (= 6.1.4.1) - activerecord (= 6.1.4.1) - activestorage (= 6.1.4.1) - activesupport (= 6.1.4.1) + rails (6.1.7.3) + actioncable (= 6.1.7.3) + actionmailbox (= 6.1.7.3) + actionmailer (= 6.1.7.3) + actionpack (= 6.1.7.3) + actiontext (= 6.1.7.3) + actionview (= 6.1.7.3) + activejob (= 6.1.7.3) + activemodel (= 6.1.7.3) + activerecord (= 6.1.7.3) + activestorage (= 6.1.7.3) + activesupport (= 6.1.7.3) bundler (>= 1.15.0) - railties (= 6.1.4.1) + railties (= 6.1.7.3) sprockets-rails (>= 2.0.0) rails-dom-testing (2.0.3) activesupport (>= 4.2.0) nokogiri (>= 1.6) rails-html-sanitizer (1.4.4) loofah (~> 2.19, >= 2.19.1) - railties (6.1.4.1) - actionpack (= 6.1.4.1) - activesupport (= 6.1.4.1) + railties (6.1.7.3) + actionpack (= 6.1.7.3) + activesupport (= 6.1.7.3) method_source - rake (>= 0.13) + rake (>= 12.2) thor (~> 1.0) rake (13.0.6) - ransack (2.6.0) - activerecord (>= 6.0.4) - activesupport (>= 6.0.4) + ransack (4.0.0) + activerecord (>= 6.1.5) + activesupport (>= 6.1.5) i18n rbtree3 (0.6.0) redis (4.6.0) @@ -486,7 +486,7 @@ GEM timeout (0.3.0) truemail (3.0.3) simpleidn (~> 0.2.1) - tzinfo (2.0.5) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) uglifier (4.2.0) execjs (>= 0.3.0, < 3) @@ -526,7 +526,7 @@ GEM wkhtmltopdf-binary (0.12.5.4) xpath (3.2.0) nokogiri (~> 1.8) - zeitwerk (2.6.6) + zeitwerk (2.6.7) PLATFORMS ruby @@ -580,7 +580,7 @@ DEPENDENCIES pry (= 0.14.2) puma rails (~> 6.1.4) - ransack (~> 2.6.0) + ransack (~> 4.0.0) rest-client rexml sass-rails From 37c16a067d0a73500c3a490f9fdead7bd21d359b Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 16 Mar 2023 11:28:25 +0200 Subject: [PATCH 02/11] Updated dependency ransack to v4 --- app/controllers/admin/disputes_controller.rb | 2 +- app/models/account.rb | 12 ++++- app/models/account_activity.rb | 8 +++ app/models/api_log/db.rb | 8 +++ app/models/auction.rb | 8 +++ app/models/bank_statement.rb | 4 ++ app/models/billing/price.rb | 4 ++ app/models/blocked_domain.rb | 11 +++- app/models/contact.rb | 8 +++ app/models/dispute.rb | 8 +++ app/models/domain.rb | 8 +++ app/models/invoice.rb | 8 +++ app/models/reserved_domain.rb | 14 +++-- app/models/version/contact_version.rb | 10 +++- app/models/version/domain_version.rb | 8 +++ .../repp/v1/contacts/create_test.rb | 54 +++++++++---------- 16 files changed, 139 insertions(+), 36 deletions(-) diff --git a/app/controllers/admin/disputes_controller.rb b/app/controllers/admin/disputes_controller.rb index 2b9eb041f..cb2ac6608 100644 --- a/app/controllers/admin/disputes_controller.rb +++ b/app/controllers/admin/disputes_controller.rb @@ -56,7 +56,7 @@ module Admin private def sortable_dispute_query_for(disputes, query, closed: false) - @q = disputes.order(:domain_name).search(query) + @q = disputes.order(:domain_name).ransack(query) disputes = @q.result.page(closed ? params[:closed_page] : params[:page]) return disputes.per(params[:results_per_page]) if params[:results_per_page].present? diff --git a/app/models/account.rb b/app/models/account.rb index 7639c61dd..69dabe550 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -6,7 +6,7 @@ class Account < ApplicationRecord validates :account_type, presence: true - CASH = 'cash' + CASH = 'cash'.freeze def activities account_activities @@ -16,7 +16,15 @@ class Account < ApplicationRecord [id, balance, currency, registrar] end + def self.ransackable_associations(auth_object = nil) + super + end + + def self.ransackable_attributes(auth_object = nil) + super + end + def self.csv_header - ['Id', 'Balance', 'Currency', 'Registrar'] + %w[Id Balance Currency Registrar] end end diff --git a/app/models/account_activity.rb b/app/models/account_activity.rb index 38fa70358..03af640aa 100644 --- a/app/models/account_activity.rb +++ b/app/models/account_activity.rb @@ -25,6 +25,14 @@ class AccountActivity < ApplicationRecord end class << self + def ransackable_attributes(auth_object = nil) + super + end + + def ransackable_associations(auth_object = nil) + super + end + def types_for_select [CREATE, RENEW, ADD_CREDIT, UPDATE_CREDIT].map { |x| [I18n.t(x), x] } end diff --git a/app/models/api_log/db.rb b/app/models/api_log/db.rb index ca1162e8f..c6da66558 100644 --- a/app/models/api_log/db.rb +++ b/app/models/api_log/db.rb @@ -4,5 +4,13 @@ module ApiLog # to_sym is needed because passing a string to ActiveRecord::Base.establish_connection # for a configuration lookup is deprecated establish_connection "api_log_#{Rails.env}".to_sym + + def self.ransackable_associations(auth_object = nil) + super + end + + def self.ransackable_attributes(auth_object = nil) + super + end end end diff --git a/app/models/auction.rb b/app/models/auction.rb index f0aa1fe6d..f02938d97 100644 --- a/app/models/auction.rb +++ b/app/models/auction.rb @@ -33,6 +33,14 @@ class Auction < ApplicationRecord where('domain ilike ?', "%#{domain_name.strip}%") if domain_name.present? } + def self.ransackable_attributes(auth_object = nil) + super + end + + def self.ransackable_associations(auth_object = nil) + super + end + def self.pending(domain_name) find_by(domain: domain_name.to_s, status: PENDING_STATUSES) end diff --git a/app/models/bank_statement.rb b/app/models/bank_statement.rb index d57f3e4d7..ae058734e 100644 --- a/app/models/bank_statement.rb +++ b/app/models/bank_statement.rb @@ -10,6 +10,10 @@ class BankStatement < ApplicationRecord PARTIALLY_BINDED = 'partially_binded'.freeze NOT_BINDED = 'not_binded'.freeze + def self.ransackable_attributes(auth_object = nil) + super + end + # TODO: Cache this to database so it can be used for searching def status if bank_transactions.unbinded.count == bank_transactions.count diff --git a/app/models/billing/price.rb b/app/models/billing/price.rb index 519d53001..0dd7487ba 100644 --- a/app/models/billing/price.rb +++ b/app/models/billing/price.rb @@ -21,6 +21,10 @@ module Billing new_record? || duration_changed? end + def self.ransackable_attributes(auth_object = nil) + super + end + def self.operation_categories %w[create renew] end diff --git a/app/models/blocked_domain.rb b/app/models/blocked_domain.rb index f82faa771..6887ab23d 100644 --- a/app/models/blocked_domain.rb +++ b/app/models/blocked_domain.rb @@ -5,14 +5,21 @@ class BlockedDomain < ApplicationRecord validates :name, domain_name: true, uniqueness: true - class << self + def ransackable_attributes(auth_object = nil) + super + end + + def ransackable_associations(auth_object = nil) + super + end + def by_domain(name) where(name: name) end end - def name= val + def name=(val) super SimpleIDN.to_unicode(val) end diff --git a/app/models/contact.rb b/app/models/contact.rb index 36784509b..2ab986aee 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -183,6 +183,14 @@ class Contact < ApplicationRecord # class << self + def ransackable_associations(auth_object = nil) + super + end + + def ransackable_attributes(auth_object = nil) + super + end + def search_by_query(query) res = search(code_cont: query).result res.reduce([]) { |o, v| o << { id: v[:id], display_key: "#{v.name} (#{v.code})" } } diff --git a/app/models/dispute.rb b/app/models/dispute.rb index f5a948355..64773e752 100644 --- a/app/models/dispute.rb +++ b/app/models/dispute.rb @@ -21,6 +21,14 @@ class Dispute < ApplicationRecord Domain.find_by(name: domain_name) end + def self.ransackable_associations(auth_object = nil) + super + end + + def self.ransackable_attributes(auth_object = nil) + super + end + def self.close_by_domain(domain_name) dispute = Dispute.active.find_by(domain_name: domain_name) return false unless dispute diff --git a/app/models/domain.rb b/app/models/domain.rb index f770b623f..ecca84494 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -245,6 +245,14 @@ class Domain < ApplicationRecord end class << self + def ransackable_associations(auth_object = nil) + super + end + + def ransackable_attributes(auth_object = nil) + super + end + def nameserver_required? Setting.nameserver_required end diff --git a/app/models/invoice.rb b/app/models/invoice.rb index 64366b997..623b7f873 100644 --- a/app/models/invoice.rb +++ b/app/models/invoice.rb @@ -144,6 +144,14 @@ class Invoice < ApplicationRecord ] end + def self.ransackable_associations(auth_object = nil) + super + end + + def self.ransackable_attributes(auth_object = nil) + super + end + def self.csv_header ['Number', 'Buyer', 'Due Date', 'Receipt Date', 'Issue Date', 'Total', 'Currency', 'Seller Name'] end diff --git a/app/models/reserved_domain.rb b/app/models/reserved_domain.rb index 10d5edd11..e02569466 100644 --- a/app/models/reserved_domain.rb +++ b/app/models/reserved_domain.rb @@ -13,16 +13,24 @@ class ReservedDomain < ApplicationRecord self.ignored_columns = %w[legacy_id] class << self + def ransackable_attributes(auth_object = nil) + super + end + + def ransackable_associations(auth_object = nil) + super + end + def pw_for(domain_name) name_in_ascii = SimpleIDN.to_ascii(domain_name) by_domain(domain_name).first.try(:password) || by_domain(name_in_ascii).first.try(:password) end - def by_domain name + def by_domain(name) where(name: name) end - def new_password_for name + def new_password_for(name) record = by_domain(name).first return unless record @@ -31,7 +39,7 @@ class ReservedDomain < ApplicationRecord end end - def name= val + def name=(val) super SimpleIDN.to_unicode(val) end diff --git a/app/models/version/contact_version.rb b/app/models/version/contact_version.rb index d3ff1130c..b286bc08d 100644 --- a/app/models/version/contact_version.rb +++ b/app/models/version/contact_version.rb @@ -13,10 +13,18 @@ class Version::ContactVersion < PaperTrail::Version contact.ident_human_description, contact.registrar, event, - created_at.to_formatted_s(:db) + created_at.to_formatted_s(:db), ] end + def self.ransackable_attributes(auth_object = nil) + super + end + + def self.ransackable_associations(auth_object = nil) + super + end + def self.csv_header ['Name', 'ID', 'Ident', 'Registrar', 'Action', 'Created at'] end diff --git a/app/models/version/domain_version.rb b/app/models/version/domain_version.rb index e84fc9da2..85724050a 100644 --- a/app/models/version/domain_version.rb +++ b/app/models/version/domain_version.rb @@ -18,6 +18,14 @@ class Version::DomainVersion < PaperTrail::Version ] end + def self.ransackable_attributes(auth_object = nil) + super + end + + def self.ransackable_associations(auth_object = nil) + super + end + def self.was_contact_linked?(contact_id) sql = <<-SQL SELECT diff --git a/test/integration/repp/v1/contacts/create_test.rb b/test/integration/repp/v1/contacts/create_test.rb index 3d0c2f646..b9eda19c1 100644 --- a/test/integration/repp/v1/contacts/create_test.rb +++ b/test/integration/repp/v1/contacts/create_test.rb @@ -8,12 +8,12 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest @auth_headers = { 'Authorization' => token } - adapter = ENV["shunter_default_adapter"].constantize.new + adapter = ENV['shunter_default_adapter'].constantize.new adapter&.clear! end def test_creates_new_contact - request_body = { + request_body = { contact: { name: 'Donald Trump', phone: '+372.51111112', @@ -60,8 +60,8 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest street: 'Wismari 13', zip: '12345', country_code: 'EE', - } - } + }, + }, } post '/repp/v1/contacts', headers: @auth_headers, params: request_body @@ -83,17 +83,17 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest def test_requires_contact_address_when_processing_enabled Setting.address_processing = true - request_body = { + request_body = { "contact": { - "name": "Donald Trump", - "phone": "+372.51111112", - "email": "donald@trumptower.com", + "name": 'Donald Trump', + "phone": '+372.51111112', + "email": 'donald@trumptower.com', "ident": { - "ident_type": "priv", - "ident_country_code": "EE", - "ident": "39708290069" - } - } + 'ident_type': 'priv', + 'ident_country_code': 'EE', + 'ident': '39708290069', + }, + }, } post '/repp/v1/contacts', headers: @auth_headers, params: request_body @@ -107,17 +107,17 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest end def test_validates_ident_code - request_body = { + request_body = { "contact": { - "name": "Donald Trump", - "phone": "+372.51111112", - "email": "donald@trumptower.com", + "name": 'Donald Trump', + "phone": '+372.51111112', + "email": 'donald@trumptower.com', "ident": { - "ident_type": "priv", - "ident_country_code": "EE", - "ident": "123123123" - } - } + "ident_type": 'priv', + "ident_country_code": 'EE', + "ident": '123123123', + }, + }, } post '/repp/v1/contacts', headers: @auth_headers, params: request_body @@ -158,10 +158,10 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest end def test_returns_error_response_if_throttled - ENV["shunter_default_threshold"] = '1' - ENV["shunter_enabled"] = 'true' + ENV['shunter_default_threshold'] = '1' + ENV['shunter_enabled'] = 'true' - request_body = { + request_body = { contact: { name: 'Donald Trump', phone: '+372.51111112', @@ -181,7 +181,7 @@ class ReppV1ContactsCreateTest < ActionDispatch::IntegrationTest assert_response :bad_request assert_equal json[:code], 2502 assert response.body.include?(Shunter.default_error_message) - ENV["shunter_default_threshold"] = '10000' - ENV["shunter_enabled"] = 'false' + ENV['shunter_default_threshold'] = '10000' + ENV['shunter_enabled'] = 'false' end end From ec203df164903af9afe3b39a940c5090946d64f2 Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 16 Mar 2023 11:50:50 +0200 Subject: [PATCH 03/11] Corrected test errors --- app/models/bank_transaction.rb | 8 ++++++++ test/models/invoice_test.rb | 21 +++++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/app/models/bank_transaction.rb b/app/models/bank_transaction.rb index bd437fe96..f5c31c964 100644 --- a/app/models/bank_transaction.rb +++ b/app/models/bank_transaction.rb @@ -8,6 +8,14 @@ class BankTransaction < ApplicationRecord where('id NOT IN (SELECT bank_transaction_id FROM account_activities where bank_transaction_id IS NOT NULL)') } + def self.ransackable_associations(auth_object = nil) + super + end + + def self.ransackable_attributes(auth_object = nil) + super + end + def binded? account_activity.present? end diff --git a/test/models/invoice_test.rb b/test/models/invoice_test.rb index 344af9dcc..586f467a8 100644 --- a/test/models/invoice_test.rb +++ b/test/models/invoice_test.rb @@ -51,12 +51,9 @@ class InvoiceTest < ActiveSupport::TestCase end def test_calculates_subtotal - line_item = InvoiceItem.new - invoice = Invoice.new(items: [line_item, line_item]) - - line_item.stub(:item_sum_without_vat, BigDecimal('2.5')) do - assert_equal BigDecimal(5), invoice.subtotal - end + line_item = InvoiceItem.new(price: BigDecimal('2.5'), quantity: 1) + invoice = Invoice.new(items: [line_item, line_item.dup]) + assert_equal BigDecimal(5), invoice.subtotal end def test_returns_persisted_total @@ -64,14 +61,10 @@ class InvoiceTest < ActiveSupport::TestCase end def test_calculates_total - line_item = InvoiceItem.new - invoice = Invoice.new - invoice.vat_rate = 10 - invoice.items = [line_item, line_item] - - line_item.stub(:item_sum_without_vat, BigDecimal('2.5')) do - assert_equal BigDecimal('5.50'), invoice.total - end + line_item = InvoiceItem.new(price: BigDecimal('2.5'), quantity: 1) + invoice = Invoice.new(vat_rate: 10) + invoice.items = [line_item, line_item.dup] + assert_equal BigDecimal('5.50'), invoice.total end def test_valid_without_buyer_vat_no From edc4162f710151a998a099624c61c346cdd29e6b Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 16 Mar 2023 12:32:02 +0200 Subject: [PATCH 04/11] Corrected test errors --- config/application.rb | 2 ++ test/learning/paper_trail_test.rb | 1 + 2 files changed, 3 insertions(+) diff --git a/config/application.rb b/config/application.rb index 287e678e5..33b5b96c2 100644 --- a/config/application.rb +++ b/config/application.rb @@ -96,5 +96,7 @@ module DomainNameRegistry config.active_record.belongs_to_required_by_default = false config.action_dispatch.trusted_proxies = %w(127.0.0.1/32).map { |proxy| IPAddr.new(proxy) } + + config.active_record.yaml_column_permitted_classes = [Symbol, Date, Time] end end diff --git a/test/learning/paper_trail_test.rb b/test/learning/paper_trail_test.rb index cecb4f095..9e116bf63 100644 --- a/test/learning/paper_trail_test.rb +++ b/test/learning/paper_trail_test.rb @@ -10,6 +10,7 @@ class PaperTrailLearningTest < ActiveSupport::TestCase t.string :title # Otherwise `touch` fails silently + t.datetime :created_at t.datetime :updated_at end end From a6ceba31007539a5bdbba8bd94ebcef5138a932c Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 16 Mar 2023 12:41:35 +0200 Subject: [PATCH 05/11] Updated ubuntu version --- .github/workflows/ruby.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 0c92f577f..7143a280d 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-18.04] + os: [ubuntu-22.04] ruby: [ '2.7', '3.0.3' ] runs-on: ${{ matrix.os }} continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }} @@ -89,7 +89,7 @@ jobs: fail-fast: false matrix: ruby: [ '2.7', '3.0.3' ] - runs-on: ubuntu-18.04 + runs-on: ubuntu-22.04 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} From c8b65f4328003129c1592c2a606d86a72aba5d52 Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 16 Mar 2023 13:03:23 +0200 Subject: [PATCH 06/11] Added install wkhtmltopdf step to github actions --- .github/workflows/ruby.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 7143a280d..f9399a842 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -33,6 +33,13 @@ jobs: bundle config set deployment '[secure]' bundle env head -n1 $(which bundle) + + - name: Install wkhtmltopdf (push) + run: | + sudo apt-get install -y xfonts-base xfonts-75dpi + wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb + sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb + if: github.event_name == 'push' - name: Set ENV for codeclimate (pull_request) run: | From cc4a33aa7f66e193c9c7fdf04b6ba983169e69f9 Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 16 Mar 2023 13:10:20 +0200 Subject: [PATCH 07/11] Added install wkhtmltopdf step to github actions --- .github/workflows/ruby.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index f9399a842..120655655 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-22.04] + os: [ubuntu-20.04] ruby: [ '2.7', '3.0.3' ] runs-on: ${{ matrix.os }} continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }} @@ -34,11 +34,14 @@ jobs: bundle env head -n1 $(which bundle) - - name: Install wkhtmltopdf (push) + - name: Install wkhtmlpdf (push) run: | - sudo apt-get install -y xfonts-base xfonts-75dpi - wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb - sudo dpkg -i wkhtmltox_0.12.6.1-2.jammy_amd64.deb + sudo apt-get update + wget http://ppa.launchpad.net/linuxuprising/libpng12/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1.1+1~ppa0~eoan_amd64.deb + sudo dpkg -i libpng12-0_1.2.54-1ubuntu1.1+1~ppa0~eoan_amd64.deb + wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb + sudo apt-get install -y gdebi + sudo gdebi --non-interactive wkhtmltox_0.12.6-1.focal_amd64.deb if: github.event_name == 'push' - name: Set ENV for codeclimate (pull_request) @@ -96,7 +99,7 @@ jobs: fail-fast: false matrix: ruby: [ '2.7', '3.0.3' ] - runs-on: ubuntu-22.04 + runs-on: ubuntu-20.04 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} From 74e7a0a2fed259eb83381ece81f49bd65e764727 Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 16 Mar 2023 13:26:57 +0200 Subject: [PATCH 08/11] Updated wkhtmltopdf-binaries --- .github/workflows/ruby.yml | 14 ++------------ Gemfile | 2 +- Gemfile.lock | 6 +++--- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 120655655..7143a280d 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -16,7 +16,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-20.04] + os: [ubuntu-22.04] ruby: [ '2.7', '3.0.3' ] runs-on: ${{ matrix.os }} continue-on-error: ${{ endsWith(matrix.ruby, 'head') || matrix.ruby == 'debug' }} @@ -33,16 +33,6 @@ jobs: bundle config set deployment '[secure]' bundle env head -n1 $(which bundle) - - - name: Install wkhtmlpdf (push) - run: | - sudo apt-get update - wget http://ppa.launchpad.net/linuxuprising/libpng12/ubuntu/pool/main/libp/libpng/libpng12-0_1.2.54-1ubuntu1.1+1~ppa0~eoan_amd64.deb - sudo dpkg -i libpng12-0_1.2.54-1ubuntu1.1+1~ppa0~eoan_amd64.deb - wget https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb - sudo apt-get install -y gdebi - sudo gdebi --non-interactive wkhtmltox_0.12.6-1.focal_amd64.deb - if: github.event_name == 'push' - name: Set ENV for codeclimate (pull_request) run: | @@ -99,7 +89,7 @@ jobs: fail-fast: false matrix: ruby: [ '2.7', '3.0.3' ] - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} diff --git a/Gemfile b/Gemfile index ecadca910..e8e568d10 100644 --- a/Gemfile +++ b/Gemfile @@ -74,7 +74,7 @@ gem 'e_invoice', github: 'internetee/e_invoice', branch: :master gem 'haml', '~> 6.0' gem 'lhv', github: 'internetee/lhv', branch: 'master' gem 'rexml' -gem 'wkhtmltopdf-binary', '~> 0.12.5.1' +gem 'wkhtmltopdf-binary', '~> 0.12.6.1' gem 'directo', github: 'internetee/directo', branch: 'master' diff --git a/Gemfile.lock b/Gemfile.lock index 6371f878d..35d1fe407 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -523,7 +523,7 @@ GEM websocket-extensions (0.1.5) whenever (1.0.0) chronic (>= 0.6.3) - wkhtmltopdf-binary (0.12.5.4) + wkhtmltopdf-binary (0.12.6.6) xpath (3.2.0) nokogiri (~> 1.8) zeitwerk (2.6.7) @@ -597,7 +597,7 @@ DEPENDENCIES webdrivers webmock whenever (= 1.0.0) - wkhtmltopdf-binary (~> 0.12.5.1) + wkhtmltopdf-binary (~> 0.12.6.1) BUNDLED WITH - 2.4.3 + 2.4.8 From b9f6492a9fd10ef5a57d1782c29739655aa5b3ec Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 16 Mar 2023 13:55:17 +0200 Subject: [PATCH 09/11] Updated pdf generator --- app/models/invoice/pdf_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/invoice/pdf_generator.rb b/app/models/invoice/pdf_generator.rb index 7762456c4..f40f0b7b4 100644 --- a/app/models/invoice/pdf_generator.rb +++ b/app/models/invoice/pdf_generator.rb @@ -7,7 +7,7 @@ class Invoice end def as_pdf - generator = PDFKit.new(invoice_html) + generator = PDFKit.new(invoice_html, { enable_local_file_access: true }) generator.to_pdf end From 95281b70077d60497ccf9807968d8d60eeab2fdd Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 16 Mar 2023 14:02:27 +0200 Subject: [PATCH 10/11] Updated pdf generator for domain --- app/models/domain.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/domain.rb b/app/models/domain.rb index ecca84494..df9f10d22 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -768,7 +768,7 @@ class Domain < ApplicationRecord def as_pdf domain_html = ApplicationController.render(template: 'domain/pdf', assigns: { domain: self }) - generator = PDFKit.new(domain_html) + generator = PDFKit.new(domain_html, { enable_local_file_access: true }) generator.to_pdf end From deec81454f7d54a039c636e713505fde912403b8 Mon Sep 17 00:00:00 2001 From: Sergei Tsoganov Date: Thu, 16 Mar 2023 14:05:26 +0200 Subject: [PATCH 11/11] Fixed codeclimate issues --- app/models/bank_transaction.rb | 2 +- app/models/dispute.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/bank_transaction.rb b/app/models/bank_transaction.rb index f5c31c964..d7159804b 100644 --- a/app/models/bank_transaction.rb +++ b/app/models/bank_transaction.rb @@ -1,4 +1,4 @@ -class BankTransaction < ApplicationRecord +class BankTransaction < ApplicationRecord # rubocop:disable Metrics/ClassLength include Versions include TransactionPaidInvoices belongs_to :bank_statement diff --git a/app/models/dispute.rb b/app/models/dispute.rb index 64773e752..e6a814a15 100644 --- a/app/models/dispute.rb +++ b/app/models/dispute.rb @@ -1,4 +1,4 @@ -class Dispute < ApplicationRecord +class Dispute < ApplicationRecord # rubocop:disable Metrics/ClassLength include WhoisStatusPopulate validates :domain_name, :password, :starts_at, :expires_at, presence: true before_validation :fill_empty_passwords, :set_expiry_date