futurism 1.2.0.rc2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +87 -85
- data/README.md +26 -0
- data/app/assets/javascripts/futurism.min.js.map +1 -1
- data/app/assets/javascripts/futurism.umd.min.js.map +1 -1
- data/futurism.gemspec +1 -4
- data/futurism.gemspec~ +1 -1
- data/lib/futurism/engine.rb +4 -0
- data/lib/futurism/helpers.rb +5 -5
- data/lib/futurism/options_transformer.rb +1 -1
- data/lib/futurism/resolver/controller/instrumentation.rb +33 -0
- data/lib/futurism/resolver/controller/renderer.rb +5 -1
- data/lib/futurism/resolver/resources.rb +3 -3
- data/lib/futurism/version.rb +1 -1
- data/lib/futurism.rb +11 -3
- data/package.json +2 -2
- data/package.json~ +2 -2
- data/yarn.lock +65 -25
- metadata +11 -100
- data/test/cable/channel_test.rb +0 -319
- data/test/dummy/app/channels/application_cable/channel.rb +0 -4
- data/test/dummy/app/channels/application_cable/connection.rb +0 -4
- data/test/dummy/app/controllers/application_controller.rb +0 -2
- data/test/dummy/app/controllers/home_controller.rb +0 -6
- data/test/dummy/app/controllers/posts_controller.rb +0 -59
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/helpers/posts_helper.rb +0 -2
- data/test/dummy/app/jobs/application_job.rb +0 -7
- data/test/dummy/app/models/action_item.rb +0 -2
- data/test/dummy/app/models/application_record.rb +0 -3
- data/test/dummy/app/models/post.rb +0 -2
- data/test/dummy/config/application.rb +0 -29
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -40
- data/test/dummy/config/environments/production.rb +0 -94
- data/test/dummy/config/environments/test.rb +0 -39
- data/test/dummy/config/initializers/application_controller_renderer.rb +0 -8
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/content_security_policy.rb +0 -28
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -5
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -9
- data/test/dummy/config/puma.rb +0 -38
- data/test/dummy/config/routes.rb +0 -12
- data/test/dummy/config/spring.rb +0 -6
- data/test/dummy/db/migrate/20200711122838_create_posts.rb +0 -9
- data/test/dummy/db/migrate/2021042923813_create_action_items.rb +0 -9
- data/test/dummy/db/schema.rb +0 -27
- data/test/futurism_test.rb +0 -28
- data/test/helper/helper_test.rb +0 -206
- data/test/integration/navigation_test.rb +0 -7
- data/test/resolver/controller/renderer_test.rb +0 -120
- data/test/resolver/controller_test.rb +0 -26
- data/test/test_helper.rb +0 -14
data/test/cable/channel_test.rb
DELETED
@@ -1,319 +0,0 @@
|
|
1
|
-
require "test_helper"
|
2
|
-
|
3
|
-
def with_mocked_renderer
|
4
|
-
renderer = Minitest::Mock.new
|
5
|
-
|
6
|
-
Futurism::Resolver::Controller::Renderer.stub(:for, renderer) do
|
7
|
-
yield(renderer)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
def with_mocked_cable_ready
|
12
|
-
cable_ready_mock = MiniTest::Mock.new
|
13
|
-
cable_ready_channel = MiniTest::Mock.new
|
14
|
-
cable_ready_channel.expect(:outer_html, nil, [Hash])
|
15
|
-
cable_ready_channel.expect(:outer_html, nil, [Hash])
|
16
|
-
|
17
|
-
cable_ready_mock.expect(:[], cable_ready_channel, ["1"])
|
18
|
-
cable_ready_mock.expect(:[], cable_ready_channel, ["1"])
|
19
|
-
cable_ready_mock.expect(:broadcast, nil)
|
20
|
-
cable_ready_mock.expect(:broadcast, nil)
|
21
|
-
cable_ready_mock.expect(:broadcast, nil)
|
22
|
-
|
23
|
-
CableReady::Broadcaster.alias_method(:orig_cable_ready, :cable_ready)
|
24
|
-
|
25
|
-
CableReady::Broadcaster.define_method(:cable_ready) do
|
26
|
-
cable_ready_mock
|
27
|
-
end
|
28
|
-
|
29
|
-
yield cable_ready_mock
|
30
|
-
|
31
|
-
CableReady::Broadcaster.undef_method(:cable_ready)
|
32
|
-
|
33
|
-
CableReady::Broadcaster.alias_method(:cable_ready, :orig_cable_ready)
|
34
|
-
end
|
35
|
-
|
36
|
-
class Futurism::ChannelTest < ActionCable::Channel::TestCase
|
37
|
-
include Futurism::Helpers
|
38
|
-
include ActionView::Helpers
|
39
|
-
include ActionView::Context
|
40
|
-
include CableReady::Broadcaster
|
41
|
-
|
42
|
-
setup do
|
43
|
-
stub_connection(env: {"SCRIPT_NAME" => "/cable"}, identifiers: [:current_user], current_user: Struct.new(:id)[1])
|
44
|
-
end
|
45
|
-
|
46
|
-
test "subscribed" do
|
47
|
-
subscribe(channel: "Futurism::Channel")
|
48
|
-
|
49
|
-
assert subscription.confirmed?
|
50
|
-
|
51
|
-
assert_has_stream "Futurism::Channel:1"
|
52
|
-
end
|
53
|
-
|
54
|
-
test "broadcasts a rendered model after receiving signed params" do
|
55
|
-
with_mocked_renderer do |mock_renderer|
|
56
|
-
post = Post.create title: "Lorem"
|
57
|
-
fragment = Nokogiri::HTML.fragment(futurize(post) {})
|
58
|
-
signed_params_array = fragment.children.map { |element| element["data-signed-params"] }
|
59
|
-
sgids = fragment.children.map { |element| element["data-sgid"] }
|
60
|
-
subscribe
|
61
|
-
|
62
|
-
mock_renderer.expect :render, "<tag></tag>", [post]
|
63
|
-
|
64
|
-
perform :receive, {"signed_params" => signed_params_array, "sgids" => sgids}
|
65
|
-
|
66
|
-
assert_mock mock_renderer
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
test "broadcasts an ActiveRecord::Relation" do
|
71
|
-
with_mocked_renderer do |mock_renderer|
|
72
|
-
post1 = Post.create(title: "Lorem")
|
73
|
-
post2 = Post.create(title: "Ipsum")
|
74
|
-
|
75
|
-
fragment = Nokogiri::HTML.fragment(futurize(Post.all) {})
|
76
|
-
signed_params_array = fragment.children.map { |element| element["data-signed-params"] }
|
77
|
-
sgids = fragment.children.map { |element| element["data-sgid"] }
|
78
|
-
subscribe
|
79
|
-
|
80
|
-
mock_renderer
|
81
|
-
.expect(:render, "<tag></tag>", [post1])
|
82
|
-
.expect :render, "<tag></tag>", [post2]
|
83
|
-
|
84
|
-
perform :receive, {"signed_params" => signed_params_array, "sgids" => sgids}
|
85
|
-
|
86
|
-
assert_mock mock_renderer
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
test "broadcasts a rendered partial after receiving signed params" do
|
91
|
-
with_mocked_renderer do |mock_renderer|
|
92
|
-
post = Post.create title: "Lorem"
|
93
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", locals: {post: post}) {})
|
94
|
-
signed_params = fragment.children.first["data-signed-params"]
|
95
|
-
subscribe
|
96
|
-
|
97
|
-
mock_renderer
|
98
|
-
.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post: post}])
|
99
|
-
|
100
|
-
perform :receive, {"signed_params" => [signed_params]}
|
101
|
-
|
102
|
-
assert_mock mock_renderer
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
test "broadcasts a rendered partial after receiving the shorthand syntax" do
|
107
|
-
with_mocked_renderer do |mock_renderer|
|
108
|
-
post = Post.create title: "Lorem"
|
109
|
-
fragment = Nokogiri::HTML.fragment(futurize("posts/card", post: post) {})
|
110
|
-
signed_params = fragment.children.first["data-signed-params"]
|
111
|
-
subscribe
|
112
|
-
|
113
|
-
mock_renderer.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post: post}])
|
114
|
-
perform :receive, {"signed_params" => [signed_params]}
|
115
|
-
|
116
|
-
assert_mock mock_renderer
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
test "broadcasts a rendered partial after receiving the shorthand syntax with html options" do
|
121
|
-
with_mocked_renderer do |mock_renderer|
|
122
|
-
post = Post.create title: "Lorem"
|
123
|
-
fragment = Nokogiri::HTML.fragment(futurize("posts/card", post: post, html_options: {style: "color: green"}) {})
|
124
|
-
signed_params = fragment.children.first["data-signed-params"]
|
125
|
-
subscribe
|
126
|
-
|
127
|
-
mock_renderer.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post: post}])
|
128
|
-
|
129
|
-
perform :receive, {"signed_params" => [signed_params]}
|
130
|
-
|
131
|
-
assert_mock mock_renderer
|
132
|
-
end
|
133
|
-
end
|
134
|
-
|
135
|
-
test "broadcasts a collection" do
|
136
|
-
with_mocked_renderer do |mock_renderer|
|
137
|
-
Post.create title: "Lorem"
|
138
|
-
Post.create title: "Ipsum"
|
139
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", collection: Post.all, locals: {important_local: "needed to render"}) {})
|
140
|
-
subscribe
|
141
|
-
|
142
|
-
mock_renderer
|
143
|
-
.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post: Post.first, important_local: "needed to render", post_counter: 0}])
|
144
|
-
.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post: Post.last, important_local: "needed to render", post_counter: 1}])
|
145
|
-
|
146
|
-
signed_params = fragment.children.first["data-signed-params"]
|
147
|
-
perform :receive, {"signed_params" => [signed_params]}
|
148
|
-
|
149
|
-
signed_params = fragment.children.last["data-signed-params"]
|
150
|
-
perform :receive, {"signed_params" => [signed_params]}
|
151
|
-
|
152
|
-
assert_mock mock_renderer
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
test "broadcasts a collection (with multi-word class)" do
|
157
|
-
with_mocked_renderer do |mock_renderer|
|
158
|
-
ActionItem.create description: "Do this"
|
159
|
-
ActionItem.create description: "Do that"
|
160
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", collection: ActionItem.all, locals: {important_local: "needed to render"}) {})
|
161
|
-
|
162
|
-
subscribe
|
163
|
-
|
164
|
-
mock_renderer
|
165
|
-
.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {action_item: ActionItem.first, important_local: "needed to render", action_item_counter: 0}])
|
166
|
-
.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {action_item: ActionItem.last, important_local: "needed to render", action_item_counter: 1}])
|
167
|
-
|
168
|
-
signed_params = fragment.children.first["data-signed-params"]
|
169
|
-
perform :receive, {"signed_params" => [signed_params]}
|
170
|
-
|
171
|
-
signed_params = fragment.children.last["data-signed-params"]
|
172
|
-
perform :receive, {"signed_params" => [signed_params]}
|
173
|
-
|
174
|
-
assert_mock mock_renderer
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
test "broadcasts a collection with :as" do
|
179
|
-
with_mocked_renderer do |mock_renderer|
|
180
|
-
Post.create title: "Lorem"
|
181
|
-
Post.create title: "Ipsum"
|
182
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", collection: Post.all, as: :post_item) {})
|
183
|
-
subscribe
|
184
|
-
|
185
|
-
mock_renderer.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post_item: Post.first, post_item_counter: 0}])
|
186
|
-
signed_params = fragment.children.first["data-signed-params"]
|
187
|
-
perform :receive, {"signed_params" => [signed_params]}
|
188
|
-
|
189
|
-
mock_renderer.expect(:render, "<tag></tag>", [partial: "posts/card", locals: {post_item: Post.last, post_item_counter: 1}])
|
190
|
-
signed_params = fragment.children.last["data-signed-params"]
|
191
|
-
perform :receive, {"signed_params" => [signed_params]}
|
192
|
-
|
193
|
-
assert_mock mock_renderer
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
test "broadcasts elements of a collection immediately" do
|
198
|
-
with_mocked_cable_ready do |cable_ready_mock|
|
199
|
-
Post.create title: "Lorem"
|
200
|
-
Post.create title: "Ipsum"
|
201
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", collection: Post.all, broadcast_each: true, locals: {important_local: "needed to render"}) {})
|
202
|
-
subscribe
|
203
|
-
|
204
|
-
signed_params_1 = fragment.children.first["data-signed-params"]
|
205
|
-
broadcast_each_1 = fragment.children.first["data-broadcast-each"]
|
206
|
-
signed_params_2 = fragment.children.last["data-signed-params"]
|
207
|
-
broadcast_each_2 = fragment.children.last["data-broadcast-each"]
|
208
|
-
perform :receive, {"signed_params" => [signed_params_1, signed_params_2], "broadcast_each" => [broadcast_each_1, broadcast_each_2]}
|
209
|
-
|
210
|
-
assert_mock cable_ready_mock
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
test "broadcasts an inline rendered text" do
|
215
|
-
fragment = Nokogiri::HTML.fragment(futurize(inline: "<%= 1 + 2 %>") {})
|
216
|
-
signed_params = fragment.children.first["data-signed-params"]
|
217
|
-
subscribe(channel: "Futurism::Channel")
|
218
|
-
|
219
|
-
assert_cable_ready_operation_on("Futurism::Channel:1", operation: "outerHtml", selector: "[data-signed-params='#{signed_params}']", html: "3") do
|
220
|
-
perform :receive, {"signed_params" => [signed_params]}
|
221
|
-
end
|
222
|
-
end
|
223
|
-
|
224
|
-
test "broadcasts a correctly formed path" do
|
225
|
-
post = Post.create title: "Lorem"
|
226
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", locals: {post: post}) {})
|
227
|
-
signed_params = fragment.children.first["data-signed-params"]
|
228
|
-
subscribe(channel: "Futurism::Channel")
|
229
|
-
|
230
|
-
assert_cable_ready_operation_on("Futurism::Channel:1", operation: "outerHtml",
|
231
|
-
selector: "[data-signed-params='#{signed_params}']",
|
232
|
-
html: "<div class=\"card\">\n Lorem\n <a href=\"/posts/1/edit\">Edit</a>\n</div>\n") do
|
233
|
-
perform :receive, {"signed_params" => [signed_params]}
|
234
|
-
end
|
235
|
-
end
|
236
|
-
|
237
|
-
test "passes parsed params to controller render" do
|
238
|
-
with_mocked_renderer do |mock_renderer|
|
239
|
-
post = Post.create title: "Lorem"
|
240
|
-
fragment = Nokogiri::HTML.fragment(futurize(post) {})
|
241
|
-
signed_params_array = fragment.children.map { |element| element["data-signed-params"] }
|
242
|
-
sgids = fragment.children.map { |element| element["data-sgid"] }
|
243
|
-
urls = Array.new(fragment.children.length, "http://www.example.org/route?param1=true¶m2=1234")
|
244
|
-
subscribe
|
245
|
-
|
246
|
-
mock_renderer.expect(:render, "<tag></tag>", [post])
|
247
|
-
|
248
|
-
perform :receive, {"signed_params" => signed_params_array, "sgids" => sgids, "urls" => urls}
|
249
|
-
|
250
|
-
assert_mock mock_renderer
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
test "renders error message when rendering invalid partial error" do
|
255
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "INVALID/PARTIAL") {})
|
256
|
-
signed_params = fragment.children.first["data-signed-params"]
|
257
|
-
subscribe(channel: "Futurism::Channel")
|
258
|
-
|
259
|
-
assert_cable_ready_operation_on("Futurism::Channel:1", operation: "outerHtml",
|
260
|
-
selector: "[data-signed-params='#{signed_params}']",
|
261
|
-
html: /Missing partial INVALID\/_PARTIAL/) do
|
262
|
-
perform :receive, {"signed_params" => [signed_params]}
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
test "renders error message when wrong variable name" do
|
267
|
-
Post.create title: "Lorem"
|
268
|
-
fragment = Nokogiri::HTML.fragment(futurize(partial: "posts/card", collection: Post.all, as: :wrong_variable_name) {})
|
269
|
-
signed_params = fragment.children.first["data-signed-params"]
|
270
|
-
subscribe(channel: "Futurism::Channel")
|
271
|
-
|
272
|
-
assert_cable_ready_operation_on("Futurism::Channel:1", operation: "outerHtml",
|
273
|
-
selector: "[data-signed-params='#{signed_params}']",
|
274
|
-
html: /undefined local variable or method/) do
|
275
|
-
perform :receive, {"signed_params" => [signed_params]}
|
276
|
-
end
|
277
|
-
end
|
278
|
-
|
279
|
-
def assert_cable_ready_operation_on(stream, operation:, selector:, html:, &block)
|
280
|
-
data = {
|
281
|
-
"cableReady" => true,
|
282
|
-
"operations" => [{
|
283
|
-
"selector" => selector,
|
284
|
-
"html" => html,
|
285
|
-
"operation" => operation
|
286
|
-
}]
|
287
|
-
}
|
288
|
-
|
289
|
-
old_messages = broadcasts(stream)
|
290
|
-
clear_messages(stream)
|
291
|
-
|
292
|
-
assert_nothing_raised(&block)
|
293
|
-
|
294
|
-
new_messages = broadcasts(stream)
|
295
|
-
clear_messages(stream)
|
296
|
-
|
297
|
-
# Restore all sent messages
|
298
|
-
(old_messages + new_messages).each { |m| pubsub_adapter.broadcast(stream, m) }
|
299
|
-
|
300
|
-
message = new_messages.find { |msg| cable_ready_match?(ActiveSupport::JSON.decode(msg), data) }
|
301
|
-
|
302
|
-
assert message, "No messages sent with #{data} to #{stream}"
|
303
|
-
end
|
304
|
-
|
305
|
-
def cable_ready_match?(message, matcher)
|
306
|
-
return true if message == matcher
|
307
|
-
|
308
|
-
first_matching_operation = ["operations", 0]
|
309
|
-
|
310
|
-
matcher_operation = matcher.dig(*first_matching_operation)
|
311
|
-
message_operation = message.dig(*first_matching_operation)
|
312
|
-
|
313
|
-
message.dig("cableReady") == true &&
|
314
|
-
(matcher_operation.dig("selector") === message_operation.dig("selector") ||
|
315
|
-
matcher_operation.dig("selector").match(message_operation.dig("selector"))) &&
|
316
|
-
(matcher_operation.dig("html") === message_operation.dig("html") ||
|
317
|
-
matcher_operation.dig("html").match(message_operation.dig("html")))
|
318
|
-
end
|
319
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
class PostsController < ApplicationController
|
2
|
-
before_action :set_post, only: [:show, :edit, :update, :destroy]
|
3
|
-
|
4
|
-
# GET /posts
|
5
|
-
def index
|
6
|
-
@posts = Post.all
|
7
|
-
end
|
8
|
-
|
9
|
-
# GET /posts/1
|
10
|
-
def show
|
11
|
-
end
|
12
|
-
|
13
|
-
# GET /posts/new
|
14
|
-
def new
|
15
|
-
@post = Post.new
|
16
|
-
end
|
17
|
-
|
18
|
-
# GET /posts/1/edit
|
19
|
-
def edit
|
20
|
-
end
|
21
|
-
|
22
|
-
# POST /posts
|
23
|
-
def create
|
24
|
-
@post = Post.new(post_params)
|
25
|
-
|
26
|
-
if @post.save
|
27
|
-
redirect_to @post, notice: "Post was successfully created."
|
28
|
-
else
|
29
|
-
render :new
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# PATCH/PUT /posts/1
|
34
|
-
def update
|
35
|
-
if @post.update(post_params)
|
36
|
-
redirect_to @post, notice: "Post was successfully updated."
|
37
|
-
else
|
38
|
-
render :edit
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# DELETE /posts/1
|
43
|
-
def destroy
|
44
|
-
@post.destroy
|
45
|
-
redirect_to posts_url, notice: "Post was successfully destroyed."
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
# Use callbacks to share common setup or constraints between actions.
|
51
|
-
def set_post
|
52
|
-
@post = Post.find(params[:id])
|
53
|
-
end
|
54
|
-
|
55
|
-
# Only allow a trusted parameter "white list" through.
|
56
|
-
def post_params
|
57
|
-
params.require(:post).permit(:title)
|
58
|
-
end
|
59
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
class ApplicationJob < ActiveJob::Base
|
2
|
-
# Automatically retry jobs that encountered a deadlock
|
3
|
-
# retry_on ActiveRecord::Deadlocked
|
4
|
-
|
5
|
-
# Most jobs are safe to ignore if the underlying records are no longer available
|
6
|
-
# discard_on ActiveJob::DeserializationError
|
7
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require_relative "boot"
|
2
|
-
|
3
|
-
require "rails"
|
4
|
-
# Pick the frameworks you want:
|
5
|
-
require "active_model/railtie"
|
6
|
-
require "active_job/railtie"
|
7
|
-
require "active_record/railtie"
|
8
|
-
# require "active_storage/engine"
|
9
|
-
require "action_controller/railtie"
|
10
|
-
# require "action_mailer/railtie"
|
11
|
-
require "action_view/railtie"
|
12
|
-
require "action_cable/engine"
|
13
|
-
# require "sprockets/railtie"
|
14
|
-
require "rails/test_unit/railtie"
|
15
|
-
|
16
|
-
Bundler.require(*Rails.groups)
|
17
|
-
require "futurism"
|
18
|
-
|
19
|
-
module Dummy
|
20
|
-
class Application < Rails::Application
|
21
|
-
# Initialize configuration defaults for originally generated Rails version.
|
22
|
-
config.load_defaults Rails::VERSION::MAJOR + (Rails::VERSION::MINOR / 10.0)
|
23
|
-
|
24
|
-
# Settings in config/environments/* take precedence over those specified here.
|
25
|
-
# Application configuration can go into files in config/initializers
|
26
|
-
# -- all .rb files in that directory are automatically loaded after loading
|
27
|
-
# the framework and any gems in your application.
|
28
|
-
end
|
29
|
-
end
|
data/test/dummy/config/boot.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
Rails.application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
-
|
4
|
-
# In the development environment your application's code is reloaded on
|
5
|
-
# every request. This slows down response time but is perfect for development
|
6
|
-
# since you don't have to restart the web server when you make code changes.
|
7
|
-
config.cache_classes = false
|
8
|
-
|
9
|
-
# Do not eager load code on boot.
|
10
|
-
config.eager_load = false
|
11
|
-
|
12
|
-
# Show full error reports.
|
13
|
-
config.consider_all_requests_local = true
|
14
|
-
|
15
|
-
# Enable/disable caching. By default caching is disabled.
|
16
|
-
# Run rails dev:cache to toggle caching.
|
17
|
-
if Rails.root.join("tmp", "caching-dev.txt").exist?
|
18
|
-
config.action_controller.perform_caching = true
|
19
|
-
config.action_controller.enable_fragment_cache_logging = true
|
20
|
-
|
21
|
-
config.cache_store = :memory_store
|
22
|
-
config.public_file_server.headers = {
|
23
|
-
"Cache-Control" => "public, max-age=#{2.days.to_i}"
|
24
|
-
}
|
25
|
-
else
|
26
|
-
config.action_controller.perform_caching = false
|
27
|
-
|
28
|
-
config.cache_store = :null_store
|
29
|
-
end
|
30
|
-
|
31
|
-
# Print deprecation notices to the Rails logger.
|
32
|
-
config.active_support.deprecation = :log
|
33
|
-
|
34
|
-
# Raises error for missing translations.
|
35
|
-
# config.action_view.raise_on_missing_translations = true
|
36
|
-
|
37
|
-
# Use an evented file watcher to asynchronously detect changes in source code,
|
38
|
-
# routes, locales, etc. This feature depends on the listen gem.
|
39
|
-
# config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
40
|
-
end
|
@@ -1,94 +0,0 @@
|
|
1
|
-
Rails.application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
-
|
4
|
-
# Code is not reloaded between requests.
|
5
|
-
config.cache_classes = true
|
6
|
-
|
7
|
-
# Eager load code on boot. This eager loads most of Rails and
|
8
|
-
# your application in memory, allowing both threaded web servers
|
9
|
-
# and those relying on copy on write to perform better.
|
10
|
-
# Rake tasks automatically ignore this option for performance.
|
11
|
-
config.eager_load = true
|
12
|
-
|
13
|
-
# Full error reports are disabled and caching is turned on.
|
14
|
-
config.consider_all_requests_local = false
|
15
|
-
config.action_controller.perform_caching = true
|
16
|
-
|
17
|
-
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
18
|
-
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
19
|
-
# config.require_master_key = true
|
20
|
-
|
21
|
-
# Disable serving static files from the `/public` folder by default since
|
22
|
-
# Apache or NGINX already handles this.
|
23
|
-
config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
|
24
|
-
|
25
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
26
|
-
# config.action_controller.asset_host = 'http://assets.example.com'
|
27
|
-
|
28
|
-
# Specifies the header that your server uses for sending files.
|
29
|
-
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
30
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
31
|
-
|
32
|
-
# Mount Action Cable outside main process or domain.
|
33
|
-
# config.action_cable.mount_path = nil
|
34
|
-
# config.action_cable.url = 'wss://example.com/cable'
|
35
|
-
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
36
|
-
|
37
|
-
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
38
|
-
# config.force_ssl = true
|
39
|
-
|
40
|
-
# Use the lowest log level to ensure availability of diagnostic information
|
41
|
-
# when problems arise.
|
42
|
-
config.log_level = :debug
|
43
|
-
|
44
|
-
# Prepend all log lines with the following tags.
|
45
|
-
config.log_tags = [:request_id]
|
46
|
-
|
47
|
-
# Use a different cache store in production.
|
48
|
-
# config.cache_store = :mem_cache_store
|
49
|
-
|
50
|
-
# Use a real queuing backend for Active Job (and separate queues per environment).
|
51
|
-
# config.active_job.queue_adapter = :resque
|
52
|
-
# config.active_job.queue_name_prefix = "dummy_production"
|
53
|
-
|
54
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
55
|
-
# the I18n.default_locale when a translation cannot be found).
|
56
|
-
config.i18n.fallbacks = true
|
57
|
-
|
58
|
-
# Send deprecation notices to registered listeners.
|
59
|
-
config.active_support.deprecation = :notify
|
60
|
-
|
61
|
-
# Use default logging formatter so that PID and timestamp are not suppressed.
|
62
|
-
config.log_formatter = ::Logger::Formatter.new
|
63
|
-
|
64
|
-
# Use a different logger for distributed setups.
|
65
|
-
# require 'syslog/logger'
|
66
|
-
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
67
|
-
|
68
|
-
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
69
|
-
logger = ActiveSupport::Logger.new(STDOUT)
|
70
|
-
logger.formatter = config.log_formatter
|
71
|
-
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
72
|
-
end
|
73
|
-
|
74
|
-
# Inserts middleware to perform automatic connection switching.
|
75
|
-
# The `database_selector` hash is used to pass options to the DatabaseSelector
|
76
|
-
# middleware. The `delay` is used to determine how long to wait after a write
|
77
|
-
# to send a subsequent read to the primary.
|
78
|
-
#
|
79
|
-
# The `database_resolver` class is used by the middleware to determine which
|
80
|
-
# database is appropriate to use based on the time delay.
|
81
|
-
#
|
82
|
-
# The `database_resolver_context` class is used by the middleware to set
|
83
|
-
# timestamps for the last write to the primary. The resolver uses the context
|
84
|
-
# class timestamps to determine how long to wait before reading from the
|
85
|
-
# replica.
|
86
|
-
#
|
87
|
-
# By default Rails will store a last write timestamp in the session. The
|
88
|
-
# DatabaseSelector middleware is designed as such you can define your own
|
89
|
-
# strategy for connection switching and pass that into the middleware through
|
90
|
-
# these configuration options.
|
91
|
-
# config.active_record.database_selector = { delay: 2.seconds }
|
92
|
-
# config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
|
93
|
-
# config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
|
94
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# The test environment is used exclusively to run your application's
|
2
|
-
# test suite. You never need to work with it otherwise. Remember that
|
3
|
-
# your test database is "scratch space" for the test suite and is wiped
|
4
|
-
# and recreated between test runs. Don't rely on the data there!
|
5
|
-
|
6
|
-
Rails.application.configure do
|
7
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
8
|
-
|
9
|
-
config.cache_classes = false
|
10
|
-
config.action_view.cache_template_loading = true
|
11
|
-
|
12
|
-
# Do not eager load code on boot. This avoids loading your whole application
|
13
|
-
# just for the purpose of running a single test. If you are using a tool that
|
14
|
-
# preloads Rails for running tests, you may have to set it to true.
|
15
|
-
config.eager_load = false
|
16
|
-
|
17
|
-
# Configure public file server for tests with Cache-Control for performance.
|
18
|
-
config.public_file_server.enabled = true
|
19
|
-
config.public_file_server.headers = {
|
20
|
-
"Cache-Control" => "public, max-age=#{1.hour.to_i}"
|
21
|
-
}
|
22
|
-
|
23
|
-
# Show full error reports and disable caching.
|
24
|
-
config.consider_all_requests_local = true
|
25
|
-
config.action_controller.perform_caching = false
|
26
|
-
config.cache_store = :null_store
|
27
|
-
|
28
|
-
# Raise exceptions instead of rendering exception templates.
|
29
|
-
config.action_dispatch.show_exceptions = false
|
30
|
-
|
31
|
-
# Disable request forgery protection in test environment.
|
32
|
-
config.action_controller.allow_forgery_protection = false
|
33
|
-
|
34
|
-
# Print deprecation notices to the stderr.
|
35
|
-
config.active_support.deprecation = :stderr
|
36
|
-
|
37
|
-
# Raises error for missing translations.
|
38
|
-
# config.action_view.raise_on_missing_translations = true
|
39
|
-
end
|
@@ -1,7 +0,0 @@
|
|
1
|
-
# Be sure to restart your server when you modify this file.
|
2
|
-
|
3
|
-
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
-
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
-
|
6
|
-
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
-
# Rails.backtrace_cleaner.remove_silencers!
|