leap_salesforce 0.2.28 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +38 -14
- data/ChangeLog +6 -1
- data/PITCHME.md +3 -3
- data/README.md +6 -0
- data/Rakefile +18 -0
- data/lib/leap_salesforce/generator/soql_enums.rb +1 -1
- data/lib/leap_salesforce/generator/soql_objects.rb +2 -2
- data/lib/leap_salesforce/generator/templates/spec/crud_eg_spec.rb.erb +2 -2
- data/lib/leap_salesforce/users/user.rb +3 -3
- data/lib/leap_salesforce/users/users.rb +12 -6
- data/lib/leap_salesforce/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 985b2a787327d829a036c867917e750a9fcbcd6c1a06879b70b99d4ca7712ef6
|
4
|
+
data.tar.gz: 3b743a1a1f41024f5f97f1213c36949ec5f447f88ed070c593851caf74dc2ee2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 97b52f1ef171e95bfaccb1564b1956d375bbdb2293b95015e87e8bcd38130d9cc46cda400330560dff5cdd23f75b8ac6f57eb3c7bce15f15ba57bb3a3a16f097
|
7
|
+
data.tar.gz: 5efd8b9a0679ac8472ae9ee8d11652c0a01c88ff51f531fbea468cf284aa9341c1a667666f6a16bf323deb183f9af8af5ce98da792f169f96d4c98484d8d3afb
|
data/.gitlab-ci.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
include:
|
2
2
|
- template: Code-Quality.gitlab-ci.yml
|
3
3
|
|
4
|
-
image: ruby:2.
|
4
|
+
image: ruby:2.7
|
5
5
|
|
6
6
|
stages:
|
7
7
|
- test
|
@@ -18,7 +18,7 @@ variables:
|
|
18
18
|
pages:
|
19
19
|
stage: deploy
|
20
20
|
dependencies:
|
21
|
-
-
|
21
|
+
- test_2.7
|
22
22
|
script:
|
23
23
|
- mv coverage/ public
|
24
24
|
artifacts:
|
@@ -600,25 +600,49 @@ pages:
|
|
600
600
|
done
|
601
601
|
}
|
602
602
|
|
603
|
-
|
603
|
+
function setup_integration_env() {
|
604
|
+
# Decrypt server key
|
605
|
+
openssl aes-256-cbc -d -md md5 -in assets/server.key.enc -out assets/server.key -k $SERVER_KEY_PASSWORD
|
606
|
+
ls -la assets
|
607
|
+
install_jq
|
608
|
+
install_salesforce_cli
|
609
|
+
# Integrated test
|
610
|
+
gem install bundler rake
|
611
|
+
bundle install
|
612
|
+
sfdx force:auth:jwt:grant --clientid "$SF_CONSUMER_KEY" --jwtkeyfile assets/server.key --username "$SF_USERNAME" --setdefaultdevhubusername --setalias HubOrg
|
613
|
+
}
|
614
|
+
|
615
|
+
test_2.6:
|
616
|
+
image: ruby:2.6
|
604
617
|
stage: test
|
618
|
+
script:
|
619
|
+
- *sfdx_helpers
|
620
|
+
- setup_integration_env
|
621
|
+
- bundle exec rake check_oauth # Check OAuth
|
622
|
+
- bundle exec rake leaps:create_soql_objects
|
623
|
+
- bundle exec rake leaps:create_enums
|
624
|
+
- bundle exec rspec
|
625
|
+
|
626
|
+
test_2.7:
|
605
627
|
script:
|
606
628
|
# Decrypt server key
|
607
629
|
- *sfdx_helpers
|
608
|
-
-
|
609
|
-
- ls -la assets
|
610
|
-
- install_jq
|
611
|
-
- install_salesforce_cli
|
612
|
-
# Integrated test
|
613
|
-
- ruby -v
|
614
|
-
- which ruby
|
615
|
-
- gem install bundler rake
|
616
|
-
- bundle install
|
617
|
-
- sfdx force:auth:jwt:grant --clientid "$SF_CONSUMER_KEY" --jwtkeyfile assets/server.key --username "$SF_USERNAME" --setdefaultdevhubusername --setalias HubOrg
|
630
|
+
- setup_integration_env
|
618
631
|
- bundle exec rake check_oauth # Check OAuth
|
619
632
|
- bundle exec rake leaps:create_soql_objects
|
620
633
|
- bundle exec rake leaps:create_enums
|
621
|
-
- bundle exec
|
634
|
+
- bundle exec rspec
|
622
635
|
artifacts:
|
623
636
|
paths:
|
624
637
|
- coverage/
|
638
|
+
|
639
|
+
test_3.0:
|
640
|
+
image: ruby:3.0
|
641
|
+
script:
|
642
|
+
# Decrypt server key
|
643
|
+
- *sfdx_helpers
|
644
|
+
- setup_integration_env
|
645
|
+
- bundle exec rake check_oauth # Check OAuth
|
646
|
+
- bundle exec rake leaps:create_soql_objects
|
647
|
+
- bundle exec rake leaps:create_enums
|
648
|
+
- bundle exec rspec
|
data/ChangeLog
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
Version 1.0.0
|
2
|
+
* Enhancement
|
3
|
+
* Disable rubocop output for pending ops when creating/fixing files
|
4
|
+
* Specify that working with Ruby 3 is a work in progress
|
5
|
+
|
1
6
|
Version 0.2.28
|
2
7
|
* Enhancement
|
3
8
|
* Make exclude method able to use class name in exclusion filter (hence easier to use)
|
@@ -226,4 +231,4 @@ Version 0.1.1
|
|
226
231
|
* Suggestions for generated factory
|
227
232
|
* Begin unit tests
|
228
233
|
* Handle Macrons by ensuring they're not copied into Ruby names / Modules
|
229
|
-
* Created executable
|
234
|
+
* Created executable
|
data/PITCHME.md
CHANGED
@@ -80,7 +80,7 @@ metadata.
|
|
80
80
|
@[3](Declare what it is you're testing)
|
81
81
|
@[5](Define what 'it' is, a the object under test must do)
|
82
82
|
@[6](Create an instance of the object class - nothing sent to Salesforce yet)
|
83
|
-
@[7-8](Set the first and last name to random names)
|
83
|
+
@[4,7-8](Set the first and last name to random names)
|
84
84
|
@[9](Create the object in Salesforce by sending request via API)
|
85
85
|
@[10](Verify creation was successful)
|
86
86
|
@[11](Verify first name set as expected)
|
@@ -92,8 +92,8 @@ metadata.
|
|
92
92
|
|
93
93
|
---?code=spec/integration/query_spec.rb&lang=ruby&title=Querying entities
|
94
94
|
|
95
|
-
@[
|
96
|
-
@[
|
95
|
+
@[21](Find an object using a specific attribute specific value)
|
96
|
+
@[29-30](Find list of objects meeting condition)
|
97
97
|
|
98
98
|
---
|
99
99
|
|
data/README.md
CHANGED
@@ -258,6 +258,10 @@ This method can be used directly with the backend name. E.g, `contact[:FieldName
|
|
258
258
|
This method in turn sets a value of the `@override_parameters[:body]` variable within the entity.
|
259
259
|
The value of request body can be interrogated with `entity.request_parameters.body`.
|
260
260
|
|
261
|
+
##### Logging
|
262
|
+
|
263
|
+
By default, API traffic will be logged in a log file in a `logs` folder.
|
264
|
+
|
261
265
|
### CRUD of data
|
262
266
|
|
263
267
|
To work data in Salesforce, an object inheriting from the `SoqlData` class is always used. The idea is
|
@@ -560,3 +564,5 @@ Everyone interacting in the LeapSalesforce project’s codebases, issue trackers
|
|
560
564
|
|
561
565
|
* Presentation on this library [here](https://gitpitch.com/leap-dojo/leap_salesforce?grs=gitlab)
|
562
566
|
* Example of this library within a CI/CD pipeline [here](https://gitlab.com/iqa_public/labs/salesforce_cicd_demo)
|
567
|
+
* Using `leap_salesforce` to download event log files [here](https://gitlab.com/samuel-garratt/leap_salesforce_event_log_files)
|
568
|
+
|
data/Rakefile
CHANGED
@@ -34,3 +34,21 @@ YARD::Doctest::RakeTask.new do |task|
|
|
34
34
|
# TODO: Get all examples working in this way
|
35
35
|
task.pattern = 'lib/leap_salesforce/ext/string.rb'
|
36
36
|
end
|
37
|
+
|
38
|
+
desc 'Task to enter pry terminal and types commands using the standard library code'
|
39
|
+
task :pry do
|
40
|
+
require 'pry'
|
41
|
+
Pry.start
|
42
|
+
end
|
43
|
+
|
44
|
+
desc 'Example of cleaning up data'
|
45
|
+
task :remove_contacts do
|
46
|
+
contacts = Contact.where first_name: '!null'
|
47
|
+
puts "Deleting #{contacts.size} contacts"
|
48
|
+
contacts.each do |contact|
|
49
|
+
contact.delete
|
50
|
+
print '.'
|
51
|
+
end
|
52
|
+
contacts = Contact.where first_name: '!null'
|
53
|
+
puts "#{contacts.size} contacts left"
|
54
|
+
end
|
@@ -62,8 +62,8 @@ module LeapSalesforce
|
|
62
62
|
generate_field_module
|
63
63
|
generate_factory
|
64
64
|
end
|
65
|
-
`rubocop -a #{SOQL_OBJECT_FOLDER}`
|
66
|
-
`rubocop -a #{FACTORY_FOLDER}`
|
65
|
+
`rubocop -a #{SOQL_OBJECT_FOLDER} --enable-pending-cops`
|
66
|
+
`rubocop -a #{FACTORY_FOLDER} --enable-pending-cops`
|
67
67
|
end
|
68
68
|
|
69
69
|
private
|
@@ -4,8 +4,8 @@
|
|
4
4
|
# Depending on validation rules and mandatory fields this may or may not work
|
5
5
|
|
6
6
|
RSpec.describe 'Contact CRUD' do
|
7
|
-
let(:uniq_value) {
|
8
|
-
let(:updated_value) {
|
7
|
+
let(:uniq_value) { "UNIQ #{Faker::Name.first_name} #{Faker::Name.middle_name}" }
|
8
|
+
let(:updated_value) { "New #{Faker::Name.first_name} #{Faker::Name.neutral_first_name}" }
|
9
9
|
it 'Create using factory bot' do
|
10
10
|
@contact = FactoryBot.create(:contact)
|
11
11
|
end
|
@@ -16,9 +16,9 @@ module LeapSalesforce
|
|
16
16
|
|
17
17
|
# @param [String, Symbol] key Key used to identify a test user
|
18
18
|
# @param [String] username Name used to login with user. In email address format.
|
19
|
-
def initialize(
|
20
|
-
self.key =
|
21
|
-
self.username =
|
19
|
+
def initialize(*user_params, description: nil)
|
20
|
+
self.key = user_params[0]
|
21
|
+
self.username = user_params[1]
|
22
22
|
self.description = description
|
23
23
|
end
|
24
24
|
|
@@ -23,8 +23,12 @@ module LeapSalesforce
|
|
23
23
|
raise LeapSalesforce::UserError, "Incorrect type #{user.class} for user. Expected either " \
|
24
24
|
'type LeapSalesforce::User or Array'
|
25
25
|
end
|
26
|
+
if user[2]
|
27
|
+
desc = user[2].is_a?(Hash) ? user[2].values[0] : user[2].dup
|
28
|
+
user[2] = nil
|
29
|
+
end
|
26
30
|
|
27
|
-
@list << User.new(*user)
|
31
|
+
@list << User.new(*user, description: desc)
|
28
32
|
end
|
29
33
|
|
30
34
|
# @example Filter user by key of :admin
|
@@ -34,14 +38,16 @@ module LeapSalesforce
|
|
34
38
|
# @example Filter user by username
|
35
39
|
# where(username: 'username@domain.com')
|
36
40
|
# @param [Symbol, Hash, String, Regexp, LeapSalesforce::User] filter Filter to find users by
|
37
|
-
# @
|
41
|
+
# @param_key [Boolean] all Whether to return all users matching criteria, not just first
|
38
42
|
# @return [LeapSalesforce::User, Array] A user that meets the criteria.
|
39
43
|
# If all is true this returns array of users
|
40
|
-
def where(filter
|
41
|
-
@all =
|
44
|
+
def where(filter)
|
45
|
+
@all = false
|
42
46
|
case filter
|
43
47
|
when :default then list.first # Will then use first user defined
|
44
|
-
when Hash
|
48
|
+
when Hash
|
49
|
+
@all = filter[:all] || false
|
50
|
+
match_params filter
|
45
51
|
when String then match_params(username: filter)
|
46
52
|
when Symbol then match_params(key: filter)
|
47
53
|
when Regexp then match_params(description: filter)
|
@@ -56,7 +62,7 @@ module LeapSalesforce
|
|
56
62
|
# Iterate through each user, narrowing on filter if provided
|
57
63
|
def each(filter = nil)
|
58
64
|
if filter
|
59
|
-
where(filter, all: true).each { yield }
|
65
|
+
where({**filter, all: true}).each { yield }
|
60
66
|
else
|
61
67
|
list.each { yield }
|
62
68
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leap_salesforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IQA
|
8
8
|
- Samuel Garratt
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2021-01-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -355,7 +355,7 @@ homepage: https://gitlab.com/leap-dojo/leap_salesforce
|
|
355
355
|
licenses:
|
356
356
|
- MIT
|
357
357
|
metadata: {}
|
358
|
-
post_install_message:
|
358
|
+
post_install_message:
|
359
359
|
rdoc_options: []
|
360
360
|
require_paths:
|
361
361
|
- lib
|
@@ -371,7 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
371
371
|
version: '0'
|
372
372
|
requirements: []
|
373
373
|
rubygems_version: 3.0.6
|
374
|
-
signing_key:
|
374
|
+
signing_key:
|
375
375
|
specification_version: 4
|
376
376
|
summary: Helps with setting up integrated automated test frameworks against Salesforce.
|
377
377
|
test_files: []
|