openstax_salesforce 3.1.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) 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/opportunity.rb +0 -2
  13. data/lib/openstax/salesforce/remote/school.rb +5 -1
  14. data/lib/openstax/salesforce/remote/term_year.rb +0 -2
  15. data/lib/openstax/salesforce/remote/tutor_course_period.rb +0 -2
  16. data/lib/openstax/salesforce/spec_helpers.rb +142 -26
  17. data/lib/openstax/salesforce/version.rb +1 -1
  18. data/lib/openstax_salesforce.rb +13 -29
  19. data/lib/tasks/openstax_salesforce_tasks.rake +1 -26
  20. metadata +15 -182
  21. data/app/controllers/openstax/salesforce/application_controller.rb +0 -7
  22. data/app/controllers/openstax/salesforce/settings_controller.rb +0 -20
  23. data/app/helpers/openstax/salesforce/application_helper.rb +0 -11
  24. data/app/models/openstax/salesforce/user.rb +0 -31
  25. data/app/views/openstax/salesforce/settings/show.html.erb +0 -33
  26. data/config/initializers/omniauth.rb +0 -8
  27. data/config/routes.rb +0 -11
  28. data/lib/openstax/salesforce/spec_helpers/salesforce_proxy.rb +0 -121
  29. data/lib/openstax/salesforce/user_missing.rb +0 -3
  30. data/spec/client_spec.rb +0 -10
  31. data/spec/dummy/README.md +0 -28
  32. data/spec/dummy/Rakefile +0 -6
  33. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  34. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  35. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  36. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  37. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  38. data/spec/dummy/bin/bundle +0 -3
  39. data/spec/dummy/bin/rails +0 -4
  40. data/spec/dummy/bin/rake +0 -4
  41. data/spec/dummy/bin/setup +0 -29
  42. data/spec/dummy/config.ru +0 -4
  43. data/spec/dummy/config/application.rb +0 -25
  44. data/spec/dummy/config/boot.rb +0 -5
  45. data/spec/dummy/config/database.yml +0 -25
  46. data/spec/dummy/config/environment.rb +0 -5
  47. data/spec/dummy/config/environments/development.rb +0 -41
  48. data/spec/dummy/config/environments/production.rb +0 -79
  49. data/spec/dummy/config/environments/test.rb +0 -42
  50. data/spec/dummy/config/initializers/assets.rb +0 -11
  51. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  52. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
  53. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  54. data/spec/dummy/config/initializers/inflections.rb +0 -16
  55. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  56. data/spec/dummy/config/initializers/session_store.rb +0 -3
  57. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  58. data/spec/dummy/config/locales/en.yml +0 -23
  59. data/spec/dummy/config/routes.rb +0 -4
  60. data/spec/dummy/config/secrets.yml +0 -22
  61. data/spec/dummy/db/schema.rb +0 -25
  62. data/spec/dummy/db/test.sqlite3 +0 -0
  63. data/spec/dummy/log/test.log +0 -2673
  64. data/spec/dummy/public/404.html +0 -67
  65. data/spec/dummy/public/422.html +0 -67
  66. data/spec/dummy/public/500.html +0 -66
  67. data/spec/dummy/public/favicon.ico +0 -0
  68. data/spec/factories/user.rb +0 -17
  69. data/spec/openstax/salesforce/controllers/application_controller_spec.rb +0 -22
  70. data/spec/openstax/salesforce/controllers/settings_controller_spec.rb +0 -80
  71. data/spec/openstax/salesforce/remote/opportunity_spec.rb +0 -11
  72. data/spec/openstax/salesforce/remote/term_year_spec.rb +0 -81
  73. data/spec/openstax/salesforce/remote/tutor_course_period_spec.rb +0 -30
  74. data/spec/openstax/salesforce/spec_helpers_spec.rb +0 -31
  75. data/spec/rails_helper.rb +0 -99
  76. data/spec/routing_spec.rb +0 -9
  77. data/spec/spec_helper.rb +0 -86
@@ -1,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Salesforce
3
- VERSION = "3.1.0"
3
+ VERSION = '4.3.0'
4
4
  end
5
5
  end
@@ -1,11 +1,9 @@
1
1
  require "restforce"
