|
349 | 349 | before { allow(subject).to receive(:access_token).and_return(access_token) } |
350 | 350 |
|
351 | 351 | describe 'id_token' do |
352 | | - shared_examples 'id_token issued by valid issuer' do |issuer| # rubocop:disable Metrics/BlockLength |
| 352 | + shared_examples 'id_token issued by valid issuer' do |issuer| |
353 | 353 | context 'when the id_token is passed into the access token' do |
354 | 354 | let(:token_info) do |
355 | 355 | { |
|
462 | 462 | expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50/photo.jpg') |
463 | 463 | end |
464 | 464 |
|
| 465 | + it 'should return the image with size specified in the `image_size` option when sizing is in the picture' do |
| 466 | + @options = { image_size: 50 } |
| 467 | + allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh4.googleusercontent.com/url/s96-c/photo.jpg' } } |
| 468 | + expect(subject.info[:image]).to eq('https://lh4.googleusercontent.com/url/s50/photo.jpg') |
| 469 | + end |
| 470 | + |
465 | 471 | it 'should handle a picture with too many slashes correctly' do |
466 | 472 | @options = { image_size: 50 } |
467 | 473 | allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url//photo.jpg' } } |
|
492 | 498 | expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40/photo.jpg') |
493 | 499 | end |
494 | 500 |
|
| 501 | + it 'should return the image with width and height specified in the `image_size` option when sizing is in the picture' do |
| 502 | + @options = { image_size: { width: 50, height: 40 } } |
| 503 | + allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/w100-h80-c/photo.jpg' } } |
| 504 | + expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40/photo.jpg') |
| 505 | + end |
| 506 | + |
495 | 507 | it 'should return square image when `image_aspect_ratio` is specified' do |
496 | 508 | @options = { image_aspect_ratio: 'square' } |
497 | 509 | allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } } |
498 | 510 | expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/c/photo.jpg') |
499 | 511 | end |
500 | 512 |
|
| 513 | + it 'should return square image when `image_aspect_ratio` is specified and sizing is in the picture' do |
| 514 | + @options = { image_aspect_ratio: 'square' } |
| 515 | + allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/c/photo.jpg' } } |
| 516 | + expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/c/photo.jpg') |
| 517 | + end |
| 518 | + |
501 | 519 | it 'should return square sized image when `image_aspect_ratio` and `image_size` is set' do |
502 | 520 | @options = { image_aspect_ratio: 'square', image_size: 50 } |
503 | 521 | allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } } |
504 | 522 | expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50-c/photo.jpg') |
505 | 523 | end |
506 | 524 |
|
| 525 | + it 'should return square sized image when `image_aspect_ratio` and `image_size` is set and sizing is in the picture' do |
| 526 | + @options = { image_aspect_ratio: 'square', image_size: 50 } |
| 527 | + allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/s90/photo.jpg' } } |
| 528 | + expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/s50-c/photo.jpg') |
| 529 | + end |
| 530 | + |
507 | 531 | it 'should return square sized image when `image_aspect_ratio` and `image_size` has height and width' do |
508 | 532 | @options = { image_aspect_ratio: 'square', image_size: { width: 50, height: 40 } } |
509 | 533 | allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photo.jpg' } } |
510 | 534 | expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40-c/photo.jpg') |
511 | 535 | end |
512 | 536 |
|
| 537 | + it 'should return square sized image when `image_aspect_ratio` and `image_size` has height and width and sizing is in the picture' do |
| 538 | + @options = { image_aspect_ratio: 'square', image_size: { width: 50, height: 40 } } |
| 539 | + allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/w100-h80/photo.jpg' } } |
| 540 | + expect(subject.info[:image]).to eq('https://lh3.googleusercontent.com/url/w50-h40-c/photo.jpg') |
| 541 | + end |
| 542 | + |
513 | 543 | it 'should return original image if image url does not end in `photo.jpg`' do |
514 | 544 | @options = { image_size: 50 } |
515 | 545 | allow(subject).to receive(:raw_info) { { 'picture' => 'https://lh3.googleusercontent.com/url/photograph.jpg' } } |
|
0 commit comments