eac_rails_utils 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +2 -0
- data/app/helpers/eac_rails_utils/formatter_helper.rb +2 -0
- data/app/helpers/eac_rails_utils/links_helper.rb +4 -1
- data/app/helpers/eac_rails_utils/open_graph_protocol_helper.rb +2 -0
- data/lib/eac/common_form_helper.rb +3 -0
- data/lib/eac/common_form_helper/form_builder.rb +2 -0
- data/lib/eac/common_form_helper/form_builder/association_select_field.rb +4 -1
- data/lib/eac/common_form_helper/form_builder/common_text_fields.rb +3 -2
- data/lib/eac/common_form_helper/form_builder/currency_field.rb +13 -11
- data/lib/eac/common_form_helper/form_builder/date_field.rb +2 -0
- data/lib/eac/common_form_helper/form_builder/fields_for.rb +2 -0
- data/lib/eac/common_form_helper/form_builder/file_field.rb +1 -0
- data/lib/eac/common_form_helper/form_builder/radio_select_field.rb +4 -1
- data/lib/eac/common_form_helper/form_builder/searchable_association_field.rb +6 -2
- data/lib/eac/common_form_helper/form_builder/select_field.rb +2 -0
- data/lib/eac/common_form_helper/form_builder/time_field.rb +1 -0
- data/lib/eac/common_form_helper/form_builder/year_month_field.rb +1 -0
- data/lib/eac/cpf_validator.rb +7 -3
- data/lib/eac/data_table_helper.rb +1 -0
- data/lib/eac/data_table_helper/column.rb +5 -2
- data/lib/eac/data_table_helper/data_table.rb +11 -9
- data/lib/eac/data_table_helper/setup.rb +1 -0
- data/lib/eac/htmlbeautifier.rb +2 -0
- data/lib/eac/inequality_queries.rb +2 -1
- data/lib/eac/menus_helper.rb +5 -1
- data/lib/eac/menus_helper/bootstrap_gui_builder.rb +7 -4
- data/lib/eac/menus_helper/data_builder.rb +6 -1
- data/lib/eac/menus_helper/gui_builder.rb +5 -2
- data/lib/eac/model.rb +8 -5
- data/lib/eac/no_presence_validator.rb +2 -2
- data/lib/eac/test_utils.rb +17 -12
- data/lib/eac_rails_utils.rb +4 -5
- data/lib/eac_rails_utils/engine.rb +1 -0
- data/lib/eac_rails_utils/patches/action_controller_base.rb +1 -0
- data/lib/eac_rails_utils/patches/model_attribute_required.rb +3 -0
- data/lib/eac_rails_utils/patches/ofx_parser.rb +5 -4
- data/lib/eac_rails_utils/tableless_model.rb +6 -4
- data/lib/eac_rails_utils/version.rb +2 -1
- data/test/app/helpers/eac_rails_utils/formatter_helper_test.rb +1 -0
- data/test/dummy/Rakefile +3 -1
- data/test/dummy/app/models/job.rb +2 -0
- data/test/dummy/app/models/user.rb +2 -0
- data/test/dummy/config.ru +2 -0
- data/test/dummy/config/application.rb +3 -1
- data/test/dummy/config/boot.rb +3 -1
- data/test/dummy/config/environment.rb +3 -1
- data/test/dummy/config/environments/test.rb +2 -0
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/db/migrate/20160415125333_create_users.rb +2 -0
- data/test/dummy/db/migrate/20160415143123_create_jobs.rb +2 -0
- data/test/dummy/db/migrate/20160415143229_add_job_to_users.rb +2 -0
- data/test/lib/eac/common_form_helper_test.rb +2 -0
- data/test/lib/eac/cpf_validator_test.rb +2 -0
- data/test/lib/eac/{data_table_test_helper.rb → data_table_test_helper_test.rb} +2 -1
- data/test/lib/eac/model_test.rb +2 -0
- data/test/lib/eac_rails_utils/patches/model_attribute_required_test.rb +2 -0
- data/test/lib/eac_rails_utils/tableless_model_test.rb +1 -1
- data/test/test_helper.rb +3 -1
- metadata +65 -51
- data/lib/eac/parsers/files_test.rb +0 -63
- data/lib/eac/source_target_fixtures.rb +0 -66
- data/test/lib/eac/parsers/files_test_test.rb +0 -27
- data/test/lib/eac/parsers/ok_test_files/a.source.yaml +0 -1
- data/test/lib/eac/parsers/ok_test_files/a.target.yaml +0 -1
- data/test/lib/eac/parsers/ok_test_files/b.source.yaml +0 -1
- data/test/lib/eac/parsers/ok_test_files/b.target.yaml +0 -1
- data/test/lib/eac/source_target_fixtures_test.rb +0 -41
@@ -1,63 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'yaml'
|
3
|
-
|
4
|
-
module Eac
|
5
|
-
module Parsers
|
6
|
-
module FilesTest
|
7
|
-
def test_data
|
8
|
-
if ENV['EAC_PARSERS_FILES_TEST_WRITE'].present?
|
9
|
-
write_results
|
10
|
-
else
|
11
|
-
test_results
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
protected
|
16
|
-
|
17
|
-
def source_data(source_file)
|
18
|
-
parser_class.new(source_file).data
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_results
|
22
|
-
sts = source_target_fixtures.source_target_files
|
23
|
-
assert_not_equal 0, sts.count, 'Source/target files count cannot be zero'
|
24
|
-
sts.each do |st|
|
25
|
-
assert_source_target_complete(st)
|
26
|
-
sd = source_data(st.source)
|
27
|
-
td = YAML.load_file(st.target)
|
28
|
-
assert_equal sort_results(td), sort_results(sd)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def write_results
|
33
|
-
source_target_fixtures.source_files.each do |source_file|
|
34
|
-
sd = sort_results(source_data(source_file))
|
35
|
-
basename = ::Eac::SourceTargetFixtures.source_target_basename(source_file)
|
36
|
-
target_file = File.expand_path("../#{basename}.target.yaml", source_file)
|
37
|
-
File.write(target_file, sd.to_yaml)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def sort_results(r)
|
42
|
-
r
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def assert_source_target_complete(st)
|
48
|
-
assert st.source, "Source not found (Target: #{st.target})"
|
49
|
-
assert st.target, "Target not found (Source: #{st.source})"
|
50
|
-
end
|
51
|
-
|
52
|
-
def source_target_fixtures
|
53
|
-
@source_target_fixtures ||= ::Eac::SourceTargetFixtures.new(
|
54
|
-
File.expand_path("../#{self.class.name.demodulize.underscore}_files", test_file)
|
55
|
-
)
|
56
|
-
end
|
57
|
-
|
58
|
-
def parser_class
|
59
|
-
self.class.name.gsub(/Test\z/, '').constantize
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'yaml'
|
5
|
-
|
6
|
-
module Eac
|
7
|
-
# Lists pairs of source/target files in a directory. See {Eac::Parsers::FilesTest} to see
|
8
|
-
# a use of this class.
|
9
|
-
class SourceTargetFixtures
|
10
|
-
class << self
|
11
|
-
def source_target_basename(file)
|
12
|
-
m = /^(.+)\.(?:source|target)(?:\..+)?$/.match(File.basename(file))
|
13
|
-
m ? m[1] : nil
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
attr_reader :fixtures_directory
|
18
|
-
|
19
|
-
def initialize(fixtures_directory)
|
20
|
-
@fixtures_directory = fixtures_directory
|
21
|
-
end
|
22
|
-
|
23
|
-
def source_target_files
|
24
|
-
sources_targets_basenames.map do |basename|
|
25
|
-
OpenStruct.new(source: source_file(basename), target: target_file(basename))
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def source_files
|
30
|
-
r = []
|
31
|
-
source_target_files.each do |st|
|
32
|
-
r << st.source if st.source
|
33
|
-
end
|
34
|
-
r
|
35
|
-
end
|
36
|
-
|
37
|
-
private
|
38
|
-
|
39
|
-
def target_file(basename)
|
40
|
-
fixture_file(basename, 'target')
|
41
|
-
end
|
42
|
-
|
43
|
-
def source_file(basename)
|
44
|
-
fixture_file(basename, 'source')
|
45
|
-
end
|
46
|
-
|
47
|
-
def fixture_file(basename, suffix)
|
48
|
-
prefix = "#{basename}.#{suffix}"
|
49
|
-
Dir.foreach(fixtures_directory) do |item|
|
50
|
-
next if item == '.' || item == '..'
|
51
|
-
return File.expand_path(item, fixtures_directory) if item.starts_with?(prefix)
|
52
|
-
end
|
53
|
-
nil
|
54
|
-
end
|
55
|
-
|
56
|
-
def sources_targets_basenames
|
57
|
-
basenames = Set.new
|
58
|
-
Dir.foreach(fixtures_directory) do |item|
|
59
|
-
next if item == '.' || item == '..'
|
60
|
-
b = self.class.source_target_basename(item)
|
61
|
-
basenames << b if b.present?
|
62
|
-
end
|
63
|
-
basenames
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'test_helper'
|
3
|
-
|
4
|
-
module Eac
|
5
|
-
module Parsers
|
6
|
-
class BaseStub
|
7
|
-
def initialize(source)
|
8
|
-
@source = source
|
9
|
-
end
|
10
|
-
|
11
|
-
def data
|
12
|
-
YAML.load(File.read(@source))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
class Ok < BaseStub
|
17
|
-
end
|
18
|
-
|
19
|
-
class OkTest < ActiveSupport::TestCase
|
20
|
-
include ::Eac::Parsers::FilesTest
|
21
|
-
|
22
|
-
def test_file
|
23
|
-
__FILE__
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
|
@@ -1 +0,0 @@
|
|
1
|
-
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'test_helper'
|
3
|
-
|
4
|
-
module Eac
|
5
|
-
class SourceTargetFixturesTest < ActionView::TestCase
|
6
|
-
def test_source_target_files
|
7
|
-
r = ::Eac::SourceTargetFixtures.new(fixtures_dir).source_target_files
|
8
|
-
assert_equal 3, r.count
|
9
|
-
|
10
|
-
a = r.find { |x| x.source && File.basename(x.source) == 'a.source.html' }
|
11
|
-
assert a
|
12
|
-
assert_equal File.join(fixtures_dir, 'a.source.html'), a.source
|
13
|
-
assert_equal File.join(fixtures_dir, 'a.target.yaml'), a.target
|
14
|
-
|
15
|
-
b = r.find { |x| x.source && File.basename(x.source) == 'b.source.html' }
|
16
|
-
assert b
|
17
|
-
assert_equal File.join(fixtures_dir, 'b.source.html'), b.source
|
18
|
-
assert_nil b.target
|
19
|
-
|
20
|
-
c = r.find { |x| x.target && File.basename(x.target) == 'c.target.yaml' }
|
21
|
-
assert c
|
22
|
-
assert_nil c.source
|
23
|
-
assert_equal File.join(fixtures_dir, 'c.target.yaml'), c.target
|
24
|
-
end
|
25
|
-
|
26
|
-
def test_source_files
|
27
|
-
r = ::Eac::SourceTargetFixtures.new(fixtures_dir).source_files
|
28
|
-
assert_equal 2, r.count
|
29
|
-
|
30
|
-
%w(a.source.html b.source.html).each do |expected|
|
31
|
-
assert r.include?(File.join(fixtures_dir, expected)), expected
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
private
|
36
|
-
|
37
|
-
def fixtures_dir
|
38
|
-
File.expand_path('../source_target_fixtures_test_files', __FILE__)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|