journaled 2.4.0 → 4.0.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 +4 -4
- data/README.md +68 -19
- data/Rakefile +7 -1
- data/app/jobs/journaled/application_job.rb +4 -0
- data/app/jobs/journaled/delivery_job.rb +105 -0
- data/app/models/journaled/change.rb +3 -3
- data/app/models/journaled/change_writer.rb +5 -5
- data/app/models/journaled/event.rb +2 -2
- data/app/models/journaled/writer.rb +8 -6
- data/lib/journaled/engine.rb +5 -0
- data/lib/journaled/relation_change_protection.rb +1 -1
- data/lib/journaled/version.rb +1 -1
- data/lib/journaled.rb +23 -5
- data/spec/dummy/config/application.rb +1 -2
- data/spec/dummy/config/database.yml +4 -19
- data/spec/dummy/config/environments/development.rb +0 -13
- data/spec/dummy/config/environments/test.rb +3 -5
- data/spec/dummy/db/schema.rb +3 -16
- data/spec/{models/journaled/delivery_spec.rb → jobs/journaled/delivery_job_spec.rb} +82 -28
- data/spec/lib/journaled_spec.rb +39 -0
- data/spec/models/database_change_protection_spec.rb +19 -25
- data/spec/models/journaled/change_writer_spec.rb +10 -10
- data/spec/models/journaled/event_spec.rb +4 -4
- data/spec/models/journaled/writer_spec.rb +18 -15
- data/spec/rails_helper.rb +1 -2
- data/spec/spec_helper.rb +1 -3
- metadata +31 -74
- data/app/models/journaled/delivery.rb +0 -88
- data/config/routes.rb +0 -2
- data/lib/journaled/enqueue.rb +0 -13
- data/spec/dummy/config/environments/production.rb +0 -78
- data/spec/dummy/config/initializers/assets.rb +0 -8
- data/spec/dummy/db/migrate/20180606205114_create_delayed_jobs.rb +0 -18
- data/spec/support/delayed_job_spec_helper.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cefb08a9d7ab294f9084f150f89cda921982fffdb0ec7b0a5bc702ede1d23b8
|
4
|
+
data.tar.gz: 21a484a10c58a3f551e95af064b5f718b9496ba7840ac6c1ac84142b859942db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59d07f836a83dde4e4a24a8a5f326ff5cbc7a751d92fb6df66ee22b5b31ac1aa63326675167d45bcd8c572a0e4afeb831774a468eb45097a71c6940a79ce2681
|
7
|
+
data.tar.gz: 807c603b1085819ed003ed8053f81b6fec59ba895c920bc24ac178b0d3188fac554a2ed9b2dcb80ceceb2a26fc5effe6af5d52819f66d041ad7959cfc30957da
|
data/README.md
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# Journaled
|
2
2
|
|
3
|
-
A Rails engine to durably deliver schematized events to Amazon Kinesis via
|
3
|
+
A Rails engine to durably deliver schematized events to Amazon Kinesis via ActiveJob.
|
4
4
|
|
5
5
|
More specifically, `journaled` is composed of three opinionated pieces:
|
6
6
|
schema definition/validation via JSON Schema, transactional enqueueing
|
7
|
-
via
|
7
|
+
via ActiveJob (specifically, via a DB-backed queue adapter), and event
|
8
8
|
transmission via Amazon Kinesis. Our current use-cases include
|
9
9
|
transmitting audit events for durable storage in S3 and/or analytical
|
10
10
|
querying in Amazon Redshift.
|
11
11
|
|
12
12
|
Journaled provides an at-least-once event delivery guarantee assuming
|
13
|
-
|
13
|
+
ActiveJob's queue adapter is not configured to delete jobs on failure.
|
14
14
|
|
15
15
|
Note: Do not use the journaled gem to build an event sourcing solution
|
16
16
|
as it does not guarantee total ordering of events. It's possible we'll
|
@@ -20,9 +20,20 @@ durable, eventually consistent record that discrete events happened.
|
|
20
20
|
|
21
21
|
## Installation
|
22
22
|
|
23
|
-
1.
|
24
|
-
|
23
|
+
1. If you haven't already,
|
24
|
+
[configure ActiveJob](https://guides.rubyonrails.org/active_job_basics.html)
|
25
|
+
to use one of the following queue adapters:
|
25
26
|
|
27
|
+
- `:delayed_job` (via `delayed_job_active_record`)
|
28
|
+
- `:que`
|
29
|
+
- `:good_job`
|
30
|
+
- `:delayed`
|
31
|
+
|
32
|
+
Ensure that your queue adapter is not configured to delete jobs on failure.
|
33
|
+
|
34
|
+
**If you launch your application in production mode and the gem detects that
|
35
|
+
`ActiveJob::Base.queue_adapter` is not in the above list, it will raise an exception
|
36
|
+
and prevent your application from performing unsafe journaling.**
|
26
37
|
|
27
38
|
2. To integrate Journaled into your application, simply include the gem in your
|
28
39
|
app's Gemfile.
|
@@ -40,20 +51,21 @@ app's Gemfile.
|
|
40
51
|
require 'journaled/rspec'
|
41
52
|
```
|
42
53
|
|
43
|
-
3. You will
|
54
|
+
3. You will need to set the following config in an initializer to allow Journaled to publish events to your AWS Kinesis event stream:
|
44
55
|
|
45
|
-
|
56
|
+
```ruby
|
57
|
+
Journaled.default_stream_name = "my_app_#{Rails.env}_events"
|
58
|
+
```
|
46
59
|
|
47
|
-
|
48
|
-
`#journaled_app_name` method to a non-nil value e.g. `my_app`, you will
|
49
|
-
instead need to provide a corresponding
|
50
|
-
`[upcased_app_name]_JOURNALED_STREAM_NAME` variable for each distinct
|
51
|
-
value, e.g. `MY_APP_JOURNALED_STREAM_NAME`. You can provide a default value
|
52
|
-
for all `Journaled::Event`s in an initializer like this:
|
60
|
+
You may also define a `#journaled_stream_name` method on `Journaled::Event` instances:
|
53
61
|
|
54
62
|
```ruby
|
55
|
-
|
56
|
-
|
63
|
+
def journaled_stream_name
|
64
|
+
"my_app_#{Rails.env}_alternate_events"
|
65
|
+
end
|
66
|
+
````
|
67
|
+
|
68
|
+
3. You may also need to define environment variables to allow Journaled to publish events to your AWS Kinesis event stream:
|
57
69
|
|
58
70
|
You may optionally define the following ENV vars to specify AWS
|
59
71
|
credentials outside of the locations that the AWS SDK normally looks:
|
@@ -71,6 +83,41 @@ app's Gemfile.
|
|
71
83
|
|
72
84
|
The AWS principal whose credentials are in the environment will need to be allowed to assume this role.
|
73
85
|
|
86
|
+
### Upgrading from 3.1.0
|
87
|
+
|
88
|
+
Versions of Journaled prior to 4.0 relied directly on environment variables for stream names, but now stream names are configured directly.
|
89
|
+
When upgrading, you can use the following configuration to maintain the previous behavior:
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
Journaled.default_stream_name = ENV['JOURNALED_STREAM_NAME']
|
93
|
+
```
|
94
|
+
|
95
|
+
If you previously specified a `Journaled.default_app_name`, you would have required a more precise environment variable name (substitute `{{upcase_app_name}}`):
|
96
|
+
|
97
|
+
```ruby
|
98
|
+
Journaled.default_stream_name = ENV["{{upcase_app_name}}_JOURNALED_STREAM_NAME"]
|
99
|
+
```
|
100
|
+
|
101
|
+
And if you had defined any `journaled_app_name` methods on `Journaled::Event` instances, you can replace them with the following:
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
def journaled_stream_name
|
105
|
+
ENV['{{upcase_app_name}}_JOURNALED_STREAM_NAME']
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
109
|
+
When upgrading from 3.1 or below, `Journaled::DeliveryJob` will handle any jobs that remain in the queue by accepting an `app_name` argument. **This behavior will be removed in version 5.0**, so it is recommended to upgrade one major version at a time.
|
110
|
+
|
111
|
+
### Upgrading from 2.5.0
|
112
|
+
|
113
|
+
Versions of Journaled prior to 3.0 relied direclty on `delayed_job` and a "performable" class called `Journaled::Delivery`.
|
114
|
+
In 3.0, this was superceded by an ActiveJob class called `Journaled::DeliveryJob`, but the `Journaled::Delivery` class was not removed until 4.0.
|
115
|
+
|
116
|
+
Therefore, when upgrading from 2.5.0 or below, it is recommended to first upgrade to 3.1.0 (to allow any `Journaled::Delivery` jobs to finish working off) before upgrading to 4.0+.
|
117
|
+
|
118
|
+
The upgrade to 3.1.0 will require a working ActiveJob config. ActiveJob can be configured globally by setting `ActiveJob::Base.queue_adapter`, or just for Journaled jobs by setting `Journaled::DeliveryJob.queue_adapter`.
|
119
|
+
The `:delayed_job` queue adapter will allow you to continue relying on `delayed_job`. You may also consider switching your app(s) to [`delayed`](https://github.com/Betterment/delayed) and using the `:delayed` queue adapter.
|
120
|
+
|
74
121
|
## Usage
|
75
122
|
|
76
123
|
### Configuration
|
@@ -85,14 +132,16 @@ Journaling provides a number of different configuation options that can be set i
|
|
85
132
|
|
86
133
|
#### `Journaled.job_priority` (default: 20)
|
87
134
|
|
88
|
-
This can be used to configure what `priority` the
|
135
|
+
This can be used to configure what `priority` the ActiveJobs are enqueued with. This will be applied to all the `Journaled::DeliveryJob`s that are created by this application.
|
89
136
|
Ex: `Journaled.job_priority = 14`
|
90
137
|
|
138
|
+
_Note that job priority is only supported on Rails 6.0+. Prior Rails versions will ignore this parameter and enqueue jobs with the underlying ActiveJob adapter's default priority._
|
139
|
+
|
91
140
|
#### `Journaled.http_idle_timeout` (default: 1 second)
|
92
141
|
|
93
142
|
The number of seconds a persistent connection is allowed to sit idle before it should no longer be used.
|
94
143
|
|
95
|
-
#### `Journaled.http_open_timeout` (default:
|
144
|
+
#### `Journaled.http_open_timeout` (default: 2 seconds)
|
96
145
|
|
97
146
|
The number of seconds before the :http_handler should timeout while trying to open a new HTTP session.
|
98
147
|
|
@@ -100,9 +149,9 @@ Journaling provides a number of different configuation options that can be set i
|
|
100
149
|
|
101
150
|
The number of seconds before the :http_handler should timeout while waiting for a HTTP response.
|
102
151
|
|
103
|
-
####
|
152
|
+
#### ActiveJob `set` options
|
104
153
|
|
105
|
-
Both model-level directives accept additional options to be passed into
|
154
|
+
Both model-level directives accept additional options to be passed into ActiveJob's `set` method:
|
106
155
|
|
107
156
|
```ruby
|
108
157
|
# For change journaling:
|
data/Rakefile
CHANGED
@@ -28,7 +28,13 @@ if %w(development test).include? Rails.env
|
|
28
28
|
RuboCop::RakeTask.new
|
29
29
|
|
30
30
|
task(:default).clear
|
31
|
-
|
31
|
+
if ENV['APPRAISAL_INITIALIZED'] || ENV['CI']
|
32
|
+
task default: %i(rubocop spec)
|
33
|
+
else
|
34
|
+
require 'appraisal'
|
35
|
+
Appraisal::Task.new
|
36
|
+
task default: :appraisal
|
37
|
+
end
|
32
38
|
|
33
39
|
task 'db:test:prepare' => 'db:setup'
|
34
40
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
module Journaled
|
2
|
+
class DeliveryJob < ApplicationJob
|
3
|
+
DEFAULT_REGION = 'us-east-1'.freeze
|
4
|
+
|
5
|
+
rescue_from(Aws::Kinesis::Errors::InternalFailure, Aws::Kinesis::Errors::ServiceUnavailable, Aws::Kinesis::Errors::Http503Error) do |e|
|
6
|
+
Rails.logger.error "Kinesis Error - Server Error occurred - #{e.class}"
|
7
|
+
raise KinesisTemporaryFailure
|
8
|
+
end
|
9
|
+
|
10
|
+
rescue_from(Seahorse::Client::NetworkingError) do |e|
|
11
|
+
Rails.logger.error "Kinesis Error - Networking Error occurred - #{e.class}"
|
12
|
+
raise KinesisTemporaryFailure
|
13
|
+
end
|
14
|
+
|
15
|
+
UNSPECIFIED = Object.new
|
16
|
+
private_constant :UNSPECIFIED
|
17
|
+
|
18
|
+
def perform(serialized_event:, partition_key:, stream_name: UNSPECIFIED, app_name: UNSPECIFIED)
|
19
|
+
@serialized_event = serialized_event
|
20
|
+
@partition_key = partition_key
|
21
|
+
if app_name != UNSPECIFIED
|
22
|
+
@stream_name = self.class.legacy_computed_stream_name(app_name: app_name)
|
23
|
+
elsif stream_name != UNSPECIFIED && !stream_name.nil?
|
24
|
+
@stream_name = stream_name
|
25
|
+
else
|
26
|
+
raise(ArgumentError, 'missing keyword: stream_name')
|
27
|
+
end
|
28
|
+
|
29
|
+
journal!
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.legacy_computed_stream_name(app_name:)
|
33
|
+
env_var_name = [app_name&.upcase, 'JOURNALED_STREAM_NAME'].compact.join('_')
|
34
|
+
ENV.fetch(env_var_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
def kinesis_client_config
|
38
|
+
{
|
39
|
+
region: ENV.fetch('AWS_DEFAULT_REGION', DEFAULT_REGION),
|
40
|
+
retry_limit: 0,
|
41
|
+
http_idle_timeout: Journaled.http_idle_timeout,
|
42
|
+
http_open_timeout: Journaled.http_open_timeout,
|
43
|
+
http_read_timeout: Journaled.http_read_timeout,
|
44
|
+
}.merge(credentials)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
attr_reader :serialized_event, :partition_key, :stream_name
|
50
|
+
|
51
|
+
def journal!
|
52
|
+
kinesis_client.put_record record if Journaled.enabled?
|
53
|
+
end
|
54
|
+
|
55
|
+
def record
|
56
|
+
{
|
57
|
+
stream_name: stream_name,
|
58
|
+
data: serialized_event,
|
59
|
+
partition_key: partition_key,
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def kinesis_client
|
64
|
+
Aws::Kinesis::Client.new(kinesis_client_config)
|
65
|
+
end
|
66
|
+
|
67
|
+
def credentials
|
68
|
+
if ENV.key?('JOURNALED_IAM_ROLE_ARN')
|
69
|
+
{
|
70
|
+
credentials: iam_assume_role_credentials,
|
71
|
+
}
|
72
|
+
else
|
73
|
+
legacy_credentials_hash_if_present
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def legacy_credentials_hash_if_present
|
78
|
+
if ENV.key?('RUBY_AWS_ACCESS_KEY_ID')
|
79
|
+
{
|
80
|
+
access_key_id: ENV.fetch('RUBY_AWS_ACCESS_KEY_ID'),
|
81
|
+
secret_access_key: ENV.fetch('RUBY_AWS_SECRET_ACCESS_KEY'),
|
82
|
+
}
|
83
|
+
else
|
84
|
+
{}
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def sts_client
|
89
|
+
Aws::STS::Client.new({
|
90
|
+
region: ENV.fetch('AWS_DEFAULT_REGION', DEFAULT_REGION),
|
91
|
+
}.merge(legacy_credentials_hash_if_present))
|
92
|
+
end
|
93
|
+
|
94
|
+
def iam_assume_role_credentials
|
95
|
+
@iam_assume_role_credentials ||= Aws::AssumeRoleCredentials.new(
|
96
|
+
client: sts_client,
|
97
|
+
role_arn: ENV.fetch('JOURNALED_IAM_ROLE_ARN'),
|
98
|
+
role_session_name: "JournaledAssumeRoleAccess",
|
99
|
+
)
|
100
|
+
end
|
101
|
+
|
102
|
+
class KinesisTemporaryFailure < NotTrulyExceptionalError
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -6,7 +6,7 @@ class Journaled::Change
|
|
6
6
|
:database_operation,
|
7
7
|
:logical_operation,
|
8
8
|
:changes,
|
9
|
-
:
|
9
|
+
:journaled_stream_name,
|
10
10
|
:journaled_enqueue_opts,
|
11
11
|
:actor
|
12
12
|
|
@@ -22,7 +22,7 @@ class Journaled::Change
|
|
22
22
|
database_operation:,
|
23
23
|
logical_operation:,
|
24
24
|
changes:,
|
25
|
-
|
25
|
+
journaled_stream_name:,
|
26
26
|
journaled_enqueue_opts:,
|
27
27
|
actor:)
|
28
28
|
@table_name = table_name
|
@@ -30,7 +30,7 @@ class Journaled::Change
|
|
30
30
|
@database_operation = database_operation
|
31
31
|
@logical_operation = logical_operation
|
32
32
|
@changes = changes
|
33
|
-
@
|
33
|
+
@journaled_stream_name = journaled_stream_name
|
34
34
|
@journaled_enqueue_opts = journaled_enqueue_opts
|
35
35
|
@actor = actor
|
36
36
|
end
|
@@ -27,7 +27,7 @@ class Journaled::ChangeWriter
|
|
27
27
|
database_operation: database_operation,
|
28
28
|
logical_operation: logical_operation,
|
29
29
|
changes: JSON.dump(changes),
|
30
|
-
|
30
|
+
journaled_stream_name: journaled_stream_name,
|
31
31
|
journaled_enqueue_opts: model.journaled_enqueue_opts,
|
32
32
|
actor: actor_uri,
|
33
33
|
)
|
@@ -57,11 +57,11 @@ class Journaled::ChangeWriter
|
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def
|
61
|
-
if model.class.respond_to?(:
|
62
|
-
model.class.
|
60
|
+
def journaled_stream_name
|
61
|
+
if model.class.respond_to?(:journaled_stream_name)
|
62
|
+
model.class.journaled_stream_name
|
63
63
|
else
|
64
|
-
Journaled.
|
64
|
+
Journaled.default_stream_name
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -3,7 +3,7 @@ class Journaled::Writer
|
|
3
3
|
journaled_schema_name
|
4
4
|
journaled_partition_key
|
5
5
|
journaled_attributes
|
6
|
-
|
6
|
+
journaled_stream_name
|
7
7
|
journaled_enqueue_opts
|
8
8
|
).freeze
|
9
9
|
|
@@ -27,7 +27,9 @@ class Journaled::Writer
|
|
27
27
|
def journal!
|
28
28
|
base_event_json_schema_validator.validate! serialized_event
|
29
29
|
json_schema_validator.validate! serialized_event
|
30
|
-
Journaled
|
30
|
+
Journaled::DeliveryJob
|
31
|
+
.set(journaled_enqueue_opts.reverse_merge(priority: Journaled.job_priority))
|
32
|
+
.perform_later(delivery_perform_args)
|
31
33
|
end
|
32
34
|
|
33
35
|
private
|
@@ -35,12 +37,12 @@ class Journaled::Writer
|
|
35
37
|
attr_reader :journaled_event
|
36
38
|
delegate(*EVENT_METHOD_NAMES, to: :journaled_event)
|
37
39
|
|
38
|
-
def
|
39
|
-
|
40
|
+
def delivery_perform_args
|
41
|
+
{
|
40
42
|
serialized_event: serialized_event,
|
41
43
|
partition_key: journaled_partition_key,
|
42
|
-
|
43
|
-
|
44
|
+
stream_name: journaled_stream_name,
|
45
|
+
}
|
44
46
|
end
|
45
47
|
|
46
48
|
def serialized_event
|
data/lib/journaled/engine.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Journaled::RelationChangeProtection
|
2
|
-
def update_all(updates, force: false) # rubocop:disable Metrics/
|
2
|
+
def update_all(updates, force: false) # rubocop:disable Metrics/AbcSize, Metrics/PerceivedComplexity
|
3
3
|
unless force || !@klass.respond_to?(:journaled_attribute_names) || @klass.journaled_attribute_names.empty?
|
4
4
|
conflicting_journaled_attribute_names = if updates.is_a?(Hash)
|
5
5
|
@klass.journaled_attribute_names & updates.keys.map(&:to_sym)
|
data/lib/journaled/version.rb
CHANGED
data/lib/journaled.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
require "aws-sdk-kinesis"
|
2
|
-
require "
|
2
|
+
require "active_job"
|
3
3
|
require "json-schema"
|
4
4
|
require "request_store"
|
5
5
|
|
6
6
|
require "journaled/engine"
|
7
|
-
require 'journaled/enqueue'
|
8
7
|
|
9
8
|
module Journaled
|
10
|
-
|
9
|
+
SUPPORTED_QUEUE_ADAPTERS = %w(delayed delayed_job good_job que).freeze
|
10
|
+
|
11
|
+
mattr_accessor :default_stream_name
|
11
12
|
mattr_accessor(:job_priority) { 20 }
|
12
13
|
mattr_accessor(:http_idle_timeout) { 5 }
|
13
|
-
mattr_accessor(:http_open_timeout) {
|
14
|
+
mattr_accessor(:http_open_timeout) { 2 }
|
14
15
|
mattr_accessor(:http_read_timeout) { 60 }
|
16
|
+
mattr_accessor(:job_base_class_name) { 'ActiveJob::Base' }
|
15
17
|
|
16
18
|
def development_or_test?
|
17
19
|
%w(development test).include?(Rails.env)
|
@@ -33,5 +35,21 @@ module Journaled
|
|
33
35
|
Journaled::ActorUriProvider.instance.actor_uri
|
34
36
|
end
|
35
37
|
|
36
|
-
|
38
|
+
def detect_queue_adapter!
|
39
|
+
adapter = job_base_class_name.constantize.queue_adapter_name
|
40
|
+
unless SUPPORTED_QUEUE_ADAPTERS.include?(adapter)
|
41
|
+
raise <<~MSG
|
42
|
+
Journaled has detected an unsupported ActiveJob queue adapter: `:#{adapter}`
|
43
|
+
|
44
|
+
Journaled jobs must be enqueued transactionally to your primary database.
|
45
|
+
|
46
|
+
Please install the appropriate gems and set `queue_adapter` to one of the following:
|
47
|
+
#{SUPPORTED_QUEUE_ADAPTERS.map { |a| "- `:#{a}`" }.join("\n")}
|
48
|
+
|
49
|
+
Read more at https://github.com/Betterment/journaled
|
50
|
+
MSG
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
module_function :development_or_test?, :enabled?, :schema_providers, :commit_hash, :actor_uri, :detect_queue_adapter!
|
37
55
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
require File.expand_path('boot', __dir__)
|
2
2
|
|
3
3
|
require "active_record/railtie"
|
4
|
+
require "active_job/railtie"
|
4
5
|
require "active_model/railtie"
|
5
6
|
require "action_controller/railtie"
|
6
|
-
require "action_mailer/railtie"
|
7
|
-
require "sprockets/railtie"
|
8
7
|
|
9
8
|
Bundler.require(*Rails.groups)
|
10
9
|
require "journaled"
|
@@ -1,21 +1,6 @@
|
|
1
|
-
default: &default
|
2
|
-
pool: 5
|
3
|
-
encoding: unicode
|
4
|
-
|
5
|
-
postgresql:
|
6
|
-
default: &postgres_default
|
7
|
-
adapter: postgresql
|
8
|
-
url: <%= ENV['DATABASE_URL'] %>
|
9
|
-
test: &postgres_test
|
10
|
-
<<: *postgres_default
|
11
|
-
url: <%= ENV['DATABASE_URL'] || "postgresql://localhost:#{ENV.fetch('PGPORT', 5432)}/journaled_test" %>
|
12
|
-
database: journaled_test
|
13
|
-
development: &postgres_development
|
14
|
-
<<: *postgres_default
|
15
|
-
url: <%= ENV['DATABASE_URL'] || "postgresql://localhost:#{ENV.fetch('PGPORT', 5432)}/journaled_development" %>
|
16
|
-
database: journaled_development
|
17
|
-
|
18
1
|
development:
|
19
|
-
|
2
|
+
adapter: sqlite3
|
3
|
+
database: ":memory:"
|
20
4
|
test:
|
21
|
-
|
5
|
+
adapter: sqlite3
|
6
|
+
database: ":memory:"
|
@@ -13,25 +13,12 @@ Rails.application.configure do
|
|
13
13
|
config.consider_all_requests_local = true
|
14
14
|
config.action_controller.perform_caching = false
|
15
15
|
|
16
|
-
# Don't care if the mailer can't send.
|
17
|
-
config.action_mailer.raise_delivery_errors = false
|
18
|
-
|
19
16
|
# Print deprecation notices to the Rails logger.
|
20
17
|
config.active_support.deprecation = :log
|
21
18
|
|
22
19
|
# Raise an error on page load if there are pending migrations.
|
23
20
|
config.active_record.migration_error = :page_load
|
24
21
|
|
25
|
-
# Debug mode disables concatenation and preprocessing of assets.
|
26
|
-
# This option may cause significant delays in view rendering with a large
|
27
|
-
# number of complex assets.
|
28
|
-
config.assets.debug = true
|
29
|
-
|
30
|
-
# Adds additional error checking when serving assets at runtime.
|
31
|
-
# Checks for improperly declared sprockets dependencies.
|
32
|
-
# Raises helpful error messages.
|
33
|
-
config.assets.raise_runtime_errors = true
|
34
|
-
|
35
22
|
# Raises error for missing translations
|
36
23
|
# config.action_view.raise_on_missing_translations = true
|
37
24
|
end
|
@@ -26,14 +26,12 @@ Rails.application.configure do
|
|
26
26
|
# Disable request forgery protection in test environment.
|
27
27
|
config.action_controller.allow_forgery_protection = false
|
28
28
|
|
29
|
-
# Tell Action Mailer not to deliver emails to the real world.
|
30
|
-
# The :test delivery method accumulates sent emails in the
|
31
|
-
# ActionMailer::Base.deliveries array.
|
32
|
-
config.action_mailer.delivery_method = :test
|
33
|
-
|
34
29
|
# Print deprecation notices to the stderr.
|
35
30
|
config.active_support.deprecation = :stderr
|
36
31
|
|
37
32
|
# Raises error for missing translations
|
38
33
|
# config.action_view.raise_on_missing_translations = true
|
34
|
+
|
35
|
+
# Use ActiveJob test adapter
|
36
|
+
config.active_job.queue_adapter = :test
|
39
37
|
end
|
data/spec/dummy/db/schema.rb
CHANGED
@@ -11,21 +11,8 @@
|
|
11
11
|
# It's strongly recommended that you check this file into your version control system.
|
12
12
|
|
13
13
|
ActiveRecord::Schema.define(version: 20180606205114) do
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
create_table "delayed_jobs", force: :cascade do |t|
|
18
|
-
t.integer "priority", default: 0, null: false
|
19
|
-
t.integer "attempts", default: 0, null: false
|
20
|
-
t.text "handler", null: false
|
21
|
-
t.text "last_error"
|
22
|
-
t.datetime "run_at"
|
23
|
-
t.datetime "locked_at"
|
24
|
-
t.datetime "failed_at"
|
25
|
-
t.string "locked_by"
|
26
|
-
t.string "queue"
|
27
|
-
t.datetime "created_at"
|
28
|
-
t.datetime "updated_at"
|
29
|
-
t.index ["priority", "run_at"], name: "delayed_jobs_priority"
|
14
|
+
create_table "widgets", force: :cascade do |t|
|
15
|
+
t.string "name"
|
16
|
+
t.string "other_column"
|
30
17
|
end
|
31
18
|
end
|