merge
This commit is contained in:
commit
9942229185
13
Gemfile
13
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
|
||||
@ -16,21 +15,29 @@ gem "net-ssh"
|
||||
gem "haml-rails"
|
||||
gem 'high_voltage', '~> 3.1'
|
||||
|
||||
gem "puma" , "4.3.10"
|
||||
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"
|
||||
|
||||
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 ]
|
||||
gem 'rspec-rails', '~> 5.0.0'
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem "web-console"
|
||||
gem "rack-mini-profiler"
|
||||
gem "mina"
|
||||
gem "mina-puma"
|
||||
gem 'mina-whenever'
|
||||
gem 'guard-rails'
|
||||
gem 'guard-rspec'
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
94
Gemfile.lock
94
Gemfile.lock
@ -82,17 +82,40 @@ 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)
|
||||
debug (1.4.0)
|
||||
irb (>= 1.3.6)
|
||||
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)
|
||||
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
|
||||
@ -108,32 +131,43 @@ 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)
|
||||
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)
|
||||
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)
|
||||
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
|
||||
mina-puma (1.1.0)
|
||||
mina (~> 1.2.0)
|
||||
puma (>= 2.13)
|
||||
mina-whenever (1.0.1)
|
||||
mina (~> 1.0)
|
||||
mini_mime (1.1.2)
|
||||
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
|
||||
@ -153,10 +187,18 @@ 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)
|
||||
pg (1.3.5)
|
||||
pry (0.14.1)
|
||||
coderay (~> 1.1)
|
||||
method_source (~> 1.0)
|
||||
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)
|
||||
@ -190,10 +232,34 @@ 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)
|
||||
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)
|
||||
@ -210,6 +276,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)
|
||||
@ -217,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)
|
||||
@ -239,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)
|
||||
@ -250,22 +318,28 @@ DEPENDENCIES
|
||||
bootsnap
|
||||
capybara
|
||||
debug
|
||||
dnsimple
|
||||
guard-rails
|
||||
guard-rspec
|
||||
haml-rails
|
||||
high_voltage (~> 3.1)
|
||||
importmap-rails
|
||||
io-wait (= 0.2.0)
|
||||
mina
|
||||
mina-puma
|
||||
mina-whenever
|
||||
net-ssh
|
||||
puma (= 4.3.10)
|
||||
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
|
||||
whenever
|
||||
|
||||
RUBY VERSION
|
||||
ruby 3.0.3p157
|
||||
|
31
Guardfile
Normal file
31
Guardfile
Normal file
@ -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
|
@ -1 +1,4 @@
|
||||
%h1 Hello again
|
||||
%h1 Hello Gateway
|
||||
|
||||
%p
|
||||
Gateway to what? And so you may well ask . . .
|
||||
|
BIN
bin/edgeos_EdgeRouter_20220401.tar.gz
Normal file
BIN
bin/edgeos_EdgeRouter_20220401.tar.gz
Normal file
Binary file not shown.
@ -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
|
||||
|
@ -10,10 +10,10 @@ require "mina/whenever"
|
||||
# branch - Branch name to deploy. (needed by mina/git)
|
||||
|
||||
set :application_name, 'gateway'
|
||||
set :domain, 'web-server.local'
|
||||
set :domain, '192.168.128.100'
|
||||
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,8 +59,9 @@ task :deploy do
|
||||
|
||||
on :launch do
|
||||
in_path(fetch(:current_path)) do
|
||||
invoke :'puma:hard_restart'
|
||||
invoke :'passenger:restart'
|
||||
end
|
||||
invoke :'whenever:update'
|
||||
end
|
||||
end
|
||||
|
||||
@ -68,6 +69,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
|
||||
|
@ -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
|
10
config/schedule.rb
Normal file
10
config/schedule.rb
Normal file
@ -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
|
27
lib/dns_update_job.rb
Normal file
27
lib/dns_update_job.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require "dnsimple"
|
||||
class DnsUpdateJob
|
||||
|
||||
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
|
||||
@ip ||= HTTParty.get("https://jsonip.com/")["ip"]
|
||||
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 same_ip(name , host)
|
||||
my_ip == find_record(name , host).content
|
||||
end
|
||||
|
||||
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
|
9
lib/tasks/dns.rake
Normal file
9
lib/tasks/dns.rake
Normal file
@ -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
|
9
spec/features/pages_spec.rb
Normal file
9
spec/features/pages_spec.rb
Normal file
@ -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
|
30
spec/jobs/dns_update_job_spec.rb
Normal file
30
spec/jobs/dns_update_job_spec.rb
Normal file
@ -0,0 +1,30 @@
|
||||
require 'rails_helper'
|
||||
require "dns_update_job"
|
||||
|
||||
RSpec.describe DnsUpdateJob, type: :task do
|
||||
|
||||
it "update ip" do
|
||||
updater = DnsUpdateJob.new
|
||||
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 start_with "80"
|
||||
end
|
||||
|
||||
it "should init client" do
|
||||
client = DnsUpdateJob.new.client
|
||||
expect(client.class).to be Dnsimple::Client
|
||||
end
|
||||
|
||||
it "should find domain" do
|
||||
updater = DnsUpdateJob.new
|
||||
zone = updater.find_record("dnsimple_test","hubfeenix.fi")
|
||||
expect(zone.class).to eq Dnsimple::Struct::ZoneRecord
|
||||
expect(zone.name).to eq "dnsimple_test"
|
||||
expect(zone.content).to eq updater.my_ip
|
||||
end
|
||||
end
|
64
spec/rails_helper.rb
Normal file
64
spec/rails_helper.rb
Normal file
@ -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
|
96
spec/spec_helper.rb
Normal file
96
spec/spec_helper.rb
Normal file
@ -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"
|
31
spec/support/request_helper.rb
Normal file
31
spec/support/request_helper.rb
Normal file
@ -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
|
@ -1,5 +0,0 @@
|
||||
require "test_helper"
|
||||
|
||||
class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||
driven_by :selenium, using: :chrome, screen_size: [1400, 1400]
|
||||
end
|
@ -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
|
0
test/fixtures/files/.keep
vendored
0
test/fixtures/files/.keep
vendored
@ -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
|
Loading…
Reference in New Issue
Block a user