openstax_accounts 7.8.0 → 7.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +7 -7
  3. data/app/handlers/openstax/accounts/sessions_callback.rb +0 -1
  4. data/app/models/openstax/accounts/account.rb +1 -0
  5. data/app/models/openstax/accounts/group.rb +47 -24
  6. data/app/routines/openstax/accounts/search_local_accounts.rb +30 -17
  7. data/db/migrate/10_assign_missing_uuids_for_local_accounts.rb +11 -0
  8. data/lib/openstax/accounts/engine.rb +5 -6
  9. data/lib/openstax/accounts/version.rb +1 -1
  10. data/spec/controllers/openstax/accounts/dev/accounts_controller_spec.rb +1 -1
  11. data/spec/controllers/openstax/accounts/sessions_controller_spec.rb +1 -1
  12. data/spec/dummy/config/database.yml +5 -15
  13. data/spec/dummy/db/development.sqlite3 +0 -0
  14. data/spec/dummy/db/schema.rb +29 -25
  15. data/spec/dummy/db/test.sqlite3 +0 -0
  16. data/spec/dummy/log/development.log +2152 -4613
  17. data/spec/dummy/log/test.log +55163 -102384
  18. data/spec/factories/openstax_accounts_account.rb +6 -6
  19. data/spec/factories/openstax_accounts_group.rb +1 -1
  20. data/spec/factories/openstax_accounts_group_member.rb +1 -1
  21. data/spec/factories/openstax_accounts_group_nesting.rb +1 -1
  22. data/spec/factories/openstax_accounts_group_owner.rb +1 -1
  23. data/spec/handlers/openstax/accounts/accounts_search_spec.rb +5 -5
  24. data/spec/handlers/openstax/accounts/dev/accounts_search_spec.rb +5 -5
  25. data/spec/handlers/openstax/accounts/sessions_callback_spec.rb +7 -5
  26. data/spec/lib/openstax/accounts/api_spec.rb +9 -9
  27. data/spec/lib/openstax/accounts/current_user_manager_spec.rb +1 -1
  28. data/spec/lib/openstax/accounts/has_many_through_groups/active_record/base_spec.rb +3 -3
  29. data/spec/models/openstax/accounts/account_spec.rb +6 -6
  30. data/spec/models/openstax/accounts/group_spec.rb +4 -4
  31. data/spec/routines/openstax/accounts/create_group_spec.rb +1 -1
  32. data/spec/routines/openstax/accounts/search_accounts_spec.rb +13 -13
  33. data/spec/routines/openstax/accounts/sync_accounts_spec.rb +26 -7
  34. data/spec/routines/openstax/accounts/sync_groups_spec.rb +51 -14
  35. data/spec/spec_helper.rb +2 -2
  36. metadata +64 -211
  37. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-4/-4AigB7SRNxiHWeamN5uh_JTU4pT-99hUByQ7hhtfM4.cache +0 -1
  38. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/-B/-BM2LkGo9LiZel0dx2cTeIoUiOvZvzvQX-qrY-PefDc.cache +0 -0
  39. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/0d/0dqBuwbmRqLO9AM5KdttlIvUSbOG2uS9fJsm4TRuY8M.cache +0 -0
  40. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1b/1bCIjOPcmZWjhnOiOIrEUVDFzGzCezkm0dIrzY7q22A.cache +0 -2
  41. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2G/2GcGY034bmlAWeI-bC8yjSfggr98_D1ysvB0hcR9PaI.cache +0 -3
  42. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/2G/2gGPkwl7LddZxTKkA0XQ6NKsdgK7mDG6PfvKrqKYsAs.cache +0 -0
  43. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/4W/4WJLh0PRMuTwbFf44QcjwkcJ57BXKVgwtaRnUiMxlbc.cache +0 -1
  44. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5T/5TLgAp4XC6JjXz-MP4IR8UIli3l091nGGpp0xomd_g0.cache +0 -0
  45. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5g/5g7dhxVp4YbZmFw_-T3aU2oYq2Z9Jgtps0CKneXYSS0.cache +0 -2
  46. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5u/5uKXJe6QpDEzhvxGUSwHZS2uGrjr0-ex9LVlRQZaQnI.cache +0 -1
  47. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/6H/6HAlvBZ_na7ir9ELSAcCJ1GTAwGaO565PgVOt7rgitw.cache +0 -1
  48. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/6b/6bUhHw6Kpj9FgN8vIU0BBQNdA1sgsa0pyhDOdq4U1a8.cache +0 -2
  49. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8w/8whA2ROqlMHhJJiXDf0onGPb8mLmBGb5UUPY7yZZuMs.cache +0 -1
  50. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/9S/9SfcyOi0r3UamY1lEOb94zdm_ybDACE3pzfyMeUnoJc.cache +0 -0
  51. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Af/AfzRuN8Wm6MIHDZEpwWkiSl3zNDMJ1tOvSt2SOmVCio.cache +0 -1
  52. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DB/DB4PIoupKZcosm_IvLp0-MJ1hiXfVw01ZdY1IOnnPsE.cache +0 -0
  53. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/DR/DRPKqdpBdXQEzG7sFT6-8d_LgGF72B8IFqYLhVsyNqw.cache +0 -1
  54. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Dh/DhSAf3h0VMpFRp_tvO8VIqn12P-Mnp3WFyVH4ORR-gs.cache +0 -0
  55. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/E3/E35l_cFnSYnnYWJwxWXR76R17KJ3tqL_-UG0Tjrp5DI.cache +0 -0
  56. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ET/ETdvBR0__vhxzfl_I4mu0h3Jrcwy0jvIvEf-AcGHuxU.cache +0 -1
  57. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/EZ/EZkBau1uUbmU8TAtNy_21ZEq6hQ-pQY-jNbMnaAlNYM.cache +0 -1
  58. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/IV/IVl_wFSpYKfB-OI07E_GP9JLqGpf6VStaDO-Pl-EcUA.cache +0 -1
  59. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/It/ItWlWNmHD7ZeVOFbsyan26cbPWTR9XFqNBmZhIsyr8k.cache +0 -2
  60. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/JB/JBrtwWy2SgF1Nl6siXGeTqdnlMdXo6F-OOkAKCHx3gw.cache +0 -1
  61. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Je/JeDnsbKYU6WfXwmBfUedz09ThQX9iPI8-sgit9Um1yE.cache +0 -1
  62. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Jr/JrzNmQmTkr6QS1BoAOEeGnCip0CCneRNMyvtaelWV1w.cache +0 -2
  63. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/KE/KEIyyOl_ruT7KuaNvukGN8LnSUVMk4MQmDUOg9oo0XE.cache +0 -0
  64. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/LK/LK8fShpIirD6_e29A0YY7pTPZbISgiHuY3QOMzj-c4c.cache +0 -1
  65. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Lr/LrK9U2KWZskR0G2rWalGnOM8fgZvGwEajG7_WYkK-Rc.cache +0 -1
  66. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/MH/MHc26ZBwFN93Q3ggSv0QW4WDhXzTQV6YvzIUUt6Su7Q.cache +0 -1
  67. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Nj/NjMmwEjtqJiXWQtb2qVmb2Js1DikSD_MgMHDlCNzLP4.cache +0 -1
  68. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Q1/Q1IElAqy9O60bh7c8syJLSGSTIxOL_WDNftM2SNTsgI.cache +0 -1
  69. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/QW/QWLUd5oxFsWTwKa1IXwWsaP8RlLh_GMPdypbqJx0VoA.cache +0 -1
  70. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/TZ/TZlHN1bHx2lwu7SRM5Y3Qp_OpbrtidFt-6223MTPMH4.cache +0 -1
  71. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/VN/VNCapNKJLeponthNeFJhaBYs92UBT3P8PugENHP0474.cache +0 -2
  72. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/WX/WXy-lTrCCH38uK_ld4QeQrhZuZZDOyHGBBrhZ0PDZyY.cache +0 -2
  73. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Yr/YrbMyaVyJ69SVCY3y1ZPJAdUcuUpzzHP7LMQNT2pGfk.cache +0 -1
  74. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Z-/Z-tPXaNX9WvhVHKT_twh9-sJ_NvUPatXyDZ48rWasiE.cache +0 -0
  75. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ay/aYOmaJvT9wpA9a2IfP3f-6A6guRGAezZCHz_3lSCE0A.cache +0 -1
  76. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ay/ayvQApV55-bf3brcKBVUc8_o-8aLmUhKYv9b7OPRXV8.cache +0 -1
  77. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bR/bRCnhDQ4uJkiX7RMvyDbsvopysp32eYxD0SYAsEpDzc.cache +0 -1
  78. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/bz/bzY1-207qUxPHd6HAeNvY34UEmIZlAnGJUuiwkGLqTw.cache +0 -0
  79. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/cj/cjLyKHfhNSrjEff7p2VGJz6ColftKx69unhJqv0UK1g.cache +0 -2
  80. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/e2/e28DqqHF8GN5VTAz03mRnOV5AV_np1CNwB_xuV03NUw.cache +0 -0
  81. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hh/hh_1YpicqmoKC8uz92Sh3iba0TBhh9GEXtUyrUlEzEU.cache +0 -0
  82. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/iK/iKFb6K0z7xwr53FXp9Qy4qO5L6lryDOpXjMnw-48oVg.cache +0 -2
  83. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jn/jnRNObm7DziGmbZR3TPAC-vAE-qmrP0tLBH9W9m6yJs.cache +0 -0
  84. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/kS/kSXVJZ4BJAsy2L9DxKUntzr90Nd9VWD0G7L2n05ISOw.cache +0 -1
  85. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/kq/kq0VL9PQ2HRlksqNC7YPlqlWFBvkHk2uIac_HZb0wEE.cache +0 -1
  86. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/l0/l0BYOaBq08_FGl4jzpCnd80-zLPHNMXs7xCHtqTcUVI.cache +0 -0
  87. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/lx/lxYKD42Es9n2EKrNchxPYKveAzYo6VAGr_CxhxvyO-c.cache +0 -0
  88. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mW/mWLVMCpv8dHPkBK4y4SLLXukqtLhRXWtNC3gm5vgwPk.cache +0 -3
  89. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/mx/mxoipKjbqPo_gvG86AgUPk6o6-OB-uqI5sGMnNqGW4A.cache +0 -1
  90. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/nZ/nZY2kcE7t2EMdrdtEQueW9UYmtEBjQv3FNpous5k1tM.cache +0 -2
  91. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/o3/o3Bz1eWxZ7poUlQGzlkJX5fFeNxKD5VEuFZSctl6Oe4.cache +0 -1
  92. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/p-/p-j1kEkMIDywvXn2EG-FF_CVz9U75IYIDMJj4U2ksCk.cache +0 -2
  93. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pZ/pZXUaTdXV2XMj_KgBsHVED1ocjtpQrIqBR3lGYSMZVc.cache +0 -2
  94. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/q6/q6BYa32YJF11eGVapO4ouNl6gayPIsARgMavlzZmoi0.cache +0 -2
  95. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/r0/r0S88W86F754buOO-eLMVX5f9YdQzd-ZkpvwEJc6hAg.cache +0 -0
  96. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/r3/r3X66JZPGDKB-xMv9rLIyo0WKYWnPrSB2qL0giC2T6g.cache +0 -0
  97. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/t7/t7deseLVHWCZ7z2LMl1YvpZi-RIhvURhm0-MSDE3qvY.cache +0 -0
  98. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/tl/tl1nInky090OX02bJpJWDa-RFuv1vogrbeY5T4K1M_Q.cache +0 -0
  99. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/uf/uf8xlrN24XDdqvg97XSNrPFSYWGELN2cEHkKsu52zJQ.cache +0 -3
  100. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wD/wDQfpqPktQEUJYqGBoTlKAOHJhn7hzFSg9lUtfzUSHM.cache +0 -1
  101. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/x7/x7KkTV3ibfIEysLB_ug5bfmnn2VLV_BldukPR3EoPBk.cache +0 -2
  102. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/y4/y4wKs_D3Zp3A5ItE5hfD5dkJEr-mnvfyNon1lhrxKKY.cache +0 -3
  103. data/spec/dummy/tmp/cache/assets/sprockets/v3.0/yp/yp55Nm9xYM0wvHSoLvfP6mrhrUIKrig6v9Q_Yb0kZpQ.cache +0 -0
