|
77 | 77 | end |
78 | 78 | end |
79 | 79 |
|
| 80 | + describe 'GET #show with roles' do |
| 81 | + let(:creator) { create(:user) } |
| 82 | + let(:school) { create(:school, creator_id: creator.id) } |
| 83 | + let(:owner) { create(:user, name: 'Olivia Owner', email: 'owner@example.com') } |
| 84 | + let(:teacher) { create(:user, name: 'Tariq Teacher', email: 'teacher@example.com') } |
| 85 | + let(:student) { create(:user, name: 'Sam Student', email: 'student@example.com') } |
| 86 | + let(:role_users) do |
| 87 | + [ |
| 88 | + owner, |
| 89 | + teacher |
| 90 | + ] |
| 91 | + end |
| 92 | + |
| 93 | + before do |
| 94 | + create(:owner_role, school:, user_id: owner.id) |
| 95 | + create(:teacher_role, school:, user_id: teacher.id) |
| 96 | + create(:student_role, school:, user_id: student.id) |
| 97 | + |
| 98 | + allow(User).to receive(:from_userinfo).with(ids: creator.id).and_return([creator]) |
| 99 | + allow(User).to receive(:from_userinfo).with(ids: contain_exactly(owner.id, teacher.id)).and_return(role_users) |
| 100 | + |
| 101 | + get admin_school_path(school) |
| 102 | + end |
| 103 | + |
| 104 | + it 'lists owner and teacher roles with names and emails' do |
| 105 | + expect(User).to have_received(:from_userinfo).with(ids: contain_exactly(owner.id, teacher.id)).once |
| 106 | + expect(response.body).to include('Owner') |
| 107 | + expect(response.body).to include('Olivia Owner (owner@example.com)') |
| 108 | + expect(response.body).to include('Teacher') |
| 109 | + expect(response.body).to include('Tariq Teacher (teacher@example.com)') |
| 110 | + end |
| 111 | + |
| 112 | + it 'does not list student roles' do |
| 113 | + expect(response.body).not_to include('Sam Student') |
| 114 | + expect(response.body).not_to include('student@example.com') |
| 115 | + end |
| 116 | + end |
| 117 | + |
80 | 118 | describe 'POST #verify' do |
81 | 119 | let(:creator) { create(:user) } |
82 | 120 | let(:verified_at) { nil } |
|
0 commit comments