2
2
  require "active_force"
3
- require "omniauth-salesforce"
4
3
 
5
4
  require "openstax/salesforce/active_force"
6
5
 
7
6
  require "openstax/salesforce/engine"
8
- require "openstax/salesforce/user_missing"
9
7
  require "openstax/salesforce/client"
10
8
 
11
9
  require "openstax/salesforce/remote/term_year"
@@ -20,7 +18,6 @@ require "openstax/salesforce/remote/campaign_member"
20
18
 
21
19
  module OpenStax
22
20
  module Salesforce
23
-
24
21
  def self.configure
25
22
  yield configuration
26
23
  end
@@ -31,40 +28,27 @@ module OpenStax
31
28
 
32
29
  # See `config/initializers/openstax_salesforce.rb` for documentation on options
33
30
  class Configuration
34
- attr_accessor :layout
35
- attr_accessor :authenticate_admin_proc
36
- attr_accessor :salesforce_client_key
37
- attr_accessor :salesforce_client_secret
38
- attr_writer :salesforce_login_site
39
- attr_accessor :sandbox_oauth_token
40
- attr_accessor :sandbox_refresh_token
41
- attr_accessor :sandbox_instance_url
42
- attr_accessor :check_sandbox_instance_url
43
- attr_accessor :skip_automatic_omniauth_setup
44
- attr_accessor :page_heading_proc
31
+ attr_writer :api_version, :login_domain
32
+ attr_accessor :username, :password, :security_token, :consumer_key, :consumer_secret
45
33
 
46
- def salesforce_login_site
47
- @salesforce_login_site || "https://login.salesforce.com"
34
+ def api_version
35
+ @api_version ||= '37.0'
48
36
  end
49
37
 
50
- def salesforce_client_options
51
- { site: salesforce_login_site }
38
+ def login_domain
39
+ @login_domain ||= 'test.salesforce.com'
52
40
  end
53
41
 
54
- def salesforce_login_domain
55
- Addressable::URI.parse(salesforce_login_site).host
42
+ def validate!
43
+ raise(IllegalState, "The Salesforce username is missing") if username.nil?
44
+ raise(IllegalState, "The Salesforce password is missing") if password.nil?
45
+ raise(IllegalState, "The Salesforce security token is missing") if security_token.nil?
46
+ raise(IllegalState, "The Salesforce consumer key is missing") if consumer_key.nil?
47
+ raise(IllegalState, "The Salesforce consumer secret is missing") if consumer_secret.nil?
56
48
  end
57
49
  end
58
50
 
59
- def self.set_top_level_routes(router)
60
- router.match '/auth/salesforce/callback',
61
- to: 'openstax/salesforce/settings#callback',
62
- via: [:get, :post]
63
- end
64
-
65
- def self.ready_for_api_usage?
66
- OpenStax::Salesforce::User.any?
51
+ module Remote
67
52
  end
68
-
69
53
  end
70
54
  end
@@ -1,8 +1,3 @@
1
- OPENSTAX_SALESFORCE_COPY_PATHS = [
2
- 'views',
3
- 'controllers'
4
- ]
5
-
6
1
  namespace :openstax_salesforce do
7
2
  namespace :install do
8
3
  desc 'Copy initializers from openstax_salesforce to application'
@@ -18,30 +13,10 @@ namespace :openstax_salesforce do
18
13
  end
19
14
  end
20
15
 
21
- namespace :copy do
22
- OPENSTAX_SALESFORCE_COPY_PATHS.each do |path|
23
- name = File.basename(path)
24
- desc "Copy #{name} from openstax_salesforce to application"
25
- task name.to_sym do
26
- cp_r File.expand_path("../../../app/#{path}/openstax/salesforce", __FILE__),
27
- "app/#{path}",
28
- verbose: false
29
- print "Copied #{name} from openstax_salesforce\n"
30
- end
31
- end
32
- end
33
-
16
+ # TODO: Remove after all servers have been migrated
34
17
  desc 'Copy migrations from openstax_salesforce to application'
35
18
  task :install do
36
19
  Rake::Task['openstax_salesforce:install:initializers'].invoke
37
20
  Rake::Task['openstax_salesforce:install:migrations'].invoke
