loga 2.1.2 → 2.2.0
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.
- checksums.yaml +5 -5
- data/.circleci/config.yml +157 -0
- data/.codeclimate.yml +4 -0
- data/.gitignore +2 -0
- data/.rubocop.yml +13 -8
- data/Appraisals +16 -6
- data/CHANGELOG.md +7 -0
- data/Gemfile +0 -1
- data/Guardfile +8 -6
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/gemfiles/rails32.gemfile +1 -2
- data/gemfiles/rails40.gemfile +1 -2
- data/gemfiles/rails42.gemfile +11 -0
- data/gemfiles/rails50.gemfile +1 -2
- data/gemfiles/rails52.gemfile +11 -0
- data/gemfiles/sinatra14.gemfile +1 -2
- data/gemfiles/unit.gemfile +1 -2
- data/lib/loga.rb +4 -2
- data/lib/loga/configuration.rb +5 -5
- data/lib/loga/ext/rails/rack/debug_exceptions.rb +1 -2
- data/lib/loga/formatters/simple_formatter.rb +1 -1
- data/lib/loga/log_subscribers/action_mailer.rb +59 -0
- data/lib/loga/rack/logger.rb +1 -1
- data/lib/loga/rack/request_id.rb +2 -2
- data/lib/loga/railtie.rb +22 -9
- data/lib/loga/version.rb +1 -1
- data/loga.gemspec +9 -8
- data/spec/fixtures/README.md +23 -3
- data/spec/fixtures/rails32.rb +79 -0
- data/spec/fixtures/rails40.rb +80 -0
- data/spec/fixtures/rails42.rb +80 -0
- data/spec/fixtures/rails50.rb +80 -0
- data/spec/fixtures/rails52.rb +80 -0
- data/spec/integration/rails/action_mailer_spec.rb +63 -0
- data/spec/integration/rails/railtie_spec.rb +15 -0
- data/spec/integration/sinatra_spec.rb +2 -2
- data/spec/spec_helper.rb +7 -8
- data/spec/support/gethostname_shared.rb +7 -0
- data/spec/support/helpers.rb +0 -4
- data/spec/unit/loga/configuration_spec.rb +4 -4
- data/spec/unit/loga/formatters/gelf_formatter_spec.rb +1 -1
- data/spec/unit/loga/formatters/simple_formatter_spec.rb +2 -2
- data/spec/unit/loga/log_subscribers/action_mailer_spec.rb +69 -0
- data/spec/unit/loga/rack/logger_spec.rb +1 -1
- data/spec/unit/loga_spec.rb +1 -1
- metadata +71 -225
- data/circle.yml +0 -23
- data/spec/fixtures/rails32/Rakefile +0 -7
- data/spec/fixtures/rails32/app/controllers/application_controller.rb +0 -28
- data/spec/fixtures/rails32/app/helpers/application_helper.rb +0 -2
- data/spec/fixtures/rails32/app/views/layouts/application.html.erb +0 -14
- data/spec/fixtures/rails32/app/views/user.html.erb +0 -1
- data/spec/fixtures/rails32/config.ru +0 -4
- data/spec/fixtures/rails32/config/application.rb +0 -71
- data/spec/fixtures/rails32/config/boot.rb +0 -6
- data/spec/fixtures/rails32/config/environment.rb +0 -5
- data/spec/fixtures/rails32/config/environments/development.rb +0 -26
- data/spec/fixtures/rails32/config/environments/production.rb +0 -50
- data/spec/fixtures/rails32/config/environments/test.rb +0 -35
- data/spec/fixtures/rails32/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/fixtures/rails32/config/initializers/inflections.rb +0 -15
- data/spec/fixtures/rails32/config/initializers/mime_types.rb +0 -5
- data/spec/fixtures/rails32/config/initializers/secret_token.rb +0 -7
- data/spec/fixtures/rails32/config/initializers/session_store.rb +0 -8
- data/spec/fixtures/rails32/config/initializers/wrap_parameters.rb +0 -10
- data/spec/fixtures/rails32/config/locales/en.yml +0 -5
- data/spec/fixtures/rails32/config/routes.rb +0 -64
- data/spec/fixtures/rails32/public/404.html +0 -26
- data/spec/fixtures/rails32/public/422.html +0 -26
- data/spec/fixtures/rails32/public/500.html +0 -25
- data/spec/fixtures/rails32/public/favicon.ico +0 -0
- data/spec/fixtures/rails32/public/index.html +0 -241
- data/spec/fixtures/rails32/public/robots.txt +0 -5
- data/spec/fixtures/rails32/script/rails +0 -6
- data/spec/fixtures/rails40/Rakefile +0 -6
- data/spec/fixtures/rails40/app/controllers/application_controller.rb +0 -30
- data/spec/fixtures/rails40/app/helpers/application_helper.rb +0 -2
- data/spec/fixtures/rails40/app/views/layouts/application.html.erb +0 -14
- data/spec/fixtures/rails40/app/views/user.html.erb +0 -1
- data/spec/fixtures/rails40/bin/bundle +0 -3
- data/spec/fixtures/rails40/bin/rails +0 -4
- data/spec/fixtures/rails40/bin/rake +0 -4
- data/spec/fixtures/rails40/config.ru +0 -4
- data/spec/fixtures/rails40/config/application.rb +0 -37
- data/spec/fixtures/rails40/config/boot.rb +0 -4
- data/spec/fixtures/rails40/config/environment.rb +0 -5
- data/spec/fixtures/rails40/config/environments/development.rb +0 -24
- data/spec/fixtures/rails40/config/environments/production.rb +0 -65
- data/spec/fixtures/rails40/config/environments/test.rb +0 -39
- data/spec/fixtures/rails40/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/fixtures/rails40/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/fixtures/rails40/config/initializers/inflections.rb +0 -16
- data/spec/fixtures/rails40/config/initializers/mime_types.rb +0 -5
- data/spec/fixtures/rails40/config/initializers/secret_token.rb +0 -12
- data/spec/fixtures/rails40/config/initializers/session_store.rb +0 -3
- data/spec/fixtures/rails40/config/initializers/wrap_parameters.rb +0 -9
- data/spec/fixtures/rails40/config/locales/en.yml +0 -23
- data/spec/fixtures/rails40/config/routes.rb +0 -62
- data/spec/fixtures/rails40/public/404.html +0 -58
- data/spec/fixtures/rails40/public/422.html +0 -58
- data/spec/fixtures/rails40/public/500.html +0 -57
- data/spec/fixtures/rails40/public/favicon.ico +0 -0
- data/spec/fixtures/rails40/public/robots.txt +0 -5
- data/spec/fixtures/rails50/Rakefile +0 -6
- data/spec/fixtures/rails50/app/controllers/application_controller.rb +0 -28
- data/spec/fixtures/rails50/app/helpers/application_helper.rb +0 -2
- data/spec/fixtures/rails50/app/views/layouts/application.html.erb +0 -13
- data/spec/fixtures/rails50/app/views/user.html.erb +0 -1
- data/spec/fixtures/rails50/bin/bundle +0 -3
- data/spec/fixtures/rails50/bin/rails +0 -4
- data/spec/fixtures/rails50/bin/rake +0 -4
- data/spec/fixtures/rails50/bin/setup +0 -34
- data/spec/fixtures/rails50/bin/update +0 -29
- data/spec/fixtures/rails50/config.ru +0 -5
- data/spec/fixtures/rails50/config/application.rb +0 -34
- data/spec/fixtures/rails50/config/boot.rb +0 -3
- data/spec/fixtures/rails50/config/cable.yml +0 -9
- data/spec/fixtures/rails50/config/environment.rb +0 -5
- data/spec/fixtures/rails50/config/environments/development.rb +0 -44
- data/spec/fixtures/rails50/config/environments/production.rb +0 -75
- data/spec/fixtures/rails50/config/environments/test.rb +0 -42
- data/spec/fixtures/rails50/config/initializers/application_controller_renderer.rb +0 -6
- data/spec/fixtures/rails50/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/fixtures/rails50/config/initializers/cookies_serializer.rb +0 -5
- data/spec/fixtures/rails50/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/fixtures/rails50/config/initializers/inflections.rb +0 -16
- data/spec/fixtures/rails50/config/initializers/mime_types.rb +0 -4
- data/spec/fixtures/rails50/config/initializers/new_framework_defaults.rb +0 -21
- data/spec/fixtures/rails50/config/initializers/session_store.rb +0 -3
- data/spec/fixtures/rails50/config/initializers/wrap_parameters.rb +0 -9
- data/spec/fixtures/rails50/config/locales/en.yml +0 -23
- data/spec/fixtures/rails50/config/puma.rb +0 -47
- data/spec/fixtures/rails50/config/routes.rb +0 -9
- data/spec/fixtures/rails50/config/secrets.yml +0 -23
- data/spec/fixtures/rails50/public/404.html +0 -67
- data/spec/fixtures/rails50/public/422.html +0 -67
- data/spec/fixtures/rails50/public/500.html +0 -66
- data/spec/fixtures/rails50/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/fixtures/rails50/public/apple-touch-icon.png +0 -0
- data/spec/fixtures/rails50/public/favicon.ico +0 -0
- data/spec/fixtures/rails50/public/robots.txt +0 -5
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
module Loga
|
|
2
|
+
module LogSubscribers
|
|
3
|
+
# Loga::LogSubscribers::ActionMailer tracks the three
|
|
4
|
+
# mailing events: 'process', 'deliver' and 'receive', and
|
|
5
|
+
# builds a loga event instance for each particular invocation.
|
|
6
|
+
class ActionMailer < ActiveSupport::LogSubscriber
|
|
7
|
+
def deliver(event)
|
|
8
|
+
mailer = event.payload[:mailer]
|
|
9
|
+
recipients = event.payload[:to].join(',')
|
|
10
|
+
unique_id = event.payload[:unique_id]
|
|
11
|
+
duration = event.duration.round(1)
|
|
12
|
+
message = "#{mailer}: Sent mail to #{recipients} in (#{duration}ms)"
|
|
13
|
+
|
|
14
|
+
loga_event = Event.new(
|
|
15
|
+
data: { mailer: mailer, unique_id: unique_id },
|
|
16
|
+
message: message,
|
|
17
|
+
type: 'action_mailer',
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
logger.info(loga_event)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def process(event)
|
|
24
|
+
mailer = event.payload[:mailer]
|
|
25
|
+
action = event.payload[:action]
|
|
26
|
+
unique_id = event.payload[:unique_id]
|
|
27
|
+
duration = event.duration.round(1)
|
|
28
|
+
|
|
29
|
+
message = "#{mailer}##{action}: Processed outbound mail in (#{duration}ms)"
|
|
30
|
+
|
|
31
|
+
loga_event = Event.new(
|
|
32
|
+
data: { mailer: mailer, unique_id: unique_id, action: action },
|
|
33
|
+
message: message,
|
|
34
|
+
type: 'action_mailer',
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
logger.debug(loga_event)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def receive(event)
|
|
41
|
+
from = event.payload[:from]
|
|
42
|
+
mailer = event.payload[:mailer]
|
|
43
|
+
unique_id = event.payload[:unique_id]
|
|
44
|
+
|
|
45
|
+
loga_event = Event.new(
|
|
46
|
+
data: { mailer: mailer, unique_id: unique_id },
|
|
47
|
+
message: "Received mail #{from} in (#{event.duration.round(1)}ms)",
|
|
48
|
+
type: 'action_mailer',
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
logger.info(loga_event)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def logger
|
|
55
|
+
Loga.logger
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
data/lib/loga/rack/logger.rb
CHANGED
|
@@ -63,7 +63,7 @@ module Loga
|
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
def compute_message
|
|
66
|
-
'
|
|
66
|
+
'%<method>s %<filtered_full_path>s %<status>d in %<duration>dms' % {
|
|
67
67
|
method: request.request_method,
|
|
68
68
|
filtered_full_path: request.filtered_full_path,
|
|
69
69
|
status: data['status'],
|
data/lib/loga/rack/request_id.rb
CHANGED
|
@@ -3,7 +3,7 @@ require 'securerandom'
|
|
|
3
3
|
require 'active_support/core_ext/string/access'
|
|
4
4
|
require 'active_support/core_ext/object/blank'
|
|
5
5
|
|
|
6
|
-
# rubocop:disable Metrics/LineLength,
|
|
6
|
+
# rubocop:disable Lint/AssignmentInCondition, Metrics/LineLength, Style/GuardClause
|
|
7
7
|
module Loga
|
|
8
8
|
module Rack
|
|
9
9
|
# Makes a unique request id available to the action_dispatch.request_id env variable (which is then accessible through
|
|
@@ -41,4 +41,4 @@ module Loga
|
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
end
|
|
44
|
-
# rubocop:enable
|
|
44
|
+
# rubocop:enable Lint/AssignmentInCondition, Metrics/LineLength, Style/GuardClause
|
data/lib/loga/railtie.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
require 'loga'
|
|
2
|
+
require 'loga/log_subscribers/action_mailer'
|
|
2
3
|
|
|
3
4
|
module Loga
|
|
4
5
|
class Railtie < Rails::Railtie
|
|
@@ -153,29 +154,41 @@ module Loga
|
|
|
153
154
|
|
|
154
155
|
def call
|
|
155
156
|
ensure_subscriptions_attached
|
|
157
|
+
subscribe_to_action_mailer
|
|
156
158
|
remove_log_subscriptions
|
|
157
159
|
end
|
|
158
160
|
|
|
159
161
|
private
|
|
160
162
|
|
|
163
|
+
def subscribe_to_action_mailer
|
|
164
|
+
LogSubscribers::ActionMailer.attach_to(:action_mailer)
|
|
165
|
+
end
|
|
166
|
+
|
|
161
167
|
# Ensure LogSubscribers are attached when available
|
|
162
168
|
def ensure_subscriptions_attached
|
|
163
169
|
ActionView::Base if defined?(ActionView::Base)
|
|
164
170
|
ActionController::Base if defined?(ActionController::Base)
|
|
171
|
+
ActionMailer::Base if defined?(ActionMailer::Base)
|
|
165
172
|
end
|
|
166
173
|
|
|
167
|
-
# rubocop:disable Metrics/LineLength
|
|
168
174
|
def remove_log_subscriptions
|
|
169
175
|
ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
+
component = log_subscription_component(subscriber)
|
|
177
|
+
|
|
178
|
+
unsubscribe(component, subscriber)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
def log_subscription_component(subscriber) # rubocop:disable CyclomaticComplexity
|
|
183
|
+
case subscriber
|
|
184
|
+
when defined?(ActionView::LogSubscriber) && ActionView::LogSubscriber
|
|
185
|
+
:action_view
|
|
186
|
+
when defined?(ActionController::LogSubscriber) && ActionController::LogSubscriber
|
|
187
|
+
:action_controller
|
|
188
|
+
when defined?(ActionMailer::LogSubscriber) && ActionMailer::LogSubscriber
|
|
189
|
+
:action_mailer
|
|
176
190
|
end
|
|
177
191
|
end
|
|
178
|
-
# rubocop:enable Metrics/LineLength
|
|
179
192
|
|
|
180
193
|
def unsubscribe(component, subscriber)
|
|
181
194
|
events = subscriber
|
|
@@ -187,7 +200,7 @@ module Loga
|
|
|
187
200
|
.listeners_for("#{event}.#{component}")
|
|
188
201
|
.each do |listener|
|
|
189
202
|
if listener.instance_variable_get('@delegate') == subscriber
|
|
190
|
-
ActiveSupport::Notifications.unsubscribe
|
|
203
|
+
ActiveSupport::Notifications.unsubscribe(listener)
|
|
191
204
|
end
|
|
192
205
|
end
|
|
193
206
|
end
|
data/lib/loga/version.rb
CHANGED
data/loga.gemspec
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'loga/version'
|
|
@@ -21,15 +21,16 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.add_dependency 'activesupport', '>= 2.3.8'
|
|
22
22
|
spec.add_dependency 'rack'
|
|
23
23
|
|
|
24
|
-
spec.add_development_dependency 'appraisal', '~> 2.0
|
|
25
|
-
spec.add_development_dependency 'bundler',
|
|
24
|
+
spec.add_development_dependency 'appraisal', '~> 2.2.0'
|
|
25
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
|
26
|
+
spec.add_development_dependency 'byebug'
|
|
27
|
+
spec.add_development_dependency 'guard', '~> 2.13'
|
|
28
|
+
spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
|
|
29
|
+
spec.add_development_dependency 'guard-rubocop', '~> 1.2'
|
|
26
30
|
spec.add_development_dependency 'pry'
|
|
27
31
|
spec.add_development_dependency 'rack-test'
|
|
28
32
|
spec.add_development_dependency 'rake'
|
|
29
|
-
spec.add_development_dependency 'rspec', '~> 3.
|
|
30
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
|
33
|
+
spec.add_development_dependency 'rspec', '~> 3.6.0'
|
|
34
|
+
spec.add_development_dependency 'rubocop', '~> 0.50.0'
|
|
31
35
|
spec.add_development_dependency 'timecop'
|
|
32
|
-
spec.add_development_dependency 'guard', '~> 2.13'
|
|
33
|
-
spec.add_development_dependency 'guard-rubocop', '~> 1.2'
|
|
34
|
-
spec.add_development_dependency 'guard-rspec', '~> 4.7.3'
|
|
35
36
|
end
|
data/spec/fixtures/README.md
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
# Generating fixture Apps
|
|
2
2
|
|
|
3
3
|
## Rails 3.2
|
|
4
|
-
`appraisal rails32 rails new spec/fixtures/rails32 --skip-gemfile --skip-git --skip-active-record --skip-sprockets --skip-javascript --skip-test-unit`
|
|
5
4
|
|
|
5
|
+
```
|
|
6
|
+
appraisal rails32 rails new spec/fixtures/rails32 --skip-gemfile --skip-git --skip-active-record --skip-sprockets --skip-javascript --skip-test-unit
|
|
7
|
+
```
|
|
6
8
|
|
|
7
9
|
## Rails 4.0
|
|
8
|
-
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
appraisal rails40 rails new spec/fixtures/rails40 --skip-gemfile --skip-git --skip-keeps --skip-active-record --skip-action-view --skip-sprockets --skip-spring --skip-javascript --skip-test-unit
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Rails 4.2
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
appraisal rails42 rails new spec/fixtures/rails42 --skip-gemfile --skip-git --skip-keeps --skip-active-record --skip-action-view --skip-sprockets --skip-spring --skip-javascript --skip-test-unit
|
|
19
|
+
```
|
|
9
20
|
|
|
10
21
|
## Rails 5.0
|
|
11
|
-
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
appraisal rails50 rails new spec/fixtures/rails50 --skip-gemfile --skip-git --skip-keeps --skip-active-record --skip-action-view --skip-sprockets --skip-spring --skip-javascript --skip-test-unit
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Rails 5.2
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
appraisal rails52 rails new spec/fixtures/rails52 --skip-gemfile --skip-git --skip-keeps --skip-active-record --skip-action-view --skip-sprockets --skip-spring --skip-javascript --skip-test-unit
|
|
31
|
+
```
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require 'action_controller/railtie'
|
|
2
|
+
require 'action_mailer/railtie'
|
|
3
|
+
|
|
4
|
+
Bundler.require(*Rails.groups(assets: %w[development test]))
|
|
5
|
+
|
|
6
|
+
STREAM = StringIO.new unless defined?(STREAM)
|
|
7
|
+
|
|
8
|
+
class Dummy < Rails::Application
|
|
9
|
+
config.filter_parameters += [:password]
|
|
10
|
+
config.secret_token = '32431967aed1c4357d311f27708a1837a938f07e0abfdefa6b8b398d7024c08c6b883ce9254cdd8573ce8e78f9dd192efff39395127811040fc695ab23677452'
|
|
11
|
+
config.session_store :cookie_store, key: '_rails32_session'
|
|
12
|
+
|
|
13
|
+
config.log_tags = [:uuid, 'TEST_TAG']
|
|
14
|
+
config.loga = {
|
|
15
|
+
device: STREAM,
|
|
16
|
+
host: 'bird.example.com',
|
|
17
|
+
service_name: 'hello_world_app',
|
|
18
|
+
service_version: '1.0',
|
|
19
|
+
}
|
|
20
|
+
config.action_mailer.delivery_method = :test
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class ApplicationController < ActionController::Base
|
|
24
|
+
include Rails.application.routes.url_helpers
|
|
25
|
+
protect_from_forgery
|
|
26
|
+
|
|
27
|
+
def ok
|
|
28
|
+
render text: 'Hello Rails'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def error
|
|
32
|
+
nil.name
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def show
|
|
36
|
+
render json: params
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def create
|
|
40
|
+
render json: params
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def new
|
|
44
|
+
redirect_to :ok
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def update
|
|
48
|
+
@id = params[:id]
|
|
49
|
+
render '/user'
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
class FakeMailer < ActionMailer::Base
|
|
54
|
+
default from: 'notifications@example.com'
|
|
55
|
+
|
|
56
|
+
def self.send_email
|
|
57
|
+
basic_mail.deliver
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def basic_mail
|
|
61
|
+
mail(
|
|
62
|
+
to: 'user@example.com',
|
|
63
|
+
subject: 'Welcome to My Awesome Site',
|
|
64
|
+
body: 'Banana muffin',
|
|
65
|
+
content_type: 'text/html',
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
Dummy.routes.append do
|
|
71
|
+
get 'ok' => 'application#ok'
|
|
72
|
+
get 'error' => 'application#error'
|
|
73
|
+
get 'show' => 'application#show'
|
|
74
|
+
post 'users' => 'application#create'
|
|
75
|
+
get 'new' => 'application#new'
|
|
76
|
+
put 'users/:id' => 'application#update'
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
Dummy.initialize!
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'action_controller/railtie'
|
|
2
|
+
require 'action_mailer/railtie'
|
|
3
|
+
|
|
4
|
+
Bundler.require(*Rails.groups)
|
|
5
|
+
|
|
6
|
+
STREAM = StringIO.new unless defined?(STREAM)
|
|
7
|
+
|
|
8
|
+
class Dummy < Rails::Application
|
|
9
|
+
config.eager_load = true
|
|
10
|
+
config.filter_parameters += [:password]
|
|
11
|
+
config.secret_key_base = '2624599ca9ab3cf3823626240138a128118a87683bf03ab8f155844c33b3cd8cbbfa3ef5e29db6f5bd182f8bd4776209d9577cfb46ac51bfd232b00ab0136b24'
|
|
12
|
+
config.session_store :cookie_store, key: '_rails40_session'
|
|
13
|
+
|
|
14
|
+
config.log_tags = [:uuid, 'TEST_TAG']
|
|
15
|
+
config.loga = {
|
|
16
|
+
device: STREAM,
|
|
17
|
+
host: 'bird.example.com',
|
|
18
|
+
service_name: 'hello_world_app',
|
|
19
|
+
service_version: '1.0',
|
|
20
|
+
}
|
|
21
|
+
config.action_mailer.delivery_method = :test
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class ApplicationController < ActionController::Base
|
|
25
|
+
include Rails.application.routes.url_helpers
|
|
26
|
+
protect_from_forgery
|
|
27
|
+
|
|
28
|
+
def ok
|
|
29
|
+
render text: 'Hello Rails'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def error
|
|
33
|
+
nil.name
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def show
|
|
37
|
+
render json: params
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def create
|
|
41
|
+
render json: params
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def new
|
|
45
|
+
redirect_to :ok
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def update
|
|
49
|
+
@id = params[:id]
|
|
50
|
+
render '/user'
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class FakeMailer < ActionMailer::Base
|
|
55
|
+
default from: 'notifications@example.com'
|
|
56
|
+
|
|
57
|
+
def self.send_email
|
|
58
|
+
basic_mail.deliver
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def basic_mail
|
|
62
|
+
mail(
|
|
63
|
+
to: 'user@example.com',
|
|
64
|
+
subject: 'Welcome to My Awesome Site',
|
|
65
|
+
body: 'Banana muffin',
|
|
66
|
+
content_type: 'text/html',
|
|
67
|
+
)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
Dummy.routes.append do
|
|
72
|
+
get 'ok' => 'application#ok'
|
|
73
|
+
get 'error' => 'application#error'
|
|
74
|
+
get 'show' => 'application#show'
|
|
75
|
+
post 'users' => 'application#create'
|
|
76
|
+
get 'new' => 'application#new'
|
|
77
|
+
put 'users/:id' => 'application#update'
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
Dummy.initialize!
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'action_controller/railtie'
|
|
2
|
+
require 'action_mailer/railtie'
|
|
3
|
+
|
|
4
|
+
Bundler.require(*Rails.groups)
|
|
5
|
+
|
|
6
|
+
STREAM = StringIO.new unless defined?(STREAM)
|
|
7
|
+
|
|
8
|
+
class Dummy < Rails::Application
|
|
9
|
+
config.eager_load = true
|
|
10
|
+
config.filter_parameters += [:password]
|
|
11
|
+
config.secret_key_base = '2624599ca9ab3cf3823626240138a128118a87683bf03ab8f155844c33b3cd8cbbfa3ef5e29db6f5bd182f8bd4776209d9577cfb46ac51bfd232b00ab0136b24'
|
|
12
|
+
config.session_store :cookie_store, key: '_rails42_session'
|
|
13
|
+
|
|
14
|
+
config.log_tags = [:uuid, 'TEST_TAG']
|
|
15
|
+
config.loga = {
|
|
16
|
+
device: STREAM,
|
|
17
|
+
host: 'bird.example.com',
|
|
18
|
+
service_name: 'hello_world_app',
|
|
19
|
+
service_version: '1.0',
|
|
20
|
+
}
|
|
21
|
+
config.action_mailer.delivery_method = :test
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class ApplicationController < ActionController::Base
|
|
25
|
+
include Rails.application.routes.url_helpers
|
|
26
|
+
protect_from_forgery
|
|
27
|
+
|
|
28
|
+
def ok
|
|
29
|
+
render text: 'Hello Rails'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def error
|
|
33
|
+
nil.name
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def show
|
|
37
|
+
render json: params
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def create
|
|
41
|
+
render json: params
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def new
|
|
45
|
+
redirect_to :ok
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def update
|
|
49
|
+
@id = params[:id]
|
|
50
|
+
render '/user'
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class FakeMailer < ActionMailer::Base
|
|
55
|
+
default from: 'notifications@example.com'
|
|
56
|
+
|
|
57
|
+
def self.send_email
|
|
58
|
+
basic_mail.deliver_now
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def basic_mail
|
|
62
|
+
mail(
|
|
63
|
+
to: 'user@example.com',
|
|
64
|
+
subject: 'Welcome to My Awesome Site',
|
|
65
|
+
body: 'Banana muffin',
|
|
66
|
+
content_type: 'text/html',
|
|
67
|
+
)
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
Dummy.routes.append do
|
|
72
|
+
get 'ok' => 'application#ok'
|
|
73
|
+
get 'error' => 'application#error'
|
|
74
|
+
get 'show' => 'application#show'
|
|
75
|
+
post 'users' => 'application#create'
|
|
76
|
+
get 'new' => 'application#new'
|
|
77
|
+
put 'users/:id' => 'application#update'
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
Dummy.initialize!
|