openstax_accounts 6.4.2 → 7.0.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.
@@ -3,5 +3,6 @@ FactoryGirl.define do
3
3
  openstax_uid { -SecureRandom.hex(4).to_i(16)/2 }
4
4
  username { SecureRandom.hex.to_s }
5
5
  access_token { SecureRandom.hex.to_s }
6
+ faculty_status { OpenStax::Accounts::Account.faculty_statuses[:no_faculty_info] }
6
7
  end
7
8
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ module OpenStax
4
+ module Accounts
5
+
6
+ describe SessionsCallback do
7
+
8
+ context "faculty_status" do
9
+ it "should deal with faculty status it doesn't know (e.g. if Accounts updated but this repo not)" do
10
+ result = described_class.handle(request: mock_omniauth_request(faculty_status: "howdy_ho"))
11
+ expect(result.outputs.account).to be_no_faculty_info
12
+ end
13
+
14
+ it "should deal with faculty status that is not present" do
15
+ request = mock_omniauth_request()
16
+ remove_faculty_status!(request)
17
+ result = described_class.handle(request: request)
18
+ expect(result.outputs.account).to be_no_faculty_info
19
+ end
20
+ end
21
+
22
+ end
23
+
24
+ end
25
+ end
data/spec/spec_helper.rb CHANGED
@@ -39,3 +39,36 @@ RSpec.configure do |config|
39
39
  # --seed 1234
40
40
  config.order = "random"
41
41
  end
42
+
43
+
44
+ def mock_omniauth_request(uid: nil, first_name: nil, last_name: nil, title: nil, nickname: nil, faculty_status: nil)
45
+ extra_hash = {
46
+ 'raw_info' => {
47
+ 'faculty_status' => faculty_status
48
+ }
49
+ }
50
+
51
+ OpenStruct.new(
52
+ env: {
53
+ 'omniauth.auth' => OpenStruct.new({
54
+ uid: uid || SecureRandom.hex(4),
55
+ provider: "openstax",
56
+ info: OpenStruct.new({
57
+ nickname: nickname || "",
58
+ first_name: first_name || "",
59
+ last_name: last_name || "",
60
+ title: title || ""
61
+ }),
62
+ credentials: OpenStruct.new({
63
+ access_token: "foo"
64
+ }),
65
+ extra: OpenStruct.new(extra_hash)
66
+ })
67
+ }
68
+ )
69
+ end
70
+
71
+ def remove_faculty_status!(omniauth_request)
72
+ omniauth_request.env["omniauth.auth"].extra.raw_info.delete("faculty_status")
73
+ end
74
+
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: 6.4.2
4
+ version: 7.0.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: 2016-09-19 00:00:00.000000000 Z
11
+ date: 2016-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -366,6 +366,7 @@ files:
366
366
  - db/migrate/2_create_openstax_accounts_group_members.rb
367
367
  - db/migrate/3_create_openstax_accounts_group_owners.rb
368
368
  - db/migrate/4_create_openstax_accounts_group_nestings.rb
369
+ - db/migrate/5_add_faculty_status_to_accounts_accounts.rb
369
370
  - lib/generators/openstax/accounts/schedule/USAGE
370
371
  - lib/generators/openstax/accounts/schedule/schedule_generator.rb
371
372
  - lib/generators/openstax/accounts/schedule/templates/schedule.rb
@@ -425,8 +426,9 @@ files:
425
426
  - spec/dummy/config/locales/en.yml
426
427
  - spec/dummy/config/routes.rb
427
428
  - spec/dummy/config/secrets.yml
428
- - spec/dummy/db/migrate/5_create_users.rb
429
- - spec/dummy/db/migrate/6_create_ownerships.rb
429
+ - spec/dummy/db/development.sqlite3
430
+ - spec/dummy/db/migrate/1000_create_users.rb
431
+ - spec/dummy/db/migrate/1001_create_ownerships.rb
430
432
  - spec/dummy/db/schema.rb
431
433
  - spec/dummy/db/test.sqlite3
432
434
  - spec/dummy/log/development.log
@@ -443,6 +445,7 @@ files:
443
445
  - spec/factories/openstax_accounts_group_owner.rb
444
446
  - spec/handlers/openstax/accounts/accounts_search_spec.rb
445
447
  - spec/handlers/openstax/accounts/dev/accounts_search_spec.rb
448
+ - spec/handlers/openstax/accounts/sessions_callback_spec.rb
446
449
  - spec/lib/openstax/accounts/api_spec.rb
447
450
  - spec/lib/openstax/accounts/configuration_spec.rb
448
451
  - spec/lib/openstax/accounts/current_user_manager_spec.rb
@@ -476,7 +479,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
476
479
  version: '0'
477
480
  requirements: []
478
481
  rubyforge_project:
479
- rubygems_version: 2.2.2
482
+ rubygems_version: 2.4.8
480
483
  signing_key:
481
484
  specification_version: 4
482
485
  summary: Rails common code and bindings for the 'accounts' API
@@ -524,8 +527,9 @@ test_files:
524
527
  - spec/dummy/config/routes.rb
525
528
  - spec/dummy/config/secrets.yml
526
529
  - spec/dummy/config.ru
527
- - spec/dummy/db/migrate/5_create_users.rb
528
- - spec/dummy/db/migrate/6_create_ownerships.rb
530
+ - spec/dummy/db/development.sqlite3
531
+ - spec/dummy/db/migrate/1000_create_users.rb
532
+ - spec/dummy/db/migrate/1001_create_ownerships.rb
529
533
  - spec/dummy/db/schema.rb
530
534
  - spec/dummy/db/test.sqlite3
531
535
  - spec/dummy/log/development.log
@@ -544,6 +548,7 @@ test_files:
544
548
  - spec/factories/openstax_accounts_group_owner.rb
545
549
  - spec/handlers/openstax/accounts/accounts_search_spec.rb
546
550
  - spec/handlers/openstax/accounts/dev/accounts_search_spec.rb
551
+ - spec/handlers/openstax/accounts/sessions_callback_spec.rb
547
552
  - spec/lib/openstax/accounts/api_spec.rb
548
553
  - spec/lib/openstax/accounts/configuration_spec.rb
549
554
  - spec/lib/openstax/accounts/current_user_manager_spec.rb