38
21
  end
39
-
40
- desc 'Copy all customizable files from openstax_salesforce to application'
41
- task :copy do
42
- OPENSTAX_SALESFORCE_COPY_PATHS.each do |path|
43
- Rake::Task["openstax_salesforce:copy:#{File.basename(path)}"].invoke
44
- end
45
- end
46
22
  end
47
-
metadata CHANGED
@@ -1,45 +1,38 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_salesforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 4.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - JP Slavinsky
8
+ - Dante Soares
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2019-10-11 00:00:00.000000000 Z
12
+ date: 2020-07-02 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rails
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '5.0'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
18
+ - - ">="
25
19
  - !ruby/object:Gem::Version
26
20
  version: '5.0'
27
- - !ruby/object:Gem::Dependency
28
- name: restforce
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
21
+ - - "<"
32
22
  - !ruby/object:Gem::Version
33
- version: '0'
23
+ version: '7.0'
34
24
  type: :runtime
35
25
  prerelease: false
36
26
  version_requirements: !ruby/object:Gem::Requirement
37
27
  requirements:
38
28
  - - ">="
39
29
  - !ruby/object:Gem::Version
40
- version: '0'
30
+ version: '5.0'
31
+ - - "<"
32
+ - !ruby/object:Gem::Version
33
+ version: '7.0'
41
34
  - !ruby/object:Gem::Dependency
42
- name: active_force
35
+ name: restforce
43
36
  requirement: !ruby/object:Gem::Requirement
44
37
  requirements:
45
38
  - - ">="
@@ -53,7 +46,7 @@ dependencies:
53
46
  - !ruby/object:Gem::Version
54
47
  version: '0'
55
48
  - !ruby/object:Gem::Dependency
56
- name: omniauth-salesforce
49
+ name: openstax_active_force
57
50
  requirement: !ruby/object:Gem::Requirement
58
51
  requirements:
59
52
  - - ">="
@@ -95,49 +88,7 @@ dependencies:
95
88
  - !ruby/object:Gem::Version
96
89
  version: '0'
97
90
  - !ruby/object:Gem::Dependency
98
- name: factory_bot_rails
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- - !ruby/object:Gem::Dependency
112
- name: faker
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: byebug
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: database_cleaner
91
+ name: sprockets
141
92
  requirement: !ruby/object:Gem::Requirement
142
93
  requirements:
143
94
  - - ">="
@@ -150,20 +101,6 @@ dependencies:
150
101
  - - ">="
151
102
  - !ruby/object:Gem::Version
152
103
  version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: sprockets
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "<"
158
- - !ruby/object:Gem::Version
159
- version: '4.0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - "<"
165
- - !ruby/object:Gem::Version
166
- version: '4.0'
167
104
  description: Interface gem for accessing OpenStax's Salesforce instance
168
105
  email:
169
106
  - jps@kindlinglabs.com
@@ -174,15 +111,9 @@ files:
174
111
  - MIT-LICENSE
175
112
  - README.md
176
113
  - Rakefile
177
- - app/controllers/openstax/salesforce/application_controller.rb
178
- - app/controllers/openstax/salesforce/settings_controller.rb
179
- - app/helpers/openstax/salesforce/application_helper.rb
180
- - app/models/openstax/salesforce/user.rb
181
- - app/views/openstax/salesforce/settings/show.html.erb
182
- - config/initializers/omniauth.rb
183
114
  - config/initializers/openstax_salesforce.rb
184
- - config/routes.rb
185
115
  - db/migrate/0_install_openstax_salesforce.rb
116
+ - db/migrate/1_drop_openstax_salesforce_users.rb
186
117
  - lib/openstax/salesforce/active_force.rb
187
118
  - lib/openstax/salesforce/client.rb
188
119
  - lib/openstax/salesforce/engine.rb
@@ -196,59 +127,9 @@ files:
196
127
  - lib/openstax/salesforce/remote/term_year.rb
197
128
  - lib/openstax/salesforce/remote/tutor_course_period.rb
198
129
  - lib/openstax/salesforce/spec_helpers.rb
