letter_opener_web_wally 2.0.1
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 +7 -0
- data/.github/workflows/brakeman-analysis.yml +36 -0
- data/.github/workflows/main.yml +29 -0
- data/.github/workflows/release-gem.yml +32 -0
- data/.gitignore +20 -0
- data/.rspec +4 -0
- data/.rubocop.yml +29 -0
- data/.rubocop_todo.yml +19 -0
- data/CHANGELOG.md +95 -0
- data/Gemfile +8 -0
- data/LICENSE.txt +0 -0
- data/README.md +176 -0
- data/Rakefile +10 -0
- data/app/controllers/letter_opener_web/application_controller.rb +7 -0
- data/app/controllers/letter_opener_web/letters_controller.rb +77 -0
- data/app/models/letter_opener_web/aws_letter.rb +98 -0
- data/app/models/letter_opener_web/base_letter.rb +93 -0
- data/app/models/letter_opener_web/letter.rb +54 -0
- data/app/models/letter_opener_web/s3_message.rb +25 -0
- data/app/views/layouts/letter_opener_web/_javascripts.html.erb +31 -0
- data/app/views/layouts/letter_opener_web/_styles.html.erb +3 -0
- data/app/views/layouts/letter_opener_web/js/_favcount.html.erb +104 -0
- data/app/views/layouts/letter_opener_web/js/_jquery.html.erb +7 -0
- data/app/views/layouts/letter_opener_web/letters.html.erb +15 -0
- data/app/views/layouts/letter_opener_web/styles/_bootstrap.html.erb +9 -0
- data/app/views/layouts/letter_opener_web/styles/_icon.html.erb +2 -0
- data/app/views/layouts/letter_opener_web/styles/_letters.html.erb +70 -0
- data/app/views/letter_opener_web/letters/_item.html.erb +10 -0
- data/app/views/letter_opener_web/letters/index.html.erb +24 -0
- data/bin/setup +6 -0
- data/config/routes.rb +9 -0
- data/letter_opener_web.gemspec +35 -0
- data/lib/letter_opener_web/delivery_method.rb +29 -0
- data/lib/letter_opener_web/engine.rb +20 -0
- data/lib/letter_opener_web/version.rb +5 -0
- data/lib/letter_opener_web.rb +52 -0
- data/script/pre-push +2 -0
- data/spec/controllers/letter_opener_web/letters_controller_spec.rb +282 -0
- data/spec/dummy/Rakefile +8 -0
- data/spec/dummy/app/assets/config/manifest.js +3 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +6 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +6 -0
- data/spec/dummy/app/controllers/application_controller.rb +4 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +4 -0
- data/spec/dummy/app/javascript/packs/application.js +15 -0
- data/spec/dummy/app/jobs/application_job.rb +9 -0
- data/spec/dummy/app/mailers/application_mailer.rb +6 -0
- data/spec/dummy/app/models/application_record.rb +5 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +33 -0
- data/spec/dummy/config/application.rb +37 -0
- data/spec/dummy/config/boot.rb +7 -0
- data/spec/dummy/config/environment.rb +7 -0
- data/spec/dummy/config/environments/development.rb +78 -0
- data/spec/dummy/config/environments/production.rb +122 -0
- data/spec/dummy/config/environments/test.rb +61 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +10 -0
- data/spec/dummy/config/initializers/assets.rb +14 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +10 -0
- data/spec/dummy/config/initializers/content_security_policy.rb +30 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +8 -0
- data/spec/dummy/config/initializers/inflections.rb +18 -0
- data/spec/dummy/config/initializers/mime_types.rb +6 -0
- data/spec/dummy/config/initializers/permissions_policy.rb +13 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +16 -0
- data/spec/dummy/config/locales/en.yml +33 -0
- data/spec/dummy/config/puma.rb +45 -0
- data/spec/dummy/config/routes.rb +5 -0
- data/spec/dummy/config.ru +8 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/letter_opener_web_spec.rb +47 -0
- data/spec/models/letter_opener_web/aws_letter_spec.rb +196 -0
- data/spec/models/letter_opener_web/letter_spec.rb +184 -0
- data/spec/rails_helper.rb +8 -0
- data/spec/spec_helper.rb +8 -0
- metadata +291 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'letter_opener'
|
4
|
+
require 'letter_opener_web/delivery_method'
|
5
|
+
|
6
|
+
module LetterOpenerWeb
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
isolate_namespace LetterOpenerWeb
|
9
|
+
|
10
|
+
initializer 'letter_opener_web.add_delivery_method' do
|
11
|
+
ActiveSupport.on_load :action_mailer do
|
12
|
+
ActionMailer::Base.add_delivery_method(
|
13
|
+
:letter_opener_web,
|
14
|
+
LetterOpenerWeb::DeliveryMethod,
|
15
|
+
location: LetterOpenerWeb.config.letters_location
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'letter_opener_web/version'
|
4
|
+
require 'letter_opener_web/engine'
|
5
|
+
require 'rexml/document'
|
6
|
+
require 'aws-sdk-s3'
|
7
|
+
|
8
|
+
module LetterOpenerWeb
|
9
|
+
class Config
|
10
|
+
attr_accessor(
|
11
|
+
:letters_storage,
|
12
|
+
:aws_access_key_id,
|
13
|
+
:aws_secret_access_key,
|
14
|
+
:aws_region,
|
15
|
+
:aws_bucket
|
16
|
+
)
|
17
|
+
|
18
|
+
def letters_location
|
19
|
+
@letters_location ||=
|
20
|
+
case LetterOpenerWeb.config.letters_storage
|
21
|
+
when :local
|
22
|
+
Rails.root.join('tmp', 'letter_opener')
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
attr_writer :letters_location
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.config
|
30
|
+
@config ||= Config.new.tap do |conf|
|
31
|
+
conf.letters_storage = :local
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.configure
|
36
|
+
yield config if block_given?
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.reset!
|
40
|
+
@config = nil
|
41
|
+
@aws_client = nil
|
42
|
+
@letters_location = nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.aws_client
|
46
|
+
@aws_client ||= ::Aws::S3::Client.new(
|
47
|
+
access_key_id: LetterOpenerWeb.config.aws_access_key_id,
|
48
|
+
secret_access_key: LetterOpenerWeb.config.aws_secret_access_key,
|
49
|
+
region: LetterOpenerWeb.config.aws_region
|
50
|
+
)
|
51
|
+
end
|
52
|
+
end
|
data/script/pre-push
ADDED
@@ -0,0 +1,282 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rails_helper'
|
4
|
+
|
5
|
+
RSpec.describe LetterOpenerWeb::LettersController do
|
6
|
+
routes { LetterOpenerWeb::Engine.routes }
|
7
|
+
|
8
|
+
after(:each) { LetterOpenerWeb.reset! }
|
9
|
+
|
10
|
+
context 'when letters location is on AWS S3 bucket' do
|
11
|
+
before do
|
12
|
+
LetterOpenerWeb.configure do |config|
|
13
|
+
config.aws_access_key_id = 'aws_access_key_id'
|
14
|
+
config.aws_secret_access_key = 'aws_secret_access_key'
|
15
|
+
config.aws_region = 'aws_region'
|
16
|
+
config.aws_bucket = 'aws_bucket'
|
17
|
+
config.letters_storage = :s3
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe 'GET index' do
|
22
|
+
before do
|
23
|
+
allow(LetterOpenerWeb::AwsLetter).to receive(:search)
|
24
|
+
get :index
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'searches for all letters' do
|
28
|
+
expect(LetterOpenerWeb::AwsLetter).to have_received(:search)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns an HTML 200 response' do
|
32
|
+
expect(response.status).to eq(200)
|
33
|
+
expect(response.content_type).to eq('text/html; charset=utf-8')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe 'GET show' do
|
38
|
+
let(:id) { 'an-id' }
|
39
|
+
let(:rich_text) { 'rich text href="plain.html"' }
|
40
|
+
let(:plain_text) { 'plain text href="rich.html"' }
|
41
|
+
let(:letter) { double(:letter, rich_text:, plain_text:, id:) }
|
42
|
+
|
43
|
+
shared_examples 'found letter examples' do |letter_style|
|
44
|
+
before(:each) do
|
45
|
+
expect(LetterOpenerWeb::AwsLetter).to receive(:find).with(id).and_return(letter)
|
46
|
+
expect(letter).to receive(:valid?).and_return(true)
|
47
|
+
get :show, params: { id:, style: letter_style }
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'renders an HTML 200 response' do
|
51
|
+
expect(response.status).to eq(200)
|
52
|
+
expect(response.content_type).to eq('text/html; charset=utf-8')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'rich text version' do
|
57
|
+
include_examples 'found letter examples', 'rich'
|
58
|
+
|
59
|
+
it 'renders the rich text contents' do
|
60
|
+
expect(response.body).to match(/^rich text/)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'fixes plain text link' do
|
64
|
+
expect(response.body).not_to match(/href="plain.html"/)
|
65
|
+
expect(response.body).to match(/href="#{Regexp.escape letter_path(id:, style: 'plain')}"/)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'plain text version' do
|
70
|
+
include_examples 'found letter examples', 'plain'
|
71
|
+
|
72
|
+
it 'renders the plain text contents' do
|
73
|
+
expect(response.body).to match(/^plain text/)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'fixes rich text link' do
|
77
|
+
expect(response.body).not_to match(/href="rich.html"/)
|
78
|
+
expect(response.body).to match(/href="#{Regexp.escape letter_path(id:, style: 'rich')}"/)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context 'with wrong parameters' do
|
83
|
+
it 'should return 404 when invalid id given' do
|
84
|
+
letter = double(:letter, attachments: {}, valid?: false)
|
85
|
+
allow(LetterOpenerWeb::AwsLetter).to receive(:find).with(id).and_return(letter)
|
86
|
+
|
87
|
+
get :show, params: { id:, style: 'rich' }
|
88
|
+
expect(response.status).to eq(404)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'GET attachment' do
|
94
|
+
let(:id) { 'an-id' }
|
95
|
+
let(:attachment_path) { 'path/to/attachment' }
|
96
|
+
let(:file_name) { 'image.jpg' }
|
97
|
+
let(:letter) { double(:letter, attachments: { file_name => attachment_path }, id:) }
|
98
|
+
|
99
|
+
before do
|
100
|
+
allow(LetterOpenerWeb::AwsLetter).to receive(:find).with(id).and_return(letter)
|
101
|
+
allow(letter).to receive(:valid?).and_return(true)
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'redirects to the s3 file' do
|
105
|
+
allow(controller).to receive(:redirect_to) { controller.head :found }
|
106
|
+
get :attachment, params: { id:, file: file_name.gsub(/\.\w+/, ''), format: File.extname(file_name)[1..] }
|
107
|
+
|
108
|
+
expect(response.status).to eq(302)
|
109
|
+
expect(controller).to have_received(:redirect_to)
|
110
|
+
.with(attachment_path, allow_other_host: true)
|
111
|
+
end
|
112
|
+
|
113
|
+
it "throws a 404 if attachment file can't be found" do
|
114
|
+
get :attachment, params: { id:, file: 'unknown', format: 'woot' }
|
115
|
+
expect(response.status).to eq(404)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
describe 'DELETE clear' do
|
120
|
+
before { allow(LetterOpenerWeb::AwsLetter).to receive(:destroy_all) }
|
121
|
+
|
122
|
+
it 'removes all letters' do
|
123
|
+
delete :clear
|
124
|
+
expect(LetterOpenerWeb::AwsLetter).to have_received(:destroy_all)
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'redirects back to index' do
|
128
|
+
delete :clear
|
129
|
+
expect(response).to redirect_to(letters_path)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe 'DELETE destroy' do
|
134
|
+
let(:id) { 'an-id' }
|
135
|
+
|
136
|
+
it 'removes the selected letter' do
|
137
|
+
allow_any_instance_of(LetterOpenerWeb::AwsLetter).to receive(:valid?).and_return(true)
|
138
|
+
expect_any_instance_of(LetterOpenerWeb::AwsLetter).to receive(:delete)
|
139
|
+
delete :destroy, params: { id: }
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'throws a 404 if attachment is not present on s3' do
|
143
|
+
bad_id = '../an-id'
|
144
|
+
|
145
|
+
allow_any_instance_of(LetterOpenerWeb::AwsLetter).to receive(:valid?).and_return(false)
|
146
|
+
expect_any_instance_of(LetterOpenerWeb::AwsLetter).not_to receive(:delete)
|
147
|
+
|
148
|
+
delete :destroy, params: { id: bad_id }
|
149
|
+
|
150
|
+
expect(response.status).to eq(404)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
describe 'GET index' do
|
156
|
+
before do
|
157
|
+
allow(LetterOpenerWeb::Letter).to receive(:search)
|
158
|
+
get :index
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'searches for all letters' do
|
162
|
+
expect(LetterOpenerWeb::Letter).to have_received(:search)
|
163
|
+
end
|
164
|
+
|
165
|
+
it 'returns an HTML 200 response' do
|
166
|
+
expect(response.status).to eq(200)
|
167
|
+
expect(response.content_type).to eq('text/html; charset=utf-8')
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
describe 'GET show' do
|
172
|
+
let(:id) { 'an-id' }
|
173
|
+
let(:rich_text) { 'rich text href="plain.html"' }
|
174
|
+
let(:plain_text) { 'plain text href="rich.html"' }
|
175
|
+
let(:letter) { double(:letter, rich_text:, plain_text:, id:) }
|
176
|
+
|
177
|
+
shared_examples 'found letter examples' do |letter_style|
|
178
|
+
before(:each) do
|
179
|
+
expect(LetterOpenerWeb::Letter).to receive(:find).with(id).and_return(letter)
|
180
|
+
expect(letter).to receive(:valid?).and_return(true)
|
181
|
+
get :show, params: { id:, style: letter_style }
|
182
|
+
end
|
183
|
+
|
184
|
+
it 'renders an HTML 200 response' do
|
185
|
+
expect(response.status).to eq(200)
|
186
|
+
expect(response.content_type).to eq('text/html; charset=utf-8')
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
context 'rich text version' do
|
191
|
+
include_examples 'found letter examples', 'rich'
|
192
|
+
|
193
|
+
it 'renders the rich text contents' do
|
194
|
+
expect(response.body).to match(/^rich text/)
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'fixes plain text link' do
|
198
|
+
expect(response.body).not_to match(/href="plain.html"/)
|
199
|
+
expect(response.body).to match(/href="#{Regexp.escape letter_path(id:, style: 'plain')}"/)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context 'plain text version' do
|
204
|
+
include_examples 'found letter examples', 'plain'
|
205
|
+
|
206
|
+
it 'renders the plain text contents' do
|
207
|
+
expect(response.body).to match(/^plain text/)
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'fixes rich text link' do
|
211
|
+
expect(response.body).not_to match(/href="rich.html"/)
|
212
|
+
expect(response.body).to match(/href="#{Regexp.escape letter_path(id:, style: 'rich')}"/)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
context 'with wrong parameters' do
|
217
|
+
it 'should return 404 when invalid id given' do
|
218
|
+
get :show, params: { id:, style: 'rich' }
|
219
|
+
expect(response.status).to eq(404)
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
|
224
|
+
describe 'GET attachment' do
|
225
|
+
let(:id) { 'an-id' }
|
226
|
+
let(:attachment_path) { 'path/to/attachment' }
|
227
|
+
let(:file_name) { 'image.jpg' }
|
228
|
+
let(:letter) { double(:letter, attachments: { file_name => attachment_path }, id:) }
|
229
|
+
|
230
|
+
before do
|
231
|
+
allow(LetterOpenerWeb::Letter).to receive(:find).with(id).and_return(letter)
|
232
|
+
allow(letter).to receive(:valid?).and_return(true)
|
233
|
+
end
|
234
|
+
|
235
|
+
it 'sends the file as an inline attachment' do
|
236
|
+
allow(controller).to receive(:send_file) { controller.head :ok }
|
237
|
+
get :attachment, params: { id:, file: file_name.gsub(/\.\w+/, ''), format: File.extname(file_name)[1..] }
|
238
|
+
|
239
|
+
expect(response.status).to eq(200)
|
240
|
+
expect(controller).to have_received(:send_file)
|
241
|
+
.with(attachment_path, filename: file_name, disposition: 'inline')
|
242
|
+
end
|
243
|
+
|
244
|
+
it "throws a 404 if attachment file can't be found" do
|
245
|
+
get :attachment, params: { id:, file: 'unknown', format: 'woot' }
|
246
|
+
expect(response.status).to eq(404)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
describe 'DELETE clear' do
|
251
|
+
it 'removes all letters' do
|
252
|
+
expect(LetterOpenerWeb::Letter).to receive(:destroy_all)
|
253
|
+
delete :clear
|
254
|
+
end
|
255
|
+
|
256
|
+
it 'redirects back to index' do
|
257
|
+
delete :clear
|
258
|
+
expect(response).to redirect_to(letters_path)
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
describe 'DELETE destroy' do
|
263
|
+
let(:id) { 'an-id' }
|
264
|
+
|
265
|
+
it 'removes the selected letter' do
|
266
|
+
allow_any_instance_of(LetterOpenerWeb::Letter).to receive(:valid?).and_return(true)
|
267
|
+
expect_any_instance_of(LetterOpenerWeb::Letter).to receive(:delete)
|
268
|
+
delete :destroy, params: { id: }
|
269
|
+
end
|
270
|
+
|
271
|
+
it 'throws a 404 if attachment is outside of the letters base path' do
|
272
|
+
bad_id = '../an-id'
|
273
|
+
|
274
|
+
allow_any_instance_of(LetterOpenerWeb::Letter).to receive(:valid?).and_return(false)
|
275
|
+
expect_any_instance_of(LetterOpenerWeb::Letter).not_to receive(:delete)
|
276
|
+
|
277
|
+
delete :destroy, params: { id: bad_id }
|
278
|
+
|
279
|
+
expect(response.status).to eq(404)
|
280
|
+
end
|
281
|
+
end
|
282
|
+
end
|
data/spec/dummy/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
4
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
5
|
+
|
6
|
+
require_relative 'config/application'
|
7
|
+
|
8
|
+
Rails.application.load_tasks
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require rails-ujs
|
14
|
+
//= require activestorage
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class ApplicationJob < ActiveJob::Base
|
4
|
+
# Automatically retry jobs that encountered a deadlock
|
5
|
+
# retry_on ActiveRecord::Deadlocked
|
6
|
+
|
7
|
+
# Most jobs are safe to ignore if the underlying records are no longer available
|
8
|
+
# discard_on ActiveJob::DeserializationError
|
9
|
+
end
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
6
|
+
<%= csrf_meta_tags %>
|
7
|
+
<%= csp_meta_tag %>
|
8
|
+
|
9
|
+
<%= stylesheet_link_tag 'application', media: 'all' %>
|
10
|
+
</head>
|
11
|
+
|
12
|
+
<body>
|
13
|
+
<%= yield %>
|
14
|
+
</body>
|
15
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= yield %>
|
data/spec/dummy/bin/rake
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
# path to your application root.
|
5
|
+
APP_ROOT = File.expand_path('..', __dir__)
|
6
|
+
|
7
|
+
def system!(*args)
|
8
|
+
system(*args) || abort("\n== Command #{args} failed ==")
|
9
|
+
end
|
10
|
+
|
11
|
+
FileUtils.chdir APP_ROOT do
|
12
|
+
# This script is a way to set up or update your development environment automatically.
|
13
|
+
# This script is idempotent, so that you can run it at any time and get an expectable outcome.
|
14
|
+
# Add necessary setup steps to this file.
|
15
|
+
|
16
|
+
puts '== Installing dependencies =='
|
17
|
+
system! 'gem install bundler --conservative'
|
18
|
+
system('bundle check') || system!('bundle install')
|
19
|
+
|
20
|
+
# puts "\n== Copying sample files =="
|
21
|
+
# unless File.exist?('config/database.yml')
|
22
|
+
# FileUtils.cp 'config/database.yml.sample', 'config/database.yml'
|
23
|
+
# end
|
24
|
+
|
25
|
+
puts "\n== Preparing database =="
|
26
|
+
system! 'bin/rails db:prepare'
|
27
|
+
|
28
|
+
puts "\n== Removing old logs and tempfiles =="
|
29
|
+
system! 'bin/rails log:clear tmp:clear'
|
30
|
+
|
31
|
+
puts "\n== Restarting application server =="
|
32
|
+
system! 'bin/rails restart'
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'boot'
|
4
|
+
|
5
|
+
require 'rails'
|
6
|
+
# Pick the frameworks you want:
|
7
|
+
# require "active_model/railtie"
|
8
|
+
# require "active_job/railtie"
|
9
|
+
# require "active_record/railtie"
|
10
|
+
# require "active_storage/engine"
|
11
|
+
require 'action_controller/railtie'
|
12
|
+
require 'action_mailer/railtie'
|
13
|
+
# require "action_mailbox/engine"
|
14
|
+
# require "action_text/engine"
|
15
|
+
require 'action_view/railtie'
|
16
|
+
# require "action_cable/engine"
|
17
|
+
# require "sprockets/railtie"
|
18
|
+
# require "rails/test_unit/railtie"
|
19
|
+
|
20
|
+
# Require the gems listed in Gemfile, including any gems
|
21
|
+
# you've limited to :test, :development, or :production.
|
22
|
+
Bundler.require(*Rails.groups)
|
23
|
+
require 'letter_opener_web'
|
24
|
+
|
25
|
+
module Dummy
|
26
|
+
class Application < Rails::Application
|
27
|
+
config.load_defaults Rails::VERSION::STRING.to_f
|
28
|
+
|
29
|
+
# Configuration for the application, engines, and railties goes here.
|
30
|
+
#
|
31
|
+
# These settings can be overridden in specific environments using the files
|
32
|
+
# in config/environments, which are processed later.
|
33
|
+
#
|
34
|
+
# config.time_zone = "Central Time (US & Canada)"
|
35
|
+
# config.eager_load_paths << Rails.root.join("extras")
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../Gemfile', __dir__)
|
5
|
+
|
6
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
7
|
+
$LOAD_PATH.unshift File.expand_path('../../../lib', __dir__)
|