@@ -1,10 +1,10 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :openstax_accounts_account, class: OpenStax::Accounts::Account do
3
- openstax_uid { -SecureRandom.hex(4).to_i(16)/2 }
4
- username { SecureRandom.hex.to_s }
5
- access_token { SecureRandom.hex.to_s }
3
+ openstax_uid { -SecureRandom.hex(4).to_i(16)/2 }
4
+ username { SecureRandom.hex.to_s }
5
+ access_token { SecureRandom.hex.to_s }
6
6
  faculty_status { OpenStax::Accounts::Account.faculty_statuses[:no_faculty_info] }
7
- role { OpenStax::Accounts::Account.roles[:unknown_role] }
8
- uuid { SecureRandom.uuid }
7
+ role { OpenStax::Accounts::Account.roles[:unknown_role] }
8
+ uuid { SecureRandom.uuid }
9
9
  end
10
10
  end
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :openstax_accounts_group, :class => OpenStax::Accounts::Group do
3
3
  openstax_uid { -SecureRandom.hex(4).to_i(16)/2 }
4
4
  name "MyGroup"
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :openstax_accounts_group_member, :class => OpenStax::Accounts::GroupMember do
3
3
  association :group, factory: :openstax_accounts_group
4
4
  association :user, factory: :openstax_accounts_account
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :openstax_accounts_group_nesting, :class => OpenStax::Accounts::GroupNesting do
3
3
  association :container_group, factory: :openstax_accounts_group