199
- - lib/openstax/salesforce/spec_helpers/salesforce_proxy.rb
200
- - lib/openstax/salesforce/user_missing.rb
201
130
  - lib/openstax/salesforce/version.rb
202
131
  - lib/openstax_salesforce.rb
203
132
  - lib/tasks/openstax_salesforce_tasks.rake
204
- - spec/client_spec.rb
205
- - spec/dummy/README.md
206
- - spec/dummy/Rakefile
207
- - spec/dummy/app/assets/javascripts/application.js
208
- - spec/dummy/app/assets/stylesheets/application.css
209
- - spec/dummy/app/controllers/application_controller.rb
210
- - spec/dummy/app/helpers/application_helper.rb
211
- - spec/dummy/app/views/layouts/application.html.erb
212
- - spec/dummy/bin/bundle
213
- - spec/dummy/bin/rails
214
- - spec/dummy/bin/rake
215
- - spec/dummy/bin/setup
216
- - spec/dummy/config.ru
217
- - spec/dummy/config/application.rb
218
- - spec/dummy/config/boot.rb
219
- - spec/dummy/config/database.yml
220
- - spec/dummy/config/environment.rb
221
- - spec/dummy/config/environments/development.rb
222
- - spec/dummy/config/environments/production.rb
223
- - spec/dummy/config/environments/test.rb
224
- - spec/dummy/config/initializers/assets.rb
225
- - spec/dummy/config/initializers/backtrace_silencers.rb
226
- - spec/dummy/config/initializers/cookies_serializer.rb
227
- - spec/dummy/config/initializers/filter_parameter_logging.rb
228
- - spec/dummy/config/initializers/inflections.rb
229
- - spec/dummy/config/initializers/mime_types.rb
230
- - spec/dummy/config/initializers/session_store.rb
231
- - spec/dummy/config/initializers/wrap_parameters.rb
232
- - spec/dummy/config/locales/en.yml
233
- - spec/dummy/config/routes.rb
234
- - spec/dummy/config/secrets.yml
235
- - spec/dummy/db/schema.rb
236
- - spec/dummy/db/test.sqlite3
237
- - spec/dummy/log/test.log
238
- - spec/dummy/public/404.html
239
- - spec/dummy/public/422.html
240
- - spec/dummy/public/500.html
241
- - spec/dummy/public/favicon.ico
242
- - spec/factories/user.rb
243
- - spec/openstax/salesforce/controllers/application_controller_spec.rb
244
- - spec/openstax/salesforce/controllers/settings_controller_spec.rb
245
- - spec/openstax/salesforce/remote/opportunity_spec.rb
246
- - spec/openstax/salesforce/remote/term_year_spec.rb
247
- - spec/openstax/salesforce/remote/tutor_course_period_spec.rb
248
- - spec/openstax/salesforce/spec_helpers_spec.rb
249
- - spec/rails_helper.rb
250
- - spec/routing_spec.rb
251
- - spec/spec_helper.rb
252
133
  homepage: https://github.com/openstax/openstax_salesforce
253
134
  licenses:
254
135
  - MIT
@@ -272,52 +153,4 @@ rubygems_version: 3.0.3
272
153
  signing_key:
273
154
  specification_version: 4
274
155
  summary: Interface gem for accessing OpenStax's Salesforce instance
