anchormodel 0.0.2 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -1
  3. data/CHANGELOG.md +11 -0
  4. data/Gemfile +3 -0
  5. data/Gemfile.lock +206 -0
  6. data/README.md +98 -9
  7. data/Rakefile +23 -3
  8. data/anchormodel.gemspec +26 -10
  9. data/bin/rails +7 -0
  10. data/doc/Anchormodel/ActiveModelTypeValue.html +14 -10
  11. data/doc/Anchormodel/Attribute.html +75 -71
  12. data/doc/Anchormodel/ModelMixin.html +190 -21
  13. data/doc/Anchormodel/Version.html +4 -4
  14. data/doc/Anchormodel.html +151 -53
  15. data/doc/_index.html +2 -2
  16. data/doc/file.README.html +118 -47
  17. data/doc/index.html +118 -47
  18. data/doc/method_list.html +9 -1
  19. data/doc/top-level-namespace.html +2 -2
  20. data/lib/anchormodel/active_model_type_value.rb +4 -4
  21. data/lib/anchormodel/attribute.rb +4 -9
  22. data/lib/anchormodel/model_mixin.rb +53 -3
  23. data/lib/anchormodel/version.rb +2 -2
  24. data/lib/anchormodel.rb +7 -2
  25. data/logo.svg +98 -0
  26. data/test/active_record_model/user_test.rb +115 -0
  27. data/test/dummy/.gitignore +29 -0
  28. data/test/dummy/Rakefile +6 -0
  29. data/test/dummy/app/anchormodels/locale.rb +6 -0
  30. data/test/dummy/app/anchormodels/role.rb +14 -0
  31. data/test/dummy/app/helpers/application_helper.rb +2 -0
  32. data/test/dummy/app/models/application_record.rb +5 -0
  33. data/test/dummy/app/models/concerns/.keep +0 -0
  34. data/test/dummy/app/models/user.rb +6 -0
  35. data/test/dummy/bin/rails +4 -0
  36. data/test/dummy/bin/rake +4 -0
  37. data/test/dummy/bin/setup +33 -0
  38. data/test/dummy/config/application.rb +37 -0
  39. data/test/dummy/config/boot.rb +3 -0
  40. data/test/dummy/config/credentials.yml.enc +1 -0
  41. data/test/dummy/config/database.yml +8 -0
  42. data/test/dummy/config/environment.rb +5 -0
  43. data/test/dummy/config/environments/test.rb +50 -0
  44. data/test/dummy/config/initializers/content_security_policy.rb +25 -0
  45. data/test/dummy/config/initializers/filter_parameter_logging.rb +8 -0
  46. data/test/dummy/config/initializers/inflections.rb +16 -0
  47. data/test/dummy/config/initializers/permissions_policy.rb +11 -0
  48. data/test/dummy/config/locales/en.yml +33 -0
  49. data/test/dummy/config/puma.rb +43 -0
  50. data/test/dummy/config/routes.rb +6 -0
  51. data/test/dummy/config.ru +6 -0
  52. data/test/dummy/db/migrate/20230107173151_create_users.rb +12 -0
  53. data/test/dummy/db/schema.rb +23 -0
  54. data/test/dummy/db/seeds.rb +7 -0
  55. data/test/dummy/lib/tasks/.keep +0 -0
  56. data/test/dummy/log/.keep +0 -0
  57. data/test/dummy/tmp/.keep +0 -0
  58. data/test/dummy/tmp/pids/.keep +0 -0
  59. data/test/test_helper.rb +21 -0
  60. metadata +149 -13
  61. data/anchormodel-0.0.1.gem +0 -0
