eac_rails_base0 0.47.0 → 0.51.0

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: 9dbf7853e319ed40781d1ba226a0a69ab73429884cbd6355c9ffc53cd8e3ac62
4
- data.tar.gz: acf438c17b387f7b2fc025d92371809a4ec2dc68c2373678bd91c275d5e3e011
3
+ metadata.gz: 8e43e3647ec0c12ea7d4f08153621cb934ec30a18198cb4e28fde9f19ee770d7
4
+ data.tar.gz: 70d2754d4ef92d0835213cc9eb4c832ba84252481468f9541285749fcb1d68be
5
5
  SHA512:
6
- metadata.gz: db2d718db7eca5f9720efcd5e3d4cf7618364611b9d08ca8329da68abcdab1acee7a414dc3dae7c676aaaf8f68c8948c5a568fbb5b958a3b3a95790087039340
7
- data.tar.gz: '08a70dac3579768cd8d3f7596e064a4ba16e2b8e8fa17b7263743669e5aab78b12bf70463324d853fca00126c7bbd516d0499f2d47aa0e790e9498ca314019f9'
6
+ metadata.gz: d2fd327487eb0048b88447ba2055b19f547c67e861900663fcdf61972b186a96e298c8cf5a8e70b4ab26a31682189e68d5040f74038d918da426cdea27a81306
7
+ data.tar.gz: d29081e42fd87229f9394db9804183d9ca1fe9bf6759f2ad59a3f55160d3cb2cfc9edf410e9cdab78ce9ef011998c39b62722b64c7b1a28c93b9a3fcd74aaf44
@@ -7,9 +7,11 @@ module EacRailsBase0
7
7
  layout 'eac_rails_base0/application'
8
8
  helper ::EacRailsBase0::AppVersionHelper
9
9
  helper ::EacRailsBase0::LayoutHelper
10
+ helper ::EacRailsBase0::MainMenuHelper
10
11
  helper ::EacRailsUtils::FormatterHelper
11
12
  helper ::EacRailsUtils::LinksHelper
12
13
  helper ::EacRailsUtils::OpenGraphProtocolHelper
14
+ helper ::EacRailsBase0::UserMenuHelper
13
15
 
14
16
  # Prevent CSRF attacks by raising an exception.
15
17
  # For APIs, you may want to use :null_session instead.
@@ -3,8 +3,6 @@
3
3
  module EacRailsBase0
4
4
  module LayoutHelper
5
5
  APP_TITLE_METHOD = 'app_title'
6
- APP_MAIN_MENU_ENTRIES_METHOD = 'app_main_menu_entries'
7
- ADMIN_ENTRIES = %w[eac_users_support tasks_scheduler aranha br_railties mailer].freeze
8
6
 
9
7
  def base0_app_title
10
8
  if respond_to?(APP_TITLE_METHOD)
@@ -13,60 +11,5 @@ module EacRailsBase0
13
11
  "Implement the helper method \"#{APP_TITLE_METHOD}\""
14
12
  end
15
13
  end
16
-
17
- def base0_app_main_menu_entries
18
- if respond_to?(APP_MAIN_MENU_ENTRIES_METHOD)
19
- send(APP_MAIN_MENU_ENTRIES_METHOD, base0_app_main_menu_default_entries)
20
- else
21
- base0_app_main_menu_default_entries
22
- end
23
- end
24
-
25
- def base0_app_main_menu_default_entries
26
- {
27
- 'Administração' => base0_app_main_menu_admin_entries
28
- }
29
- end
30
-
31
- def base0_app_main_menu_admin_entries
32
- ADMIN_ENTRIES.map do |identifier|
33
- [::I18n.t("eac_rails_base0.main_menu.admin.#{identifier}"),
34
- send("#{identifier}_main_menu_admin_entries")]
35
- end.to_h
36
- end
37
-
38
- def mailer_main_menu_admin_entries
39
- %w[info send_test].map do |action|
40
- [
41
- t("eac_rails_base0.mailer.#{action}"),
42
- main_app.send("#{action}_eac_rails_base0_mailer_index_path")
43
- ]
44
- end.to_h
45
- end
46
-
47
- def eac_users_support_main_menu_admin_entries
48
- {
49
- ::EacUsersSupport::User.model_name.human(count: 2) => [eac_users_support.admin_users_path]
50
- }
51
- end
52
-
53
- def tasks_scheduler_main_menu_admin_entries
54
- {
55
- t('activerecord.models.scheduled_task.other') => [main_app.status_scheduled_tasks_path]
56
- }
57
- end
58
-
59
- def aranha_main_menu_admin_entries
60
- {
61
- ::Aranha::Address.model_name.human(count: 2) => [aranha.addresses_path]
62
- }
63
- end
64
-
65
- def br_railties_main_menu_admin_entries
66
- {
67
- ::BrRailties::FederalUnit.model_name.human(count: 2) => [br_railties.federal_units_path],
68
- ::BrRailties::Municipality.model_name.human(count: 2) => [br_railties.municipalities_path]
69
- }
70
- end
71
14
  end
