|
57 | 57 |
|
58 | 58 | it "destroys the tracked incomplete activity on hub visit" do |
59 | 59 | activity = create(:volunteering_activity, activity_flow: current_flow) |
60 | | - session[:creating_activity] = { "class_name" => "VolunteeringActivity", "id" => activity.id } |
| 60 | + session[:creating_activity] = { "class_name" => "VolunteeringActivity", "id" => activity.id, "activity_flow_id" => current_flow.id } |
61 | 61 |
|
62 | 62 | expect { get :index }.to change(VolunteeringActivity, :count).by(-1) |
63 | 63 | expect(session[:creating_activity]).to be_nil |
|
69 | 69 | expect { get :index }.not_to change(VolunteeringActivity, :count) |
70 | 70 | end |
71 | 71 |
|
72 | | - it "does not destroy an activity belonging to a different flow" do |
| 72 | + it "does not destroy an activity belonging to a different flow and preserves session" do |
73 | 73 | other_flow = create(:activity_flow) |
74 | 74 | activity = create(:volunteering_activity, activity_flow: other_flow) |
75 | | - session[:creating_activity] = { "class_name" => "VolunteeringActivity", "id" => activity.id } |
| 75 | + session[:creating_activity] = { "class_name" => "VolunteeringActivity", "id" => activity.id, "activity_flow_id" => other_flow.id } |
76 | 76 |
|
77 | 77 | expect { get :index }.not_to change(VolunteeringActivity, :count) |
78 | | - expect(session[:creating_activity]).to be_nil |
| 78 | + expect(session[:creating_activity]).to be_present |
79 | 79 | end |
80 | 80 |
|
81 | 81 | it "handles an already-deleted activity gracefully" do |
82 | | - session[:creating_activity] = { "class_name" => "VolunteeringActivity", "id" => -1 } |
| 82 | + session[:creating_activity] = { "class_name" => "VolunteeringActivity", "id" => -1, "activity_flow_id" => current_flow.id } |
83 | 83 |
|
84 | 84 | expect { get :index }.not_to raise_error |
85 | 85 | expect(session[:creating_activity]).to be_nil |
86 | 86 | end |
87 | 87 |
|
88 | 88 | it "destroys a tracked incomplete payroll account on hub visit" do |
89 | 89 | payroll_account = create(:payroll_account, :pinwheel_fully_synced, flow: current_flow) |
90 | | - session[:creating_payroll_account] = payroll_account.aggregator_account_id |
| 90 | + session[:creating_payroll_account] = { "aggregator_account_id" => payroll_account.aggregator_account_id, "flow_id" => current_flow.id } |
91 | 91 |
|
92 | 92 | expect { get :index }.to change(current_flow.payroll_accounts, :count).by(-1) |
93 | 93 | expect(session[:creating_payroll_account]).to be_nil |
94 | 94 | end |
95 | 95 |
|
| 96 | + it "does not destroy a payroll account tracked for a different flow and preserves session" do |
| 97 | + other_flow = create(:activity_flow) |
| 98 | + payroll_account = create(:payroll_account, :pinwheel_fully_synced, flow: other_flow) |
| 99 | + session[:creating_payroll_account] = { "aggregator_account_id" => payroll_account.aggregator_account_id, "flow_id" => other_flow.id } |
| 100 | + |
| 101 | + expect { get :index }.not_to change(PayrollAccount, :count) |
| 102 | + expect(session[:creating_payroll_account]).to be_present |
| 103 | + end |
| 104 | + |
96 | 105 | it "handles an already-deleted payroll account gracefully" do |
97 | | - session[:creating_payroll_account] = "nonexistent-account-id" |
| 106 | + session[:creating_payroll_account] = { "aggregator_account_id" => "nonexistent-account-id", "flow_id" => current_flow.id } |
98 | 107 |
|
99 | 108 | expect { get :index }.not_to raise_error |
100 | 109 | expect(session[:creating_payroll_account]).to be_nil |
|
0 commit comments