openstax_salesforce 3.1.0 → 4.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.
Files changed (75) 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 +9 -38
  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/remote/campaign.rb +0 -2
  10. data/lib/openstax/salesforce/remote/campaign_member.rb +0 -1
  11. data/lib/openstax/salesforce/remote/opportunity.rb +0 -2
  12. data/lib/openstax/salesforce/remote/term_year.rb +0 -2
  13. data/lib/openstax/salesforce/remote/tutor_course_period.rb +0 -2
  14. data/lib/openstax/salesforce/spec_helpers.rb +119 -26
  15. data/lib/openstax/salesforce/version.rb +1 -1
  16. data/lib/openstax_salesforce.rb +13 -29
  17. data/lib/tasks/openstax_salesforce_tasks.rake +1 -26
  18. metadata +6 -179
  19. data/app/controllers/openstax/salesforce/application_controller.rb +0 -7
  20. data/app/controllers/openstax/salesforce/settings_controller.rb +0 -20
  21. data/app/helpers/openstax/salesforce/application_helper.rb +0 -11
  22. data/app/models/openstax/salesforce/user.rb +0 -31
  23. data/app/views/openstax/salesforce/settings/show.html.erb +0 -33
  24. data/config/initializers/omniauth.rb +0 -8
  25. data/config/routes.rb +0 -11
  26. data/lib/openstax/salesforce/spec_helpers/salesforce_proxy.rb +0 -121
  27. data/lib/openstax/salesforce/user_missing.rb +0 -3
  28. data/spec/client_spec.rb +0 -10
  29. data/spec/dummy/README.md +0 -28
  30. data/spec/dummy/Rakefile +0 -6
  31. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  32. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  33. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  34. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  35. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  36. data/spec/dummy/bin/bundle +0 -3
  37. data/spec/dummy/bin/rails +0 -4
  38. data/spec/dummy/bin/rake +0 -4
  39. data/spec/dummy/bin/setup +0 -29
  40. data/spec/dummy/config/application.rb +0 -25
  41. data/spec/dummy/config/boot.rb +0 -5
  42. data/spec/dummy/config/database.yml +0 -25
  43. data/spec/dummy/config/environment.rb +0 -5
  44. data/spec/dummy/config/environments/development.rb +0 -41
  45. data/spec/dummy/config/environments/production.rb +0 -79
  46. data/spec/dummy/config/environments/test.rb +0 -42
  47. data/spec/dummy/config/initializers/assets.rb +0 -11
  48. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  49. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  50. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  51. data/spec/dummy/config/initializers/inflections.rb +0 -16
  52. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  53. data/spec/dummy/config/initializers/session_store.rb +0 -3
  54. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  55. data/spec/dummy/config/locales/en.yml +0 -23
  56. data/spec/dummy/config/routes.rb +0 -4
  57. data/spec/dummy/config/secrets.yml +0 -22
  58. data/spec/dummy/config.ru +0 -4
  59. data/spec/dummy/db/schema.rb +0 -25
  60. data/spec/dummy/db/test.sqlite3 +0 -0
  61. data/spec/dummy/log/test.log +0 -2673
  62. data/spec/dummy/public/404.html +0 -67
  63. data/spec/dummy/public/422.html +0 -67
  64. data/spec/dummy/public/500.html +0 -66
  65. data/spec/dummy/public/favicon.ico +0 -0
  66. data/spec/factories/user.rb +0 -17
  67. data/spec/openstax/salesforce/controllers/application_controller_spec.rb +0 -22
  68. data/spec/openstax/salesforce/controllers/settings_controller_spec.rb +0 -80
  69. data/spec/openstax/salesforce/remote/opportunity_spec.rb +0 -11
  70. data/spec/openstax/salesforce/remote/term_year_spec.rb +0 -81
  71. data/spec/openstax/salesforce/remote/tutor_course_period_spec.rb +0 -30
  72. data/spec/openstax/salesforce/spec_helpers_spec.rb +0 -31
  73. data/spec/rails_helper.rb +0 -99
  74. data/spec/routing_spec.rb +0 -9
  75. 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
