openstax_salesforce 3.0.0 → 4.2.0

Sign up to get free protection for your applications and to get access to all the features.
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,5 +1,5 @@
1
1
  module OpenStax
2
2
  module Salesforce
3
- VERSION = "3.0.0"
3
+ VERSION = '4.2.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,29 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openstax_salesforce
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.2.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-05-24 00:00:00.000000000 Z
12
+ date: 2020-05-28 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
+ - - "~>"
18
19
  - !ruby/object:Gem::Version
19
- version: '0'
20
+ version: '5.0'
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - ">="
25
+ - - "~>"
25
26
  - !ruby/object:Gem::Version
26
- version: '0'
27
+ version: '5.0'
27
28
  - !ruby/object:Gem::Dependency
28
29
  name: restforce
29
30
  requirement: !ruby/object:Gem::Requirement
@@ -39,21 +40,7 @@ dependencies:
39
40
  - !ruby/object:Gem::Version
40
41
  version: '0'
41
42
  - !ruby/object:Gem::Dependency
42
- name: active_force
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: omniauth-salesforce
43
+ name: openstax_active_force
57
44
  requirement: !ruby/object:Gem::Requirement
58
45
  requirements:
59
46
  - - ">="
@@ -95,61 +82,19 @@ dependencies:
95
82
  - !ruby/object:Gem::Version
96
83
  version: '0'
97
84
  - !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
85
+ name: sprockets
113
86
  requirement: !ruby/object:Gem::Requirement
114
87
  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
- - - ">="
88
+ - - "<"
137
89
  - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: database_cleaner
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
90
+ version: '4.0'
146
91
  type: :development
147
92
  prerelease: false
148
93
  version_requirements: !ruby/object:Gem::Requirement
149
94
  requirements:
150
- - - ">="
95
+ - - "<"
151
96
  - !ruby/object:Gem::Version
152
- version: '0'
97
+ version: '4.0'
153
98
  description: Interface gem for accessing OpenStax's Salesforce instance
154
99
  email:
155
100
  - jps@kindlinglabs.com
@@ -160,15 +105,9 @@ files:
160
105
  - MIT-LICENSE
161
106
  - README.md
162
107
  - Rakefile
163
- - app/controllers/openstax/salesforce/application_controller.rb
164
- - app/controllers/openstax/salesforce/settings_controller.rb
165
- - app/helpers/openstax/salesforce/application_helper.rb
166
- - app/models/openstax/salesforce/user.rb
167
- - app/views/openstax/salesforce/settings/show.html.erb
168
- - config/initializers/omniauth.rb
169
108
  - config/initializers/openstax_salesforce.rb
170
- - config/routes.rb
171
109
  - db/migrate/0_install_openstax_salesforce.rb
110
+ - db/migrate/1_drop_openstax_salesforce_users.rb
172
111
  - lib/openstax/salesforce/active_force.rb
173
112
  - lib/openstax/salesforce/client.rb
174
113
  - lib/openstax/salesforce/engine.rb
@@ -182,61 +121,9 @@ files:
182
121
  - lib/openstax/salesforce/remote/term_year.rb
183
122
  - lib/openstax/salesforce/remote/tutor_course_period.rb
184
123
  - lib/openstax/salesforce/spec_helpers.rb
185
- - lib/openstax/salesforce/spec_helpers/salesforce_proxy.rb
186
- - lib/openstax/salesforce/user_missing.rb
187
124
  - lib/openstax/salesforce/version.rb
188
125
  - lib/openstax_salesforce.rb
189
126
  - lib/tasks/openstax_salesforce_tasks.rake