275
- test_files:
276
- - spec/spec_helper.rb
277
- - spec/client_spec.rb
278
- - spec/dummy/app/controllers/application_controller.rb
279
- - spec/dummy/app/views/layouts/application.html.erb
280
- - spec/dummy/app/assets/javascripts/application.js
281
- - spec/dummy/app/assets/stylesheets/application.css
282
- - spec/dummy/app/helpers/application_helper.rb
283
- - spec/dummy/bin/rake
284
- - spec/dummy/bin/setup
285
- - spec/dummy/bin/bundle
286
- - spec/dummy/bin/rails
287
- - spec/dummy/config/secrets.yml
288
- - spec/dummy/config/routes.rb
289
- - spec/dummy/config/locales/en.yml
290
- - spec/dummy/config/environments/production.rb
291
- - spec/dummy/config/environments/development.rb
292
- - spec/dummy/config/environments/test.rb
293
- - spec/dummy/config/environment.rb
294
- - spec/dummy/config/application.rb
295
- - spec/dummy/config/database.yml
296
- - spec/dummy/config/boot.rb
297
- - spec/dummy/config/initializers/backtrace_silencers.rb
298
- - spec/dummy/config/initializers/mime_types.rb
299
- - spec/dummy/config/initializers/filter_parameter_logging.rb
300
- - spec/dummy/config/initializers/session_store.rb
301
- - spec/dummy/config/initializers/wrap_parameters.rb
302
- - spec/dummy/config/initializers/assets.rb
303
- - spec/dummy/config/initializers/cookies_serializer.rb
304
- - spec/dummy/config/initializers/inflections.rb
305
- - spec/dummy/config.ru
306
- - spec/dummy/README.md
307
- - spec/dummy/Rakefile
308
- - spec/dummy/public/favicon.ico
309
- - spec/dummy/public/422.html
310
- - spec/dummy/public/500.html
311
- - spec/dummy/public/404.html
312
- - spec/dummy/db/schema.rb
313
- - spec/dummy/db/test.sqlite3
314
- - spec/dummy/log/test.log
315
- - spec/openstax/salesforce/spec_helpers_spec.rb
316
- - spec/openstax/salesforce/controllers/settings_controller_spec.rb
317
- - spec/openstax/salesforce/controllers/application_controller_spec.rb
318
- - spec/openstax/salesforce/remote/term_year_spec.rb
319
- - spec/openstax/salesforce/remote/opportunity_spec.rb
320
- - spec/openstax/salesforce/remote/tutor_course_period_spec.rb
321
- - spec/factories/user.rb
322
- - spec/routing_spec.rb
323
- - spec/rails_helper.rb
156
+ test_files: []
@@ -1,7 +0,0 @@
1
- module OpenStax::Salesforce
2
- class ApplicationController < ActionController::Base
3
- protect_from_forgery with: :exception
4
-
5
- before_action { OpenStax::Salesforce.configuration.authenticate_admin_proc.call(self) }
6
- end
7
- end
@@ -1,20 +0,0 @@
1
- module OpenStax::Salesforce
2
- class SettingsController < OpenStax::Salesforce::ApplicationController
3
- layout OpenStax::Salesforce.configuration.layout
4
-
5
- def show
6
- end
7
-
8
- def callback
9
- OpenStax::Salesforce::User.save_from_omniauth!(request.env["omniauth.auth"])
10
- redirect_to root_path
11
- end
12
-
13
- def destroy_user
14
- OpenStax::Salesforce::User.destroy_all
15
- ActiveForce.clear_sfdc_client! # since user is now gone, any client invalid
16
- redirect_to root_path
17
- end
18
-
19
- end
20
- end
@@ -1,11 +0,0 @@
1
- module OpenStax::Salesforce
2
- module ApplicationHelper
3
- def config
4
- OpenStax::Salesforce.configuration
5
- end
6
-
7
- def page_heading(context, text)
8
- config.page_heading_proc.call(context, text)
9
- end
10
- end
11
- end
@@ -1,31 +0,0 @@
1
- module OpenStax::Salesforce
2
- class User < ActiveRecord::Base
3
- validates :uid, presence: true
4
- validates :oauth_token, presence: true
5
- validates :refresh_token, presence: true
6
- validates :instance_url, presence: true
7
-
8
- after_save :ensure_only_one_record
9
-
10
- def self.save_from_omniauth!(auth)
11
- where(uid: auth[:uid]).first_or_initialize.tap do |user|
12
- user.uid = auth.uid
13
- user.name = auth.info.name
14
- user.oauth_token = auth.credentials.token
15
- user.refresh_token = auth.credentials.refresh_token
16
- user.instance_url = auth.credentials.instance_url
17
- user.save!
18
- end
19
- end
20
-
21
- def ensure_only_one_record
22
- self.class.where.not(id: id).destroy_all
23
- end
24
-
25
- def refresh_oauth_token!
26
- OpenStax::Salesforce::Remote::Contact.count
27
- valid_token = ActiveForce.sfdc_client.options[:oauth_token]
28
- update_attribute(:oauth_token, valid_token) if self.oauth_token != valid_token
29
- end
30
- end
31
- end