Skip to content

Commit 6160d38

Browse files
cleanup test files
1 parent 9bbf451 commit 6160d38

File tree

4 files changed

+48
-61
lines changed

4 files changed

+48
-61
lines changed

spec/dummy/app/controllers/inertia_share_test_controller.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@ class InertiaShareTestController < ApplicationController
77
number: number,
88
}
99
end
10-
10+
1111
def share
1212
render inertia: 'ShareTestComponent'
1313
end
1414

15-
def error
16-
raise RuntimeError
17-
end
18-
1915
private
2016

2117
def number

spec/dummy/config/application.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,5 @@ class Application < Rails::Application
3232

3333
# Required for Rails 5.0 and 5.1
3434
config.secret_key_base = SecureRandom.hex
35-
36-
config.exceptions_app = ->(env) do
37-
Class.new(ActionController::Base) do
38-
def show
39-
render inertia: 'Error', props: {
40-
status: request.path_info[1..-1].to_i
41-
}
42-
end
43-
end.action(:show).call(env)
44-
end
4535
end
4636
end

spec/dummy/config/routes.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
get 'view_data' => 'inertia_render_test#view_data'
66
get 'component' => 'inertia_render_test#component'
77
get 'share' => 'inertia_share_test#share'
8-
get 'error' => 'inertia_share_test#error'
98
get 'share_with_inherited' => 'inertia_child_share_test#share_with_inherited'
109
get 'empty_test' => 'inertia_test#empty_test'
1110
get 'with_different_layout' => 'inertia_test#with_different_layout'

spec/inertia/sharing_spec.rb

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -77,58 +77,18 @@
7777

7878
threads.each(&:join)
7979
end
80+
end
8081

81-
describe 'deep or shallow merging shared data' do
82-
context 'with default settings (shallow merge)' do
83-
describe 'shallow merging by default' do
84-
let(:props) { { nested: { assists: 200 } } }
85-
before { get merge_shared_path, headers: {'X-Inertia' => true} }
86-
it { is_expected.to eq props }
87-
end
88-
89-
context 'with deep merge added to the renderer' do
90-
let(:props) { { nested: { goals: 100, assists: 300 } } }
91-
before { get deep_merge_shared_path, headers: {'X-Inertia' => true} }
92-
it { is_expected.to eq props }
93-
end
94-
end
95-
96-
context 'with deep merge configured as the default' do
97-
before {
98-
InertiaRails.configure { |config| config.deep_merge_shared_data = true }
99-
}
100-
after {
101-
InertiaRails.configure { |config| config.deep_merge_shared_data = false }
102-
}
103-
describe 'deep merging by default' do
104-
let(:props) { { nested: { goals: 100, assists: 200 } } }
105-
before { get merge_shared_path, headers: {'X-Inertia' => true} }
106-
it { is_expected.to eq props }
107-
end
108-
109-
describe 'overriding deep merge in a specific action' do
110-
let(:props) { { nested: { assists: 200 } } }
111-
before { get shallow_merge_shared_path, headers: {'X-Inertia' => true} }
112-
it { is_expected.to eq props }
113-
end
114-
end
115-
116-
context 'merging with instance props' do
117-
let(:props) { { nested: { points: 100, rebounds: 10 } } }
118-
before { get merge_instance_props_path, headers: {'X-Inertia' => true} }
119-
it { is_expected.to eq props }
120-
end
121-
end
122-
82+
context 'when raises an exception' do
12383
it 'is expected not to leak shared data across requests' do
12484
begin
12585
get share_multithreaded_error_path, headers: {'X-Inertia' => true}
12686
rescue Exception
12787
end
12888

129-
# TODO: How to test this? We really neeed?
130-
# expect(InertiaRails.shared_plain_data).to be_empty
131-
# expect(InertiaRails.shared_blocks).to be_empty
89+
get share_path, headers: {'X-Inertia' => true}
90+
91+
is_expected.to eq({name: 'Brandon', sport: 'hockey', position: 'center', number: 29})
13292
end
13393
end
13494

@@ -144,4 +104,46 @@
144104

145105
it { is_expected.to eq props }
146106
end
107+
108+
describe 'deep or shallow merging shared data' do
109+
context 'with default settings (shallow merge)' do
110+
describe 'shallow merging by default' do
111+
let(:props) { { nested: { assists: 200 } } }
112+
before { get merge_shared_path, headers: {'X-Inertia' => true} }
113+
it { is_expected.to eq props }
114+
end
115+
116+
context 'with deep merge added to the renderer' do
117+
let(:props) { { nested: { goals: 100, assists: 300 } } }
118+
before { get deep_merge_shared_path, headers: {'X-Inertia' => true} }
119+
it { is_expected.to eq props }
120+
end
121+
end
122+
123+
context 'with deep merge configured as the default' do
124+
before {
125+
InertiaRails.configure { |config| config.deep_merge_shared_data = true }
126+
}
127+
after {
128+
InertiaRails.configure { |config| config.deep_merge_shared_data = false }
129+
}
130+
describe 'deep merging by default' do
131+
let(:props) { { nested: { goals: 100, assists: 200 } } }
132+
before { get merge_shared_path, headers: {'X-Inertia' => true} }
133+
it { is_expected.to eq props }
134+
end
135+
136+
describe 'overriding deep merge in a specific action' do
137+
let(:props) { { nested: { assists: 200 } } }
138+
before { get shallow_merge_shared_path, headers: {'X-Inertia' => true} }
139+
it { is_expected.to eq props }
140+
end
141+
end
142+
143+
context 'merging with instance props' do
144+
let(:props) { { nested: { points: 100, rebounds: 10 } } }
145+
before { get merge_instance_props_path, headers: {'X-Inertia' => true} }
146+
it { is_expected.to eq props }
147+
end
148+
end
147149
end

0 commit comments

Comments
 (0)