72
15
  end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsBase0
4
+ module MainMenuHelper
5
+ APP_MAIN_MENU_ENTRIES_METHOD = 'app_main_menu_entries'
6
+ ADMIN_ENTRIES = %w[eac_users_support tasks_scheduler aranha br_railties mailer].freeze
7
+
8
+ def base0_app_main_menu_entries
9
+ if respond_to?(APP_MAIN_MENU_ENTRIES_METHOD)
10
+ send(APP_MAIN_MENU_ENTRIES_METHOD, base0_app_main_menu_default_entries)
11
+ else
12
+ base0_app_main_menu_default_entries
13
+ end
14
+ end
15
+
16
+ def base0_app_main_menu_default_entries
17
+ {
18
+ 'Administração' => base0_app_main_menu_admin_entries
19
+ }
20
+ end
21
+
22
+ def base0_app_main_menu_admin_entries
23
+ ADMIN_ENTRIES.map do |identifier|
24
+ [::I18n.t("eac_rails_base0.main_menu.admin.#{identifier}"),
25
+ send("#{identifier}_main_menu_admin_entries")]
26
+ end.to_h
27
+ end
28
+
29
+ def mailer_main_menu_admin_entries
30
+ %w[info send_test].map do |action|
31
+ [
32
+ t("eac_rails_base0.mailer.#{action}"),
33
+ main_app.send("#{action}_eac_rails_base0_mailer_index_path")
34
+ ]
35
+ end.to_h
36
+ end
37
+
38
+ def eac_users_support_main_menu_admin_entries
39
+ {
40
+ ::EacUsersSupport::User.model_name.human(count: 2) => [eac_users_support.admin_users_path]
41
+ }
42
+ end
43
+
44
+ def tasks_scheduler_main_menu_admin_entries
45
+ {
46
+ t('activerecord.models.scheduled_task.other') => [main_app.status_scheduled_tasks_path]
47
+ }
48
+ end
49
+
50
+ def aranha_main_menu_admin_entries
51
+ {
52
+ ::Aranha::Address.model_name.human(count: 2) => [aranha.addresses_path]
53
+ }
54
+ end
55
+
56
+ def br_railties_main_menu_admin_entries
57
+ {
58
+ ::BrRailties::FederalUnit.model_name.human(count: 2) => [br_railties.federal_units_path],
59
+ ::BrRailties::Municipality.model_name.human(count: 2) => [br_railties.municipalities_path]
60
+ }
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsBase0
4
+ module UserMenuHelper
5
+ def base0_user_menu_entries
6
+ r = {}
7
+ if current_user
8
+ r[current_user.to_s] = {
9
+ 'Alterar senha' => [eac_users_support.edit_user_registration_path]
10
+ }
11
+ r['Sair'] = [eac_users_support.destroy_user_session_path, link_method: :delete]
12
+ else
13
+ r['Entrar'] = [eac_users_support.new_user_session_path]
14
+ end
15
+ r
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRailsBase0
4
+ class ApplicationMailer < (
5
+ begin
6
+ ::ApplicationMailer
7
+ rescue StandardError
8
+ ::ActionMailer::Base
9
+ end
10
+ )
11
+ end
12
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsBase0
4
- class SendTestMailer < ::ApplicationMailer
4
+ class SendTestMailer < ::EacRailsBase0::ApplicationMailer
5
5
  def main
6
6
  @subject = "#{t('eac_rails_base0.mailer.send_test')} [#{::Time.zone.now}]"
7
7
  mail(to: params.fetch(:address), subject: @subject)
