eac_rails_utils 0.12.1 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 073522cee9ea661c5e7904a6d59d433cf5778a894d714f4c7a557dc6e6624485
4
- data.tar.gz: e3e27609574ad571772fcea4993c2ce79fafbc946a9229ad5dcc0367a1a9ef5c
3
+ metadata.gz: 88a56887267261f2552a66ec8d52a9198be27aedc0dcf17929cd9b37800d90a5
4
+ data.tar.gz: 8dfae899c7cbde6ea7935e482f1568154ef4d14f7a312740bb71f69bd8f2a20d
5
5
  SHA512:
6
- metadata.gz: af37d4d4cf954c3129f5665ad7c4e1ce2705e3388e6eac9dd723753c1c6747c56393d446d104b2a4f61dd02e2c0e8c8a7bcebd403b3e2e927d57abc5068fb3fe
7
- data.tar.gz: 9fda204909c22767dc38ee2bb4773d4c68ad31a178733a3580679c1f5f6d87c1a9901d93a23b46c2d8eaf92d00e71112c082651becfc7ee7b614997e3b32ad9b
6
+ metadata.gz: c6eafd597cae6299dfcc6b3da6d13cd67ae2c596c275d68c5820464203d6a4828e9d66f85a22a644c52fc272324b5ae95925e3d3cde73fdc1fe99e11ca1e7e80
7
+ data.tar.gz: 9c413abc77ce04328afef5ad36fae4e45d2f07de827fff960f32942ece93a8e224fa4209ecf8eb4b133d92a287d559c014279d5c7b184dd81a1c59a49ac3928c
data/Rakefile CHANGED
@@ -7,14 +7,3 @@ rescue LoadError
7
7
  end
8
8
 
9
9
  Bundler::GemHelper.install_tasks
10
-
11
- require 'rake/testtask'
12
-
13
- Rake::TestTask.new(:test) do |t|
14
- t.libs << 'lib'
15
- t.libs << 'test'
16
- t.pattern = 'test/**/*_test.rb'
17
- t.verbose = false
18
- end
19
-
20
- task default: :test
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRailsUtils
6
+ module EngineHelper
7
+ common_concern do
8
+ append_self_migrations
9
+ end
10
+
11
+ module ClassMethods
12
+ def append_self_migrations
13
+ initializer :append_migrations do |app|
14
+ config.paths['db/migrate'].expanded.each do |expanded_path|
15
+ app.config.paths['db/migrate'] << expanded_path
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsUtils
4
- VERSION = '0.12.1'
4
+ VERSION = '0.13.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rails_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.1
4
+ version: 0.13.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - E.A.C.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-16 00:00:00.000000000 Z
11
+ date: 2021-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel-associations
@@ -44,14 +44,20 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.49'
47
+ version: '0.56'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 0.56.1
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
55
  - - "~>"
53
56
  - !ruby/object:Gem::Version
54
- version: '0.49'
57
+ version: '0.56'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 0.56.1
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: htmlbeautifier
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +78,14 @@ dependencies:
72
78
  requirements:
73
79
  - - ">="
74
80
  - !ruby/object:Gem::Version
75
- version: 4.2.11.1
81
+ version: 4.2.11
76
82
  type: :runtime
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
86
  - - ">="
81
87
  - !ruby/object:Gem::Version
82
- version: 4.2.11.1
88
+ version: 4.2.11
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: virtus
85
91
  requirement: !ruby/object:Gem::Requirement
@@ -109,7 +115,7 @@ dependencies:
109
115
  - !ruby/object:Gem::Version
110
116
  version: '0'
111
117
  - !ruby/object:Gem::Dependency
112
- name: eac_ruby_gem_support
118
+ name: eac_rails_gem_support
113
119
  requirement: !ruby/object:Gem::Requirement
114
120
  requirements:
115
121
  - - "~>"
@@ -122,34 +128,6 @@ dependencies:
122
128
  - - "~>"
123
129
  - !ruby/object:Gem::Version
124
130
  version: '0.1'
125
- - !ruby/object:Gem::Dependency
126
- name: rspec-rails
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: sqlite3
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 1.3.13
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: 1.3.13
153
131
  description:
154
132
  email:
155
133
  executables: []
