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.
- checksums.yaml +4 -4
- data/README.md +17 -46
- data/Rakefile +2 -5
- data/config/initializers/openstax_salesforce.rb +9 -38
- data/db/migrate/0_install_openstax_salesforce.rb +1 -0
- data/db/migrate/1_drop_openstax_salesforce_users.rb +14 -0
- data/lib/openstax/salesforce/active_force.rb +0 -4
- data/lib/openstax/salesforce/client.rb +11 -17
- data/lib/openstax/salesforce/remote/campaign.rb +0 -2
- data/lib/openstax/salesforce/remote/campaign_member.rb +0 -1
- data/lib/openstax/salesforce/remote/opportunity.rb +0 -2
- data/lib/openstax/salesforce/remote/term_year.rb +0 -2
- data/lib/openstax/salesforce/remote/tutor_course_period.rb +0 -2
- data/lib/openstax/salesforce/spec_helpers.rb +119 -26
- data/lib/openstax/salesforce/version.rb +1 -1
- data/lib/openstax_salesforce.rb +13 -29
- data/lib/tasks/openstax_salesforce_tasks.rake +1 -26
- metadata +6 -179
- data/app/controllers/openstax/salesforce/application_controller.rb +0 -7
- data/app/controllers/openstax/salesforce/settings_controller.rb +0 -20
- data/app/helpers/openstax/salesforce/application_helper.rb +0 -11
- data/app/models/openstax/salesforce/user.rb +0 -31
- data/app/views/openstax/salesforce/settings/show.html.erb +0 -33
- data/config/initializers/omniauth.rb +0 -8
- data/config/routes.rb +0 -11
- data/lib/openstax/salesforce/spec_helpers/salesforce_proxy.rb +0 -121
- data/lib/openstax/salesforce/user_missing.rb +0 -3
- data/spec/client_spec.rb +0 -10
- data/spec/dummy/README.md +0 -28
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/javascripts/application.js +0 -13
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -5
- data/spec/dummy/app/helpers/application_helper.rb +0 -2
- data/spec/dummy/app/views/layouts/application.html.erb +0 -14
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/config/application.rb +0 -25
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/database.yml +0 -25
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -41
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/routes.rb +0 -4
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/schema.rb +0 -25
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +0 -2673
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/factories/user.rb +0 -17
- data/spec/openstax/salesforce/controllers/application_controller_spec.rb +0 -22
- data/spec/openstax/salesforce/controllers/settings_controller_spec.rb +0 -80
- data/spec/openstax/salesforce/remote/opportunity_spec.rb +0 -11
- data/spec/openstax/salesforce/remote/term_year_spec.rb +0 -81
- data/spec/openstax/salesforce/remote/tutor_course_period_spec.rb +0 -30
- data/spec/openstax/salesforce/spec_helpers_spec.rb +0 -31
- data/spec/rails_helper.rb +0 -99
- data/spec/routing_spec.rb +0 -9
- data/spec/spec_helper.rb +0 -86
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openstax_salesforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.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-
|
12
|
+
date: 2019-11-22 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: rails
|
@@ -39,21 +40,7 @@ dependencies:
|
|
39
40
|
- !ruby/object:Gem::Version
|
40
41
|
version: '0'
|
41
42
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
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
|
- - ">="
|
@@ -94,62 +81,6 @@ dependencies:
|
|
94
81
|
- - ">="
|
95
82
|
- !ruby/object:Gem::Version
|
96
83
|
version: '0'
|
97
|
-
- !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
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - ">="
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: '0'
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - ">="
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: '0'
|
153
84
|
- !ruby/object:Gem::Dependency
|
154
85
|
name: sprockets
|
155
86
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,15 +105,9 @@ files:
|
|
174
105
|
- MIT-LICENSE
|
175
106
|
- README.md
|
176
107
|
- 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
108
|
- config/initializers/openstax_salesforce.rb
|
184
|
-
- config/routes.rb
|
185
109
|
- db/migrate/0_install_openstax_salesforce.rb
|
110
|
+
- db/migrate/1_drop_openstax_salesforce_users.rb
|
186
111
|
- lib/openstax/salesforce/active_force.rb
|
187
112
|
- lib/openstax/salesforce/client.rb
|
188
113
|
- lib/openstax/salesforce/engine.rb
|
@@ -196,59 +121,9 @@ files:
|
|
196
121
|
- lib/openstax/salesforce/remote/term_year.rb
|
197
122
|
- lib/openstax/salesforce/remote/tutor_course_period.rb
|
198
123
|
- lib/openstax/salesforce/spec_helpers.rb
|
199
|
-
- lib/openstax/salesforce/spec_helpers/salesforce_proxy.rb
|
200
|
-
- lib/openstax/salesforce/user_missing.rb
|
201
124
|
- lib/openstax/salesforce/version.rb
|
202
125
|
- lib/openstax_salesforce.rb
|
203
126
|
- 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
127
|
homepage: https://github.com/openstax/openstax_salesforce
|
253
128
|
licenses:
|
254
129
|
- MIT
|
@@ -272,52 +147,4 @@ rubygems_version: 3.0.3
|
|
272
147
|
signing_key:
|
273
148
|
specification_version: 4
|
274
149
|
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
|
150
|
+
test_files: []
|
@@ -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,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
|
@@ -1,33 +0,0 @@
|
|
1
|
-
<div class="salesforce-settings">
|
2
|
-
|
3
|
-
<%= page_heading(self, "Salesforce Setup") %>
|
4
|
-
|
5
|
-
<p>When Accounts makes calls to Salesforce's API, it must do so on behalf of a
|
6
|
-
specific Salesforce user. At any one time, Accounts has information for either
|
7
|
-
zero or one such user. Use the link below to set the current user that Accounts
|
8
|
-
acts as when calling the Salesforce API.</p>
|
9
|
-
|
10
|
-
<% @user = OpenStax::Salesforce::User.first %>
|
11
|
-
|
12
|
-
<div style="margin: 30px 0px">
|
13
|
-
<p>
|
14
|
-
<% if @user.present? %>
|
15
|
-
The current Salesforce user is <b><%= @user.name || "[Unknown Name]" %></b>.
|
16
|
-
<% else %>
|
17
|
-
There <b>is no</b> Salesforce user currently set.
|
18
|
-
<% end %>
|
19
|
-
</p>
|
20
|
-
</div>
|
21
|
-
|
22
|
-
<%= link_to "Set Salesforce User",
|
23
|
-
"/auth/salesforce?redirect_uri=#{main_app.auth_salesforce_callback_url}",
|
24
|
-
id: "sign_in", class: 'btn btn-primary' %>
|
25
|
-
|
26
|
-
<%= link_to "Clear Salesforce User",
|
27
|
-
destroy_user_settings_path,
|
28
|
-
class: 'btn btn-danger pull-right',
|
29
|
-
method: :delete %>
|
30
|
-
|
31
|
-
<hr/>
|
32
|
-
|
33
|
-
</div>
|
@@ -1,8 +0,0 @@
|
|
1
|
-
Rails.application.config.middleware.use OmniAuth::Builder do
|
2
|
-
unless OpenStax::Salesforce.configuration.skip_automatic_omniauth_setup
|
3
|
-
provider :salesforce,
|
4
|
-
OpenStax::Salesforce.configuration.salesforce_client_key,
|
5
|
-
OpenStax::Salesforce.configuration.salesforce_client_secret,
|
6
|
-
client_options: OpenStax::Salesforce.configuration.salesforce_client_options
|
7
|
-
end
|
8
|
-
end
|
data/config/routes.rb
DELETED
@@ -1,121 +0,0 @@
|
|
1
|
-
module OpenStax::Salesforce::SpecHelpers
|
2
|
-
class SalesforceProxy
|
3
|
-
|
4
|
-
include OpenStax::Salesforce::Remote
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
end
|
8
|
-
|
9
|
-
# Used to filter records to the scope of one spec
|
10
|
-
def reset_unique_token(token = SecureRandom.hex(10))
|
11
|
-
@unique_token = token
|
12
|
-
end
|
13
|
-
|
14
|
-
def clear_unique_token
|
15
|
-
@unique_token = nil
|
16
|
-
end
|
17
|
-
|
18
|
-
def new_contact(first_name: nil, last_name: nil, school_name: "JP University",
|
19
|
-
email: nil, email_alt: nil, faculty_verified: nil, school_type: nil)
|
20
|
-
ensure_schools_exist([school_name])
|
21
|
-
|
22
|
-
Contact.new(
|
23
|
-
first_name: first_name || Faker::Name.first_name,
|
24
|
-
last_name: last_name!(last_name),
|
25
|
-
school_id: school_id(school_name),
|
26
|
-
email: email,
|
27
|
-
email_alt: email_alt,
|
28
|
-
faculty_verified: faculty_verified,
|
29
|
-
school_type: school_type
|
30
|
-
).tap do |contact|
|
31
|
-
if !contact.save
|
32
|
-
raise "Could not save SF contact: #{contact.errors}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def new_lead(email:, status: nil, last_name: nil, source: nil, school_name: "JP University")
|
38
|
-
Lead.new(
|
39
|
-
email: email,
|
40
|
-
status: status,
|
41
|
-
last_name: last_name!(last_name),
|
42
|
-
school: school_name,
|
43
|
-
source: source
|
44
|
-
).tap do |lead|
|
45
|
-
if !lead.save
|
46
|
-
raise "Could not save SF lead: #{lead.errors}"
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def new_campaign(name: SecureRandom.hex(8))
|
52
|
-
Campaign.new(
|
53
|
-
name: name
|
54
|
-
).tap do |campaign|
|
55
|
-
if !campaign.save
|
56
|
-
raise "Could not save SF Campaign: #{campaign.errors}"
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def new_campaign_member(contact_id:, campaign_id:)
|
62
|
-
CampaignMember.new(
|
63
|
-
contact_id: contact_id,
|
64
|
-
campaign_id: campaign_id
|
65
|
-
).tap do |campaign_member|
|
66
|
-
if !campaign_member.save
|
67
|
-
raise "Could not save SF Campaign Member: #{campaign_member.errors}"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
def last_name!(input)
|
73
|
-
"#{input || Faker::Name.last_name}#{@unique_token if @unique_token.present?}"
|
74
|
-
end
|
75
|
-
|
76
|
-
def ensure_books_exist(book_names)
|
77
|
-
book_names.each do |book_name|
|
78
|
-
if books.none? {|bb| bb.name == book_name}
|
79
|
-
book = Book.new(name: book_name)
|
80
|
-
book.save!
|
81
|
-
books.push(book)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def ensure_schools_exist(school_names)
|
87
|
-
school_names.compact.each do |school_name|
|
88
|
-
if schools.none? {|ss| ss.name == school_name}
|
89
|
-
school = School.new(name: school_name)
|
90
|
-
school.save!
|
91
|
-
schools.push(school)
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def books
|
97
|
-
@books ||= Book.all
|
98
|
-
end
|
99
|
-
|
100
|
-
def book(name)
|
101
|
-
books.find { |bb| bb.name == name }
|
102
|
-
end
|
103
|
-
|
104
|
-
def book_id(name)
|
105
|
-
book(name).id
|
106
|
-
end
|
107
|
-
|
108
|
-
def schools
|
109
|
-
@schools ||= School.all
|
110
|
-
end
|
111
|
-
|
112
|
-
def school_id(name)
|
113
|
-
school(name).try(:id)
|
114
|
-
end
|
115
|
-
|
116
|
-
def school(name)
|
117
|
-
schools.find { |ss| ss.name == name }
|
118
|
-
end
|
119
|
-
|
120
|
-
end
|
121
|
-
end
|
data/spec/client_spec.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
require 'rails_helper'
|
2
|
-
|
3
|
-
RSpec.describe OpenStax::Salesforce::Client do
|
4
|
-
|
5
|
-
it 'raises when there is no SF user' do
|
6
|
-
allow(OpenStax::Salesforce::User).to receive(:first) { nil }
|
7
|
-
expect{ described_class.new }.to raise_error(OpenStax::Salesforce::UserMissing)
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
data/spec/dummy/README.md
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
== README
|
2
|
-
|
3
|
-
This README would normally document whatever steps are necessary to get the
|
4
|
-
application up and running.
|
5
|
-
|
6
|
-
Things you may want to cover:
|
7
|
-
|
8
|
-
* Ruby version
|
9
|
-
|
10
|
-
* System dependencies
|
11
|
-
|
12
|
-
* Configuration
|
13
|
-
|
14
|
-
* Database creation
|
15
|
-
|
16
|
-
* Database initialization
|
17
|
-
|
18
|
-
* How to run the test suite
|
19
|
-
|
20
|
-
* Services (job queues, cache servers, search engines, etc.)
|
21
|
-
|
22
|
-
* Deployment instructions
|
23
|
-
|
24
|
-
* ...
|
25
|
-
|
26
|
-
|
27
|
-
Please feel free to use a different markup language if you do not plan to run
|
28
|
-
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
-
// listed below.
|
3
|
-
//
|
4
|
-
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
-
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
-
//
|
7
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
-
// compiled file.
|
9
|
-
//
|
10
|
-
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
11
|
-
// about supported directives.
|
12
|
-
//
|
13
|
-
//= require_tree .
|
@@ -1,15 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
-
* listed below.
|
4
|
-
*
|
5
|
-
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
-
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
-
*
|
8
|
-
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
-
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
-
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
-
* file per style scope.
|
12
|
-
*
|
13
|
-
*= require_tree .
|
14
|
-
*= require_self
|
15
|
-
*/
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Dummy</title>
|
5
|
-
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
-
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|
data/spec/dummy/bin/bundle
DELETED
data/spec/dummy/bin/rails
DELETED
data/spec/dummy/bin/rake
DELETED
data/spec/dummy/bin/setup
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
# path to your application root.
|
5
|
-
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
6
|
-
|
7
|
-
Dir.chdir APP_ROOT do
|
8
|
-
# This script is a starting point to setup your application.
|
9
|
-
# Add necessary setup steps to this file:
|
10
|
-
|
11
|
-
puts "== Installing dependencies =="
|
12
|
-
system "gem install bundler --conservative"
|
13
|
-
system "bundle check || bundle install"
|
14
|
-
|
15
|
-
# puts "\n== Copying sample files =="
|
16
|
-
# unless File.exist?("config/database.yml")
|
17
|
-
# system "cp config/database.yml.sample config/database.yml"
|
18
|
-
# end
|
19
|
-
|
20
|
-
puts "\n== Preparing database =="
|
21
|
-
system "bin/rake db:setup"
|
22
|
-
|
23
|
-
puts "\n== Removing old logs and tempfiles =="
|
24
|
-
system "rm -f log/*"
|
25
|
-
system "rm -rf tmp/cache"
|
26
|
-
|
27
|
-
puts "\n== Restarting application server =="
|
28
|
-
system "touch tmp/restart.txt"
|
29
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
require 'rails/all'
|
4
|
-
|
5
|
-
Bundler.require(*Rails.groups)
|
6
|
-
require "openstax_salesforce"
|
7
|
-
|
8
|
-
module Dummy
|
9
|
-
class Application < Rails::Application
|
10
|
-
# Initialize configuration defaults for originally generated Rails version.
|
11
|
-
config.load_defaults 5.2
|
12
|
-
|
13
|
-
# Settings in config/environments/* take precedence over those specified here.
|
14
|
-
# Application configuration should go into files in config/initializers
|
15
|
-
# -- all .rb files in that directory are automatically loaded.
|
16
|
-
|
17
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
18
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
19
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
20
|
-
|
21
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
22
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
23
|
-
# config.i18n.default_locale = :de
|
24
|
-
end
|
25
|
-
end
|
data/spec/dummy/config/boot.rb
DELETED