web47core 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/{lib/app → app}/assets/stylesheets/status.sass +0 -0
  3. data/{lib/app → app}/controllers/status_controller.rb +0 -0
  4. data/{lib/app → app}/views/status/index.html.haml +0 -0
  5. metadata +6 -79
  6. data/.circleci/config.yml +0 -58
  7. data/.gitignore +0 -70
  8. data/.rubocop.yml +0 -33
  9. data/Gemfile +0 -5
  10. data/Gemfile.lock +0 -318
  11. data/Rakefile +0 -7
  12. data/bin/cron_server +0 -4
  13. data/test/controllers/status_controller_test.rb +0 -158
  14. data/test/factories/account_factories.rb +0 -9
  15. data/test/factories/notification_factories.rb +0 -14
  16. data/test/fixtures/mongoid.yml +0 -8
  17. data/test/fixtures/redis/host.yml +0 -5
  18. data/test/fixtures/redis/options.yml +0 -8
  19. data/test/fixtures/redis/sentinel.yml +0 -8
  20. data/test/fixtures/redis/url.yml +0 -2
  21. data/test/jobs/cron/server_test.rb +0 -160
  22. data/test/jobs/cron/switchboard_sync_configuration_test.rb +0 -64
  23. data/test/jobs/cron/trim_cron_servers_test.rb +0 -28
  24. data/test/jobs/cron/trim_failed_delayed_jobs_test.rb +0 -71
  25. data/test/models/concerns/app47_logger_test.rb +0 -88
  26. data/test/models/concerns/cdn_url_test.rb +0 -54
  27. data/test/models/concerns/email_able_test.rb +0 -145
  28. data/test/models/concerns/search_able_test.rb +0 -80
  29. data/test/models/concerns/standard_model_test.rb +0 -154
  30. data/test/models/concerns/system_configuration_test.rb +0 -212
  31. data/test/models/concerns/time_zone_able_test.rb +0 -77
  32. data/test/models/email_notification_test.rb +0 -297
  33. data/test/models/job_cron_tab_test.rb +0 -25
  34. data/test/models/notification_test.rb +0 -127
  35. data/test/models/redis_configuration_test.rb +0 -86
  36. data/test/models/slack_notification_test.rb +0 -91
  37. data/test/models/sms_notification_test.rb +0 -69
  38. data/test/models/smtp_configuration_test.rb +0 -66
  39. data/test/models/web47core_test.rb +0 -18
  40. data/test/notification_test_helper.rb +0 -146
  41. data/test/rails_setup.rb +0 -61
  42. data/test/shoulda_macros/mongoid.rb +0 -70
  43. data/test/test_helper.rb +0 -93
  44. data/test/test_models_helper.rb +0 -14
  45. data/web47core.gemspec +0 -58
