openstax_salesforce 3.0.0 → 4.2.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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +17 -46
  3. data/Rakefile +2 -5
  4. data/config/initializers/openstax_salesforce.rb +11 -36
  5. data/db/migrate/0_install_openstax_salesforce.rb +1 -0
  6. data/db/migrate/1_drop_openstax_salesforce_users.rb +14 -0
  7. data/lib/openstax/salesforce/active_force.rb +0 -4
  8. data/lib/openstax/salesforce/client.rb +11 -17
  9. data/lib/openstax/salesforce/engine.rb +5 -3
  10. data/lib/openstax/salesforce/remote/campaign.rb +0 -2
  11. data/lib/openstax/salesforce/remote/campaign_member.rb +0 -1
  12. data/lib/openstax/salesforce/remote/contact.rb +1 -0
  13. data/lib/openstax/salesforce/remote/opportunity.rb +0 -2
  14. data/lib/openstax/salesforce/remote/school.rb +5 -1
  15. data/lib/openstax/salesforce/remote/term_year.rb +0 -2
  16. data/lib/openstax/salesforce/remote/tutor_course_period.rb +0 -2
  17. data/lib/openstax/salesforce/spec_helpers.rb +142 -26
  18. data/lib/openstax/salesforce/version.rb +1 -1
  19. data/lib/openstax_salesforce.rb +13 -29
  20. data/lib/tasks/openstax_salesforce_tasks.rake +1 -26
  21. metadata +16 -179
  22. data/app/controllers/openstax/salesforce/application_controller.rb +0 -7
  23. data/app/controllers/openstax/salesforce/settings_controller.rb +0 -20
  24. data/app/helpers/openstax/salesforce/application_helper.rb +0 -11
  25. data/app/models/openstax/salesforce/user.rb +0 -31
  26. data/app/views/openstax/salesforce/settings/show.html.erb +0 -33
  27. data/config/initializers/omniauth.rb +0 -8
  28. data/config/routes.rb +0 -11
  29. data/lib/openstax/salesforce/spec_helpers/salesforce_proxy.rb +0 -121
  30. data/lib/openstax/salesforce/user_missing.rb +0 -3
  31. data/spec/client_spec.rb +0 -10
  32. data/spec/dummy/README.md +0 -28
  33. data/spec/dummy/Rakefile +0 -6
  34. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  35. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  36. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  37. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  38. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  39. data/spec/dummy/bin/bundle +0 -3
  40. data/spec/dummy/bin/rails +0 -4
  41. data/spec/dummy/bin/rake +0 -4
  42. data/spec/dummy/bin/setup +0 -29
  43. data/spec/dummy/config.ru +0 -4
  44. data/spec/dummy/config/application.rb +0 -25
  45. data/spec/dummy/config/boot.rb +0 -5
  46. data/spec/dummy/config/database.yml +0 -25
  47. data/spec/dummy/config/environment.rb +0 -5
  48. data/spec/dummy/config/environments/development.rb +0 -41
  49. data/spec/dummy/config/environments/production.rb +0 -79
  50. data/spec/dummy/config/environments/test.rb +0 -42
  51. data/spec/dummy/config/initializers/assets.rb +0 -11
  52. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  53. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  54. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  55. data/spec/dummy/config/initializers/inflections.rb +0 -16
  56. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  57. data/spec/dummy/config/initializers/session_store.rb +0 -3
  58. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  59. data/spec/dummy/config/locales/en.yml +0 -23
  60. data/spec/dummy/config/routes.rb +0 -4
  61. data/spec/dummy/config/secrets.yml +0 -22
  62. data/spec/dummy/db/development.sqlite3 +0 -0
  63. data/spec/dummy/db/schema.rb +0 -25
  64. data/spec/dummy/db/test.sqlite3 +0 -0
  65. data/spec/dummy/log/development.log +0 -15
  66. data/spec/dummy/log/test.log +0 -1915
  67. data/spec/dummy/public/404.html +0 -67
  68. data/spec/dummy/public/422.html +0 -67
  69. data/spec/dummy/public/500.html +0 -66
  70. data/spec/dummy/public/favicon.ico +0 -0
  71. data/spec/factories/user.rb +0 -17
  72. data/spec/openstax/salesforce/controllers/application_controller_spec.rb +0 -22
  73. data/spec/openstax/salesforce/controllers/settings_controller_spec.rb +0 -80
  74. data/spec/openstax/salesforce/remote/opportunity_spec.rb +0 -11
  75. data/spec/openstax/salesforce/remote/term_year_spec.rb +0 -81
  76. data/spec/openstax/salesforce/remote/tutor_course_period_spec.rb +0 -30
  77. data/spec/openstax/salesforce/spec_helpers_spec.rb +0 -31
  78. data/spec/rails_helper.rb +0 -99
  79. data/spec/routing_spec.rb +0 -9
  80. data/spec/spec_helper.rb +0 -86
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/404.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The page you were looking for doesn't exist.</h1>
62
- <p>You may have mistyped the address or the page may have moved.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,67 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/422.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>The change you wanted was rejected.</h1>
62
- <p>Maybe you tried to change something you didn't have access to.</p>
63
- </div>
64
- <p>If you are the application owner check the logs for more information.</p>
65
- </div>
66
- </body>
67
- </html>
@@ -1,66 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
- <style>
7
- body {
8
- background-color: #EFEFEF;
9
- color: #2E2F30;
10
- text-align: center;
11
- font-family: arial, sans-serif;
12
- margin: 0;
13
- }
14
-
15
- div.dialog {
16
- width: 95%;
17
- max-width: 33em;
18
- margin: 4em auto 0;
19
- }
20
-
21
- div.dialog > div {
22
- border: 1px solid #CCC;
23
- border-right-color: #999;
24
- border-left-color: #999;
25
- border-bottom-color: #BBB;
26
- border-top: #B00100 solid 4px;
27
- border-top-left-radius: 9px;
28
- border-top-right-radius: 9px;
29
- background-color: white;
30
- padding: 7px 12% 0;
31
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
- }
33
-
34
- h1 {
35
- font-size: 100%;
36
- color: #730E15;
37
- line-height: 1.5em;
38
- }
39
-
40
- div.dialog > p {
41
- margin: 0 0 1em;
42
- padding: 1em;
43
- background-color: #F7F7F7;
44
- border: 1px solid #CCC;
45
- border-right-color: #999;
46
- border-left-color: #999;
47
- border-bottom-color: #999;
48
- border-bottom-left-radius: 4px;
49
- border-bottom-right-radius: 4px;
50
- border-top-color: #DADADA;
51
- color: #666;
52
- box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
- }
54
- </style>
55
- </head>
56
-
57
- <body>
58
- <!-- This file lives in public/500.html -->
59
- <div class="dialog">
60
- <div>
61
- <h1>We're sorry, but something went wrong.</h1>
62
- </div>
63
- <p>If you are the application owner check the logs for more information.</p>
64
- </div>
65
- </body>
66
- </html>
File without changes
@@ -1,17 +0,0 @@
1
- FactoryBot.define do
2
- factory :user, class: 'OpenStax::Salesforce::User' do
3
- uid { SecureRandom.hex(10) }
4
- name { Faker::Name.name }
5
- oauth_token { SecureRandom.hex }
6
- refresh_token { SecureRandom.hex }
7
- instance_url { Faker::Internet.url }
8
-
9
- transient do
10
- do_not_destroy_others { false }
11
- end
12
-
13
- after(:build) do |user, evaluator|
14
- user.define_singleton_method(:ensure_only_one_record) {} if evaluator.do_not_destroy_others
15
- end
16
- end
17
- end
@@ -1,22 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe OpenStax::Salesforce::ApplicationController, type: :controller do
4
-
5
- controller do
6
- def index
7
- render plain: "Yo"
8
- end
9
- end
10
-
11
- it 'has forbidden status by default' do
12
- get :index
13
- expect(response).to have_http_status(:forbidden)
14
- end
15
-
16
- it 'can have its admin check overridden' do
17
- mock_admin_user
18
- get :index
19
- expect(response).to have_http_status(:ok)
20
- end
21
-
22
- end
@@ -1,80 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe OpenStax::Salesforce::SettingsController, type: :controller do
4
-
5
- context 'as admin' do
6
- before(:each) { mock_admin_user }
7
-
8
- context '#callback' do
9
- context 'when there is not yet a SF user' do
10
- it 'adds a user' do
11
- allow(request).to receive(:env).and_return(omniauth_env_hash)
12
-
13
- expect{post :callback}.to change {OpenStax::Salesforce::User.count}.by(1)
14
- end
15
- end
16
-
17
- context 'when there are other SF users' do
18
- it 'adds a user and removes existing users' do
19
- other_user_1 = FactoryBot.create(:user, do_not_destroy_others: true)
20
- other_user_2 = FactoryBot.create(:user, do_not_destroy_others: true)
21
-
22
- allow(request).to receive(:env).and_return(omniauth_env_hash)
23
-
24
- expect{post :callback}.to change {OpenStax::Salesforce::User.count}.by(-1)
25
-
26
- expect(OpenStax::Salesforce::User.all.map(&:id)).not_to contain_exactly(other_user_1.id, other_user_2.id)
27
- end
28
- end
29
-
30
- context 'when a user with the same uid already exists' do
31
- it 'reuses that user' do
32
- a_user_1 = FactoryBot.create(:user, uid: 'someuid')
33
-
34
- allow(request).to receive(:env).and_return(omniauth_env_hash)
35
-
36
- post :callback
37
-
38
- expect(a_user_1.reload.name).to eq "Bobby Thomas"
39
- end
40
- end
41
- end
42
-
43
- context '#destroy_user' do
44
- # https://content.pivotal.io/blog/writing-rails-engine-rspec-controller-tests
45
- # not needed elsewhere since we do other things to make them top-level routes
46
- routes { OpenStax::Salesforce::Engine.routes }
47
-
48
- it 'destroys users' do
49
- FactoryBot.create(:user)
50
- expect{delete :destroy_user}.to change {OpenStax::Salesforce::User.count}.by(-1)
51
- end
52
- end
53
-
54
- end
55
-
56
- context 'as non-admin' do
57
- routes { OpenStax::Salesforce::Engine.routes }
58
-
59
- it 'has forbidden status' do
60
- get :show
61
- expect(response).to have_http_status(:forbidden)
62
- end
63
- end
64
-
65
- def omniauth_env_hash
66
- {
67
- "omniauth.auth" => Hashie::Mash.new({
68
- uid: 'someuid',
69
- info: {
70
- name: 'Bobby Thomas',
71
- },
72
- credentials: {
73
- token: 'oauth_token',
74
- refresh_token: 'refresh_token',
75
- instance_url: 'http://blah.com/'
76
- }
77
- })
78
- }
79
- end
80
- end
@@ -1,11 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe OpenStax::Salesforce::Remote::Opportunity do
4
-
5
- subject(:opportunity) { described_class.new(term_year: '2016 - 17 Fall') }
6
-
7
- it 'returns a TermYear object' do
8
- expect(opportunity.term_year_object).to be_a OpenStax::Salesforce::Remote::TermYear
9
- end
10
-
11
- end
@@ -1,81 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe OpenStax::Salesforce::Remote::TermYear do
4
-
5
- context "#from_string" do
6
- it "works for Fall" do
7
- term_year = described_class.from_string("2015 - 16 Fall")
8
-
9
- expect(term_year.start_year).to eq 2015
10
- expect(term_year.end_year).to eq 2016
11
- expect(term_year).to be_fall
12
- expect(term_year).not_to be_spring
13
- end
14
-
15
- it "works for Spring" do
16
- term_year = described_class.from_string("2015 - 16 Spring")
17
-
18
- expect(term_year.start_year).to eq 2015
19
- expect(term_year.end_year).to eq 2016
20
- expect(term_year).not_to be_fall
21
- expect(term_year).to be_spring
22
- end
23
-
24
- it "works for nil" do
25
- term_year = described_class.from_string(nil)
26
-
27
- expect(term_year).to be_nil
28
- end
29
-
30
- it "freaks out for bad years" do
31
- expect{
32
- described_class.from_string("2015 - 17 Fall")
33
- }.to raise_error(StandardError)
34
- end
35
-
36
- it "freaks out for bad formats" do
37
- expect{
38
- described_class.from_string("fix formula 2016")
39
- }.to raise_error(described_class::ParseError)
40
- end
41
- end
42
-
43
- context "#initialize" do
44
- it "freaks out for bad terms" do
45
- expect{
46
- described_class.new(start_year: 2015, term: :blah)
47
- }.to raise_error(StandardError)
48
- end
49
- end
50
-
51
- context "#next" do
52
- it "moves from fall to spring" do
53
- expect(described_class.from_string("2015 - 16 Fall").next.to_s).to eq "2015 - 16 Spring"
54
- end
55
-
56
- it "moves from spring to fall" do
57
- expect(described_class.from_string("2015 - 16 Spring").next.to_s).to eq "2016 - 17 Fall"
58
- end
59
- end
60
-
61
- context "#guess_from_created_at" do
62
- it "guess early part of year into spring" do
63
- expect(
64
- described_class.guess_from_created_at(Time.zone.local(2016,2)).to_s
65
- ).to eq "2015 - 16 Spring"
66
- end
67
-
68
- it "guesses summerish into fall" do
69
- expect(
70
- described_class.guess_from_created_at(Time.zone.local(2016,5)).to_s
71
- ).to eq "2016 - 17 Fall"
72
- end
73
-
74
- it "guesses late fall into next spring" do
75
- expect(
76
- described_class.guess_from_created_at(Time.zone.local(2016,12)).to_s
77
- ).to eq "2016 - 17 Spring"
78
- end
79
- end
80
-
81
- end
@@ -1,30 +0,0 @@
1
- require 'rails_helper'
2
-
3
- RSpec.describe OpenStax::Salesforce::Remote::TutorCoursePeriod do
4
-
5
- subject { described_class.new }
6
-
7
- it 'can reset stats' do
8
- subject.num_periods = 1
9
- subject.num_students = 8
10
- subject.num_students_comped = 7
11
- subject.num_students_dropped = 6
12
- subject.num_students_paid = 5
13
- subject.num_students_refunded = 4
14
- subject.num_students_with_work = 3
15
- subject.num_teachers = 2
16
-
17
- subject.reset_stats
18
-
19
- expect(subject.num_periods).to eq 0
20
- expect(subject.num_students).to eq 0
21
- expect(subject.num_students_comped).to eq 0
22
- expect(subject.num_students_dropped).to eq 0
23
- expect(subject.num_students_paid).to eq 0
24
- expect(subject.num_students_refunded).to eq 0
25
- expect(subject.num_students_paid).to eq 0
26
- expect(subject.num_students_with_work).to eq 0
27
- expect(subject.num_teachers).to eq 0
28
- end
29
-
30
- end