|
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 |
46 | 49 | it 'creates schools and returns successful results' do |
47 | 50 | results = described_class.new.perform( |
48 | 51 | schools_data: schools_data, |
|
67 | 70 |
|
68 | 71 | context 'when owner email is not found' do |
69 | 72 | before do |
70 | | - allow(UserInfoApiClient).to receive(:find_user_by_email) |
71 | | - .with('owner1@example.com') |
72 | | - .and_return(nil) |
| 73 | + stub_user_info_api_find_by_email(email: 'owner1@example.com', user: nil) |
73 | 74 | end |
74 | 75 |
|
75 | 76 | it 'adds failed result for that school' do |
|
91 | 92 |
|
92 | 93 | before do |
93 | 94 | Role.owner.create!(school_id: existing_school.id, user_id: owner1_id) |
| 95 | + |
| 96 | + stub_user_info_api_find_by_email( |
| 97 | + email: 'owner1@example.com', |
| 98 | + user: { id: owner1_id, email: 'owner1@example.com' } |
| 99 | + ) |
94 | 100 | end |
95 | 101 |
|
96 | 102 | it 'adds failed result for that school' do |
|
123 | 129 | end |
124 | 130 |
|
125 | 131 | 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' }) |
| 132 | + stub_user_info_api_find_by_email( |
| 133 | + email: 'owner1@example.com', |
| 134 | + user: { id: owner1_id, email: 'owner1@example.com' } |
| 135 | + ) |
129 | 136 | end |
130 | 137 |
|
131 | 138 | it 'handles string keys correctly' do |
|
0 commit comments