Skip to content

Commit 033c341

Browse files
authored
Add country to Authenticable (#60)
Add `#country` as an attribute in `Authenticable`. This is to support work in experience-ai, see https://github.com/RaspberryPiFoundation/experience-ai/issues/205
2 parents ea963ad + ef2dca6 commit 033c341

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add country attribute to `Authenticable` (#60)
13+
1014
## [v3.2.0]
1115

1216
### Added

lib/rpi_auth/models/authenticatable.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module Authenticatable
66
extend ActiveSupport::Concern
77

88
PROFILE_KEYS = %w[
9+
country
910
country_code
1011
email
1112
email_verified

spec/rpi_auth/models/authenticatable_spec.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class DummyUser
1010
subject { described_class.new }
1111

1212
it { is_expected.to respond_to(:user_id) }
13+
it { is_expected.to respond_to(:country) }
1314
it { is_expected.to respond_to(:country_code) }
1415
it { is_expected.to respond_to(:email) }
1516
it { is_expected.to respond_to(:name) }
@@ -32,6 +33,7 @@ class DummyUser
3233
email: 'test@example.com',
3334
name: 'Bodkin Van Horn',
3435
nickname: 'Hoos-Foos',
36+
country: 'Zimbabwe',
3537
country_code: 'ZW',
3638
picture: 'https://placecage.com/100/100',
3739
profile: 'https://my.raspberry.pi/profile/edit'
@@ -52,13 +54,11 @@ class DummyUser
5254

5355
it 'returns a user with the correct attributes' do
5456
expect(omniauth_user).to be_a described_class
55-
expect(omniauth_user.user_id).to eq('testuserid')
56-
expect(omniauth_user.name).to eq('Bodkin Van Horn')
57-
expect(omniauth_user.nickname).to eq('Hoos-Foos')
58-
expect(omniauth_user.email).to eq('test@example.com')
59-
expect(omniauth_user.country_code).to eq('ZW')
60-
expect(omniauth_user.picture).to eq('https://placecage.com/100/100')
61-
expect(omniauth_user.profile).to eq('https://my.raspberry.pi/profile/edit')
57+
expect(omniauth_user).to have_attributes(user_id: 'testuserid', name: 'Bodkin Van Horn',
58+
nickname: 'Hoos-Foos', email: 'test@example.com',
59+
country: 'Zimbabwe', country_code: 'ZW',
60+
picture: 'https://placecage.com/100/100',
61+
profile: 'https://my.raspberry.pi/profile/edit')
6262
end
6363

6464
context 'with unusual keys in info' do

0 commit comments

Comments
 (0)