|
77 | 77 |
|
78 | 78 | threads.each(&:join)
|
79 | 79 | end
|
| 80 | + end |
80 | 81 |
|
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 |
123 | 83 | it 'is expected not to leak shared data across requests' do
|
124 | 84 | begin
|
125 | 85 | get share_multithreaded_error_path, headers: {'X-Inertia' => true}
|
126 | 86 | rescue Exception
|
127 | 87 | end
|
128 | 88 |
|
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}) |
132 | 92 | end
|
133 | 93 | end
|
134 | 94 |
|
|
144 | 104 |
|
145 | 105 | it { is_expected.to eq props }
|
146 | 106 | 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 |
147 | 149 | end
|
0 commit comments