@@ -1,10 +1 @@
1
- <%
2
- user_menu = {}
3
- if current_user
4
- user_menu[current_user.to_s] = [main_app.root_path]
5
- user_menu['Sair'] = [eac_users_support.destroy_user_session_path, link_method: :delete]
6
- else
7
- user_menu['Entrar'] = [eac_users_support.new_user_session_path]
8
- end
9
- %>
10
- <%= bootstrap_dropdown_menu(user_menu, class: 'navbar-right') %>
1
+ <%= bootstrap_dropdown_menu(base0_user_menu_entries, class: 'navbar-right') %>
@@ -1,24 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Rails.application.configure do
4
- config.action_mailer.smtp_settings = {
5
- address: ENV['action_mailer_smtp_address'],
6
- port: ENV['action_mailer_smtp_port'],
7
- domain: ENV['action_mailer_smtp_domain'],
8
- user_name: ENV['action_mailer_smtp_username'],
9
- password: ENV['action_mailer_smtp_password'],
10
- authentication: ENV['action_mailer_smtp_authentication'],
11
- enable_starttls_auto:
12
- ::EacRailsBase0::BooleanValue.to_b(ENV['action_mailer_smtp_enable_starttls_auto'])
13
- }
14
- %i[host port].each do |option|
15
- value = ENV["action_mailer_default_url_#{option}"]
16
- if value.present?
17
- config.action_mailer.default_url_options ||= {}
18
- config.action_mailer.default_url_options[option] = value
3
+ unless ::Rails.env.test?
4
+ Rails.application.configure do
5
+ config.action_mailer.smtp_settings = {
6
+ address: ENV['action_mailer_smtp_address'],
7
+ port: ENV['action_mailer_smtp_port'],
8
+ domain: ENV['action_mailer_smtp_domain'],
9
+ user_name: ENV['action_mailer_smtp_username'],
10
+ password: ENV['action_mailer_smtp_password'],
11
+ authentication: ENV['action_mailer_smtp_authentication'],
12
+ enable_starttls_auto:
13
+ ::EacRailsBase0::BooleanValue.to_b(ENV['action_mailer_smtp_enable_starttls_auto'])
14
+ }
15
+ %i[host port].each do |option|
16
+ value = ENV["action_mailer_default_url_#{option}"]
17
+ if value.present?
18
+ config.action_mailer.default_url_options ||= {}
19
+ config.action_mailer.default_url_options[option] = value
20
+ end
19
21
  end
22
+ config.action_mailer.default_options ||= {}
23
+ config.action_mailer.default_options[:from] = ENV['action_mailer_default_options_from']
24
+ config.action_mailer.default_options[:reply_to] = ENV['action_mailer_default_options_reply_to']
20
25
  end
21
- config.action_mailer.default_options ||= {}
22
- config.action_mailer.default_options[:from] = ENV['action_mailer_default_options_from']
23
- config.action_mailer.default_options[:reply_to] = ENV['action_mailer_default_options_reply_to']
24
26
  end
@@ -1,11 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aranha/engine'
4
-
5
3
  Rails.application.routes.draw do
6
4
  mount ::EacRailsUtils::Engine => '/'
7
5
  mount ::EacUsersSupport::Engine => '/'
8
- mount ::Aranha::Engine => '/aranha'
6
+ mount ::Aranha::Rails::Engine => '/aranha'
9
7
  mount ::BrRailties::Engine => '/br_railties'
10
8
 
11
9
  namespace(:eac_rails_base0) do
@@ -10,6 +10,12 @@ Bundler.require(*Rails.groups)
10
10
  module EacRailsBase0App
11
11
  class Application < Rails::Application
12
12
  class << self
13
+ def new_stdout_logger
14
+ logger = ActiveSupport::Logger.new(STDOUT)
15
+ logger.formatter = config.log_formatter
16
+ ::ActiveSupport::TaggedLogging.new(logger)
17
+ end
18
+
13
19
  def setup(*args)
14
20
  args.each { |a| send("setup_#{a}") }
15
21
  end
@@ -6,8 +6,7 @@ module EacRailsBase0App
6
6
  class Application < Rails::Application
7
7
  module All
8
8
  common_concern do
9
- setup('local_configuration', 'assets_cache', 'dependencies', 'localization', 'load_paths',
10
- 'loggers')
9
+ setup('assets_cache', 'dependencies', 'localization', 'load_paths', 'loggers')
11
10
  end
12
11
 
13
12
  module ClassMethods
@@ -45,12 +44,6 @@ module EacRailsBase0App
45
44
  config.autoload_paths << Rails.root.join('lib')
46
45
  end
47
46
 
48
- def setup_local_configuration
49
- local_configuration = ::File.join(rails_root(APP_PATH), 'config',
50
- 'local_configuration.rb')
51
- require local_configuration if File.exist?(local_configuration)
52
- end
53
-
54
47
  def setup_localization