@@ -1,31 +0,0 @@
1
- require 'rails_helper'
2
- require 'openstax/salesforce/spec_helpers'
3
-
4
- include OpenStax::Salesforce::SpecHelpers
5
-
6
- RSpec.describe OpenStax::Salesforce::SpecHelpers do
7
-
8
- context '#limit_salesforce_queries' do
9
- it 'limits by one wildcard' do
10
- limit_salesforce_queries(OpenStax::Salesforce::Remote::Contact, email: "%foo.com")
11
- expect(OpenStax::Salesforce::Remote::Contact.select(:id).to_s).to eq(
12
- "SELECT Id FROM Contact WHERE (Email LIKE '%foo.com')"
13
- )
14
- end
15
-
16
- it 'limit by multiple wildcards' do
17
- limit_salesforce_queries(OpenStax::Salesforce::Remote::Contact, email: "%foo.com", first_name: 'JP%')
18
- expect(OpenStax::Salesforce::Remote::Contact.select(:id).to_s).to eq(
19
- "SELECT Id FROM Contact WHERE (Email LIKE '%foo.com') AND (FirstName LIKE 'JP%')"
20
- )
21
- end
22
-
23
- it 'limits by wildcard and another condition' do
24
- limit_salesforce_queries(OpenStax::Salesforce::Remote::Contact, email: "%foo.com", first_name: 'Bob')
25
- expect(OpenStax::Salesforce::Remote::Contact.select(:id).to_s).to eq(
26
- "SELECT Id FROM Contact WHERE (Email LIKE '%foo.com') AND (FirstName = 'Bob')"
27
- )
28
- end
29
- end
30
-
31
- end
data/spec/rails_helper.rb DELETED
@@ -1,99 +0,0 @@
1
- ENV["RAILS_ENV"] ||= 'test'
2
-
3
- require 'spec_helper'
4
- require File.expand_path("../dummy/config/environment", __FILE__)
5
- require 'rspec/rails'
6
- require 'factory_bot_rails'
7
- require 'faker'
8
- require 'byebug'
9
- require 'database_cleaner'
10
-
11
- # Add additional requires below this line. Rails is not loaded until this point!
12
-
13
- # Requires supporting ruby files with custom matchers and macros, etc, in
14
- # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
15
- # run as spec files by default. This means that files in spec/support that end
16
- # in _spec.rb will both be required and run as specs, causing the specs to be
17
- # run twice. It is recommended that you do not name files matching this glob to
18
- # end with _spec.rb. You can configure this pattern with the --pattern
19
- # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
20
- #
21
- # The following line is provided for convenience purposes. It has the downside
22
- # of increasing the boot-up time by auto-requiring all files in the support
23
- # directory. Alternatively, in the individual `*_spec.rb` files, manually
24
- # require only the support files necessary.
25
- #
26
- # Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f }
27
-
28
- # Checks for pending migrations before tests are run.
29
- # If you are not using ActiveRecord, you can remove this line.
30
- ActiveRecord::Migration.maintain_test_schema!
31
-
32
- RSpec.configure do |config|
33
- # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
34
- # config.fixture_path = "#{::Rails.root}/spec/fixtures"
35
-
36
- # If you're not using ActiveRecord, or you'd prefer not to run each of your
37
- # examples within a transaction, remove the following line or assign false
38
- # instead of true.
39
- config.use_transactional_fixtures = false
40
-
41
- # RSpec Rails can automatically mix in different behaviours to your tests
42
- # based on their file location, for example enabling you to call `get` and
43
- # `post` in specs under `spec/controllers`.
44
- #
45
- # You can disable this behaviour by removing the line below, and instead
46
- # explicitly tag your specs with their type, e.g.:
47
- #
48
- # RSpec.describe UsersController, :type => :controller do
49
- # # ...
50
- # end
51
- #
52
- # The different available types are documented in the features, such as in
53
- # https://relishapp.com/rspec/rspec-rails/docs
54
- config.infer_spec_type_from_file_location!
55
-
56
- # Use DatabaseCleaner instead of rspec transaction rollbacks
57
- # http://tomdallimore.com/blog/taking-the-test-trash-out-with-databasecleaner-and-rspec/
58
-
59
- config.prepend_before(:suite) do
60
- DatabaseCleaner.clean_with(:truncation)
61
- end
62
-
63
- config.prepend_before(:all) do
64
- DatabaseCleaner.start
65
- end
66
-
67
- config.prepend_before(:all, js: true) do
68
- DatabaseCleaner.strategy = :truncation
69
- end
70
-
71
- config.prepend_before(:all, truncation: true) do
72
- DatabaseCleaner.strategy = :truncation
73
- end
74
-
75
- config.prepend_before(:all) do
76
- DatabaseCleaner.strategy = :transaction
77
- end
78
-
79
- config.prepend_before(:each) do
80
- DatabaseCleaner.start
81
- end
82
-
83
- # https://github.com/DatabaseCleaner/database_cleaner#rspec-with-capybara-example says:
84
- # "It's also recommended to use append_after to ensure DatabaseCleaner.clean
85
- # runs after the after-test cleanup capybara/rspec installs."
86
- config.append_after(:each) do
87
- DatabaseCleaner.clean
88
- end
89
-
90
- config.append_after(:all) do
91
- DatabaseCleaner.clean
92
- end
93
- end
94
-
95
- def mock_admin_user
96
- allow(OpenStax::Salesforce.configuration).to receive(:authenticate_admin_proc) {
97
- ->(controller) { return true }
98
- }
99
- end
data/spec/routing_spec.rb DELETED
@@ -1,9 +0,0 @@
1
- require "rails_helper"
2
-
3
- RSpec.describe 'Engine routes', type: :routing do
4
- describe "/auth/salesforce/callback" do
5
- it "routes to #callback" do
6
- expect(get '/auth/salesforce/callback').to route_to('openstax/salesforce/settings#callback')
7
- end
8
- end
9
- end
data/spec/spec_helper.rb DELETED
@@ -1,86 +0,0 @@
1
- require 'rspec/core'
2
- # This file was generated by the `rails generate rspec:install` command. Conventionally, all
3
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
4
- # The generated `.rspec` file contains `--require spec_helper` which will cause this
5
- # file to always be loaded, without a need to explicitly require it in any files.
6
- #
7
- # Given that it is always loaded, you are encouraged to keep this file as
8
- # light-weight as possible. Requiring heavyweight dependencies from this file
9
- # will add to the boot time of your test suite on EVERY test run, even for an
10
- # individual file that may not need all of that loaded. Instead, consider making
11
- # a separate helper file that requires the additional dependencies and performs
12
- # the additional setup, and require it from the spec files that actually need it.
13
- #
14
- # The `.rspec` file also contains a few flags that are not defaults but that
15
- # users commonly want.
16
- #
17
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
- RSpec.configure do |config|
19
- # rspec-expectations config goes here. You can use an alternate
20
- # assertion/expectation library such as wrong or the stdlib/minitest
21
- # assertions if you prefer.
22
- config.expect_with :rspec do |expectations|
23
- # This option will default to `true` in RSpec 4. It makes the `description`
24
- # and `failure_message` of custom matchers include text for helper methods
25
- # defined using `chain`, e.g.:
26
- # be_bigger_than(2).and_smaller_than(4).description
27
- # # => "be bigger than 2 and smaller than 4"
28
- # ...rather than:
29
- # # => "be bigger than 2"
30
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
- end
32
-
33
- # rspec-mocks config goes here. You can use an alternate test double
34
- # library (such as bogus or mocha) by changing the `mock_with` option here.
35
- config.mock_with :rspec do |mocks|
36
- # Prevents you from mocking or stubbing a method that does not exist on
37
- # a real object. This is generally recommended, and will default to
38
- # `true` in RSpec 4.
39
- mocks.verify_partial_doubles = true
40
- end
41
-
42
- # The settings below are suggested to provide a good initial experience
43
- # with RSpec, but feel free to customize to your heart's content.
44
- =begin
45
- # These two settings work together to allow you to limit a spec run
46
- # to individual examples or groups you care about by tagging them with
47
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
48
- # get run.
49
- config.filter_run :focus
50
- config.run_all_when_everything_filtered = true
51
-
52
- # Limits the available syntax to the non-monkey patched syntax that is recommended.
53
- # For more details, see:
54
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
55
- # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
56
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
57
- config.disable_monkey_patching!
58
-
59
- # Many RSpec users commonly either run the entire suite or an individual
60
- # file, and it's useful to allow more verbose output when running an
61
- # individual spec file.
62
- if config.files_to_run.one?
63
- # Use the documentation formatter for detailed output,
64
- # unless a formatter has already been configured
65
- # (e.g. via a command-line flag).
66
- config.default_formatter = 'doc'
67
- end
68
-
69
- # Print the 10 slowest examples and example groups at the
70
- # end of the spec run, to help surface which specs are running
71
- # particularly slow.
72
- config.profile_examples = 10
73
-
74
- # Run specs in random order to surface order dependencies. If you find an
75
- # order dependency and want to debug it, you can fix the order by providing
76
- # the seed, which is printed after each run.
77
- # --seed 1234
78
- config.order = :random
79
-
80
- # Seed global randomization in this process using the `--seed` CLI option.
81
- # Setting this allows you to use `--seed` to deterministically reproduce
82
- # test failures related to randomization by passing the same `--seed` value
83
- # as the one that triggered the failure.
84
- Kernel.srand config.seed
85
- =end
86
- end