4
4
  association :member_group, factory: :openstax_accounts_group
@@ -1,4 +1,4 @@
1
- FactoryGirl.define do
1
+ FactoryBot.define do
2
2
  factory :openstax_accounts_group_owner, :class => OpenStax::Accounts::GroupOwner do
3
3
  association :group, factory: :openstax_accounts_group
4
4
  association :user, factory: :openstax_accounts_account
@@ -5,28 +5,28 @@ module OpenStax
5
5
 
6
6
  describe AccountsSearch do
7
7
 
8
- let!(:account_1) { FactoryGirl.create :openstax_accounts_account,
8
+ let!(:account_1) { FactoryBot.create :openstax_accounts_account,
9
9
  first_name: 'John',
10
10
  last_name: 'Stravinsky',
11
11
  username: 'jstrav' }
12
- let!(:account_2) { FactoryGirl.create :openstax_accounts_account,
12
+ let!(:account_2) { FactoryBot.create :openstax_accounts_account,
13
13
  first_name: 'Mary',
14
14
  last_name: 'Mighty',
15
15
  full_name: 'Mary Mighty',
16
16
  username: 'mary' }
17
- let!(:account_3) { FactoryGirl.create :openstax_accounts_account,
17
+ let!(:account_3) { FactoryBot.create :openstax_accounts_account,
18
18
  first_name: 'John',
19
19
  last_name: 'Stead',
20
20
  username: 'jstead' }
21
21
 
22
- let!(:account_4) { FactoryGirl.create :openstax_accounts_account,
22
+ let!(:account_4) { FactoryBot.create :openstax_accounts_account,
23
23
  first_name: 'Bob',
24
24
  last_name: 'JST',
25
25
  username: 'bigbear' }
26
26
 
27
27
  let!(:billy_accounts) {
28
28
  (0..49).to_a.collect{|ii|
29
- FactoryGirl.create :openstax_accounts_account,
29
+ FactoryBot.create :openstax_accounts_account,
30
30
  first_name: "Billy#{ii.to_s.rjust(2, '0')}",
31
31
  last_name: "Bob_#{(49-ii).to_s.rjust(2,'0')}",
32
32
  username: "billy_#{ii.to_s.rjust(2, '0')}"
@@ -5,28 +5,28 @@ module OpenStax
5
5
 
6
6
  describe Dev::AccountsSearch do
7
7
 
8
- let!(:account_1) { FactoryGirl.create :openstax_accounts_account,
8
+ let!(:account_1) { FactoryBot.create :openstax_accounts_account,
9
9
  first_name: 'John',
10
10
  last_name: 'Stravinsky',
11
11
  username: 'jstrav' }
12
- let!(:account_2) { FactoryGirl.create :openstax_accounts_account,
12
+ let!(:account_2) { FactoryBot.create :openstax_accounts_account,
13
13
  first_name: 'Mary',
14
14
  last_name: 'Mighty',
15
15
  full_name: 'Mary Mighty',
16
16
  username: 'mary' }
17
- let!(:account_3) { FactoryGirl.create :openstax_accounts_account,
17
+ let!(:account_3) { FactoryBot.create :openstax_accounts_account,
18
18
  first_name: 'John',
19
19
  last_name: 'Stead',
20
20
  username: 'jstead' }
21
21
 
22
- let!(:account_4) { FactoryGirl.create :openstax_accounts_account,
22
+ let!(:account_4) { FactoryBot.create :openstax_accounts_account,
23
23
  first_name: 'Bob',
24
24
  last_name: 'JST',
25
25
  username: 'bigbear' }
26
26
 
27
27
  let!(:billy_accounts) {
28
28
  (0..49).to_a.collect{|ii|
29
- FactoryGirl.create :openstax_accounts_account,
29
+ FactoryBot.create :openstax_accounts_account,
30
30
  first_name: "Billy#{ii.to_s.rjust(2, '0')}",
31
31
  last_name: "Bob_#{(49-ii).to_s.rjust(2,'0')}",
32
32
  username: "billy_#{ii.to_s.rjust(2, '0')}"
@@ -31,8 +31,9 @@ module OpenStax
31
31
 
32
32
  context "uuid" do
33
33
  it "sets the UUID on the account" do
34
- result = described_class.handle(request: mock_omniauth_request(uuid: "howdy_ho"))
35
- expect(result.outputs.account.uuid).to eq "howdy_ho"
34
+ uuid = SecureRandom.uuid
35
+ result = described_class.handle(request: mock_omniauth_request(uuid: uuid))
36
+ expect(result.outputs.account.uuid).to eq uuid
36
37
  end
37
38
  end
38
39
 
@@ -50,7 +51,8 @@ module OpenStax
50
51
 
51
52
  context "user exists" do
52
53
  it "updates the user's data" do
53
- existing_account = FactoryGirl.create :openstax_accounts_account
54
+ existing_account = FactoryBot.create :openstax_accounts_account
55
+ uuid = SecureRandom.uuid
54
56
  result = described_class.handle(
55
57
  request: mock_omniauth_request(
56
58
  uid: existing_account.openstax_uid,
@@ -59,7 +61,7 @@ module OpenStax
59
61
  title: "900",
60
62
  nickname: "191919",
61
63
  faculty_status: "confirmed_faculty",
62
- uuid: "yoyoma",
64
+ uuid: uuid,
63
65
  self_reported_role: "instructor")
64
66
  )
65
67
 
@@ -70,7 +72,7 @@ module OpenStax
70
72
  expect(account.title).to eq "900"
71
73
  expect(account.username).to eq "191919"
72
74
  expect(account).to be_confirmed_faculty
73
- expect(account.uuid).to eq "yoyoma"
75
+ expect(account.uuid).to eq uuid
74
76
  expect(account).to be_instructor
75
77
  end
76
78
  end
@@ -23,7 +23,7 @@ module OpenStax
23
23
 
24
24
  context 'users' do
25
25
  before(:each) { reset(::Api::UsersController) }
26
- let!(:account) { FactoryGirl.create :openstax_accounts_account }
26
+ let!(:account) { FactoryBot.create :openstax_accounts_account }
27
27
 
28
28
  it 'makes api call to users index' do
29
29
  Api.search_accounts('something')
@@ -89,8 +89,8 @@ module OpenStax
89
89
  context 'groups' do
90
90
  before(:each) { reset(::Api::GroupsController) }
91
91
 
92
- let!(:account) { FactoryGirl.create :openstax_accounts_account }
93
- let!(:group) { FactoryGirl.create :openstax_accounts_group }
92
+ let!(:account) { FactoryBot.create :openstax_accounts_account }
93
+ let!(:group) { FactoryBot.create :openstax_accounts_group }
94
94
 
95
95
  it 'makes api call to groups create' do
96
96
  Api.create_group(account, group)
@@ -121,8 +121,8 @@ module OpenStax
121
121
  context 'group_members' do
122
122
  before(:each) { reset(::Api::GroupMembersController) }
123
123
 
124
- let!(:account) { FactoryGirl.create :openstax_accounts_account }
125
- let!(:group_member) { FactoryGirl.build :openstax_accounts_group_member }
124
+ let!(:account) { FactoryBot.create :openstax_accounts_account }
125
+ let!(:group_member) { FactoryBot.build :openstax_accounts_group_member }
126
126
 
127
127
  it 'makes api call to group_members create' do
128
128
  Api.create_group_member(account, group_member)
@@ -145,8 +145,8 @@ module OpenStax
145
145
  context 'group_owners' do
146
146
  before(:each) { reset(::Api::GroupOwnersController) }
147
147
 
148
- let!(:account) { FactoryGirl.create :openstax_accounts_account }
149
- let!(:group_owner) { FactoryGirl.build :openstax_accounts_group_owner }
148
+ let!(:account) { FactoryBot.create :openstax_accounts_account }
149
+ let!(:group_owner) { FactoryBot.build :openstax_accounts_group_owner }
150
150
 
151
151
  it 'makes api call to group_owners create' do
152
152
  Api.create_group_owner(account, group_owner)
@@ -169,8 +169,8 @@ module OpenStax
169
169
  context 'group_nestings' do
170
170
  before(:each) { reset(::Api::GroupNestingsController) }
171
171
 
172
- let!(:account) { FactoryGirl.create :openstax_accounts_account }
173
- let!(:group_nesting) { FactoryGirl.build :openstax_accounts_group_nesting }
172
+ let!(:account) { FactoryBot.create :openstax_accounts_account }
173
+ let!(:group_nesting) { FactoryBot.build :openstax_accounts_group_nesting }
174
174
 
175
175
  it 'makes api call to group_nestings (create)' do
176
176
  Api.create_group_nesting(account, group_nesting)
@@ -1,7 +1,7 @@
1
1
  module OpenStax
2
2
  module Accounts
3
3
  describe CurrentUserManager do
4
- let!(:account) { FactoryGirl.create(:openstax_accounts_account,
4
+ let!(:account) { FactoryBot.create(:openstax_accounts_account,
5
5
  username: 'some_user',
6
6
  openstax_uid: 1) }
7
7
  let!(:user) { User.create(:account => account) }
@@ -3,17 +3,17 @@ module OpenStax
3
3
  module HasManyThroughGroups
4
4
  module ActiveRecord
5
5
  describe Base do
6
- let!(:account_1) { FactoryGirl.create(:openstax_accounts_account,
6
+ let!(:account_1) { FactoryBot.create(:openstax_accounts_account,
7
7
  username: 'some_user',
8
8
  openstax_uid: 1) }
9
9
  let!(:user_1) { User.create(:account => account_1) }
10
10
 
11
- let!(:account_2) { FactoryGirl.create(:openstax_accounts_account,
11
+ let!(:account_2) { FactoryBot.create(:openstax_accounts_account,
12
12
  username: 'another_user',
13
13
  openstax_uid: 2) }
14
14
  let!(:user_2) { User.create(:account => account_2) }
15
15
 
16
- let!(:group_nesting) { FactoryGirl.create(:openstax_accounts_group_nesting) }
16
+ let!(:group_nesting) { FactoryBot.create(:openstax_accounts_group_nesting) }
17
17
 
18
18
  before(:each) do
19
19
  group_nesting.member_group.add_member(account_1)
@@ -2,7 +2,7 @@ require 'spec_helper'
2
2
 
3
3
  module OpenStax::Accounts
4
4
  RSpec.describe Account do
5
- subject(:account) { FactoryGirl.create(:openstax_accounts_account) }
5
+ subject(:account) { FactoryBot.create(:openstax_accounts_account) }
6
6
 
7
7
  context 'validation' do
8
8
  it 'requires a unique openstax_uid, if given' do
@@ -12,7 +12,7 @@ module OpenStax::Accounts
12
12
  account.openstax_uid = -1
13
13
  account.save!
14
14
 
15
- account_2 = FactoryGirl.build(:openstax_accounts_account, openstax_uid: -1)
15
+ account_2 = FactoryBot.build(:openstax_accounts_account, openstax_uid: -1)
16
16
  expect(account_2).not_to be_valid
17
17
  expect(account_2.errors[:openstax_uid]).to eq(['has already been taken'])
18
18
  end
@@ -24,20 +24,20 @@ module OpenStax::Accounts
24
24
 
25
25
  it 'requires unique username if not nil' do
26
26
  expect{
27
- FactoryGirl.create(:openstax_accounts_account, username: account.username)
27
+ FactoryBot.create(:openstax_accounts_account, username: account.username)
28
28
  }.to raise_error(ActiveRecord::RecordInvalid)
29
29
  end
30
30
 
31
31
  it 'allows multiple accounts saved with nil username' do
32
- FactoryGirl.create(:openstax_accounts_account, username: nil)
32
+ FactoryBot.create(:openstax_accounts_account, username: nil)
33
33
  expect{
34
- FactoryGirl.create(:openstax_accounts_account, username: nil)
34
+ FactoryBot.create(:openstax_accounts_account, username: nil)
35
35
  }.not_to raise_error
36
36
  end
37
37
 
38
38
  it 'requires a role' do
39
39
  expect{
40
- FactoryGirl.create(:openstax_accounts_account, role: nil)
40
+ FactoryBot.create(:openstax_accounts_account, role: nil)
41
41
  }.to raise_error(ActiveRecord::RecordInvalid)
42
42
  end
43
43
  end
@@ -4,14 +4,14 @@ module OpenStax::Accounts
4
4
  describe Group do
5
5
  context 'validation' do
6
6
  it 'requires a unique openstax_uid' do
7
- group = FactoryGirl.build(:openstax_accounts_group, openstax_uid: nil)
7
+ group = FactoryBot.build(:openstax_accounts_group, openstax_uid: nil)
8
8
  expect(group).not_to be_valid
9
9
  expect(group.errors[:openstax_uid]).to eq(['can\'t be blank'])
10
10
 
11
11
  group.openstax_uid = 1
12
12
  group.save!
13
13
 
14
- group_2 = FactoryGirl.build(:openstax_accounts_group, openstax_uid: 1)
14
+ group_2 = FactoryBot.build(:openstax_accounts_group, openstax_uid: 1)
15
15
  expect(group_2).not_to be_valid
16
16
  expect(group_2.errors[:openstax_uid]).to eq(['has already been taken'])
17
17
  end
@@ -25,9 +25,9 @@ module OpenStax::Accounts
25
25
 
26
26
  after(:all) { OpenStax::Accounts.configuration.enable_stubbing = @stubbing }
27
27
 
28
- let!(:requestor) { FactoryGirl.create(:openstax_accounts_account) }
28
+ let!(:requestor) { FactoryBot.create(:openstax_accounts_account) }
29
29
  let!(:group) do
30
- FactoryGirl.build(:openstax_accounts_group).tap{ |group| group.requestor = requestor }
30
+ FactoryBot.build(:openstax_accounts_group).tap{ |group| group.requestor = requestor }
31
31
  end
32
32
 
33
33
  it 'calls OpenStax Accounts when created' do
@@ -10,7 +10,7 @@ module OpenStax
10
10
  OpenStax::Accounts.configuration.enable_stubbing = true
11
11
  end
12
12
 
13
- let!(:owner) { FactoryGirl.create :openstax_accounts_account }
13
+ let!(:owner) { FactoryBot.create :openstax_accounts_account }
14
14
 
15
15
  it 'can create groups' do
16
16
  group = CreateGroup[owner: owner, name: 'Test', is_public: true]
@@ -5,21 +5,21 @@ module OpenStax
5
5
 
6
6
  describe SearchAccounts, type: :routine do
7
7
 
8
- let!(:account_1) { FactoryGirl.create :openstax_accounts_account,
8
+ let!(:account_1) { FactoryBot.create :openstax_accounts_account,
9
9
  first_name: 'John',
10
10
  last_name: 'Stravinsky',
11
11
  username: 'jstrav' }
12
- let!(:account_2) { FactoryGirl.create :openstax_accounts_account,
12
+ let!(:account_2) { FactoryBot.create :openstax_accounts_account,
13
13
  first_name: 'Mary',
14
14
  last_name: 'Mighty',
15
15
  full_name: 'Mary Mighty',
16
16
  username: 'mary' }
17
- let!(:account_3) { FactoryGirl.create :openstax_accounts_account,
17
+ let!(:account_3) { FactoryBot.create :openstax_accounts_account,
18
18
  first_name: 'John',
19
19
  last_name: 'Stead',
20
20
  username: 'jstead' }
21
21
 
22
- let!(:account_4) { FactoryGirl.create :openstax_accounts_account,
22
+ let!(:account_4) { FactoryBot.create :openstax_accounts_account,
23
23
  first_name: 'Bob',
24
24
  last_name: 'JST',
25
25
  username: 'bigbear' }
@@ -78,7 +78,7 @@ module OpenStax
78
78
 
79
79
  let!(:billy_accounts) {
80
80
  (0..45).to_a.collect{|ii|
81
- FactoryGirl.create :openstax_accounts_account,
81
+ FactoryBot.create :openstax_accounts_account,
82
82
  first_name: "Billy#{ii.to_s.rjust(2, '0')}",
83
83
  last_name: "Bob_#{(45-ii).to_s.rjust(2,'0')}",
84
84
  username: "billy_#{ii.to_s.rjust(2, '0')}"
@@ -88,30 +88,30 @@ module OpenStax
88
88
  it "should return the first page of values by default when requested" do
89
89
  outcome = SearchAccounts.call("username:billy", per_page: 20).outputs.items
90
90
  expect(outcome.length).to eq 20
91
- expect(outcome[0]).to eq Account.where{username.eq "billy_00"}.first
92
- expect(outcome[19]).to eq Account.where{username.eq "billy_19"}.first
91
+ expect(outcome[0]).to eq Account.find_by!(username: "billy_00")
92
+ expect(outcome[19]).to eq Account.find_by!(username: "billy_19")
93
93
  end
94
94
 
95
95
  it "should return the second page when requested" do
96
96
  outcome = SearchAccounts.call("username:billy", page: 2, per_page: 20).outputs.items
97
97
  expect(outcome.length).to eq 20
98
- expect(outcome[0]).to eq Account.where{username.eq "billy_20"}.first
99
- expect(outcome[19]).to eq Account.where{username.eq "billy_39"}.first
98
+ expect(outcome[0]).to eq Account.find_by!(username: "billy_20")
99
+ expect(outcome[19]).to eq Account.find_by!(username: "billy_39")
100
100
  end
101
101
 
102
102
  it "should return the incomplete 3rd page when requested" do
103
103
  outcome = SearchAccounts.call("username:billy", page: 3, per_page: 20).outputs.items
104
104
  expect(outcome.length).to eq 6
105
- expect(outcome[5]).to eq Account.where{username.eq "billy_45"}.first
105
+ expect(outcome[5]).to eq Account.find_by!(username: "billy_45")
106
106
  end
107
107
 
108
108
  end
109
109
 
110
110
  context "sorting" do
111
111
 
112
- let!(:bob_brown) { FactoryGirl.create :openstax_accounts_account, first_name: "Bob", last_name: "Brown", username: "foo_bb" }
113
- let!(:bob_jones) { FactoryGirl.create :openstax_accounts_account, first_name: "Bob", last_name: "Jones", username: "foo_bj" }
114
- let!(:tim_jones) { FactoryGirl.create :openstax_accounts_account, first_name: "Tim", last_name: "Jones", username: "foo_tj" }
112
+ let!(:bob_brown) { FactoryBot.create :openstax_accounts_account, first_name: "Bob", last_name: "Brown", username: "foo_bb" }
113
+ let!(:bob_jones) { FactoryBot.create :openstax_accounts_account, first_name: "Bob", last_name: "Jones", username: "foo_bj" }
114
+ let!(:tim_jones) { FactoryBot.create :openstax_accounts_account, first_name: "Tim", last_name: "Jones", username: "foo_tj" }
115
115
 
116
116
  it "should allow sort by multiple fields in different directions" do
117
117
  outcome = SearchAccounts.call("username:foo", order_by: "first_name, last_name DESC").outputs.items
@@ -7,14 +7,33 @@ module OpenStax
7
7
 
8
8
  it 'can sync accounts' do
9
9
  controller_class = ::Api::ApplicationUsersController
10
+ uuid = SecureRandom.uuid
10
11
  allow_any_instance_of(controller_class).to(
11
12
  receive(:updates) do |controller|
12
- controller.render :json => [{id: 1, application_id: 1,
13
- user: {id: 2, username: 'user', self_reported_role: 'instructor', uuid: 'booyah'},
14
- unread_updates: 1, default_contact_info_id: 1},
15
- {id: 3, application_id: 1,
16
- user: {id: 4, username: 'fuego'},
17
- unread_updates: 2, default_contact_info_id: 5}]
13
+ controller.render json: [
14
+ {
15
+ id: 1,
16
+ application_id: 1,
17
+ user: {
18
+ id: 2,
19
+ username: 'user',
20
+ self_reported_role: 'instructor',
21
+ uuid: uuid
22
+ },
23
+ unread_updates: 1,
24
+ default_contact_info_id: 1
25
+ },
26
+ {
27
+ id: 3,
28
+ application_id: 1,
29
+ user: {
30
+ id: 4,
31
+ username: 'fuego'
32
+ },
33
+ unread_updates: 2,
34
+ default_contact_info_id: 5
35
+ }
36
+ ]
18
37
  end
19
38
  )
20
39
 
@@ -37,7 +56,7 @@ module OpenStax
37
56
  expect(Account.first.openstax_uid).to eq 2
38
57
  expect(Account.first.username).to eq 'user'
39
58
  expect(Account.first.role).to eq 'instructor'
40
- expect(Account.first.uuid).to eq 'booyah'
59
+ expect(Account.first.uuid).to eq uuid
41
60
  expect(Account.last.openstax_uid).to eq 4
42
61
  expect(Account.last.username).to eq 'fuego'
43
62
 
@@ -9,20 +9,57 @@ module OpenStax
9
9
  controller_class = ::Api::ApplicationGroupsController
10
10
  allow_any_instance_of(controller_class).to(
11
11
  receive(:updates) do |controller|
12
- controller.render :json => [{id: 1, application_id: 1,
13
- group: {id: 2, name: 'M', members: [], owners: [],
14
- nestings: [{container_group_id: 2,
15
- member_group_id: 3}]},
16
- unread_updates: 1, default_contact_info_id: 1},
17
- {id: 3, application_id: 1,
18
- group: {id: 3, name: 'Fuego\'s Deputies',
19
- members: [{group_id: 3,
20
- user: {id: 2, username: 'User'}}],
21
- owners: [{group_id: 3,
22
- user: {id: 3, username: 'Fuego'}}],
23
- nestings: []},
24
- unread_updates: 2, default_contact_info_id: 5}]
25
- end)
12
+ controller.render json: [
13
+ {
14
+ id: 1,
15
+ application_id: 1,
16
+ group: {
17
+ id: 2,
18
+ name: 'M',
19
+ members: [],
20
+ owners: [],
21
+ nestings: [
22
+ {
23
+ container_group_id: 2,
24
+ member_group_id: 3
25
+ }
26
+ ]
27
+ },
28
+ unread_updates: 1,
29
+ default_contact_info_id: 1
30
+ },
31
+ {
32
+ id: 3,
33
+ application_id: 1,
34
+ group: {
35
+ id: 3,
36
+ name: 'Fuego\'s Deputies',
37
+ members: [
38
+ {
39
+ group_id: 3,
40
+ user: {
41
+ id: 2,
42
+ username: 'User'
43
+ }
44
+ }
45
+ ],
46
+ owners: [
47
+ {
48
+ group_id: 3,
49
+ user: {
50
+ id: 3,
51
+ username: 'Fuego'
52
+ }
53
+ }
54
+ ],
55
+ nestings: []
56
+ },
57
+ unread_updates: 2,
58
+ default_contact_info_id: 5
59
+ }
60
+ ]
61
+ end
62
+ )
26
63
 
27
64
  u = OpenStax::Accounts::Account.new
28
65
  u.openstax_uid = 2