web47core 0.0.2 → 0.0.7

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.
@@ -0,0 +1,258 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # The System configuration. Various configuration items that can be updated/defined at run time
5
+ #
6
+ # Use of this class allows you to simply ask for the configuration parameter directly without
7
+ # first having to get an instance of it.
8
+ #
9
+ # SystemConfiguration.queue_impl #=> 'RedisQueue'
10
+ #
11
+ # This method only is allowed for accessors, you should NEVER set values on the SystemConfiguration
12
+ # unless you are updating via the Admin or Stack UI, or during testing to setup a specific configuration
13
+ # for that.
14
+ #
15
+ module CoreSystemConfiguration
16
+ extend ActiveSupport::Concern
17
+
18
+ def self.included(base)
19
+ base.class_eval do
20
+ #
21
+ # Fields
22
+ #
23
+ field :environment, type: String, default: 'test'
24
+ # SMTP configuration
25
+ field :default_email, type: String, default: 'support@app47.com'
26
+ field :support_email, type: String, default: 'support@app47.com'
27
+ field :smtp_name, type: String
28
+ field :smtp_address, type: String
29
+ field :smtp_domain, type: String
30
+ field :smtp_port, type: Integer, default: 587
31
+ field :smtp_user_name, type: String
32
+ field :smtp_password, type: String
33
+ field :smtp_enable_starttls_auto, type: Boolean
34
+ field :mailgun_api_key, type: String
35
+ # Twillio support
36
+ field :twilio_account_id, type: String
37
+ field :twilio_auth_token, type: String
38
+ field :twilio_phone_number, type: String
39
+ # URLs
40
+ field :base_url, type: String
41
+ field :cdn_url, type: String
42
+ # Slack support
43
+ field :slack_api_url, type: String
44
+ field :slack_support_channel, type: String, default: 'support'
45
+ field :slack_sales_channel, type: String, default: 'sales'
46
+ # Time Zone Support
47
+ field :default_time_zone, type: String, default: 'US/Eastern'
48
+ # AWS
49
+ field :aws_region, type: String
50
+ field :aws_access_key, type: String
51
+ field :aws_access_secret, type: String
52
+ field :aws_auto_scaling_group_name, type: String
53
+ # Zendesk
54
+ field :zendesk_token, type: String
55
+ field :zendesk_base_url, type: String, default: 'https://app47.zendesk.com'
56
+ field :zendesk_documentation_path, type: String, default: 'hc'
57
+ field :zendesk_support_path, type: String, default: 'hc/en-us/requests'
58
+ field :zendesk_updates_path, type: String, default: 'hc'
59
+ # Switchboard
60
+ field :switchboard_base_url, type: String, default: 'https://switchboard.app47.com'
61
+ field :switchboard_stack_id, type: String
62
+ field :switchboard_stack_api_token, type: String
63
+ #
64
+ # Validations
65
+ #
66
+ validates :environment, presence: true, uniqueness: true
67
+ end
68
+ base.extend ClassMethods
69
+ end
70
+
71
+ module ClassMethods
72
+ #
73
+ # Fetch the system configuration based on environment name. First try the rails cache
74
+ # if not there, then go to the database.
75
+ #
76
+ # Also, if an argument error is thrown, then just fetch from the database.
77
+ #
78
+ def configuration
79
+ cache_key = "SystemConfiguration::#{Rails.env}"
80
+
81
+ begin
82
+ config = Rails.cache.fetch(cache_key, expires_in: 90.seconds) do
83
+ SystemConfiguration.find_by(environment: Rails.env)
84
+ end
85
+ rescue StandardError
86
+ # This seems to happen in testing relative to Country, when it does, remove
87
+ # ourselves from the cache and return the DB entry.
88
+ Rails.cache.delete cache_key
89
+ config = SystemConfiguration.find_or_create_by!(environment: Rails.env)
90
+ end
91
+
92
+ config.nil? ? SystemConfiguration.create(environment: Rails.env) : config
93
+ end
94
+
95
+ def smtp_configuration
96
+ output = {}
97
+ config = configuration
98
+ fields = %w[name address domain port user_name password enable_starttls_auto]
99
+ fields.each do |field|
100
+ field_name = "smtp_#{field}".to_sym
101
+ output[field.to_sym] = config.send(field_name)
102
+ end
103
+ output
104
+ end
105
+
106
+ #
107
+ # NOTE: Currently ignored Codacy issue: When using 'method_missing', fall back on 'super'
108
+ #
109
+ # rubocop:disable Style/MethodMissingSuper
110
+ def method_missing(method, *args, &block)
111
+ configuration.send method, *args
112
+ end
113
+
114
+ def respond_to?(method_name, _include_private = false)
115
+ SystemConfiguration.fields.include?(method_name)
116
+ end
117
+ # rubocop:enable Style/MethodMissingSuper
118
+ end
119
+ #
120
+ # Make sure the password doesn't get blanked out on an update
121
+ #
122
+ def update_attributes(params)
123
+ %i[smtp_password aws_access_secret].each { |field| params[field] = send(field) if params[field].blank? }
124
+ super(params)
125
+ end
126
+
127
+ #
128
+ # Determine if SMTP is configured
129
+ #
130
+ def smtp_configured?
131
+ smtp_name.present? && smtp_address.present? && smtp_domain.present?
132
+ end
133
+
134
+ #
135
+ # Determine if mailgun is configured
136
+ #
137
+ def mailgun_configured?
138
+ smtp_configured? && mailgun_api_key.present?
139
+ end
140
+
141
+ #
142
+ # Determine if AWS is configured
143
+ #
144
+ def aws_configured?
145
+ [aws_region.present?, aws_access_key.present?, aws_access_secret.present?].all?
146
+ end
147
+
148
+ #
149
+ # Determine if auto scaling group is configured
150
+ #
151
+ def aws_auto_scaling_configured?
152
+ aws_configured? && aws_auto_scaling_group_name.present?
153
+ end
154
+
155
+ #
156
+ # AWS client.
157
+ #
158
+ def aws_ec2_client
159
+ return nil unless aws_configured?
160
+
161
+ Aws::EC2::Client.new region: aws_region,
162
+ credentials: Aws::Credentials.new(aws_access_key, aws_access_secret)
163
+ end
164
+
165
+ #
166
+ # Return the zendesk documentation URL
167
+ #
168
+ def zendesk_documentation_url(user = nil)
169
+ zendesk_url(forward_to: zendesk_documentation_path, user: user)
170
+ end
171
+
172
+ #
173
+ # Return the zendesk support URL
174
+ #
175
+ def zendesk_requests_url(user = nil)
176
+ zendesk_url(forward_to: zendesk_support_path, user: user)
177
+ end
178
+
179
+ #
180
+ # Return the zendesk support URL
181
+ #
182
+ def zendesk_new_request_url(user = nil)
183
+ zendesk_url(forward_to: "#{zendesk_support_path}/new", user: user)
184
+ end
185
+
186
+ #
187
+ # Return the zendesk update URL
188
+ #
189
+ def zendesk_updates_url(user = nil)
190
+ zendesk_url(forward_to: zendesk_updates_path, user: user)
191
+ end
192
+
193
+ #
194
+ # Generate a Zendesk URL
195
+ #
196
+ # If a user is passed in and Zendesk is configured then return a JWT enabled URL for
197
+ # SSO authentication to Zendesk.
198
+ #
199
+ def zendesk_url(forward_to: zendesk_documentation_path, user: nil)
200
+ config = SystemConfiguration.configuration
201
+ path = if config.zendesk_configured? && user.present?
202
+ time_now = Time.now.to_i
203
+ jti = "#{time_now}/#{rand(36 ** 64).to_s(36)}"
204
+ payload = { jwt: JWT.encode({ iat: time_now, # Seconds since epoch, determine when this token is stale
205
+ jti: jti, # Unique token identifier, helps prevent replay attacks
206
+ name: user.name,
207
+ email: user.email }, config.zendesk_token),
208
+ return_to: CGI.escape([config.zendesk_base_url, forward_to].join('/')) }
209
+ ['access/jwt', payload.to_query].join('?')
210
+ else
211
+ forward_to
212
+ end
213
+ [config.zendesk_base_url, path].join('/')
214
+ end
215
+
216
+ #
217
+ # Is zendesk configured?
218
+ #
219
+ def zendesk_configured?
220
+ [zendesk_token.present?,
221
+ zendesk_base_url.present?,
222
+ zendesk_documentation_path.present?,
223
+ zendesk_support_path.present?].all?
224
+ end
225
+
226
+ #
227
+ # Public: Determine if switchboard is configured
228
+ #
229
+ # Examples
230
+ #
231
+ # switchboard_configured?
232
+ # # => true || false
233
+ #
234
+ def switchboard_configured?
235
+ [switchboard_base_url.present?, switchboard_stack_api_token.present?, switchboard_stack_id.present?].all?
236
+ end
237
+
238
+ #
239
+ # Determine if twillio is configured at a system configuration
240
+ #
241
+ # Examples
242
+ #
243
+ # switchboard_configured?
244
+ # # => true || false
245
+ #
246
+ def twilio_configured?
247
+ [twilio_account_id.present?, twilio_auth_token.present?, twilio_phone_number.present?].all?
248
+ end
249
+
250
+ private
251
+
252
+ #
253
+ # Clear the cache when the object is saved
254
+ #
255
+ def clear_cache
256
+ Rails.cache.delete "SystemConfiguration::#{Rails.env}"
257
+ end
258
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ #
4
+ # Mixin to standardize the setup of all models, i.e., the standard or base model
5
+ # definitions they should all have
6
+ #
7
+ module StandardModel
8
+ extend ActiveSupport::Concern
9
+
10
+ def self.included(base)
11
+ base.class_eval do
12
+ include Mongoid::Document
13
+ include Mongoid::Timestamps
14
+ # include App47Logger
15
+ # include Auditable
16
+ # include Formable
17
+ include AutoClearCache
18
+ end
19
+ end
20
+ end
data/lib/web47core.rb CHANGED
@@ -1 +1,4 @@
1
- require 'app/models/concerns/auto_clear_cache'
1
+ require 'app/models/concerns/auto_clear_cache'
2
+ require 'app/models/concerns/cdn_url'
3
+ require 'app/models/concerns/standard_model'
4
+ require 'app/models/concerns/core_system_configuration'
@@ -0,0 +1,27 @@
1
+ require 'test_helper'
2
+
3
+ # TODO: CMS add tests for clearing by account id as well as id
4
+ class AutoClearCacheTest < ActiveSupport::TestCase
5
+ setup do
6
+ @model = TestAutoClearCache.new
7
+ assert @model.save
8
+ @model.update_cache
9
+ end
10
+
11
+ context 'Remove cache on save' do
12
+ should 'return the original url' do
13
+ assert Rails.cache.exist? @model.id.to_s
14
+ assert @model.save
15
+ refute Rails.cache.exist? @model.id.to_s
16
+ end
17
+ end
18
+ end
19
+
20
+ class TestAutoClearCache
21
+ include Mongoid::Document
22
+ include AutoClearCache
23
+
24
+ def update_cache(value = 'abc123')
25
+ Rails.cache.write id.to_s, value, expires_in: 60
26
+ end
27
+ end
@@ -0,0 +1,54 @@
1
+ require 'test_helper'
2
+
3
+ class CdnUrlTest < ActiveSupport::TestCase
4
+
5
+ setup do
6
+ @original_url = 'https://s3.amazon.com/test_bucket/test_cdn_url_models/id/original.png'
7
+ @model = TestCdnUrlModel.new
8
+ @model.file_url = @original_url
9
+ assert @model.save
10
+ end
11
+
12
+ context 'CDN not setup' do
13
+
14
+ should 'not respond to errant entry' do
15
+ assert_raises(NoMethodError) { @model.cdn_bad_url }
16
+ end
17
+
18
+ should 'return the original url' do
19
+ assert_equal @original_url, @model.file_url
20
+ assert_equal @original_url, @model.cdn_file_url
21
+ end
22
+ end
23
+
24
+ context 'CDN setup' do
25
+ setup do
26
+ @cdn_url = 'https://9asdfasd9asd.amazon.com'
27
+ config = SystemConfiguration.configuration
28
+ assert config.update cdn_url: @cdn_url
29
+ end
30
+ should 'return CDN url' do
31
+ assert_equal @original_url, @model.file_url
32
+ assert_not_equal @original_url, @model.cdn_file_url
33
+ assert_equal "#{@cdn_url}/test_cdn_url_models/id/original.png", @model.cdn_file_url
34
+ end
35
+ should 'return CDN url with size' do
36
+ assert_equal "#{@original_url}?size=medium", @model.image_url('medium')
37
+ assert_equal "#{@cdn_url}/test_cdn_url_models/id/original.png?size=medium", @model.cdn_image_url('medium')
38
+ end
39
+ should 'return url' do
40
+ assert @model.update file_url: 'https://s3.amazon.com/test_bucket/another_model/id/original.png'
41
+ assert_equal 'https://s3.amazon.com/test_bucket/another_model/id/original.png', @model.cdn_file_url
42
+ end
43
+ end
44
+ end
45
+
46
+ class TestCdnUrlModel
47
+ include Mongoid::Document
48
+ include CdnUrl
49
+ field :file_url, type: String
50
+
51
+ def image_url(size)
52
+ "#{file_url}?size=#{size}"
53
+ end
54
+ end
@@ -0,0 +1,223 @@
1
+ require 'test_helper'
2
+
3
+ #
4
+ # Test the system configuration model object
5
+ #
6
+ class SystemConfigurationTest < ActiveSupport::TestCase
7
+ should_have_field :environment, type: String, klass: SystemConfiguration, default: 'test'
8
+ should_have_field :default_email, type: String, klass: SystemConfiguration, default: 'support@app47.com'
9
+ should_have_field :support_email, type: String, klass: SystemConfiguration, default: 'support@app47.com'
10
+ should_have_field :smtp_name, type: String, klass: SystemConfiguration
11
+ should_have_field :smtp_address, type: String, klass: SystemConfiguration
12
+ should_have_field :smtp_domain, type: String, klass: SystemConfiguration
13
+ should_have_field :smtp_port, type: Integer, klass: SystemConfiguration, default: 587
14
+ should_have_field :smtp_user_name, type: String, klass: SystemConfiguration
15
+ should_have_field :smtp_password, type: String, klass: SystemConfiguration
16
+ should_have_field :smtp_enable_starttls_auto, type: Mongoid::Boolean, klass: SystemConfiguration
17
+ should_have_field :mailgun_api_key, type: String, klass: SystemConfiguration
18
+ should_have_field :base_url, type: String, klass: SystemConfiguration
19
+ should_have_field :cdn_url, type: String, klass: SystemConfiguration
20
+ # Slack
21
+ should_have_field :slack_api_url, type: String, klass: SystemConfiguration
22
+ should_have_field :slack_support_channel, type: String, klass: SystemConfiguration, default: 'support'
23
+ should_have_field :slack_sales_channel, type: String, klass: SystemConfiguration, default: 'sales'
24
+ # Twillo
25
+ should_have_field :twilio_account_id, type: String, klass: SystemConfiguration
26
+ should_have_field :twilio_auth_token, type: String, klass: SystemConfiguration
27
+ should_have_field :twilio_phone_number, type: String, klass: SystemConfiguration
28
+ # Zendesk
29
+ should_have_field :zendesk_token, type: String, klass: SystemConfiguration
30
+ should_have_field :zendesk_base_url, type: String, default: 'https://app47.zendesk.com', klass: SystemConfiguration
31
+ should_have_field :zendesk_documentation_path, type: String, default: 'hc', klass: SystemConfiguration
32
+ should_have_field :zendesk_support_path, type: String, default: 'hc/en-us/requests', klass: SystemConfiguration
33
+ should_have_field :zendesk_updates_path, type: String, klass: SystemConfiguration, default: 'hc'
34
+ # AWS
35
+ should_have_field :aws_region, type: String, klass: SystemConfiguration
36
+ should_have_field :aws_access_key, type: String, klass: SystemConfiguration
37
+ should_have_field :aws_access_secret, type: String, klass: SystemConfiguration
38
+ should_have_field :aws_auto_scaling_group_name, type: String, klass: SystemConfiguration
39
+ # Switchboard
40
+ should_have_field :switchboard_base_url, type: String, klass: SystemConfiguration, default: 'https://switchboard.app47.com'
41
+ should_have_field :switchboard_stack_id, type: String, klass: SystemConfiguration
42
+ should_have_field :switchboard_stack_api_token, type: String, klass: SystemConfiguration
43
+
44
+ teardown do
45
+ Rails.cache.delete 'SystemConfiguration::test'
46
+ end
47
+
48
+ context 'default behavior' do
49
+ should 'automatically create a system configuration' do
50
+ SystemConfiguration.destroy_all
51
+ assert_equal 0, SystemConfiguration.all.count
52
+ SystemConfiguration.configuration
53
+ assert_equal 1, SystemConfiguration.all.count
54
+ end
55
+ should 'have default values' do
56
+ assert_equal 587, SystemConfiguration.smtp_port
57
+ end
58
+ end
59
+
60
+ context 'handle exception' do
61
+ should 'deal with rails catch throwing an exception' do
62
+ Rails.cache.expects(:fetch).once.raises(ArgumentError)
63
+ Rails.cache.expects(:delete).twice
64
+ SystemConfiguration.expects(:create).never
65
+ SystemConfiguration.base_url
66
+ Rails.cache.unstub(:fetch)
67
+ Rails.cache.unstub(:delete)
68
+ end
69
+ end
70
+
71
+ context 'handle' do
72
+ should 'respond_to_missing?' do
73
+ assert SystemConfiguration.respond_to? 'base_url'
74
+ refute SystemConfiguration.respond_to? 'url'
75
+ end
76
+ end
77
+
78
+ context 'only call things once' do
79
+ setup do
80
+ if SystemConfiguration.all.blank?
81
+ SystemConfiguration.create!(base_url: 'http://somewhere.com',
82
+ environment: Rails.env,
83
+ smtp_name: 'SMTP')
84
+ end
85
+ SystemConfiguration.expects(:where).once.returns(SystemConfiguration.all)
86
+ end
87
+ should 'only call once' do
88
+ SystemConfiguration.base_url
89
+ SystemConfiguration.smtp_port
90
+ SystemConfiguration.smtp_name
91
+ end
92
+ should 'update base_url' do
93
+ url = 'http://something.new'
94
+ config = SystemConfiguration.all.first || SystemConfiguration.new
95
+ config.update_attributes!(base_url: url)
96
+ assert_equal url, SystemConfiguration.base_url
97
+ end
98
+ end
99
+
100
+ context 'smtp configuration' do
101
+ should 'have smtp config' do
102
+ smtp_config = SystemConfiguration.smtp_configuration
103
+ assert_not_nil smtp_config
104
+ assert_not_empty smtp_config
105
+ end
106
+ should 'not be configured' do
107
+ refute SystemConfiguration.smtp_configured?
108
+ refute SystemConfiguration.mailgun_configured?
109
+ end
110
+ should 'be configured' do
111
+ assert SystemConfiguration.configuration.update smtp_name: 'app47', smtp_address: 'app47.com', smtp_domain: 'app47.com'
112
+ assert SystemConfiguration.smtp_configured?
113
+ refute SystemConfiguration.mailgun_configured?
114
+ end
115
+ should 'be configured with mailgun' do
116
+ assert SystemConfiguration.configuration.update smtp_name: 'app47', smtp_address: 'app47.com', smtp_domain: 'app47.com', mailgun_api_key: 'abc123'
117
+ assert SystemConfiguration.smtp_configured?
118
+ assert SystemConfiguration.mailgun_configured?
119
+ end
120
+ end
121
+
122
+ context 'aws configuration' do
123
+ should 'not be configured' do
124
+ refute SystemConfiguration.aws_configured?
125
+ refute SystemConfiguration.aws_auto_scaling_configured?
126
+ end
127
+ should 'aws is configured' do
128
+ assert SystemConfiguration.configuration.update aws_region: 'us'
129
+ refute SystemConfiguration.aws_configured?
130
+ refute SystemConfiguration.aws_auto_scaling_configured?
131
+ assert SystemConfiguration.configuration.update aws_access_key: 'key'
132
+ refute SystemConfiguration.aws_configured?
133
+ refute SystemConfiguration.aws_auto_scaling_configured?
134
+ assert SystemConfiguration.configuration.update aws_access_secret: 'abc123'
135
+ assert SystemConfiguration.aws_configured?
136
+ refute SystemConfiguration.aws_auto_scaling_configured?
137
+ assert SystemConfiguration.configuration.update aws_auto_scaling_group_name: 'g1'
138
+ assert SystemConfiguration.aws_configured?
139
+ assert SystemConfiguration.aws_auto_scaling_configured?
140
+ end
141
+ should 'not retrieve client' do
142
+ assert_nil SystemConfiguration.aws_ec2_client
143
+ end
144
+ should 'retrieve client' do
145
+ assert SystemConfiguration.configuration.update aws_region: 'us',
146
+ aws_access_key: 'key',
147
+ aws_access_secret: 'key'
148
+ client = SystemConfiguration.aws_ec2_client
149
+ assert_not_nil client
150
+ assert client.is_a?(Aws::EC2::Client)
151
+ end
152
+ end
153
+
154
+ context 'twilio configuration' do
155
+ should 'not be configured' do
156
+ refute SystemConfiguration.twilio_configured?
157
+ end
158
+ should 'configured' do
159
+ assert SystemConfiguration.configuration.update twilio_account_id: 'us'
160
+ refute SystemConfiguration.twilio_configured?
161
+ assert SystemConfiguration.configuration.update twilio_auth_token: 'key'
162
+ refute SystemConfiguration.twilio_configured?
163
+ assert SystemConfiguration.configuration.update twilio_phone_number: 'abc123'
164
+ assert SystemConfiguration.twilio_configured?
165
+ end
166
+ end
167
+
168
+ context 'switchboard configuration' do
169
+ should 'not be configured' do
170
+ refute SystemConfiguration.switchboard_configured?
171
+ end
172
+ should 'configured' do
173
+ assert SystemConfiguration.configuration.update switchboard_base_url: 'us'
174
+ refute SystemConfiguration.switchboard_configured?
175
+ assert SystemConfiguration.configuration.update switchboard_stack_api_token: 'key'
176
+ refute SystemConfiguration.switchboard_configured?
177
+ assert SystemConfiguration.configuration.update switchboard_stack_id: 'abc123'
178
+ assert SystemConfiguration.switchboard_configured?
179
+ end
180
+ end
181
+
182
+ context 'zendesk configuration' do
183
+ should 'not be configured' do
184
+ refute SystemConfiguration.zendesk_configured?
185
+ end
186
+ should 'configured' do
187
+ assert SystemConfiguration.configuration.update zendesk_token: 'us'
188
+ assert SystemConfiguration.zendesk_configured?
189
+ end
190
+ should 'zendesk url with no user' do
191
+ assert_equal 'https://app47.zendesk.com/hc', SystemConfiguration.zendesk_url
192
+ assert_equal 'https://app47.zendesk.com/hc', SystemConfiguration.zendesk_documentation_url
193
+ assert_equal 'https://app47.zendesk.com/hc/en-us/requests', SystemConfiguration.zendesk_requests_url
194
+ assert_equal 'https://app47.zendesk.com/hc/en-us/requests/new', SystemConfiguration.zendesk_new_request_url
195
+ assert_equal 'https://app47.zendesk.com/hc', SystemConfiguration.zendesk_updates_url
196
+ end
197
+ should 'zendesk url with user but not configured' do
198
+ user = MockUser.new email: 'foo@bar.com'
199
+ assert_equal 'https://app47.zendesk.com/hc', SystemConfiguration.zendesk_url(user: user)
200
+ assert_equal 'https://app47.zendesk.com/hc', SystemConfiguration.zendesk_documentation_url(user)
201
+ assert_equal 'https://app47.zendesk.com/hc/en-us/requests', SystemConfiguration.zendesk_requests_url(user)
202
+ assert_equal 'https://app47.zendesk.com/hc/en-us/requests/new', SystemConfiguration.zendesk_new_request_url(user)
203
+ assert_equal 'https://app47.zendesk.com/hc', SystemConfiguration.zendesk_updates_url(user)
204
+ end
205
+ should 'zendesk url with user and configured' do
206
+ assert SystemConfiguration.configuration.update zendesk_token: 'us'
207
+ user = MockUser.create(email: 'foo@bar.com', name: 'Foo')
208
+ assert_not_nil user
209
+ assert SystemConfiguration.zendesk_url(user: user).start_with?('https://app47.zendesk.com/access/jwt?jwt=')
210
+ assert SystemConfiguration.zendesk_documentation_url(user).start_with?('https://app47.zendesk.com/access/jwt?jwt=')
211
+ assert SystemConfiguration.zendesk_requests_url(user).start_with?('https://app47.zendesk.com/access/jwt?jwt=')
212
+ assert SystemConfiguration.zendesk_new_request_url(user).start_with?('https://app47.zendesk.com/access/jwt?jwt=')
213
+ assert SystemConfiguration.zendesk_updates_url(user).start_with?('https://app47.zendesk.com/access/jwt?jwt=')
214
+ end
215
+ end
216
+ end
217
+
218
+ class MockUser
219
+ include StandardModel
220
+ field :email, type: String
221
+ field :name, type: String
222
+ end
223
+
data/test/rails_setup.rb CHANGED
@@ -1,4 +1,3 @@
1
- ENV['RAILS_ENV'] = 'test'
2
1
  # require File.expand_path('../../config/environment', __FILE__)