@@ -1,18 +0,0 @@
1
- require 'test_helper'
2
-
3
- class Web47coreTest < ActiveSupport::TestCase
4
- context 'models' do
5
- should 'email able be empty by default then able to add to it' do
6
- assert_empty Web47core.config.email_able_models
7
- Web47core.config.email_able_models += [Account]
8
- assert_equal 1, Web47core.config.email_able_models.count
9
- assert_equal Account, Web47core.config.email_able_models.first
10
- end
11
- should 'Switchboard able be empty by default then able to add to it' do
12
- assert_empty Web47core.config.switchboard_able_models
13
- Web47core.config.switchboard_able_models += [Account]
14
- assert_equal 1, Web47core.config.switchboard_able_models.count
15
- assert_equal Account, Web47core.config.switchboard_able_models.first
16
- end
17
- end
18
- end
@@ -1,146 +0,0 @@
1
- module NotificationTestHelper
2
- # helper to assert no emails were sent.
3
- def assert_no_emails(account = nil)
4
- assert_emails_count(account, 0)
5
- end
6
-
7
- def assert_emails_count(account = nil, count = 1)
8
- assert_equal count, email_notifications(account).count
9
- end
10
-
11
- def assert_emails_subject(subject, account = nil)
12
- assert_emails_field(:subject, subject, account)
13
- end
14
-
15
- def assert_emails_from(from, account = nil)
16
- assert_emails_field(:from, from, account)
17
- end
18
-
19
- def assert_emails_to(to, account = nil)
20
- assert_emails_field(:to, to, account)
21
- end
22
-
23
- def assert_emails_reply_to(reply_to, account = nil)
24
- assert_emails_field(:reply_to, reply_to, account)
25
- end
26
-
27
- def assert_emails_includes(parts, account = nil)
28
- assert_notifications_includes(email_notifications(account), parts)
29
- end
30
-
31
- def assert_emails_excludes(parts, account = nil)
32
- assert_notifications_excludes(email_notifications(account), parts)
33
- end
34
-
35
- def assert_emails_attachment_count(account = nil, count = 1)
36
- email_notifications(account).each do |email|
37
- assert_equal count, email.attachments.count
38
- end
39
- end
40
-
41
- ########################
42
- # Slack notifications
43
- #
44
- # helper to assert no slack messages were sent.
45
- def assert_no_slacks(account = nil)
46
- assert_slacks_count(account, 0)
47
- end
48
-
49
- def assert_slacks_count(account = nil, count = 1)
50
- assert_equal count, slack_notifications(account).where(state:'processed').count, 'Incorrect number of notifications sent'
51
- end
52
-
53
- def assert_slacks_includes(parts, account = nil)
54
- assert_notifications_includes(slack_notifications(account), parts)
55
- end
56
-
57
- def assert_slacks_excludes(parts, account = nil)
58
- assert_notifications_excludes(slack_notifications(account), parts)
59
- end
60
-
61
- ########################
62
- # SMS notifications
63
- #
64
- def assert_no_sms(account = nil)
65
- assert_sms_count(account, 0)
66
- end
67
-
68
- def assert_sms_count(account = nil, count = 1)
69
- assert_equal count, sms_notifications(account).count, 'Incorrect number of notifications sent'
70
- end
71
-
72
- def assert_sms_includes(parts, account = nil)
73
- assert_notifications_includes(sms_notifications(account), parts)
74
- end
75
-
76
- def assert_sms_excludes(parts, account = nil)
77
- assert_notifications_excludes(sms_notifications(account), parts)
78
- end
79
-
80
- private
81
-
82
- def assert_emails_field(field, value, account = nil)
83
- email_notifications(account).each do |email|
84
- assert_equal value, email.send(field), "Incorrect #{field}: #{email.inspect}"
85
- end
86
- end
87
-
88
- #
89
- # Assert the list of notifications include parts in the message of the notification
90
- #
91
- def assert_notifications_includes(notifications, parts)
92
- raise 'No matching notifications to compare' if notifications.blank?
93
-
94
- notifications.each do |notification|
95
- message = notification.message
96
- assert_not_nil message, "Message should not be nil: #{notification.inspect}"
97
- parts = [parts] unless parts.is_a?(Array)
98
- parts.each do |part|
99
- assert message.to_s.include?(part), "Does not have message part '#{part}' in message: \n#{message}"
100
- end
101
- end
102
- end
103
-
104
- #
105
- # Assert the list of notifications exclude parts in the message of the notification
106
- #
107
- def assert_notifications_excludes(notifications, parts)
108
- raise 'No matching notifications to compare' if notifications.blank?
109
-
110
- notifications.each do |notification|
111
- message = notification.message
112
- assert_not_nil message, "Message should not be nil: #{notification.inspect}"
113
- parts = [parts] unless parts.is_a?(Array)
114
- parts.each do |part|
115
- refute message.to_s.include?(part), "Message should not have part '#{part}' in message: \n#{message}"
116
- end
117
- end
118
- end
119
-
120
- #
121
- # Get email notifications for an account
122
- #
123
- def email_notifications(account = nil)
124
- return EmailNotification.all if account.nil?
125
-
126
- account.is_a?(Account) ? account.notifications.emails : EmailNotification.where(account_id: account)
127
- end
128
-
129
- #
130
- # Get slack notifications for an account
131
- #
132
- def slack_notifications(account = nil)
133
- return SlackNotification.all if account.nil?
134
-
135
- account.is_a?(Account) ? account.notifications.slacks : SlackNotification.where(account_id: account)
136
- end
137
-
138
- #
139
- # Get SMS notification for an account
140
- #
141
- def sms_notifications(account = nil)
142
- return SmsNotification.all if account.nil?
143
-
144
- account.is_a?(Account) ? account.notifications.sms : SmsNotification.where(account_id: account)
145
- end
146
- end
@@ -1,61 +0,0 @@
1
- # require File.expand_path('../../config/environment', __FILE__)
2
- # Load the Rails application.
3
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
4
-
5
- require 'bundler/setup' # Set up gems listed in the Gemfile.
6
-
7
- require 'rails'
8
-
9
- %w[
10
- action_controller/railtie
11
- action_view/railtie
12
- action_mailer/railtie
13
- active_job/railtie
14
- action_cable/engine
15
- rails/test_unit/railtie
16
- sprockets/railtie
17
- ].each do |railtie|
18
- begin
19
- require railtie
20
- rescue LoadError => error
21
- puts 'Unable to load libraries'
22
- puts error.message
23
- end
24
- end
25
-
26
- require 'mail'
27
-
28
- # Require the gems listed in Gemfile, including any gems
29
- # you've limited to :test, :development, or :production.
30
- Bundler.require(*Rails.groups)
31
-
32
-
33
- module WebCore
34
- class Application < Rails::Application
35
- # Settings in config/environments/* take precedence over those specified here.
36
- # Application configuration should go into files in config/initializers
37
- # -- all .rb files in that directory are automatically loaded.
38
- # Configure redis cache
39
- config.eager_load = false
40
- config.cache_store = :redis_store, 'redis://127.0.0.1:6379/11/cache'
41
- config.autoload_paths += %W(#{config.root}/lib)
42
- config.generators do |g|
43
- g.template_engine :haml
44
- g.orm :mongoid
45
- g.test_framework :shoulda
46
- g.fallbacks[:shoulda] = :test_unit
47
- g.fixture_replacement :factory_bot
48
- end
49
- config.active_job.queue_adapter = :delayed_job
50
-
51
- # Configure the default encoding used in templates for Ruby 1.9.
52
- config.encoding = 'utf-8'
53
- config.logger = Logger.new(STDOUT)
54
- config.logger.level = Logger::DEBUG
55
- end
56
- end
57
-
58
- Delayed::Worker.delay_jobs = false
59
-
60
- # Initialize the Rails application.
61
- Rails.application.initialize!
@@ -1,70 +0,0 @@
1
- module ActiveSupport
2
- class TestCase
3
- class << self
4
- def should_have_field(name, options = {})
5
- should "have field named #{name}" do
6
- assert subject.class.fields[name.to_s], "#{name} field not present"
7
- assert_equal options, subject.class.fields[name.to_s].options
8
- end
9
- end
10
-
11
- #
12
- # NOTE: Temporarily commented out methods until we need them to avoid Codacy issues
13
- #
14
- # def should_have_index(name, options = { unique: false })
15
- # should "have index on #{name.inspect}" do
16
- # assert_equal options, subject.class.index_options[name]
17
- # end
18
- # end
19
- #
20
- def should_be_embedded_in(name, options = {})
21
- should_have_relation name, Mongoid::Relations::Embedded::In, 'be embedded in'
22
- end
23
- #
24
- # def should_embed_many(name)
25
- # should_have_relation name, Mongoid::Relations::Embedded::Many, 'embed many'
26
- # end
27
- #
28
- # def should_embed_one(name)
29
- # should_have_relation name, Mongoid::Relations::Embedded::One, 'embed one'
30
- # end
31
-
32
- def should_reference_many(name, _options = {})
33
- should_have_relation name, Mongoid::Relations::Referenced::Many, 'reference many'
34
- end
35
- alias should_have_many should_reference_many
36
- #
37
- # def should_reference_and_be_referenced_in_many(name, options = {})
38
- # should_have_relation name, Mongoid::Relations::Referenced::ManyToMany, 'reference and be referenced in many'
39
- # end
40
- # alias should_have_and_belong_to_many should_reference_and_be_referenced_in_many
41
-
42
- def should_reference_one(name)
43
- should_have_relation name, Mongoid::Relations::Referenced::One, 'reference one'
44
- end
45
- alias should_have_one should_reference_one
46
-
47
- def should_be_referenced_in(name)
48
- should_have_relation name, Mongoid::Relations::Referenced::In, 'be referenced in'
49
- end
50
- alias should_belong_to should_be_referenced_in
51
-
52
- def should_have_relation(name, relation_class, relationship)
53
- should "#{relationship} #{name}" do
54
- reflection = subject.class.reflect_on_association(name)
55
- assert reflection.present?, "#{name} association not present"
56
- assert_equal relation_class, reflection.relation
57
- end
58
- end
59
- #
60
- # def should_have_scope(name, conditions = {})
61
- # should "have scope #{name}" do
62
- # scope = subject.class.scopes[name.to_sym]
63
- # assert scope.present?, "#{name} scope not present"
64
- # assert_equal conditions, scope.conditions
65
- # end
66
- # end
67
- # alias should_have_named_scope should_have_scope
68
- end
69
- end
70
- end
@@ -1,93 +0,0 @@
1
- ENV['RAILS_ENV'] = 'test'
2
-
3
- if ENV['CODACY_PROJECT_TOKEN']
4
- require 'simplecov'
5
- require 'codacy-coverage'
6
-
7
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([SimpleCov::Formatter::HTMLFormatter,
8
- Codacy::Formatter])
9
- Codacy::Reporter.start do
10
- add_filter '/spec/'
11
- add_filter '/test/'
12
- add_filter '/config/'
13
- add_filter 'vendor/**/*'
14
- end
15
- end
16
-
17
- require 'rubygems'
18
- require 'aws-sdk-autoscaling'
19
- require 'mongoid'
20
- require 'delayed_job_mongoid'
21
- require 'email_format'
22
- require 'liquid'
23
- require 'jwt'
24
- require 'rest-client'
25
- require 'twilio-ruby'
26
- require_relative 'rails_setup'
27
- require 'rails/test_help'
28
- require 'test/unit'
29
- require 'mocha/minitest'
30
- require 'shoulda'
31
- require 'minitest/rails/capybara'
32
- require 'minitest/reporters'
33
- require 'factory_bot'
34
- require 'webmock/minitest'
35
- require 'database_cleaner'
36
- Mongoid.logger.level = Logger::ERROR
37
- Mongo::Logger.logger.level = Logger::ERROR
38
- DatabaseCleaner.strategy = :truncation
39
- if ENV['CODACY_PROJECT_TOKEN']
40
- Minitest::Reporters.use!(Minitest::Reporters::DefaultReporter.new)
41
- else
42
- Minitest::Reporters.use!(Minitest::Reporters::RubyMineReporter.new)
43
- end
44
-
45
- require_relative 'test_models_helper'
46
-
47
- module ActiveSupport
48
- class TestCase
49
- FactoryBot.find_definitions
50
- Shoulda.autoload_macros Rails.root.to_s
51
- Mongoid.load!('./test/fixtures/mongoid.yml')
52
- DatabaseCleaner.strategy = :truncation
53
- setup do
54
- mocha_setup
55
- DatabaseCleaner.clean
56
- DatabaseCleaner.start
57
- Rails.cache.clear
58
- SystemConfiguration.configuration.update!(base_url: 'http://localhost:3000')
59
- WebMock.enable!
60
- end
61
- teardown do
62
- DatabaseCleaner.clean
63
- Mail::TestMailer.deliveries.clear
64
- mocha_teardown
65
- WebMock.disable!
66
- WebMock.reset!
67
- end
68
- end
69
- end
70
-
71
- module ActionDispatch
72
- class IntegrationTest
73
- # include Devise::Test::IntegrationHelpers
74
- Shoulda.autoload_macros Rails.root.to_s
75
- DatabaseCleaner.strategy = :truncation
76
- Mongoid.load!('./test/fixtures/mongoid.yml')
77
- setup do
78
- mocha_setup
79
- DatabaseCleaner.clean
80
- DatabaseCleaner.start
81
- Rails.cache.clear
82
- SystemConfiguration.configuration.update!(base_url: 'http://localhost:3000')
83
- WebMock.enable!
84
- end
85
- teardown do
86
- DatabaseCleaner.clean
87
- Mail::TestMailer.deliveries.clear
88
- mocha_teardown
89
- WebMock.disable!
90
- WebMock.reset!
91
- end
92
- end
93
- end
@@ -1,14 +0,0 @@
1
- unless defined? SystemConfiguration
2
- class SystemConfiguration
3
- include StandardModel
4
- include CoreSystemConfiguration
5
- end
6
- end
7
-
8
- unless defined? Account
9
- class Account
10
- include StandardModel
11
- include CoreAccount
12
- end
13
- end
14
-
@@ -1,58 +0,0 @@
1
- #
2
- # Spec of App47 Web Core GEM
3
- #
4
- lib = File.expand_path('lib', __dir__)
5
-
6
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
-
8
- Gem::Specification.new do |spec|
9
- spec.required_ruby_version = '~> 2.4.1'
10
- spec.name = 'web47core'
11
- spec.version = '0.1.4'
12
- spec.authors = ['Chris Schroeder']
13
- spec.email = ['chris@app47.com']
14
- spec.summary = 'App47 Web Core Library.'
15
- spec.description = 'Common core components used in all our web products.'
16
- spec.homepage = 'https://app47.com'
17
- spec.license = 'MIT'
18
-
19
- spec.files = `git ls-files -z`.split("\x0")
20
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
- spec.test_files = spec.files.grep(%r{^(test)/})
22
- spec.require_paths = ['lib']
23
-
24
- # spec.add_dependency 'json'
25
- spec.add_runtime_dependency 'activesupport', '~> 5.0'
26
- spec.add_runtime_dependency 'aws-sdk-autoscaling'
27
- spec.add_runtime_dependency 'delayed_job_mongoid', '~> 2.3'
28
- spec.add_runtime_dependency 'daemons'
29
- spec.add_runtime_dependency 'email_format'
30
- spec.add_runtime_dependency 'haml'
31
- spec.add_runtime_dependency 'jwt'
32
- spec.add_runtime_dependency 'liquid'
33
- spec.add_runtime_dependency 'materialize-sass'
34
- spec.add_runtime_dependency 'mongoid', '> 6', '< 7'
35
- spec.add_runtime_dependency 'rails', '< 5.3', '>= 4.2'
36
- spec.add_runtime_dependency 'redis', '~> 4.1'
37
- spec.add_runtime_dependency 'redis-rails', '> 5', '< 6'
38
- spec.add_runtime_dependency 'rest-client', '<= 2.1.0', '>=0'
39
- spec.add_runtime_dependency 'twilio-ruby', '<= 4.13', '>= 3.0'
40
- spec.add_runtime_dependency 'tzinfo'
41
- spec.add_development_dependency 'bundler'
42
- spec.add_development_dependency 'codacy-coverage', '~> 2.1.0'
43
- spec.add_development_dependency 'database_cleaner'
44
- spec.add_development_dependency 'factory_bot'
45
- spec.add_development_dependency 'factory_bot_rails'
46
- spec.add_development_dependency 'listen'
47
- spec.add_development_dependency 'minitest', '= 5.10.3'
48
- spec.add_development_dependency 'minitest-rails', '= 3.0.0'
49
- spec.add_development_dependency 'minitest-rails-capybara', '= 3.0.1'
50
- spec.add_development_dependency 'minitest-reporters'
51
- spec.add_development_dependency 'mocha'
52
- spec.add_development_dependency 'shoulda', '= 3.6.0'
53
- spec.add_development_dependency 'shoulda-matchers'
54
- spec.add_development_dependency 'simplecov', '= 0.16.1'
55
- spec.add_development_dependency 'test-unit'
56
- spec.add_development_dependency 'vcr'
57
- spec.add_development_dependency 'webmock'
58
- end