|
31 | 31 | end |
32 | 32 |
|
33 | 33 | before do |
34 | | - allow(UserInfoApiClient).to receive(:find_user_by_email) |
35 | | - .with('owner1@example.com') |
36 | | - .and_return({ id: owner1_id, email: 'owner1@example.com' }) |
37 | | - |
38 | | - allow(UserInfoApiClient).to receive(:find_user_by_email) |
39 | | - .with('owner2@example.com') |
40 | | - .and_return({ id: owner2_id, email: 'owner2@example.com' }) |
41 | | - |
42 | 34 | allow(ProfileApiClient).to receive(:create_school).and_return(true) |
43 | 35 | end |
44 | 36 |
|
45 | 37 | context 'when all schools can be created successfully' do |
| 38 | + before do |
| 39 | + stub_user_info_api_find_by_email( |
| 40 | + email: 'owner1@example.com', |
| 41 | + user: { id: owner1_id, email: 'owner1@example.com' } |
| 42 | + ) |
| 43 | + |
| 44 | + stub_user_info_api_find_by_email( |
| 45 | + email: 'owner2@example.com', |
| 46 | + user: { id: owner2_id, email: 'owner2@example.com' } |
| 47 | + ) |
| 48 | + end |
| 49 | + |
46 | 50 | it 'creates schools and returns successful results' do |
47 | 51 | results = described_class.new.perform( |
48 | 52 | schools_data: schools_data, |
|
67 | 71 |
|
68 | 72 | context 'when owner email is not found' do |
69 | 73 | before do |
70 | | - allow(UserInfoApiClient).to receive(:find_user_by_email) |
71 | | - .with('owner1@example.com') |
72 | | - .and_return(nil) |
| 74 | + stub_user_info_api_find_by_email(email: 'owner1@example.com', user: nil) |
73 | 75 | end |
74 | 76 |
|
75 | 77 | it 'adds failed result for that school' do |
|
91 | 93 |
|
92 | 94 | before do |
93 | 95 | Role.owner.create!(school_id: existing_school.id, user_id: owner1_id) |
| 96 | + |
| 97 | + stub_user_info_api_find_by_email( |
| 98 | + email: 'owner1@example.com', |
| 99 | + user: { id: owner1_id, email: 'owner1@example.com' } |
| 100 | + ) |
94 | 101 | end |
95 | 102 |
|
96 | 103 | it 'adds failed result for that school' do |
|
123 | 130 | end |
124 | 131 |
|
125 | 132 | before do |
126 | | - allow(UserInfoApiClient).to receive(:find_user_by_email) |
127 | | - .with('owner1@example.com') |
128 | | - .and_return({ id: owner1_id, email: 'owner1@example.com' }) |
| 133 | + stub_user_info_api_find_by_email( |
| 134 | + email: 'owner1@example.com', |
| 135 | + user: { id: owner1_id, email: 'owner1@example.com' } |
| 136 | + ) |
129 | 137 | end |
130 | 138 |
|
131 | 139 | it 'handles string keys correctly' do |
|
0 commit comments