55
48
  config.i18n.default_locale = :'pt-BR'
56
49
  end
@@ -48,9 +48,7 @@ module EacRailsBase0App
48
48
 
49
49
  def setup_log
50
50
  config.active_support.deprecation = :log
51
- logger = ActiveSupport::Logger.new(STDOUT)
52
- logger.formatter = config.log_formatter
53
- config.logger = ActiveSupport::TaggedLogging.new(logger)
51
+ config.logger = new_stdout_logger
54
52
  end
55
53
  end
56
54
  end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/yaml'
5
+
6
+ module EacRailsBase0App
7
+ class Application < Rails::Application
8
+ module Envvars
9
+ ENVVARS_FILE_BASENAME = 'envvars'
10
+ ENVVARS_DIRECTORY_NAME = "#{ENVVARS_FILE_BASENAME}.d"
11
+ ENVVARS_FILE_EXTENSIONS = %w[.yml .yaml].freeze
12
+
13
+ common_concern do
14
+ setup('envvars')
15
+ end
16
+
17
+ module ClassMethods
18
+ def config_root
19
+ ::Rails.root.join('config')
20
+ end
21
+
22
+ def envvars_files
23
+ ENVVARS_FILE_EXTENSIONS.flat_map do |extension|
24
+ [config_root.join("#{ENVVARS_FILE_BASENAME}#{extension}")] +
25
+ config_root.join(ENVVARS_DIRECTORY_NAME).glob("*#{extension}")
26
+ end
27
+ end
28
+
29
+ def load_envvars_file(path)
30
+ return unless path.exist?
31
+
32
+ vars = ::EacRubyUtils::Yaml.load(path.read)
33
+ raise "\"#{path}\" does not contain a Hash" unless vars.is_a?(::Hash)
34
+
35
+ vars.each { |name, value| ENV[name.to_s] = value }
36
+ end
37
+
38
+ def setup_envvars
39
+ envvars_files.each { |path| load_envvars_file(path) }
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -33,11 +33,7 @@ module EacRailsBase0App
33
33
  config.log_tags = [:request_id]
34
34
  config.active_support.deprecation = :notify
35
35
  config.log_formatter = ::Logger::Formatter.new
36
- return if ENV['RAILS_LOG_TO_STDOUT'].blank?
37
-
38
- logger = ActiveSupport::Logger.new(STDOUT)
39
- logger.formatter = config.log_formatter
40
- config.logger = ActiveSupport::TaggedLogging.new(logger)
36
+ config.logger = new_stdout_logger if ENV['RAILS_LOG_TO_STDOUT'].blank?
41
37
  end
42
38
 
43
39
  def setup_public_file_server
@@ -5,10 +5,16 @@ require 'eac_ruby_utils/core_ext'
5
5
  module EacRailsBase0App
6
6
  class Application < Rails::Application
7
7
  module Test
8
+ ACTION_MAILER_CONFIGS = {
9
+ delivery_method: :test,
10
+ default_url_options: { host: 'localhost', port: 3000 },
11
+ default_options: { from: 'myadddress@example.net', reply_to: '' }
12
+ }.freeze
13
+
8
14
  common_concern do
9
15
  next unless ::Rails.env.test?
10
16
 
11
- setup('action_controller', 'general', 'log', 'public_file_server')
17
+ setup('action_controller', 'action_mailer', 'general', 'log', 'public_file_server')
12
18
  end
13
19
 
14
20
  module ClassMethods
@@ -17,6 +23,12 @@ module EacRailsBase0App
17
23
  config.action_controller.allow_forgery_protection = false
18
24
  end
19
25
 
26
+ def setup_action_mailer
27
+ ACTION_MAILER_CONFIGS.each do |key, value|
28
+ config.action_mailer.send("#{key}=", value)
29
+ end
30
+ end
31
+
20
32
  def setup_general
21
33
  config.cache_classes = true
22
34
  config.eager_load = false
@@ -24,7 +36,6 @@ module EacRailsBase0App
24
36
  config.consider_all_requests_local = true
25
37
  config.action_controller.perform_caching = false
26
38
  config.action_dispatch.show_exceptions = false
27
- config.action_mailer.delivery_method = :test
28
39
  end
29
40
 
30
41
  def setup_log
@@ -20,4 +20,5 @@
20
20
 
21
21
  # Configuration files
22
22
  config/database.y*ml