@@ -0,0 +1,115 @@
1
+ class UserTest < Minitest::Test
2
+ def setup; end
3
+
4
+ def teardown
5
+ User.destroy_all
6
+ end
7
+
8
+ def test_retrieval
9
+ assert_equal Role.find(:guest), Role.find('guest')
10
+ end
11
+
12
+ def test_collections
13
+ # Order must fit as well
14
+ assert_equal(
15
+ %i[guest moderator admin the_chosen_one].map { |key| Role.find(key) },
16
+ Role.all
17
+ )
18
+ assert_equal(
19
+ %i[en de fr it].map { |key| Locale.find(key) },
20
+ Locale.all
21
+ )
22
+ end
23
+
24
+ def test_missing_key
25
+ assert_raises { Role.find(:does_not_exist) }
26
+ end
27
+
28
+ def test_basic_setters_and_getters
29
+ u = User.create!(role: 'guest', locale: 'de') # String assignment
30
+ assert_equal Role.find(:guest), u.role
31
+ assert_equal Locale.find(:de), u.locale
32
+ u.update!(role: :admin, locale: Locale.find(:en)) # Symbol and Anchormodel assignemnt
33
+ assert_equal Role.find(:admin), u.role
34
+ assert_equal Locale.find(:en), u.locale
35
+ end
36
+
37
+ def test_comparison
38
+ bob = User.create(locale: :en)
39
+ alice = User.create(locale: :fr)
40
+ celine = User.create(locale: :fr)
41
+ assert_equal(alice.locale, celine.locale)
42
+ assert bob.locale != alice.locale
43
+ end
44
+
45
+ def test_attributes
46
+ # Standalone
47
+ assert_equal 0, Role.find(:guest).privilege_level
48
+ # With a model
49
+ u = User.create(role: :the_chosen_one)
50
+ assert_equal 42, u.role.privilege_level
51
+ end
52
+
53
+ def test_custom_comparison
54
+ assert_equal(-1, Role.find(:moderator) <=> Role.find(:admin))
55
+ assert_equal(1, Role.find(:moderator) <=> Role.find(:guest))
56
+ assert_equal(0, Role.find(:moderator) <=> Role.find(:moderator))
57
+ assert Role.find(:moderator) < Role.find(:admin)
58
+ end
59
+
60
+ def test_presence_validation
61
+ valentine = User.new
62
+ assert_raises(ActiveRecord::RecordInvalid) { valentine.save! }
63
+ end
64
+
65
+ def test_alternative_column_name
66
+ ben = User.create!(
67
+ role: Role.find(:moderator),
68
+ secondary_role: Role.find(:admin),
69
+ locale: Locale.find(:de)
70
+ )
71
+ assert_equal(Role.find(:moderator), ben.role)
72
+ assert_equal(Role.find(:admin), ben.secondary_role)
73
+ assert_equal(Locale.find(:de), ben.locale)
74
+ end
75
+
76
+ def test_optional_attribute
77
+ jenny = User.create!(role: :admin, locale: :en)
78
+ assert_nil jenny.secondary_role
79
+ end
80
+
81
+ def test_model_readers_and_writers
82
+ pia = User.new
83
+ pia.admin!
84
+ assert_equal true, pia.admin?
85
+ assert_equal false, pia.guest?
86
+ assert_equal Role.find(:admin), pia.role
87
+ end
88
+
89
+ def test_model_scopes
90
+ User.create!(role: :admin, locale: :en)
91
+ User.create!(role: :admin, locale: :en)
92
+ User.create!(role: :moderator, locale: :en)
93
+ assert_equal 2, User.admin.count
94
+ assert_equal 1, User.moderator.count
95
+ assert_equal 0, User.guest.count
96
+ end
97
+
98
+ def test_model_readers_writers_with_different_class_name
99
+ pia = User.new(locale: :en)
100
+ pia.de!
101
+ assert_equal true, pia.de?
102
+ assert_equal false, pia.fr?
103
+ assert_equal Locale.find(:de), pia.preferred_locale
104
+ assert_equal Locale.find(:en), pia.locale
105
+ end
106
+
107
+ def test_model_scopes_with_different_class_name
108
+ User.create!(role: :admin, locale: :en, preferred_locale: :de)
109
+ User.create!(role: :admin, locale: :en, preferred_locale: :de)
110
+ User.create!(role: :admin, locale: :en, preferred_locale: :fr)
111
+ assert_equal 2, User.de.count
112
+ assert_equal 1, User.fr.count
113
+ assert_equal 0, User.en.count
114
+ end
115
+ end
@@ -0,0 +1,29 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-*
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*
16
+ /tmp/*
17
+ !/log/.keep
18
+ !/tmp/.keep
19
+
20
+ # Ignore pidfiles, but keep the directory.
21
+ /tmp/pids/*
22
+ !/tmp/pids/
23
+ !/tmp/pids/.keep
24
+
25
+
26
+ /public/assets
27
+
28
+ # Ignore master key for decrypting credentials and more.
29
+ /config/master.key
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,6 @@
1
+ class Locale < Anchormodel
2
+ new :en
3
+ new :de
4
+ new :fr
5
+ new :it
6
+ end
@@ -0,0 +1,14 @@
1
+ class Role < Anchormodel
2
+ include Comparable
3
+
4
+ attr_reader :privilege_level
5
+
6
+ new :guest, privilege_level: 0
7
+ new :moderator, privilege_level: 1
8
+ new :admin, privilege_level: 2
9
+ new :the_chosen_one, privilege_level: 42
10
+
11
+ def <=>(other)
12
+ @privilege_level <=> other.privilege_level
13
+ end
14
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,5 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ include Anchormodel::ModelMixin
3
+
4
+ primary_abstract_class
5
+ end
File without changes
@@ -0,0 +1,6 @@
1
+ class User < ApplicationRecord
2
+ belongs_to_anchormodel :role
3
+ belongs_to_anchormodel :secondary_role, Role, optional: true, model_readers: false, model_writers: false, model_scopes: false
4
+ belongs_to_anchormodel :locale, model_methods: false
5
+ belongs_to_anchormodel :preferred_locale, Locale
6
+ end
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../config/application', __dir__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+ require 'fileutils'
3
+
4
+ # path to your application root.
5
+ APP_ROOT = File.expand_path('..', __dir__)
6
+
7
+ def system!(*args)
8
+ system(*args) || abort("\n== Command #{args} failed ==")
9
+ end
10
+
11
+ FileUtils.chdir APP_ROOT do
12
+ # This script is a way to set up or update your development environment automatically.
13
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
14
+ # Add necessary setup steps to this file.
15
+
16
+ puts '== Installing dependencies =='
17
+ system! 'gem install bundler --conservative'
18
+ system('bundle check') || system!('bundle install')
19
+
20
+ # puts "\n== Copying sample files =="
21
+ # unless File.exist?("config/database.yml")
22
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
23
+ # end
24
+
25
+ puts "\n== Preparing database =="
26
+ system! 'bin/rails db:prepare'
27
+
28
+ puts "\n== Removing old logs and tempfiles =="
29
+ system! 'bin/rails log:clear tmp:clear'
30
+
31
+ puts "\n== Restarting application server =="
32
+ system! 'bin/rails restart'
33
+ end
@@ -0,0 +1,37 @@
1
+ require_relative 'boot'
2
+
3
+ require 'rails'
4
+ # Pick the frameworks you want:
5
+ require 'active_model/railtie'
6
+ # require "active_job/railtie"
7
+ require 'active_record/railtie'
8
+ # require "active_storage/engine"
9
+ # require "action_controller/railtie"
10
+ # require "action_mailer/railtie"
11
+ # require "action_mailbox/engine"
12
+ # require "action_text/engine"
13
+ # require "action_view/railtie"
14
+ # require "action_cable/engine"
15
+ # require "rails/test_unit/railtie"
16
+
17
+ # Require the gems listed in Gemfile, including any gems
18
+ # you've limited to :test, :development, or :production.
19
+ Bundler.require(*Rails.groups)
20
+
21
+ module Dummy
22
+ class Application < Rails::Application
23
+ # Initialize configuration defaults for originally generated Rails version.
24
+ config.load_defaults 7.0
25
+
26
+ # Configuration for the application, engines, and railties goes here.
27
+ #
28
+ # These settings can be overridden in specific environments using the files
29
+ # in config/environments, which are processed later.
30
+ #
31
+ # config.time_zone = "Central Time (US & Canada)"
32
+ # config.eager_load_paths << Rails.root.join("extras")
33
+
34
+ # Don't generate system test files.
35
+ config.generators.system_tests = nil
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
2
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
3
+ $LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
@@ -0,0 +1 @@
1
+ P7kFGwr6/RaXmQCebyeCrAyHgw+3lIjhK1w0ibCxdg5tKNHKbOq3EAC67l+QqSiww4eAKZ2ShT/dPBFXVNlYlwinxeap/Uu3ZulCjQdZT1GGnv8umlUsvznAe4FXJtBhEyKB60HRcTt/wwqDaz0uUeE1qQNpGbN4h7yQPlIPMMn+6XsBnY+32KYHhsZVwN92oQdR6hjwuethgN31HZtP+F97N3+HKbN9P/Nh778kOyZqZHdQygMWUuLM9ZoNOr8BsmUEonLGZB8stJThhu9sZQHGVafTXPMSw0P3cpPx/PfiU6rjQtOZGsc58e/i/VL6poF0Bd526VGaaHBCXj9rzb8HlgUWzCiJdBi52wVozf8ax9Fg/Rjx0NfVtryScyNvCQQaK/iRrPi3CWjOD0ldgjs7PkMTwvbO18i/--+VAjSXw8o2l4pFRL--EQZXxxTinNbA8IUp8M3i3w==
@@ -0,0 +1,8 @@
1
+ default: &default
2
+ adapter: sqlite3
3
+ pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
4
+ timeout: 5000
5
+
6
+ test:
7
+ <<: *default
8
+ database: db/development.sqlite3
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative 'application'
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,50 @@
1
+ require 'active_support/core_ext/integer/time'
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+
8
+ Rails.application.configure do
9
+ # Settings specified here will take precedence over those in config/application.rb.
10
+
11
+ # Turn false under Spring and add config.action_view.cache_template_loading = true.
12
+ config.cache_classes = true
13
+
14
+ # Eager loading loads your whole application. When running a single test locally,
15
+ # this probably isn't necessary. It's a good idea to do in a continuous integration
16
+ # system, or in some way before deploying your code.
17
+ config.eager_load = ENV['CI'].present?
18
+
19
+ # Configure public file server for tests with Cache-Control for performance.
20
+ config.public_file_server.enabled = true
21
+ config.public_file_server.headers = {
22
+ 'Cache-Control' => "public, max-age=#{1.hour.to_i}"
23
+ }
24
+
25
+ # Show full error reports and disable caching.
26
+ config.consider_all_requests_local = true
27
+ config.action_controller.perform_caching = false
28
+ config.cache_store = :null_store
29
+
30
+ # Raise exceptions instead of rendering exception templates.
31
+ config.action_dispatch.show_exceptions = false
32
+
33
+ # Disable request forgery protection in test environment.
34
+ config.action_controller.allow_forgery_protection = false
35
+
36
+ # Print deprecation notices to the stderr.
37
+ config.active_support.deprecation = :stderr
38
+
39
+ # Raise exceptions for disallowed deprecations.
40
+ config.active_support.disallowed_deprecation = :raise
41
+
42
+ # Tell Active Support which deprecation messages to disallow.
43
+ config.active_support.disallowed_deprecation_warnings = []
44
+
45
+ # Raises error for missing translations.
46
+ # config.i18n.raise_on_missing_translations = true
47
+
48
+ # Annotate rendered view with file names.
49
+ # config.action_view.annotate_rendered_view_with_filenames = true
50
+ end
@@ -0,0 +1,25 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Define an application-wide content security policy.
4
+ # See the Securing Rails Applications Guide for more information:
5
+ # https://guides.rubyonrails.org/security.html#content-security-policy-header
6
+
7
+ # Rails.application.configure do
8
+ # config.content_security_policy do |policy|
9
+ # policy.default_src :self, :https
10
+ # policy.font_src :self, :https, :data
11
+ # policy.img_src :self, :https, :data
12
+ # policy.object_src :none
13
+ # policy.script_src :self, :https
14
+ # policy.style_src :self, :https
15
+ # # Specify URI for violation reports
16
+ # # policy.report_uri "/csp-violation-report-endpoint"
17
+ # end
18
+ #
19
+ # # Generate session nonces for permitted importmap and inline scripts
20
+ # config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
21
+ # config.content_security_policy_nonce_directives = %w(script-src)
22
+ #
23
+ # # Report violations without enforcing the policy.
24
+ # # config.content_security_policy_report_only = true
25
+ # end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure parameters to be filtered from the log file. Use this to limit dissemination of
4
+ # sensitive information. See the ActiveSupport::ParameterFilter documentation for supported
5
+ # notations and behaviors.
6
+ Rails.application.config.filter_parameters += %i[
7
+ passw secret token _key crypt salt certificate otp ssn
8
+ ]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, "\\1en"
8
+ # inflect.singular /^(ox)en/i, "\\1"
9
+ # inflect.irregular "person", "people"
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym "RESTful"
16
+ # end
@@ -0,0 +1,11 @@
1
+ # Define an application-wide HTTP permissions policy. For further
2
+ # information see https://developers.google.com/web/updates/2018/06/feature-policy
3
+ #
4
+ # Rails.application.config.permissions_policy do |f|
5
+ # f.camera :none
6
+ # f.gyroscope :none
7
+ # f.microphone :none
8
+ # f.usb :none
9
+ # f.fullscreen :self
10
+ # f.payment :self, "https://secure.example.com"
11
+ # end
@@ -0,0 +1,33 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t "hello"
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t("hello") %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # The following keys must be escaped otherwise they will not be retrieved by
20
+ # the default I18n backend:
21
+ #
22
+ # true, false, on, off, yes, no
23
+ #
24
+ # Instead, surround them with single quotes.
25
+ #
26
+ # en:
27
+ # "true": "foo"
28
+ #
29
+ # To learn more, please read the Rails Internationalization guide
30
+ # available at https://guides.rubyonrails.org/i18n.html.
31
+
32
+ en:
33
+ hello: "Hello world"
@@ -0,0 +1,43 @@
1
+ # Puma can serve each request in a thread from an internal thread pool.
2
+ # The `threads` method setting takes two numbers: a minimum and maximum.
3
+ # Any libraries that use thread pools should be configured to match
4
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
5
+ # and maximum; this matches the default thread size of Active Record.
6
+ #
7
+ max_threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
8
+ min_threads_count = ENV.fetch('RAILS_MIN_THREADS') { max_threads_count }
9
+ threads min_threads_count, max_threads_count
10
+
11
+ # Specifies the `worker_timeout` threshold that Puma will use to wait before
12
+ # terminating a worker in development environments.
13
+ #
14
+ worker_timeout 3600 if ENV.fetch('RAILS_ENV', 'development') == 'development'
15
+
16
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17
+ #
18
+ port ENV.fetch('PORT', 3000)
19
+
20
+ # Specifies the `environment` that Puma will run in.
21
+ #
22
+ environment ENV.fetch('RAILS_ENV') { 'development' }
23
+
24
+ # Specifies the `pidfile` that Puma will use.
25
+ pidfile ENV.fetch('PIDFILE') { 'tmp/pids/server.pid' }
26
+
27
+ # Specifies the number of `workers` to boot in clustered mode.
28
+ # Workers are forked web server processes. If using threads and workers together
29
+ # the concurrency of the application would be max `threads` * `workers`.
30
+ # Workers do not work on JRuby or Windows (both of which do not support
31
+ # processes).
32
+ #
33
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34
+
35
+ # Use the `preload_app!` method when specifying a `workers` number.
36
+ # This directive tells Puma to first boot the application and load code
37
+ # before forking the application. This takes advantage of Copy On Write
38
+ # process behavior so workers use less memory.
39
+ #
40
+ # preload_app!
41
+
42
+ # Allow puma to be restarted by `bin/rails restart` command.
43
+ plugin :tmp_restart
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ # Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
3
+
4
+ # Defines the root path route ("/")
5
+ # root "articles#index"
6
+ end
@@ -0,0 +1,6 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require_relative 'config/environment'
4
+
5
+ run Rails.application
6
+ Rails.application.load_server
@@ -0,0 +1,12 @@
1
+ class CreateUsers < ActiveRecord::Migration[7.0]
2
+ def change
3
+ create_table :users do |t|
4
+ t.string :role
5
+ t.string :secondary_role
6
+ t.string :locale
7
+ t.string :preferred_locale, null: false, default: :en
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # This file is the source Rails uses to define your schema when running `bin/rails
6
+ # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
7
+ # be faster and is potentially less error prone than running all of your
8
+ # migrations from scratch. Old migrations may fail to apply correctly if those
9
+ # migrations use external dependencies or application code.
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema[7.0].define(version: 2023_01_24_084241) do
14
+ create_table "users", force: :cascade do |t|
15
+ t.string "role"
16
+ t.string "locale"
17
+ t.datetime "created_at", null: false
18
+ t.datetime "updated_at", null: false
19
+ t.string "secondary_role"
20
+ t.string "preferred_locale", default: "en", null: false
21
+ end
22
+
23
+ end
@@ -0,0 +1,7 @@
1
+ # This file should contain all the record creation needed to seed the database with its default values.
2
+ # The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
3
+ #
4
+ # Examples:
5
+ #
6
+ # movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
7
+ # Character.create(name: "Luke", movie: movies.first)
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,21 @@
1
+ # Configure Rails Environment
2
+ ENV['RAILS_ENV'] = 'test'
3
+ ENV['RAILS_ROOT'] ||= "#{File.dirname(__FILE__)}../../../test/dummy"
4
+
5
+ require_relative '../test/dummy/config/environment'
6
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path('../test/dummy/db/migrate', __dir__)]
7
+ require 'rails/test_help'
8
+
9
+ # Filter out the backtrace from minitest while preserving the one from other libraries.
10
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
11
+
12
+ require 'rails/test_unit/reporter'
13
+ Rails::TestUnitReporter.executable = 'bin/test'
14
+
15
+ # Load fixtures from the engine
16
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
17
+ ActiveSupport::TestCase.fixture_path = File.expand_path('fixtures', __dir__)
18
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
19
+ ActiveSupport::TestCase.file_fixture_path = "#{ActiveSupport::TestCase.fixture_path}/files"
20
+ ActiveSupport::TestCase.fixtures :all
21
+ end