@@ -206,6 +184,7 @@ files:
206
184
  - lib/assets/stylesheets/jmenu.scss
207
185
  - lib/eac_rails_utils.rb
208
186
  - lib/eac_rails_utils/engine.rb
187
+ - lib/eac_rails_utils/engine_helper.rb
209
188
  - lib/eac_rails_utils/htmlbeautifier.rb
210
189
  - lib/eac_rails_utils/models.rb
211
190
  - lib/eac_rails_utils/models/fetch_errors.rb
@@ -217,29 +196,6 @@ files:
217
196
  - lib/eac_rails_utils/patches/action_controller_base.rb
218
197
  - lib/eac_rails_utils/patches/active_model_associations.rb
219
198
  - lib/eac_rails_utils/version.rb
220
- - test/dummy/Rakefile
221
- - test/dummy/app/assets/config/manifest.js
222
- - test/dummy/app/models/job.rb
223
- - test/dummy/app/models/user.rb
224
- - test/dummy/bin/rails
225
- - test/dummy/config.ru
226
- - test/dummy/config/application.rb
227
- - test/dummy/config/boot.rb
228
- - test/dummy/config/database.yml
229
- - test/dummy/config/environment.rb
230
- - test/dummy/config/environments/test.rb
231
- - test/dummy/config/locales/pt-BR.yml
232
- - test/dummy/config/routes.rb
233
- - test/dummy/config/secrets.yml
234
- - test/dummy/db/migrate/20160415125333_create_users.rb
235
- - test/dummy/db/migrate/20160415143123_create_jobs.rb
236
- - test/dummy/db/migrate/20160415143229_add_job_to_users.rb
237
- - test/dummy/db/schema.rb
238
- - test/helpers/eac_rails_utils/data_table_test_helper_test.rb
239
- - test/helpers/eac_rails_utils/formatter_helper_test.rb
240
- - test/lib/eac_rails_utils/models/fetch_errors_test.rb
241
- - test/test_helper.rb
242
- - test/validators/cpf_validator_test.rb
243
199
  homepage:
244
200
  licenses: []
245
201
  metadata: {}
@@ -258,31 +214,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
258
214
  - !ruby/object:Gem::Version
259
215
  version: '0'
260
216
  requirements: []
261
- rubygems_version: 3.0.8
217
+ rubygems_version: 3.1.6
262
218
  signing_key:
263
219
  specification_version: 4
264
220
  summary: Código reutilizável para as aplicações Rails da E.A.C..
