|
1 | 1 | RSpec.describe "conditionally shared data in a controller", type: :request do
|
2 |
| - it 'does not leak data between requests' do |
3 |
| - get conditional_share_index_path, headers: {'X-Inertia' => true} |
4 |
| - expect(JSON.parse(response.body)['props'].deep_symbolize_keys).to eq({ |
5 |
| - index_only_prop: 1, |
6 |
| - normal_shared_prop: 1, |
7 |
| - }) |
| 2 | + context "when there is a before_action inside a inertia_share" do |
| 3 | + it "does leak data between requests" do |
| 4 | + get conditional_share_index_path, headers: {'X-Inertia' => true} |
| 5 | + expect(JSON.parse(response.body)['props'].deep_symbolize_keys).to eq({ |
| 6 | + index_only_prop: 1, |
| 7 | + normal_shared_prop: 1, |
| 8 | + }) |
8 | 9 |
|
9 |
| - # NOTE: we actually have to run the show action twice since the new implementation |
10 |
| - # sets up a before_action within a before_action to share the data. |
11 |
| - # In effect, that means that the shared data isn't rendered until the second time the action is run. |
12 |
| - get conditional_share_show_path, headers: {'X-Inertia' => true} |
13 |
| - get conditional_share_show_path, headers: {'X-Inertia' => true} |
14 |
| - expect(JSON.parse(response.body)['props'].deep_symbolize_keys).to eq({ |
15 |
| - normal_shared_prop: 1, |
16 |
| - show_only_prop: 1, |
17 |
| - conditionally_shared_show_prop: 1, |
18 |
| - }) |
| 10 | + # NOTE: we actually have to run the show action twice since the new implementation |
| 11 | + # sets up a before_action within a before_action to share the data. |
| 12 | + # In effect, that means that the shared data isn't rendered until the second time the action is run. |
| 13 | + get conditional_share_show_path, headers: {'X-Inertia' => true} |
| 14 | + get conditional_share_show_path, headers: {'X-Inertia' => true} |
| 15 | + expect(JSON.parse(response.body)['props'].deep_symbolize_keys).to eq({ |
| 16 | + normal_shared_prop: 1, |
| 17 | + show_only_prop: 1, |
| 18 | + conditionally_shared_show_prop: 1, |
| 19 | + }) |
19 | 20 |
|
20 |
| - get conditional_share_index_path, headers: {'X-Inertia' => true} |
21 |
| - expect(JSON.parse(response.body)['props'].deep_symbolize_keys).to eq({ |
22 |
| - index_only_prop: 1, |
23 |
| - normal_shared_prop: 1, |
24 |
| - conditionally_shared_show_prop: 1, # TODO: Because we call before_action twice, this is leaking. |
25 |
| - }) |
| 21 | + get conditional_share_index_path, headers: {'X-Inertia' => true} |
| 22 | + expect(JSON.parse(response.body)['props'].deep_symbolize_keys).to eq({ |
| 23 | + index_only_prop: 1, |
| 24 | + normal_shared_prop: 1, |
| 25 | + conditionally_shared_show_prop: 1, |
| 26 | + }) |
| 27 | + end |
26 | 28 | end
|
27 | 29 | end
|
0 commit comments