|
50 | 50 | end
|
51 | 51 | end
|
52 | 52 |
|
| 53 | + describe '.from_userinfo' do |
| 54 | + subject(:users) { described_class.from_userinfo(ids:) } |
| 55 | + |
| 56 | + let(:ids) { ['00000000-0000-0000-0000-000000000000'] } |
| 57 | + let(:user) { users.first } |
| 58 | + |
| 59 | + before do |
| 60 | + stub_user_info_api |
| 61 | + end |
| 62 | + |
| 63 | + it 'returns an Array' do |
| 64 | + expect(users).to be_an Array |
| 65 | + end |
| 66 | + |
| 67 | + it 'returns an array of instances of the described class' do |
| 68 | + expect(user).to be_a described_class |
| 69 | + end |
| 70 | + |
| 71 | + it 'returns a user with the correct ID' do |
| 72 | + expect(user.id).to eq '00000000-0000-0000-0000-000000000000' |
| 73 | + end |
| 74 | + |
| 75 | + it 'returns a user with the correct name' do |
| 76 | + expect(user.name).to eq 'School Owner' |
| 77 | + end |
| 78 | + |
| 79 | + it 'returns a user with the correct email' do |
| 80 | + expect(user.email).to eq '[email protected]' |
| 81 | + end |
| 82 | + |
| 83 | + it 'returns a user with the correct organisations' do |
| 84 | + expect(user.organisations).to eq(organisation_id => 'school-owner') |
| 85 | + end |
| 86 | + |
| 87 | + context 'when no organisations are returned' do |
| 88 | + let(:ids) { ['33333333-3333-3333-3333-333333333333'] } # student without organisations |
| 89 | + |
| 90 | + it 'returns a user with the correct organisations' do |
| 91 | + expect(user.organisations).to eq(organisation_id => 'school-student') |
| 92 | + end |
| 93 | + end |
| 94 | + end |
| 95 | + |
53 | 96 | describe '.from_token' do
|
54 | 97 | subject(:user) { described_class.from_token(token: UserProfileMock::TOKEN) }
|
55 | 98 |
|
| 99 | + let(:user_index) { 0 } |
| 100 | + |
56 | 101 | before do
|
57 |
| - stub_hydra_public_api |
| 102 | + stub_hydra_public_api(user_index:) |
58 | 103 | end
|
59 | 104 |
|
60 | 105 | it 'returns an instance of the described class' do
|
|
77 | 122 | expect(user.organisations).to eq(organisation_id => 'school-owner')
|
78 | 123 | end
|
79 | 124 |
|
| 125 | + context 'when no organisations are returned' do |
| 126 | + let(:user_index) { 3 } # student without organisations |
| 127 | + |
| 128 | + it 'returns a user with the correct organisations' do |
| 129 | + expect(user.organisations).to eq(organisation_id => 'school-student') |
| 130 | + end |
| 131 | + end |
| 132 | + |
80 | 133 | context 'when BYPASS_AUTH is true' do
|
81 | 134 | around do |example|
|
82 | 135 | ClimateControl.modify(BYPASS_AUTH: 'true') do
|
|
0 commit comments