190
- - spec/client_spec.rb
191
- - spec/dummy/README.md
192
- - spec/dummy/Rakefile
193
- - spec/dummy/app/assets/javascripts/application.js
194
- - spec/dummy/app/assets/stylesheets/application.css
195
- - spec/dummy/app/controllers/application_controller.rb
196
- - spec/dummy/app/helpers/application_helper.rb
197
- - spec/dummy/app/views/layouts/application.html.erb
198
- - spec/dummy/bin/bundle
199
- - spec/dummy/bin/rails
200
- - spec/dummy/bin/rake
201
- - spec/dummy/bin/setup
202
- - spec/dummy/config.ru
203
- - spec/dummy/config/application.rb
204
- - spec/dummy/config/boot.rb
205
- - spec/dummy/config/database.yml
206
- - spec/dummy/config/environment.rb
207
- - spec/dummy/config/environments/development.rb
208
- - spec/dummy/config/environments/production.rb
209
- - spec/dummy/config/environments/test.rb
210
- - spec/dummy/config/initializers/assets.rb
211
- - spec/dummy/config/initializers/backtrace_silencers.rb
212
- - spec/dummy/config/initializers/cookies_serializer.rb
213
- - spec/dummy/config/initializers/filter_parameter_logging.rb
214
- - spec/dummy/config/initializers/inflections.rb
215
- - spec/dummy/config/initializers/mime_types.rb
216
- - spec/dummy/config/initializers/session_store.rb
217
- - spec/dummy/config/initializers/wrap_parameters.rb
218
- - spec/dummy/config/locales/en.yml
219
- - spec/dummy/config/routes.rb
220
- - spec/dummy/config/secrets.yml
221
- - spec/dummy/db/development.sqlite3
222
- - spec/dummy/db/schema.rb
223
- - spec/dummy/db/test.sqlite3
224
- - spec/dummy/log/development.log
225
- - spec/dummy/log/test.log
226
- - spec/dummy/public/404.html
227
- - spec/dummy/public/422.html
228
- - spec/dummy/public/500.html
229
- - spec/dummy/public/favicon.ico
230
- - spec/factories/user.rb
231
- - spec/openstax/salesforce/controllers/application_controller_spec.rb
232
- - spec/openstax/salesforce/controllers/settings_controller_spec.rb
233
- - spec/openstax/salesforce/remote/opportunity_spec.rb
234
- - spec/openstax/salesforce/remote/term_year_spec.rb
235
- - spec/openstax/salesforce/remote/tutor_course_period_spec.rb
236
- - spec/openstax/salesforce/spec_helpers_spec.rb
237
- - spec/rails_helper.rb
238
- - spec/routing_spec.rb
239
- - spec/spec_helper.rb
240
127
  homepage: https://github.com/openstax/openstax_salesforce
241
128
  licenses:
242
129
  - MIT
@@ -256,58 +143,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
143
  - !ruby/object:Gem::Version
257
144
  version: '0'
258
145
  requirements: []
259
- rubygems_version: 3.0.1
146
+ rubygems_version: 3.0.3
260
147
  signing_key:
261
148
  specification_version: 4
262
149
  summary: Interface gem for accessing OpenStax's Salesforce instance
263
- test_files:
264
- - spec/rails_helper.rb
265
- - spec/spec_helper.rb
266
- - spec/openstax/salesforce/spec_helpers_spec.rb
267
- - spec/openstax/salesforce/remote/opportunity_spec.rb
268
- - spec/openstax/salesforce/remote/term_year_spec.rb
269
- - spec/openstax/salesforce/remote/tutor_course_period_spec.rb
270
- - spec/openstax/salesforce/controllers/application_controller_spec.rb
271
- - spec/openstax/salesforce/controllers/settings_controller_spec.rb
272
- - spec/factories/user.rb
273
- - spec/client_spec.rb
274
- - spec/dummy/app/assets/javascripts/application.js
275
- - spec/dummy/app/assets/stylesheets/application.css
276
- - spec/dummy/app/views/layouts/application.html.erb
277
- - spec/dummy/app/controllers/application_controller.rb
278
- - spec/dummy/app/helpers/application_helper.rb
279
- - spec/dummy/db/development.sqlite3
280
- - spec/dummy/db/test.sqlite3
281
- - spec/dummy/db/schema.rb
282
- - spec/dummy/log/test.log
283
- - spec/dummy/log/development.log
284
- - spec/dummy/README.md
285
- - spec/dummy/public/favicon.ico
286
- - spec/dummy/public/422.html
287
- - spec/dummy/public/404.html
288
- - spec/dummy/public/500.html
289
- - spec/dummy/config.ru
290
- - spec/dummy/bin/rails
291
- - spec/dummy/bin/rake
292
- - spec/dummy/bin/setup
293
- - spec/dummy/bin/bundle
294
- - spec/dummy/config/application.rb
295
- - spec/dummy/config/initializers/filter_parameter_logging.rb
296
- - spec/dummy/config/initializers/assets.rb
297
- - spec/dummy/config/initializers/cookies_serializer.rb
298
- - spec/dummy/config/initializers/inflections.rb
299
- - spec/dummy/config/initializers/backtrace_silencers.rb
300
- - spec/dummy/config/initializers/wrap_parameters.rb
301
- - spec/dummy/config/initializers/session_store.rb
302
- - spec/dummy/config/initializers/mime_types.rb
303
- - spec/dummy/config/locales/en.yml
304
- - spec/dummy/config/routes.rb
305
- - spec/dummy/config/database.yml
306
- - spec/dummy/config/environment.rb
307
- - spec/dummy/config/boot.rb
308
- - spec/dummy/config/environments/production.rb
309
- - spec/dummy/config/environments/test.rb
310
- - spec/dummy/config/environments/development.rb
311
- - spec/dummy/config/secrets.yml
312
- - spec/dummy/Rakefile
313
- - spec/routing_spec.rb
150
+ 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