3
2
  # Load the Rails application.
4
3
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
@@ -28,6 +27,7 @@ end
28
27
  # you've limited to :test, :development, or :production.
29
28
  Bundler.require(*Rails.groups)
30
29
 
30
+
31
31
  module WebCore
32
32
  class Application < Rails::Application
33
33
  # Settings in config/environments/* take precedence over those specified here.
@@ -36,7 +36,7 @@ module WebCore
36
36
  # Configure redis cache
37
37
  config.eager_load = false
38
38
  config.cache_store = :redis_store, 'redis://127.0.0.1:6379/11/cache'
39
- config.autoload_paths += %W(#{config.root}/lib #{File.join(Rails.root, 'app', 'mixins')} #{File.join(Rails.root, 'app', 'classes')})
39
+ config.autoload_paths += %W(#{config.root}/lib)
40
40
  config.generators do |g|
41
41
  g.template_engine :haml
42
42
  g.orm :mongoid
@@ -46,9 +46,10 @@ module WebCore
46
46
  end
47
47
  config.active_job.queue_adapter = :delayed_job
48
48
 
49
- config.exceptions_app = ->(env) { ExceptionsController.action(:show).call(env) }
50
49
  # Configure the default encoding used in templates for Ruby 1.9.
51
50
  config.encoding = 'utf-8'
51
+ config.logger = Logger.new(STDOUT)
52
+ config.logger.level = Logger::DEBUG
52
53
  end
53
54
  end
54
55