23
- config/local_configuration.rb
23
+ config/envvars.y*ml
24
+ config/envvars.d/*.y*ml
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'aranha/engine'
3
+ require 'aranha/rails/engine'
4
4
  require 'br_railties/engine'
5
5
  require 'eac_rails_utils/engine'
6
6
  require 'eac_users_support/engine'
@@ -12,15 +12,39 @@ RSpec.configure do |config|
12
12
  end
13
13
 
14
14
  FactoryBot.define do
15
- factory :user, class: ::EacUsersSupport::User do
15
+ factory :admin_user, class: ::EacUsersSupport::User do
16
16
  email { 'admin@example.com' }
17
17
  password { 'mysecret' }
18
18
  confirmed_at { ::Time.zone.now }
19
19
  end
20
+
21
+ factory :non_admin_user, class: ::EacUsersSupport::User do
22
+ email { 'nonadmin@example.com' }
23
+ password { 'mysecret' }
24
+ confirmed_at { ::Time.zone.now }
25
+ end
20
26
  end
21
27
 
22
28
  RSpec.shared_context 'when user is admin', shared_context: :metadata do
23
- let(:user) { ::FactoryBot.create(:user) }
29
+ let(:user) { ::FactoryBot.create(:admin_user) }
30
+
31
+ before do
32
+ visit '/users/sign_in'
33
+ fill_in ::I18n.translate!('activerecord.attributes.eac_users_support/user.email'),
34
+ with: user.email
35
+ fill_in ::I18n.translate!('activerecord.attributes.eac_users_support/user.password'),
36
+ with: user.password
37
+ click_button ::I18n.translate!('devise.log_in')
38
+ end
39
+
40
+ it 'user should be logged' do
41
+ expect(page).to have_content user.email
42
+ expect(::EacUsersSupport::User.current_user).not_to be_nil
43
+ end
44
+ end
45
+
46
+ RSpec.shared_context 'when user is non admin', shared_context: :metadata do
47
+ let(:user) { ::FactoryBot.create(:non_admin_user) }
24
48
 
25
49
  before do
26
50
  visit '/users/sign_in'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRailsBase0
4
- VERSION = '0.47.0'
4
+ VERSION = '0.51.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_rails_base0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.47.0
4
+ version: 0.51.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-18 00:00:00.000000000 Z
11
+ date: 2020-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_scaffold
@@ -31,25 +31,33 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: 3.5.5
33
33
  - !ruby/object:Gem::Dependency
34
- name: aranha
34
+ name: aranha-parsers
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '0.14'
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- version: 0.14.2
39
+ version: '0.6'
43
40
  type: :runtime
44
41
  prerelease: false
45
42
  version_requirements: !ruby/object:Gem::Requirement
46
43
  requirements:
47
44
  - - "~>"
48
45
  - !ruby/object:Gem::Version
49
- version: '0.14'
50
- - - ">="
46
+ version: '0.6'
47
+ - !ruby/object:Gem::Dependency
48
+ name: aranha-rails
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
51
52
  - !ruby/object:Gem::Version
52
- version: 0.14.2
53
+ version: '0.1'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.1'
53
61
  - !ruby/object:Gem::Dependency
54
62
  name: bootstrap-sass
55
63
  requirement: !ruby/object:Gem::Requirement
@@ -580,7 +588,10 @@ files:
580
588
  - app/controllers/eac_rails_base0/mailer_controller.rb
581
589
  - app/helpers/eac_rails_base0/app_version_helper.rb
582
590
  - app/helpers/eac_rails_base0/layout_helper.rb
591
+ - app/helpers/eac_rails_base0/main_menu_helper.rb
583
592
  - app/helpers/eac_rails_base0/panel_default_helper.rb
593
+ - app/helpers/eac_rails_base0/user_menu_helper.rb
594
+ - app/mailers/eac_rails_base0/application_mailer.rb
584
595
  - app/mailers/eac_rails_base0/send_test_mailer.rb
585
596
  - app/models/eac_rails_base0/application_record.rb
586
597
  - app/tableless_models/eac_rails_base0/email_send_test.rb
@@ -625,6 +636,7 @@ files:
625
636
  - lib/eac_rails_base0/app_base/application.rb
626
637
  - lib/eac_rails_base0/app_base/application/all.rb
627
638
  - lib/eac_rails_base0/app_base/application/development.rb
639
+ - lib/eac_rails_base0/app_base/application/envvars.rb
628
640
  - lib/eac_rails_base0/app_base/application/production.rb
629
641
  - lib/eac_rails_base0/app_base/application/test.rb
630
642
  - lib/eac_rails_base0/app_generator/builder.rb