openstax_accounts 7.12.0 → 7.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,7 @@ FactoryBot.define do
5
5
  access_token { SecureRandom.hex.to_s }
6
6
  faculty_status { OpenStax::Accounts::Account.faculty_statuses[:no_faculty_info] }
7
7
  role { OpenStax::Accounts::Account.roles[:unknown_role] }
8
+ school_type { OpenStax::Accounts::Account.school_types[:unknown_school_type] }
8
9
  uuid { SecureRandom.uuid }
9
10
  support_identifier { "cs_#{SecureRandom.hex(4)}" }
10
11
  is_test true
@@ -5,30 +5,13 @@ module OpenStax
5
5
 
6
6
  RSpec.describe SessionsCallback do
7
7
 
8
- context "faculty_status" do
9
- it "should default to no_faculty_info if the received faculty_status is unknown" +
10
- " (e.g. if Accounts is updated but this repo is not)" do
11
- result = described_class.handle(
12
- request: mock_omniauth_request(faculty_status: "howdy_ho")
13
- )
14
- expect(result.outputs.account).to be_no_faculty_info
15
- end
16
-
17
- it "should default to no_faculty_info if faculty status is not present" do
18
- request = mock_omniauth_request()
19
- remove_faculty_status!(request)
8
+ it "deals with null faculty_status" do
9
+ with_stubbing(false) do
10
+ request = mock_omniauth_request
11
+ remove_nickname!(request)
20
12
  result = described_class.handle(request: request)
21
- expect(result.outputs.account).to be_no_faculty_info
22
- end
23
-
24
- it "should deal with null nicknames" do
25
- with_stubbing(false) do
26
- request = mock_omniauth_request
27
- remove_nickname!(request)
28
- result = described_class.handle(request: request)
29
- expect(result.outputs.account).to be_valid
30
- expect(result.outputs.account).to be_persisted
31
- end
13
+ expect(result.outputs.account).to be_valid
14
+ expect(result.outputs.account).to be_persisted
32
15
  end
33
16
  end
34
17
 
@@ -50,12 +33,29 @@ module OpenStax
50
33
  end
51
34
  end
52
35
 
36
+ context "faculty_status" do
37
+ it "defaults to no_faculty_info if the received faculty_status is unknown" +
38
+ " (e.g. if Accounts is updated but this repo is not)" do
39
+ result = described_class.handle(
40
+ request: mock_omniauth_request(faculty_status: "howdy_ho")
41
+ )
42
+ expect(result.outputs.account).to be_no_faculty_info
43
+ end
44
+
45
+ it "defaults to no_faculty_info if faculty status is not present" do
46
+ request = mock_omniauth_request()
47
+ remove_faculty_status!(request)
48
+ result = described_class.handle(request: request)
49
+ expect(result.outputs.account).to be_no_faculty_info
50
+ end
51
+ end
52
+
53
53
  context "role" do
54
54
  it "sets the role on the account" do
55
55
  result = described_class.handle(
56
56
  request: mock_omniauth_request(self_reported_role: "instructor")
57
57
  )
58
- expect(result.outputs.account.role).to eq "instructor"
58
+ expect(result.outputs.account).to be_instructor
59
59
  end
60
60
 
61
61
  it "deals with unknown role (e.g. if Accounts update but this repo not)" do
@@ -66,6 +66,22 @@ module OpenStax
66
66
  end
67
67
  end
68
68
 
69
+ context "school_type" do
70
+ it "sets the school_type on the account" do
71
+ result = described_class.handle(
72
+ request: mock_omniauth_request(school_type: "college")
73
+ )
74
+ expect(result.outputs.account).to be_college
75
+ end
76
+
77
+ it "deals with unknown school_type (e.g. if Accounts update but this repo not)" do
78
+ result = described_class.handle(
79
+ request: mock_omniauth_request(school_type: "howdy_ho")
80
+ )
81
+ expect(result.outputs.account).to be_unknown_school_type
82
+ end
83
+ end
84
+
69
85
  context "user exists" do
70
86
  it "updates the user's data" do
71
87
  existing_account = FactoryBot.create :openstax_accounts_account
@@ -49,7 +49,7 @@ module OpenStax
49
49
  email: 'bob@example.com', username: nil, password: nil,
50
50
  first_name: 'Bob', last_name: 'Smith', full_name: 'Bob Smith',
51
51
  salesforce_contact_id: 'b0b', faculty_status: :rejected_faculty,
52
- role: :instructor
52
+ role: :instructor, school_type: :college
53
53
  ).and_return(find_or_create_account_response)
54
54
 
55
55
  described_class.call(
@@ -59,7 +59,8 @@ module OpenStax
59
59
  full_name: 'Bob Smith',
60
60
  salesforce_contact_id: 'b0b',
61
61
  faculty_status: :rejected_faculty,
62
- role: :instructor
62
+ role: :instructor,
63
+ school_type: :college
63
64
  )
64
65
  end
65
66
 
@@ -52,14 +52,15 @@ end
52
52
 
53
53
  def mock_omniauth_request(
54
54
  uid: nil, first_name: nil, last_name: nil, title: nil, nickname: nil, faculty_status: nil,
55
- uuid: nil, support_identifier: nil, self_reported_role: nil
55
+ uuid: nil, support_identifier: nil, self_reported_role: nil, school_type: nil
56
56
  )
57
57
  extra_hash = {
58
58
  'raw_info' => {
59
59
  'faculty_status' => faculty_status,
60
60
  'uuid' => uuid || SecureRandom.uuid,
61
61
  'support_identifier' => support_identifier || "cs_#{SecureRandom.hex(4)}",
62
- 'self_reported_role' => self_reported_role
62
+ 'self_reported_role' => self_reported_role,
63
+ 'school_type' => school_type
63
64
  }
64
65
  }
65
66
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_accounts
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.12.0
4
+ version: 7.13.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-21 00:00:00.000000000 Z
11
+ date: 2018-04-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -174,16 +174,16 @@ dependencies:
174
174
  name: pg
175
175
  requirement: !ruby/object:Gem::Requirement
176
176
  requirements:
177
- - - ">="
177
+ - - "<"
178
178
  - !ruby/object:Gem::Version
179
- version: '0'
179
+ version: 1.0.0
180
180
  type: :runtime
181
181
  prerelease: false
182
182
  version_requirements: !ruby/object:Gem::Requirement
183
183
  requirements:
184
- - - ">="
184
+ - - "<"
185
185
  - !ruby/object:Gem::Version
186
- version: '0'
186
+ version: 1.0.0
187
187
  - !ruby/object:Gem::Dependency
188
188
  name: rspec-rails
189
189
  requirement: !ruby/object:Gem::Requirement
@@ -371,6 +371,7 @@ files:
371
371
  - db/migrate/10_assign_missing_uuids_for_local_accounts.rb
372
372
  - db/migrate/11_add_support_identifier_to_accounts_accounts.rb
373
373
  - db/migrate/12_add_is_test_to_accounts_accounts.rb
374
+ - db/migrate/13_add_school_type_to_accounts_accounts.rb
374
375
  - db/migrate/1_create_openstax_accounts_groups.rb
375
376
  - db/migrate/2_create_openstax_accounts_group_members.rb
376
377
  - db/migrate/3_create_openstax_accounts_group_owners.rb
@@ -495,7 +496,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
495
496
  version: '0'
496
497
  requirements: []
497
498
  rubyforge_project:
498
- rubygems_version: 2.4.5.1
499
+ rubygems_version: 2.7.3
499
500
  signing_key:
500
501
  specification_version: 4
501
502
  summary: Rails common code and bindings for the 'accounts' API