265
- test_files:
266
- - test/dummy/Rakefile
267
- - test/dummy/config.ru
268
- - test/dummy/config/boot.rb
269
- - test/dummy/config/database.yml
270
- - test/dummy/config/secrets.yml
271
- - test/dummy/config/locales/pt-BR.yml
272
- - test/dummy/config/application.rb
273
- - test/dummy/config/environments/test.rb
274
- - test/dummy/config/environment.rb
275
- - test/dummy/config/routes.rb
276
- - test/dummy/db/schema.rb
277
- - test/dummy/db/migrate/20160415143123_create_jobs.rb
278
- - test/dummy/db/migrate/20160415143229_add_job_to_users.rb
279
- - test/dummy/db/migrate/20160415125333_create_users.rb
280
- - test/dummy/app/models/job.rb
281
- - test/dummy/app/models/user.rb
282
- - test/dummy/app/assets/config/manifest.js
283
- - test/dummy/bin/rails
284
- - test/test_helper.rb
285
- - test/validators/cpf_validator_test.rb
286
- - test/helpers/eac_rails_utils/data_table_test_helper_test.rb
287
- - test/helpers/eac_rails_utils/formatter_helper_test.rb
288
- - test/lib/eac_rails_utils/models/fetch_errors_test.rb
221
+ test_files: []
data/test/dummy/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Add your own tasks in files placed in lib/tasks ending in .rake,
4
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
5
-
6
- require File.expand_path('config/application', __dir__)
7
-
8
- Rails.application.load_tasks
@@ -1,3 +0,0 @@
1
- //= link_tree ../images
2
- //= link_directory ../javascripts .js
3
- //= link_directory ../stylesheets .css
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class Job < ActiveRecord::Base
4
- has_many :users
5
- accepts_nested_attributes_for :users, reject_if: :all_blank, allow_destroy: true
6
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class User < ActiveRecord::Base
4
- belongs_to :job
5
-
6
- validates :job, presence: true
7
- validates :password, presence: true
8
- validates :email, format: { with: /\A[^@\s]+@[^@\s]+\z/ }
9
- end
data/test/dummy/bin/rails DELETED
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- APP_PATH = File.expand_path('../config/application', __dir__)
5
- require_relative '../config/boot'
6
- require 'rails/commands'
data/test/dummy/config.ru DELETED
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # This file is used by Rack-based servers to start the application.
4
-
5
- require ::File.expand_path('../config/environment', __FILE__)
6
- run Rails.application
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require File.expand_path('boot', __dir__)
4
-
5
- require 'rails/all'
6
-
7
- Bundler.require(*Rails.groups)
8
- require 'eac_rails_utils'
9
-
10
- module Dummy
11
- class Application < Rails::Application
12
- config.active_record.raise_in_transactional_callbacks = true if ::Rails.version < '5'
13
- end
14
- end
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Set up gems listed in the Gemfile.
4
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
5
-
6
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
@@ -1,5 +0,0 @@
1
- test:
2
- adapter: sqlite3
3
- pool: 5
4
- timeout: 5000
5
- database: db/test.sqlite3
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Load the Rails application.
4
- require File.expand_path('application', __dir__)
5
-
6
- # Initialize the Rails application.
7
- Rails.application.initialize!
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.application.configure do
4
- # Settings specified here will take precedence over those in config/application.rb.
5
-
6
- # The test environment is used exclusively to run your application's
7
- # test suite. You never need to work with it otherwise. Remember that
8
- # your test database is "scratch space" for the test suite and is wiped
9
- # and recreated between test runs. Don't rely on the data there!
10
- config.cache_classes = true
11
-
12
- # Do not eager load code on boot. This avoids loading your whole application
13
- # just for the purpose of running a single test. If you are using a tool that
14
- # preloads Rails for running tests, you may have to set it to true.
15
- config.eager_load = false
16
-
17
- # Configure static file server for tests with Cache-Control for performance.
18
- config.serve_static_files = true
19
- config.static_cache_control = 'public, max-age=3600'
20
-
21
- # Show full error reports and disable caching.
22
- config.consider_all_requests_local = true
23
- config.action_controller.perform_caching = false
24
-
25
- # Raise exceptions instead of rendering exception templates.
26
- config.action_dispatch.show_exceptions = false
27
-
28
- # Disable request forgery protection in test environment.
29
- config.action_controller.allow_forgery_protection = false
30
-
31
- # Tell Action Mailer not to deliver emails to the real world.
32
- # The :test delivery method accumulates sent emails in the
33
- # ActionMailer::Base.deliveries array.
34
- config.action_mailer.delivery_method = :test
35
-
36
- # Randomize the order test cases are executed.
37
- config.active_support.test_order = :random
38
-
39
- # Print deprecation notices to the stderr.
40
- config.active_support.deprecation = :stderr
41
-
42
- # Raises error for missing translations
43
- # config.action_view.raise_on_missing_translations = true
44
- end
@@ -1,38 +0,0 @@
1
- pt-BR:
2
- eac:
3
- listable:
4
- eac/listable_test/stub:
5
- inteiro:
6
- a:
7
- label: Inteiro A
8
- description: Inteiro A Descr.
9
- b:
10
- label: Inteiro BB
11
- description: Inteiro BB Descr.
12
- c:
13
- label: Inteiro CCC
14
- description: Inteiro CCC Descr.
15
- cadeia:
16
- a:
17
- label: Cadeia AAA
18
- description: Cadeia AAA Descr.
19
- b:
20
- label: Cadeia BB
21
- description: Cadeia BB Descr.
22
- c:
23
- label: Cadeia C
24
- description: Cadeia C Descr.
25
- code:
26
- a:
27
- label: Código A
28
- description: Código A Descr.
29
- b:
30
- label: Código B
31
- description: Código B Descr.
32
- type:
33
- a:
34
- label: Tipo A
35
- description: Tipo A Descr.
36
- b:
37
- label: Tipo B
38
- description: Tipo B Descr.
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Rails.application.routes.draw do
4
- resources :jobs do
5
- collection do
6
- get 'search'
7
- end
8
- end
9
- resources :users
10
- end
@@ -1,22 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key is used for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
-
6
- # Make sure the secret is at least 30 characters and all random,
7
- # no regular words or you'll be exposed to dictionary attacks.
8
- # You can use `rake secret` to generate a secure secret key.
9
-
10
- # Make sure the secrets in this file are kept private
11
- # if you're sharing your code publicly.
12
-
13
- development:
14
- secret_key_base: 50d3bce23e309d961dafde3edfa89be2713718a5e2fb75b6c3e1f61826230921535243d2f221b8cecebeaceccb574a1e74fbbf3b89a9d53758ac988950f1753c
15
-
16
- test:
17
- secret_key_base: 75f37392ef7726b50b4ce117bd6a7eca7cdc299608e256f7ca163b14032559217364d41b7c091483ce02179a18c956f6e076331a611c0500f2862f83979a6c16
18
-
19
- # Do not keep production secrets in the repository,
20
- # instead read values from the environment.
21
- production:
22
- secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateUsers < (
4
- Rails.version < '5' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
5
- )
6
- def change
7
- create_table :users do |t|
8
- t.string :name
9
- t.string :email
10
- t.string :password
11
- end
12
- end
13
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateJobs < (
4
- Rails.version < '5' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
5
- )
6
- def change
7
- create_table :jobs do |t|
8
- t.string :name
9
- end
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class AddJobToUsers < (
4
- Rails.version < '5' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
5
- )
6
- def change
7
- add_belongs_to :users, :job
8
- end
9
- end
@@ -1,25 +0,0 @@
1
- # encoding: UTF-8
2
- # This file is auto-generated from the current state of the database. Instead
3
- # of editing this file, please use the migrations feature of Active Record to
4
- # incrementally modify your database, and then regenerate this schema definition.
5
- #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
11
- #
12
- # It's strongly recommended that you check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(version: 20_160_415_143_229) do
15
- create_table 'jobs', force: :cascade do |t|
16
- t.string 'name'
17
- end
18
-
19
- create_table 'users', force: :cascade do |t|
20
- t.string 'name'
21
- t.string 'email'
22
- t.string 'password'
23
- t.integer 'job_id'
24
- end
25
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- module EacRailsUtils
6
- class DataTableTestHelperTest < ActionView::TestCase
7
- include ::EacRailsUtils::DataTableHelper
8
-
9
- class Person
10
- attr_reader :name, :age, :job
11
-
12
- def initialize(name, age, job)
13
- @name = name
14
- @age = age
15
- @job = job
16
- end
17
- end
18
-
19
- class Job
20
- attr_reader :name, :id
21
-
22
- def initialize(name)
23
- @name = name
24
- @id = SecureRandom.random_number(100_000)
25
- end
26
- end
27
-
28
- def test_data_table
29
- ds = []
30
- ds << Person.new('Fulano', 15, Job.new('Padeiro'))
31
- ds << Person.new('Sicrano', 25, nil)
32
-
33
- data_table(ds) do |s|
34
- s.paging = false
35
- s.column('Name', 'name')
36
- s.column('Age', 'age')
37
- s.column('Name + Age') { |v| "#{v.name} + #{v.age}" }
38
- s.column('Job', 'job')
39
- s.column('Job ID', 'job.id')
40
- s.column('Job ID + 10', 'job.id') { |_v| + 10 }
41
- end
42
- end
43
- end
44
- end
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- module EacRailsUtils
6
- class FormatterHelperTest < ActionView::TestCase
7
- include ::EacRailsUtils::FormatterHelper
8
-
9
- test 'should convert BRL currency to float' do
10
- brl_currency = { a: '1', b: '1,2', c: '1,23', d: '123.456.789,01',
11
- e: 'R$1,23', f: 'R$ 123.4,56' }
12
- float_currency = { a: 1, b: 1.2, c: 1.23, d: 123_456_789.01,
13
- e: 1.23, f: 123_4.56 }
14
-
15
- brl_currency.each do |k, v|
16
- assert_equal float_currency[k], brl_currency_to_float(v),
17
- "#{v} should be #{float_currency[k]}"
18
- end
19
- end
20
- end
21
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- module EacRailsUtils
6
- module Models
7
- class FetchErrorsTest < ActiveSupport::TestCase
8
- class M1
9
- include ActiveModel::Model
10
- include EacRailsUtils::Models::FetchErrors
11
- attr_accessor :name, :age, :account, :country_id, :other
12
- end
13
-
14
- class M2
15
- include ActiveModel::Model
16
- attr_accessor :name, :myage, :account_id, :country
17
-
18
- validate :my_validate
19
-
20
- def my_validate
21
- errors.add(:name, 'NAME_ERROR')
22
- errors.add(:myage, 'MYAGE_ERROR')
23
- errors.add(:account_id, 'ACCOUNT_ID_ERROR')
24
- errors.add(:country, 'COUNTRY_ERROR')
25
- end
26
- end
27
-
28
- def setup
29
- reset_m1
30
- reset_m2
31
- end
32
-
33
- def test_fetch_column_errors
34
- @m1.fetch_column_errors(@m2, :myage, :age)
35
- assert_equal @m2.errors[:myage], @m1.errors[:age]
36
- end
37
-
38
- def test_fetch_record_errors
39
- @m1.fetch_record_errors(@m2)
40
- { name: :name, account_id: :account, country: :country_id }.each do |c2, c1|
41
- assert_equal @m2.errors[c2], @m1.errors[c1], "c2: #{c2}, c1: #{c1}"
42
- end
43
- assert @m1.errors[:age].empty?
44
- end
45
-
46
- def test_fetch_record_errors_with_default_column
47
- @m1.fetch_record_errors(@m2, default_column: :other)
48
- assert_equal @m2.errors[:name], @m1.errors[:name]
49
- assert @m1.errors[:age].empty?
50
- assert_equal ['Myage: MYAGE_ERROR'], @m1.errors[:other]
51
- end
52
-
53
- def test_fetch_record_errors_with_skip_option
54
- @m1.fetch_record_errors(@m2, skip: [:name])
55
- assert @m1.errors[:name].empty?
56
- assert @m1.errors[:age].empty?
57
- end
58
-
59
- def test_fetch_record_errors_by_mapping
60
- @m1.fetch_record_errors_by_mapping(@m2, name: :name, myage: :age)
61
- assert_equal @m2.errors[:name], @m1.errors[:name]
62
- assert_equal @m2.errors[:myage], @m1.errors[:age]
63
- end
64
-
65
- private
66
-
67
- def reset_m1
68
- @m1 = M1.new
69
- assert @m1.errors.empty?
70
- end
71
-
72
- def reset_m2
73
- @m2 = M2.new
74
- assert_not @m2.valid?
75
- assert_not @m2.errors[:name].empty?
76
- assert_not @m2.errors[:myage].empty?
77
- end
78
- end
79
- end
80
- end
data/test/test_helper.rb DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- ENV['RAILS_ENV'] = 'test'
4
- require File.expand_path('../test/dummy/config/environment.rb', __dir__)
5
- require 'rails/test_help'
6
-
7
- module ActiveSupport
8
- class TestCase
9
- def reset_test_database
10
- ActiveRecord::Tasks::DatabaseTasks.load_schema_current(:ruby, ENV['SCHEMA'])
11
- end
12
- end
13
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'test_helper'
4
-
5
- module EacRailsUtils
6
- class CpfValidatorTest < ActiveSupport::TestCase
7
- class M1
8
- include ActiveModel::Model
9
-
10
- attr_accessor :cpf
11
-
12
- validates :cpf, 'eac_rails_utils/cpf' => true, allow_nil: true
13
- end
14
-
15
- def setup
16
- @record = M1.new
17
- end
18
-
19
- def test_valid_cpfs
20
- ['85630275305', '66244374487', nil].each do |v|
21
- @record.cpf = v
22
- @record.valid?
23
- assert_equal [], @record.errors[:cpf], "CPF: \"#{v}\""
24
- end
25
- end
26
-
27
- def test_invalid_cpfs
28
- ['', ' ', 'abc', '856.302.753-05', '662.443.744-87', '85630275304'].each do |v|
29
- @record.cpf = v
30
- @record.valid?
31
- assert_not_equal [], @record.errors[:cpf], "CPF: \"#{v}\""
32
- end
33
- end
34
- end
35
- end