From 03c970a9e4f385216c6cb7c79b15ff5342989ffd Mon Sep 17 00:00:00 2001 From: Torsten Date: Thu, 31 Mar 2022 11:54:31 +0300 Subject: [PATCH 01/14] back to passenger --- Gemfile | 3 +-- Gemfile.lock | 11 ++++------- config/deploy.rb | 4 ++-- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index f76e586..350463d 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ gem "net-ssh" gem "haml-rails" gem 'high_voltage', '~> 3.1' -gem "puma" , "4.3.10" +gem "passenger", require: "phusion_passenger/rack_handler" # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # gem "image_processing", "~> 1.2" @@ -30,7 +30,6 @@ group :development do gem "web-console" gem "rack-mini-profiler" gem "mina" - gem "mina-puma" end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index b241ff6..dadb919 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -128,9 +128,6 @@ GEM mina (1.2.4) open4 (~> 1.3.4) rake - mina-puma (1.1.0) - mina (~> 1.2.0) - puma (>= 2.13) mini_mime (1.1.2) minitest (5.15.0) msgpack (1.4.5) @@ -154,9 +151,10 @@ GEM nokogiri (1.13.3-x86_64-linux) racc (~> 1.4) open4 (1.3.4) + passenger (6.0.13) + rack + rake (>= 0.8.1) public_suffix (4.0.6) - puma (4.3.10) - nio4r (~> 2.0) racc (1.6.0) rack (2.2.3) rack-mini-profiler (3.0.0) @@ -254,9 +252,8 @@ DEPENDENCIES high_voltage (~> 3.1) importmap-rails mina - mina-puma net-ssh - puma (= 4.3.10) + passenger rack-mini-profiler rails (~> 7.0) sassc-rails diff --git a/config/deploy.rb b/config/deploy.rb index 28c2d90..73f4876 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -13,7 +13,7 @@ set :application_name, 'gateway' set :domain, 'web-server.local' set :deploy_to, '/home/feenix/gateway' set :repository, "https://github.com/rubydesign/gateway.git" -set :branch, 'main' +set :branch, 'passenger' # Optional settings: set :user, 'feenix' # Username in the server to SSH to. @@ -59,7 +59,7 @@ task :deploy do on :launch do in_path(fetch(:current_path)) do - invoke :'puma:hard_restart' + invoke :'passenger:restart' end end end From 87571dc71fae3ab2a133334a0e8c6a4ce930821a Mon Sep 17 00:00:00 2001 From: Torsten Date: Thu, 31 Mar 2022 11:55:25 +0300 Subject: [PATCH 02/14] uups --- config/deploy.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index 73f4876..0c49212 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -1,7 +1,6 @@ require 'mina/rails' require 'mina/git' require 'mina/rbenv' # for rbenv support. (https://rbenv.org) -require 'mina/puma' # Basic settings: # domain - The hostname to SSH to. From 9d9314317fdb1716c259e609790a936ef89b78a0 Mon Sep 17 00:00:00 2001 From: Torsten Date: Thu, 31 Mar 2022 15:35:28 +0300 Subject: [PATCH 03/14] remove puma --- app/views/pages/index.haml | 5 +++- config/deploy.rb | 12 +++++++--- config/puma.rb | 48 -------------------------------------- 3 files changed, 13 insertions(+), 52 deletions(-) delete mode 100644 config/puma.rb diff --git a/app/views/pages/index.haml b/app/views/pages/index.haml index 0b2da07..2b7f7c4 100644 --- a/app/views/pages/index.haml +++ b/app/views/pages/index.haml @@ -1 +1,4 @@ -%h1 Hello again +%h1 Hello Gateway + +%p + Gateway to what? And so you may well ask . . . diff --git a/config/deploy.rb b/config/deploy.rb index 0c49212..c63bc71 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -67,6 +67,12 @@ task :deploy do # run(:local){ say 'done' } end -# For help in making your deploy script, see the Mina documentation: -# -# - https://github.com/mina-deploy/mina/tree/master/docs +namespace :passenger do + desc "Restart Passenger" + task :restart do + command %{ + echo "-----> Restarting passenger" + #{echo_cmd %[touch tmp/restart.txt]} + } + end +end diff --git a/config/puma.rb b/config/puma.rb deleted file mode 100644 index 86c1c69..0000000 --- a/config/puma.rb +++ /dev/null @@ -1,48 +0,0 @@ -# Puma can serve each request in a thread from an internal thread pool. -# The `threads` method setting takes two numbers: a minimum and maximum. -# Any libraries that use thread pools should be configured to match -# the maximum value specified for Puma. Default is set to 5 threads for minimum -# and maximum; this matches the default thread size of Active Record. -# -max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } -min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } -threads min_threads_count, max_threads_count - -# Specifies the `worker_timeout` threshold that Puma will use to wait before -# terminating a worker in development environments. -# -worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development" - -# Specifies the `port` that Puma will listen on to receive requests; default is 3000. -# -port ENV.fetch("PORT") { 3000 } - -# Specifies the `environment` that Puma will run in. -# -environment ENV.fetch("RAILS_ENV") { "development" } - -# Specifies the `pidfile` that Puma will use. -pidfile ENV.fetch("PIDFILE") { "tmp/pids/puma.pid" } - -bind 'unix://tmp/sockets/pumactl.sock' - -# mina/puma expects it -state_path 'tmp/sockets/puma.state' - -# Specifies the number of `workers` to boot in clustered mode. -# Workers are forked web server processes. If using threads and workers together -# the concurrency of the application would be max `threads` * `workers`. -# Workers do not work on JRuby or Windows (both of which do not support -# processes). -# -# workers ENV.fetch("WEB_CONCURRENCY") { 2 } - -# Use the `preload_app!` method when specifying a `workers` number. -# This directive tells Puma to first boot the application and load code -# before forking the application. This takes advantage of Copy On Write -# process behavior so workers use less memory. -# -# preload_app! - -# Allow puma to be restarted by `bin/rails restart` command. -plugin :tmp_restart From 0297c57361dd9f4f3b5d15bc952790e75300c25e Mon Sep 17 00:00:00 2001 From: Torsten Date: Thu, 31 Mar 2022 15:53:39 +0300 Subject: [PATCH 04/14] first spec --- .rspec | 1 + Gemfile | 1 + Gemfile.lock | 19 ++++ spec/features/pages_spec.rb | 9 ++ spec/rails_helper.rb | 64 +++++++++++++ spec/spec_helper.rb | 96 +++++++++++++++++++ spec/support/request_helper.rb | 31 ++++++ test/application_system_test_case.rb | 5 - .../application_cable/connection_test.rb | 11 --- test/controllers/.keep | 0 test/fixtures/files/.keep | 0 test/helpers/.keep | 0 test/integration/.keep | 0 test/mailers/.keep | 0 test/models/.keep | 0 test/system/.keep | 0 test/test_helper.rb | 13 --- 17 files changed, 221 insertions(+), 29 deletions(-) create mode 100644 .rspec create mode 100644 spec/features/pages_spec.rb create mode 100644 spec/rails_helper.rb create mode 100644 spec/spec_helper.rb create mode 100644 spec/support/request_helper.rb delete mode 100644 test/application_system_test_case.rb delete mode 100644 test/channels/application_cable/connection_test.rb delete mode 100644 test/controllers/.keep delete mode 100644 test/fixtures/files/.keep delete mode 100644 test/helpers/.keep delete mode 100644 test/integration/.keep delete mode 100644 test/mailers/.keep delete mode 100644 test/models/.keep delete mode 100644 test/system/.keep delete mode 100644 test/test_helper.rb diff --git a/.rspec b/.rspec new file mode 100644 index 0000000..c99d2e7 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/Gemfile b/Gemfile index 350463d..c9115b2 100644 --- a/Gemfile +++ b/Gemfile @@ -24,6 +24,7 @@ gem "passenger", require: "phusion_passenger/rack_handler" group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[ mri mingw x64_mingw ] + gem 'rspec-rails', '~> 5.0.0' end group :development do diff --git a/Gemfile.lock b/Gemfile.lock index dadb919..a7a3725 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -87,6 +87,7 @@ GEM debug (1.4.0) irb (>= 1.3.6) reline (>= 0.2.7) + diff-lcs (1.5.0) digest (3.1.0) erubi (1.10.0) erubis (2.7.0) @@ -192,6 +193,23 @@ GEM reline (0.3.1) io-console (~> 0.5) rexml (3.2.5) + rspec-core (3.11.0) + rspec-support (~> 3.11.0) + rspec-expectations (3.11.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.11.0) + rspec-mocks (3.11.0) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.11.0) + rspec-rails (5.0.3) + actionpack (>= 5.2) + activesupport (>= 5.2) + railties (>= 5.2) + rspec-core (~> 3.10) + rspec-expectations (~> 3.10) + rspec-mocks (~> 3.10) + rspec-support (~> 3.10) + rspec-support (3.11.0) ruby_parser (3.18.1) sexp_processor (~> 4.16) rubyzip (2.3.2) @@ -256,6 +274,7 @@ DEPENDENCIES passenger rack-mini-profiler rails (~> 7.0) + rspec-rails (~> 5.0.0) sassc-rails selenium-webdriver sprockets-rails diff --git a/spec/features/pages_spec.rb b/spec/features/pages_spec.rb new file mode 100644 index 0000000..9ae5047 --- /dev/null +++ b/spec/features/pages_spec.rb @@ -0,0 +1,9 @@ +require 'spec_helper' + +describe "Pages" do + + it "should render index" do + visit_path "/" + expect(page).to have_text("Gateway") + end +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000..e299b31 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,64 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f } + +# Checks for pending migrations and applies them before tests are run. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + puts e.to_s.strip + exit 1 +end +RSpec.configure do |config| + config.include Rails.application.routes.url_helpers + config.infer_base_class_for_anonymous_controllers = false + config.infer_spec_type_from_file_location! + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails can automatically mix in different behaviours to your tests + # based on their file location, for example enabling you to call `get` and + # `post` in specs under `spec/controllers`. + # + # You can disable this behaviour by removing the line below, and instead + # explicitly tag your specs with their type, e.g.: + # + # RSpec.describe UsersController, type: :controller do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://relishapp.com/rspec/rspec-rails/docs + config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..7643233 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,96 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # https://relishapp.com/rspec/rspec-core/docs/configuration/zero-monkey-patching-mode + config.disable_monkey_patching! + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end +require_relative "rails_helper" diff --git a/spec/support/request_helper.rb b/spec/support/request_helper.rb new file mode 100644 index 0000000..8073af6 --- /dev/null +++ b/spec/support/request_helper.rb @@ -0,0 +1,31 @@ +module RequestHelper + def ensure_path path + expect(page.current_path).to eq path + end + def visit_path path + visit path + expect(status_code).to be 200 + expect(page).not_to have_css(".translation_missing") + ensure_path path + end + + def ensure_admin + admin = Clerk.where(:admin => true).first + admin = create :admin unless admin + expect(admin).not_to be nil + admin + end + + def sign_in + admin = ensure_admin + visit sign_in_path + fill_in "email" , :with => admin.email + fill_in "password" , :with => "password" + click_button I18n.t(:sign_in) + expect(page).to have_content I18n.t(:baskets) + end +end + +RSpec.configure do |config| + config.include RequestHelper +end diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb deleted file mode 100644 index d19212a..0000000 --- a/test/application_system_test_case.rb +++ /dev/null @@ -1,5 +0,0 @@ -require "test_helper" - -class ApplicationSystemTestCase < ActionDispatch::SystemTestCase - driven_by :selenium, using: :chrome, screen_size: [1400, 1400] -end diff --git a/test/channels/application_cable/connection_test.rb b/test/channels/application_cable/connection_test.rb deleted file mode 100644 index 800405f..0000000 --- a/test/channels/application_cable/connection_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require "test_helper" - -class ApplicationCable::ConnectionTest < ActionCable::Connection::TestCase - # test "connects with cookies" do - # cookies.signed[:user_id] = 42 - # - # connect - # - # assert_equal connection.user_id, "42" - # end -end diff --git a/test/controllers/.keep b/test/controllers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/helpers/.keep b/test/helpers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/integration/.keep b/test/integration/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/mailers/.keep b/test/mailers/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/models/.keep b/test/models/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/system/.keep b/test/system/.keep deleted file mode 100644 index e69de29..0000000 diff --git a/test/test_helper.rb b/test/test_helper.rb deleted file mode 100644 index d713e37..0000000 --- a/test/test_helper.rb +++ /dev/null @@ -1,13 +0,0 @@ -ENV["RAILS_ENV"] ||= "test" -require_relative "../config/environment" -require "rails/test_help" - -class ActiveSupport::TestCase - # Run tests in parallel with specified workers - parallelize(workers: :number_of_processors) - - # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. - fixtures :all - - # Add more helper methods to be used by all tests here... -end From ab7329cbae59cde132df626994a5d689995e6acc Mon Sep 17 00:00:00 2001 From: Torsten Date: Thu, 31 Mar 2022 17:03:11 +0300 Subject: [PATCH 05/14] add dnsimple --- Gemfile | 2 ++ Gemfile.lock | 10 ++++++++++ app/jobs/dns_update_job.rb | 11 +++++++++++ spec/jobs/dns_update_job_spec.rb | 5 +++++ 4 files changed, 28 insertions(+) create mode 100644 app/jobs/dns_update_job.rb create mode 100644 spec/jobs/dns_update_job_spec.rb diff --git a/Gemfile b/Gemfile index c9115b2..1db15e7 100644 --- a/Gemfile +++ b/Gemfile @@ -18,6 +18,8 @@ gem 'high_voltage', '~> 3.1' gem "passenger", require: "phusion_passenger/rack_handler" +gem "dnsimple" + # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # gem "image_processing", "~> 1.2" diff --git a/Gemfile.lock b/Gemfile.lock index a7a3725..8a0907a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -89,6 +89,8 @@ GEM reline (>= 0.2.7) diff-lcs (1.5.0) digest (3.1.0) + dnsimple (7.1.1) + httparty erubi (1.10.0) erubis (2.7.0) ffi (1.15.5) @@ -109,6 +111,9 @@ GEM haml (>= 4.0, < 6) nokogiri (>= 1.6.0) ruby_parser (~> 3.5) + httparty (0.20.0) + mime-types (~> 3.0) + multi_xml (>= 0.5.2) i18n (1.10.0) concurrent-ruby (~> 1.0) importmap-rails (1.0.3) @@ -126,12 +131,16 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2022.0105) mina (1.2.4) open4 (~> 1.3.4) rake mini_mime (1.1.2) minitest (5.15.0) msgpack (1.4.5) + multi_xml (0.6.0) net-imap (0.2.3) digest net-protocol @@ -266,6 +275,7 @@ DEPENDENCIES bootsnap capybara debug + dnsimple haml-rails high_voltage (~> 3.1) importmap-rails diff --git a/app/jobs/dns_update_job.rb b/app/jobs/dns_update_job.rb new file mode 100644 index 0000000..9480161 --- /dev/null +++ b/app/jobs/dns_update_job.rb @@ -0,0 +1,11 @@ +require "dnsimple" +class DnsUpdateJob < ApplicationJob + def self.get_client + Dnsimple::Client.new(access_token: Rails.application.credentials.simple_token) + end + queue_as :default + + def perform(*args) + # Do something later + end +end diff --git a/spec/jobs/dns_update_job_spec.rb b/spec/jobs/dns_update_job_spec.rb new file mode 100644 index 0000000..f7d8c35 --- /dev/null +++ b/spec/jobs/dns_update_job_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe DnsUpdateJob, type: :job do + pending "add some examples to (or delete) #{__FILE__}" +end From 58fe0ef5fbad28756832fd79715c93ebbeb499fb Mon Sep 17 00:00:00 2001 From: Torsten Date: Thu, 31 Mar 2022 20:47:53 +0300 Subject: [PATCH 06/14] add guard --- Gemfile | 2 ++ Gemfile.lock | 40 ++++++++++++++++++++++++++++++++++++++++ Guardfile | 31 +++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 Guardfile diff --git a/Gemfile b/Gemfile index 1db15e7..61224c6 100644 --- a/Gemfile +++ b/Gemfile @@ -33,6 +33,8 @@ group :development do gem "web-console" gem "rack-mini-profiler" gem "mina" + gem 'guard-rails' + gem 'guard-rspec' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 8a0907a..5e35626 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -82,6 +82,7 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) childprocess (4.1.0) + coderay (1.1.3) concurrent-ruby (1.1.10) crass (1.0.6) debug (1.4.0) @@ -94,8 +95,26 @@ GEM erubi (1.10.0) erubis (2.7.0) ffi (1.15.5) + formatador (1.1.0) globalid (1.0.0) activesupport (>= 5.0) + guard (2.18.0) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (>= 1.0.12, < 2.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.13.0) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-rails (0.8.1) + guard (~> 2.11) + guard-compat (~> 1.0) + guard-rspec (4.7.3) + guard (~> 2.1) + guard-compat (~> 1.1) + rspec (>= 2.99.0, < 4.0) haml (5.2.2) temple (>= 0.8.0) tilt @@ -123,9 +142,13 @@ GEM io-wait (0.2.1) irb (1.4.1) reline (>= 0.3.0) + listen (3.7.1) + rb-fsevent (~> 0.10, >= 0.10.3) + rb-inotify (~> 0.9, >= 0.9.10) loofah (2.15.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) + lumberjack (1.2.8) mail (2.7.1) mini_mime (>= 0.1.1) marcel (1.0.2) @@ -141,6 +164,7 @@ GEM minitest (5.15.0) msgpack (1.4.5) multi_xml (0.6.0) + nenv (0.3.0) net-imap (0.2.3) digest net-protocol @@ -160,10 +184,16 @@ GEM nio4r (2.5.8) nokogiri (1.13.3-x86_64-linux) racc (~> 1.4) + notiffany (0.1.3) + nenv (~> 0.1) + shellany (~> 0.0) open4 (1.3.4) passenger (6.0.13) rack rake (>= 0.8.1) + pry (0.14.1) + coderay (~> 1.1) + method_source (~> 1.0) public_suffix (4.0.6) racc (1.6.0) rack (2.2.3) @@ -198,10 +228,17 @@ GEM thor (~> 1.0) zeitwerk (~> 2.5) rake (13.0.6) + rb-fsevent (0.11.1) + rb-inotify (0.10.1) + ffi (~> 1.0) regexp_parser (2.2.1) reline (0.3.1) io-console (~> 0.5) rexml (3.2.5) + rspec (3.11.0) + rspec-core (~> 3.11.0) + rspec-expectations (~> 3.11.0) + rspec-mocks (~> 3.11.0) rspec-core (3.11.0) rspec-support (~> 3.11.0) rspec-expectations (3.11.0) @@ -235,6 +272,7 @@ GEM rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2) sexp_processor (4.16.0) + shellany (0.0.1) sprockets (4.0.3) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -276,6 +314,8 @@ DEPENDENCIES capybara debug dnsimple + guard-rails + guard-rspec haml-rails high_voltage (~> 3.1) importmap-rails diff --git a/Guardfile b/Guardfile new file mode 100644 index 0000000..237a689 --- /dev/null +++ b/Guardfile @@ -0,0 +1,31 @@ +command = "rspec" +begin + require "rubygems" + require "spring/version" #safe to try + command = "spring rspec" + puts "Using Spring loaded rspec" +rescue LoadError +end +guard :rspec , cmd: "bundle exec rspec" do + watch(%r{^spec/.+_spec\.rb$}) + watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" } + watch('spec/spec_helper.rb') { "spec" } + + # Rails example + watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" } + watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" } + watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] } + watch(%r{^spec/support/(.+)\.rb$}) { "spec" } + watch('config/routes.rb') { "spec/routing" } + watch('app/controllers/application_controller.rb') { "spec/controllers" } + + + watch('app/models/basket.rb') { Dir["spec/models/baskets/*_spec.rb"] } + watch('app/controllers/baskets_controller.rb') { Dir["spec/features/baskets/*_spec.rb"] } + + # Capybara features specs + watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" } + + # locales + watch(%r{^config/locales/.*yml}) { |m| "spec/i18n_spec.rb" } +end From 8e88fc7ac63036a33f6e7b81c3f316a6df92f8d1 Mon Sep 17 00:00:00 2001 From: Torsten Date: Thu, 31 Mar 2022 20:48:14 +0300 Subject: [PATCH 07/14] build ip updating logic, own dyn dns --- app/jobs/dns_update_job.rb | 23 +++++++++++++++++++---- spec/jobs/dns_update_job_spec.rb | 27 ++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/app/jobs/dns_update_job.rb b/app/jobs/dns_update_job.rb index 9480161..06e32af 100644 --- a/app/jobs/dns_update_job.rb +++ b/app/jobs/dns_update_job.rb @@ -1,11 +1,26 @@ require "dnsimple" class DnsUpdateJob < ApplicationJob - def self.get_client - Dnsimple::Client.new(access_token: Rails.application.credentials.simple_token) - end queue_as :default + def client + @client ||= Dnsimple::Client.new(access_token: Rails.application.credentials.simple_token) + end + def simple_id + Rails.application.credentials.simple_id + end + def my_ip + HTTParty.get("http://icanhazip.com").strip + end + + def find_record(name , host) + zones = client.zones.list_zone_records(simple_id, host, filter: { type: 'A' , name: name }) + zones.data.first + end + + def update_ip + record = find_record("gateway" , "hubfeenix.fi") + client.zones.update_zone_record(simple_id,"hubfeenix.fi", record.id , content: my_ip) + end def perform(*args) - # Do something later end end diff --git a/spec/jobs/dns_update_job_spec.rb b/spec/jobs/dns_update_job_spec.rb index f7d8c35..c79c8c3 100644 --- a/spec/jobs/dns_update_job_spec.rb +++ b/spec/jobs/dns_update_job_spec.rb @@ -1,5 +1,30 @@ require 'rails_helper' RSpec.describe DnsUpdateJob, type: :job do - pending "add some examples to (or delete) #{__FILE__}" + ActiveJob::Base.queue_adapter = :test + let(:my_ip){"85.76.133.88"} + + it "should get ip" do + res = DnsUpdateJob.new.my_ip + expect(res).to eq my_ip + end + + it "should init client" do + client = DnsUpdateJob.new.client + expect(client.class).to be Dnsimple::Client + end + + it "should find domain" do + zone = DnsUpdateJob.new.find_record("gateway","hubfeenix.fi") + expect(zone.class).to eq Dnsimple::Struct::ZoneRecord + expect(zone.name).to eq "gateway" + expect(zone.content).to eq my_ip + end + + it "update ip" do + updater = DnsUpdateJob.new + updater.update_ip + zone = updater.find_record("gateway","hubfeenix.fi") + expect(zone.content).to eq my_ip + end end From 29003907aa47e2ea1878050c8f5756f7b9b17be6 Mon Sep 17 00:00:00 2001 From: Torsten Date: Sat, 2 Apr 2022 21:49:32 +0300 Subject: [PATCH 08/14] update server --- app/jobs/dns_update_job.rb | 6 +++++- config/deploy.rb | 2 +- spec/jobs/dns_update_job_spec.rb | 14 +++++++------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/jobs/dns_update_job.rb b/app/jobs/dns_update_job.rb index 06e32af..bff9e80 100644 --- a/app/jobs/dns_update_job.rb +++ b/app/jobs/dns_update_job.rb @@ -9,7 +9,7 @@ class DnsUpdateJob < ApplicationJob Rails.application.credentials.simple_id end def my_ip - HTTParty.get("http://icanhazip.com").strip + HTTParty.get("https://jsonip.com/")["ip"] end def find_record(name , host) @@ -17,6 +17,10 @@ class DnsUpdateJob < ApplicationJob zones.data.first end + def same_ip + my_ip == find_record("gateway" , "hubfeenix.fi").content + end + def update_ip record = find_record("gateway" , "hubfeenix.fi") client.zones.update_zone_record(simple_id,"hubfeenix.fi", record.id , content: my_ip) diff --git a/config/deploy.rb b/config/deploy.rb index c63bc71..c7fb40d 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -9,7 +9,7 @@ require 'mina/rbenv' # for rbenv support. (https://rbenv.org) # branch - Branch name to deploy. (needed by mina/git) set :application_name, 'gateway' -set :domain, 'web-server.local' +set :domain, '192.168.128.3' set :deploy_to, '/home/feenix/gateway' set :repository, "https://github.com/rubydesign/gateway.git" set :branch, 'passenger' diff --git a/spec/jobs/dns_update_job_spec.rb b/spec/jobs/dns_update_job_spec.rb index c79c8c3..03b3e1a 100644 --- a/spec/jobs/dns_update_job_spec.rb +++ b/spec/jobs/dns_update_job_spec.rb @@ -4,6 +4,13 @@ RSpec.describe DnsUpdateJob, type: :job do ActiveJob::Base.queue_adapter = :test let(:my_ip){"85.76.133.88"} + it "update ip" do + updater = DnsUpdateJob.new + updater.update_ip + zone = updater.find_record("gateway","hubfeenix.fi") + expect(zone.content).to eq my_ip + end + it "should get ip" do res = DnsUpdateJob.new.my_ip expect(res).to eq my_ip @@ -20,11 +27,4 @@ RSpec.describe DnsUpdateJob, type: :job do expect(zone.name).to eq "gateway" expect(zone.content).to eq my_ip end - - it "update ip" do - updater = DnsUpdateJob.new - updater.update_ip - zone = updater.find_record("gateway","hubfeenix.fi") - expect(zone.content).to eq my_ip - end end From 157cd60b04e8b2bf4a6ba30e4e1e924227f27af2 Mon Sep 17 00:00:00 2001 From: Torsten Date: Sat, 9 Apr 2022 11:42:56 +0300 Subject: [PATCH 09/14] update passenger --- Gemfile | 2 +- Gemfile.lock | 2 +- bin/edgeos_EdgeRouter_20220401.tar.gz | Bin 0 -> 16728 bytes 3 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 bin/edgeos_EdgeRouter_20220401.tar.gz diff --git a/Gemfile b/Gemfile index 61224c6..da5ea0b 100644 --- a/Gemfile +++ b/Gemfile @@ -16,7 +16,7 @@ gem "net-ssh" gem "haml-rails" gem 'high_voltage', '~> 3.1' -gem "passenger", require: "phusion_passenger/rack_handler" +gem "passenger", "6.0.13" , require: "phusion_passenger/rack_handler" gem "dnsimple" diff --git a/Gemfile.lock b/Gemfile.lock index 5e35626..4b09b3f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -321,7 +321,7 @@ DEPENDENCIES importmap-rails mina net-ssh - passenger + passenger (= 6.0.13) rack-mini-profiler rails (~> 7.0) rspec-rails (~> 5.0.0) diff --git a/bin/edgeos_EdgeRouter_20220401.tar.gz b/bin/edgeos_EdgeRouter_20220401.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..719a0a802dbc2d4f9061cb336e341df1db4cc88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%p1+CcPxeZxrc?XE+C`A z&n>s%;U~#*{3@&510eLYAoLCkVU^B72_gTEzbAwh-$|B>9xR(x2D-|9vih+j=+`3@ zIyEhpTu~}r?bqfptC~bD3{qwe{4_S5`UKlDC`GA&<_7 z9@fHDoft_?1?%^VmLmzW(5f>v`Fmu?`X1RY>^-^z*5f{I2$6pt2Ir3Jo=1E6A$-t9 zX3ix7E`x8UYtO+}*`s+ohgv$1_U-t#En|aEK;GD7%Vd&)Q~@VvZ4Ux2dMPJ)*_T~I zlCH?+3euG`Hl#C5qcgR+eRV5zqK2KgfwQpYi<%iEUcb6~NtD7wJq8Hy@-2Lf=vkBfzFWetS z&!(3@F8=zyc(ZaZ|Ldo3IySowYslVYGt?cU7EjlU7C@zvW1n;VX??yZirG2;!g;Y2 z6@j0-Uw8Dr&h)jnR?{C(SaQjOb`8q7?dOSIy4NoMxoc_t-F9|mWA!Dv0dEr|I@9H@rTZT`fl{^H2>ZUpB4XUZ@8)4{XgiU|Mizv dvCChV%w2c6beA6?j&l5eevN!4M+O5X1^{3|U|j$J literal 0 HcmV?d00001 From 61deb08b54e493bc49427d8bb0993b21e6680747 Mon Sep 17 00:00:00 2001 From: Torsten Date: Sat, 9 Apr 2022 11:49:54 +0300 Subject: [PATCH 10/14] fix io-wait --- Gemfile | 2 +- config/deploy.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index da5ea0b..69d4f13 100644 --- a/Gemfile +++ b/Gemfile @@ -17,7 +17,7 @@ gem "haml-rails" gem 'high_voltage', '~> 3.1' gem "passenger", "6.0.13" , require: "phusion_passenger/rack_handler" - +gem "io-wait" , "0.2.0" gem "dnsimple" # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] diff --git a/config/deploy.rb b/config/deploy.rb index c7fb40d..bd80985 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -9,7 +9,7 @@ require 'mina/rbenv' # for rbenv support. (https://rbenv.org) # branch - Branch name to deploy. (needed by mina/git) set :application_name, 'gateway' -set :domain, '192.168.128.3' +set :domain, '192.168.128.100' set :deploy_to, '/home/feenix/gateway' set :repository, "https://github.com/rubydesign/gateway.git" set :branch, 'passenger' From c39b2e39fdf91d11f2f3ca31449090e61995d714 Mon Sep 17 00:00:00 2001 From: Torsten Date: Sat, 9 Apr 2022 11:50:37 +0300 Subject: [PATCH 11/14] forgot bundle --- Gemfile.lock | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index 4b09b3f..2e292ff 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -139,7 +139,7 @@ GEM actionpack (>= 6.0.0) railties (>= 6.0.0) io-console (0.5.11) - io-wait (0.2.1) + io-wait (0.2.0) irb (1.4.1) reline (>= 0.3.0) listen (3.7.1) @@ -319,6 +319,7 @@ DEPENDENCIES haml-rails high_voltage (~> 3.1) importmap-rails + io-wait (= 0.2.0) mina net-ssh passenger (= 6.0.13) From 21bbc6dcd702351774fdb6d0b4b7df651fff3f5b Mon Sep 17 00:00:00 2001 From: Torsten Date: Sat, 9 Apr 2022 13:59:36 +0300 Subject: [PATCH 12/14] add whenever and make rake for dns update --- Gemfile | 2 ++ Gemfile.lock | 7 +++++++ config/deploy.rb | 1 + config/schedule.rb | 10 ++++++++++ {app/jobs => lib}/dns_update_job.rb | 17 +++++++---------- lib/tasks/dns.rake | 9 +++++++++ spec/jobs/dns_update_job_spec.rb | 20 ++++++++++---------- 7 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 config/schedule.rb rename {app/jobs => lib}/dns_update_job.rb (51%) create mode 100644 lib/tasks/dns.rake diff --git a/Gemfile b/Gemfile index 69d4f13..b5ba106 100644 --- a/Gemfile +++ b/Gemfile @@ -19,6 +19,7 @@ gem 'high_voltage', '~> 3.1' gem "passenger", "6.0.13" , require: "phusion_passenger/rack_handler" gem "io-wait" , "0.2.0" gem "dnsimple" +gem 'whenever', require: false # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # gem "image_processing", "~> 1.2" @@ -33,6 +34,7 @@ group :development do gem "web-console" gem "rack-mini-profiler" gem "mina" + gem 'mina-whenever' gem 'guard-rails' gem 'guard-rspec' end diff --git a/Gemfile.lock b/Gemfile.lock index 2e292ff..a4af6d5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -82,6 +82,7 @@ GEM regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) childprocess (4.1.0) + chronic (0.10.2) coderay (1.1.3) concurrent-ruby (1.1.10) crass (1.0.6) @@ -160,6 +161,8 @@ GEM mina (1.2.4) open4 (~> 1.3.4) rake + mina-whenever (1.0.1) + mina (~> 1.0) mini_mime (1.1.2) minitest (5.15.0) msgpack (1.4.5) @@ -302,6 +305,8 @@ GEM websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) + whenever (1.0.0) + chronic (>= 0.6.3) xpath (3.2.0) nokogiri (~> 1.8) zeitwerk (2.5.4) @@ -321,6 +326,7 @@ DEPENDENCIES importmap-rails io-wait (= 0.2.0) mina + mina-whenever net-ssh passenger (= 6.0.13) rack-mini-profiler @@ -333,6 +339,7 @@ DEPENDENCIES stimulus-rails web-console webdrivers + whenever RUBY VERSION ruby 3.0.3p157 diff --git a/config/deploy.rb b/config/deploy.rb index bd80985..d5bd9cf 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -60,6 +60,7 @@ task :deploy do in_path(fetch(:current_path)) do invoke :'passenger:restart' end + invoke :'whenever:update' end end diff --git a/config/schedule.rb b/config/schedule.rb new file mode 100644 index 0000000..7fd5ce8 --- /dev/null +++ b/config/schedule.rb @@ -0,0 +1,10 @@ +# Use this file to easily define all of your cron jobs. +# + +set :output, "/home/feenix/gateway/shared/log/whenever.log" + +every :hour do + rake "dns:update" +end + +# Learn more: http://github.com/javan/whenever diff --git a/app/jobs/dns_update_job.rb b/lib/dns_update_job.rb similarity index 51% rename from app/jobs/dns_update_job.rb rename to lib/dns_update_job.rb index bff9e80..b0a04dc 100644 --- a/app/jobs/dns_update_job.rb +++ b/lib/dns_update_job.rb @@ -1,6 +1,5 @@ require "dnsimple" -class DnsUpdateJob < ApplicationJob - queue_as :default +class DnsUpdateJob def client @client ||= Dnsimple::Client.new(access_token: Rails.application.credentials.simple_token) @@ -9,7 +8,7 @@ class DnsUpdateJob < ApplicationJob Rails.application.credentials.simple_id end def my_ip - HTTParty.get("https://jsonip.com/")["ip"] + @ip ||= HTTParty.get("https://jsonip.com/")["ip"] end def find_record(name , host) @@ -17,14 +16,12 @@ class DnsUpdateJob < ApplicationJob zones.data.first end - def same_ip - my_ip == find_record("gateway" , "hubfeenix.fi").content + def same_ip(name , host) + my_ip == find_record(name , host).content end - def update_ip - record = find_record("gateway" , "hubfeenix.fi") - client.zones.update_zone_record(simple_id,"hubfeenix.fi", record.id , content: my_ip) - end - def perform(*args) + def update_ip(name , host) + record = find_record(name , host) + client.zones.update_zone_record(simple_id, host , record.id , content: my_ip) end end diff --git a/lib/tasks/dns.rake b/lib/tasks/dns.rake new file mode 100644 index 0000000..7a3c03d --- /dev/null +++ b/lib/tasks/dns.rake @@ -0,0 +1,9 @@ +namespace :dns do + desc "Update own dyn dns records" + task update: :environment do + job = DnsUpdateJob.new + puts "My ip is #{job.my_ip}" + job.update_ip("gateway" , "hubfeenix.fi") + end + +end diff --git a/spec/jobs/dns_update_job_spec.rb b/spec/jobs/dns_update_job_spec.rb index 03b3e1a..5e64ee4 100644 --- a/spec/jobs/dns_update_job_spec.rb +++ b/spec/jobs/dns_update_job_spec.rb @@ -1,19 +1,18 @@ require 'rails_helper' +require "dns_update_job" -RSpec.describe DnsUpdateJob, type: :job do - ActiveJob::Base.queue_adapter = :test - let(:my_ip){"85.76.133.88"} +RSpec.describe DnsUpdateJob, type: :task do it "update ip" do updater = DnsUpdateJob.new - updater.update_ip - zone = updater.find_record("gateway","hubfeenix.fi") - expect(zone.content).to eq my_ip + updater.update_ip("dnsimple_test","hubfeenix.fi") + zone = updater.find_record("dnsimple_test","hubfeenix.fi") + expect(zone.content).to eq updater.my_ip end it "should get ip" do res = DnsUpdateJob.new.my_ip - expect(res).to eq my_ip + expect(res).to start_with "80" end it "should init client" do @@ -22,9 +21,10 @@ RSpec.describe DnsUpdateJob, type: :job do end it "should find domain" do - zone = DnsUpdateJob.new.find_record("gateway","hubfeenix.fi") + updater = DnsUpdateJob.new + zone = updater.find_record("dnsimple_test","hubfeenix.fi") expect(zone.class).to eq Dnsimple::Struct::ZoneRecord - expect(zone.name).to eq "gateway" - expect(zone.content).to eq my_ip + expect(zone.name).to eq "dnsimple_test" + expect(zone.content).to eq updater.my_ip end end From 04ec074bed1e7cf381d32c63ce486b4f13c25216 Mon Sep 17 00:00:00 2001 From: Torsten Date: Sat, 9 Apr 2022 14:04:12 +0300 Subject: [PATCH 13/14] move to pg --- Gemfile | 3 ++- Gemfile.lock | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index b5ba106..276d8d3 100644 --- a/Gemfile +++ b/Gemfile @@ -5,7 +5,6 @@ ruby "3.0.3" gem "rails", "~> 7.0" gem "sprockets-rails" -gem "sqlite3", "~> 1.4" gem "importmap-rails" gem "stimulus-rails" gem "bootsnap", require: false @@ -24,6 +23,8 @@ gem 'whenever', require: false # Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] # gem "image_processing", "~> 1.2" +gem "pg" + group :development, :test do # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem gem "debug", platforms: %i[ mri mingw x64_mingw ] diff --git a/Gemfile.lock b/Gemfile.lock index a4af6d5..8b87a77 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -194,6 +194,7 @@ GEM passenger (6.0.13) rack rake (>= 0.8.1) + pg (1.3.5) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) @@ -283,7 +284,6 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.4.2) stimulus-rails (1.0.4) railties (>= 6.0.0) strscan (3.0.1) @@ -329,13 +329,13 @@ DEPENDENCIES mina-whenever net-ssh passenger (= 6.0.13) + pg rack-mini-profiler rails (~> 7.0) rspec-rails (~> 5.0.0) sassc-rails selenium-webdriver sprockets-rails - sqlite3 (~> 1.4) stimulus-rails web-console webdrivers From ec037750b47626ad6116af910ecc4d51a29eac48 Mon Sep 17 00:00:00 2001 From: Torsten Date: Sat, 9 Apr 2022 14:08:37 +0300 Subject: [PATCH 14/14] pg config --- config/database.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/database.yml b/config/database.yml index fcba57f..a2ebaa9 100644 --- a/config/database.yml +++ b/config/database.yml @@ -5,21 +5,21 @@ # gem "sqlite3" # default: &default - adapter: sqlite3 - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> - timeout: 5000 + adapter: postgresql + encoding: unicode + user: postgres development: <<: *default - database: db/development.sqlite3 + database: gateway_test # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default - database: db/test.sqlite3 + database: gateway_dev production: <<: *default - database: db/production.sqlite3 + database: gateway_production