|
38 | 38 | allow(UserInfoApiClient).to receive(:find_user_by_email) |
39 | 39 | .with('owner2@example.com') |
40 | 40 | .and_return({ id: owner2_id, email: 'owner2@example.com' }) |
| 41 | + |
| 42 | + allow(ProfileApiClient).to receive(:create_school).and_return(true) |
41 | 43 | end |
42 | 44 |
|
43 | 45 | context 'when all schools can be created successfully' do |
44 | 46 | it 'creates schools and returns successful results' do |
45 | 47 | results = described_class.new.perform( |
46 | 48 | schools_data: schools_data, |
47 | | - user_id: user_id |
| 49 | + user_id: user_id, |
| 50 | + token: token |
48 | 51 | ) |
49 | 52 |
|
50 | 53 | expect(results[:successful].count).to eq(2) |
|
56 | 59 | expect(school_1.code).to be_present |
57 | 60 | expect(school_1.user_origin).to eq('experience_cs') |
58 | 61 |
|
59 | | - # Check owner role was created |
| 62 | + # Check owner and teacher roles were created |
60 | 63 | expect(Role.owner.exists?(school_id: school_1.id, user_id: owner1_id)).to be true |
| 64 | + expect(Role.teacher.exists?(school_id: school_1.id, user_id: owner1_id)).to be true |
61 | 65 | end |
62 | 66 | end |
63 | 67 |
|
|
71 | 75 | it 'adds failed result for that school' do |
72 | 76 | results = described_class.new.perform( |
73 | 77 | schools_data: [schools_data.first], |
74 | | - user_id: user_id |
| 78 | + user_id: user_id, |
| 79 | + token: token |
75 | 80 | ) |
76 | 81 |
|
77 | 82 | expect(results[:successful].count).to eq(0) |
|
91 | 96 | it 'adds failed result for that school' do |
92 | 97 | results = described_class.new.perform( |
93 | 98 | schools_data: [schools_data.first], |
94 | | - user_id: user_id |
| 99 | + user_id: user_id, |
| 100 | + token: token |
95 | 101 | ) |
96 | 102 |
|
97 | 103 | expect(results[:successful].count).to eq(0) |
|
125 | 131 | it 'handles string keys correctly' do |
126 | 132 | results = described_class.new.perform( |
127 | 133 | schools_data: schools_data_with_string_keys, |
128 | | - user_id: user_id |
| 134 | + user_id: user_id, |
| 135 | + token: token |
129 | 136 | ) |
130 | 137 |
|
131 | 138 | expect(results[:successful].count).to eq(1) |
|
0 commit comments