leap_salesforce 1.0.1 → 1.0.2
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/.gitlab-ci.yml +0 -11
- data/ChangeLog +6 -0
- data/README.md +1 -1
- data/lib/leap_salesforce.rb +4 -1
- data/lib/leap_salesforce/error.rb +4 -0
- data/lib/leap_salesforce/ext/string.rb +2 -2
- data/lib/leap_salesforce/generator/default.rb +1 -1
- data/lib/leap_salesforce/generator/exe_helpers.rb +2 -2
- data/lib/leap_salesforce/parameters.rb +3 -2
- data/lib/leap_salesforce/soql_data/soql_global_object_data.rb +2 -2
- data/lib/leap_salesforce/soql_data/soql_object_describe.rb +23 -0
- data/lib/leap_salesforce/users/user.rb +2 -4
- data/lib/leap_salesforce/users/users.rb +5 -5
- data/lib/leap_salesforce/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '08942c56565447b0c7fa381bb9b853f1553b17683b53cf801be10ee777d6e4e0'
|
4
|
+
data.tar.gz: 3f6ef92d1f1d198f4512dd452bed489246e598a3a838eb4dec503098d96ee61b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e28c9f6dda53de160fe0eab240a174ce92043662d089cfd329de54d0fc3a4fcc70c25edafa5ec2a5aeea1b2b25986b1df67c24dbff3189bfb7fed321905dfbe
|
7
|
+
data.tar.gz: b57058beb487934fbc70ce50d9ac1467c0970d0fc14f82e9cb328e7cc3c0ba807599c58f8cdf75e2e269c6679c44c058d4e54e4da386319765e2b374833bb4e3
|
data/.gitlab-ci.yml
CHANGED
@@ -612,17 +612,6 @@ pages:
|
|
612
612
|
sfdx force:auth:jwt:grant --clientid "$SF_CONSUMER_KEY" --jwtkeyfile assets/server.key --username "$SF_USERNAME" --setdefaultdevhubusername --setalias HubOrg
|
613
613
|
}
|
614
614
|
|
615
|
-
test_2.6:
|
616
|
-
image: ruby:2.6
|
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
615
|
test_2.7:
|
627
616
|
script:
|
628
617
|
# Decrypt server key
|
data/ChangeLog
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
Version 1.0.2
|
2
|
+
* Enhancement
|
3
|
+
* Only load sub folders of leap_salesforce.lib_folder that are needed by this gem, allowing room for UI
|
4
|
+
and other gems to use other folders independently
|
5
|
+
* New method 'accessors' on object to make it easy to pass list of fields for an object
|
6
|
+
|
1
7
|
Version 1.0.1
|
2
8
|
* Bug fix
|
3
9
|
* Fix #28 allowing !nil for query by non null values
|
data/README.md
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Welcome to LeapSalesforce gem. This gem helps ones to perform integration tests on Salesforce. It reads the Metadata
|
4
4
|
from Salesforce and creates the foundation for API tests.
|
5
5
|
|
6
|
-
|
6
|
+
Support for UI testing is being worked on in another gem [leap_salesforce_ui](https://gitlab.com/leap-dojo/leap_salesforce_ui)
|
7
7
|
|
8
8
|
## Is this for you?
|
9
9
|
|
data/lib/leap_salesforce.rb
CHANGED
@@ -74,7 +74,10 @@ module LeapSalesforce
|
|
74
74
|
require 'leap_salesforce/limits'
|
75
75
|
|
76
76
|
FileUtils.mkdir_p lib_folder unless Dir.exist? lib_folder
|
77
|
-
|
77
|
+
%w[factories metadata soql_data].each do |folder|
|
78
|
+
sub_folder = File.join(lib_folder, folder)
|
79
|
+
require_all sub_folder if Dir.exist? sub_folder
|
80
|
+
end
|
78
81
|
|
79
82
|
self.objects_to_verify = SoqlData.descendants if objects_to_verify.empty?
|
80
83
|
end
|
@@ -3,12 +3,16 @@
|
|
3
3
|
module LeapSalesforce
|
4
4
|
# Any error specific to LeapSalesforce
|
5
5
|
class Error < StandardError; end
|
6
|
+
|
6
7
|
# Error related to handling a request
|
7
8
|
class RequestError < StandardError; end
|
9
|
+
|
8
10
|
# Error related to handling a response
|
9
11
|
class ResponseError < StandardError; end
|
12
|
+
|
10
13
|
# Error related to setup of test automation suite
|
11
14
|
class SetupError < Error; end
|
15
|
+
|
12
16
|
# Error related to Test Users
|
13
17
|
class UserError < Error; end
|
14
18
|
end
|
@@ -27,8 +27,8 @@ class String
|
|
27
27
|
def to_ruby_friendly
|
28
28
|
tr('&|=', '_').gsub('<', '_lt_').gsub('>', '_gt_')
|
29
29
|
.remove_macrons
|
30
|
-
.gsub(
|
31
|
-
.gsub(
|
30
|
+
.gsub(/\s+/, '_')
|
31
|
+
.gsub(/\W/, '') # Remove any other special characters
|
32
32
|
.handle_initial_characters # Previous step could have removed all characters
|
33
33
|
.humanize_numbered_string
|
34
34
|
end
|
@@ -23,7 +23,7 @@ module LeapSalesforce
|
|
23
23
|
when 'boolean' then set('true')
|
24
24
|
when 'picklist' then set("#{class_name}::#{field['label'].to_class_name}.sample")
|
25
25
|
when 'reference'
|
26
|
-
return set(
|
26
|
+
return set(%{User.find(CreatedDate: "<#{0.days.ago}").id}) if field['name'] == 'OwnerId'
|
27
27
|
|
28
28
|
soql_obj = LeapSalesforce.soql_objects.find { |so| so.backend_name == field['relationshipName'] }&.reference
|
29
29
|
if soql_obj
|
@@ -34,8 +34,8 @@ module LeapSalesforce
|
|
34
34
|
def verify_oauth
|
35
35
|
unless LeapSalesforce.sfdx
|
36
36
|
LeapSalesforce.client_id = options[:client_id] || input_for('Client id (Customer Id)')
|
37
|
-
LeapSalesforce.client_secret = options[:client_secret] ||
|
38
|
-
LeapSalesforce.password = options[:password] ||
|
37
|
+
LeapSalesforce.client_secret = options[:client_secret] || $stdin.getpass('Client secret (Consumer Secret)')
|
38
|
+
LeapSalesforce.password = options[:password] || $stdin.getpass('Password (Recommendation is that 1 password' \
|
39
39
|
' be shared across all test users to be easier to manage):')
|
40
40
|
end
|
41
41
|
LeapSalesforce.api_user = ERB.new(options[:username] || input_for('Salesforce username. It is ideal to start with a System admin' \
|
@@ -17,7 +17,7 @@ module LeapSalesforce
|
|
17
17
|
@client_secret = ENV['client_secret']
|
18
18
|
@password = ENV['password']
|
19
19
|
@environment = nil
|
20
|
-
@logger = Logger.new
|
20
|
+
@logger = Logger.new $stdout
|
21
21
|
@sfdx = false
|
22
22
|
# @access_token = nil
|
23
23
|
@instance_url = nil
|
@@ -98,7 +98,7 @@ module LeapSalesforce
|
|
98
98
|
else
|
99
99
|
LeapSalesforce::Users.where(user)&.username
|
100
100
|
end
|
101
|
-
Soaspec::SpecLogger.info "Using user '#{@api_user}'"
|
101
|
+
Soaspec::SpecLogger.info "Using user '#{@api_user}' for API"
|
102
102
|
end
|
103
103
|
|
104
104
|
# @return [String] Salesforce username used to execute API tests. This can be changed during tests
|
@@ -128,6 +128,7 @@ module LeapSalesforce
|
|
128
128
|
attr_reader :soql_objects
|
129
129
|
# @return [Logger] Logger used by LeapSalesforce
|
130
130
|
attr_accessor :logger
|
131
|
+
|
131
132
|
# @return [Array] list_of_soql_objects Array describing Soql objects taken from .leap_salesforce.yml
|
132
133
|
def soql_objects=(list_of_soql_objects)
|
133
134
|
@soql_objects = list_of_soql_objects.collect do |soql_object_desc|
|
@@ -72,13 +72,13 @@ module SoqlGlobalObjectData
|
|
72
72
|
# @param [Hash] lookup Key value pair unique to Salesforce to query for
|
73
73
|
# @yield [id] Perform block for each id returned. The 'id' parameter in a block represents an id matching the query
|
74
74
|
# @return [Array] List of ids matching criteria. Only used if no block given
|
75
|
-
def ids_where(lookup = {})
|
75
|
+
def ids_where(lookup = {}, &block)
|
76
76
|
lookup[:limit] ||= nil # Don't limit results returned
|
77
77
|
SoqlHandler.new("Each Id where #{self}").use
|
78
78
|
results = soql.query soql.soql_id(lookup), wait: false
|
79
79
|
ids = results.ids
|
80
80
|
if block_given?
|
81
|
-
ids.each
|
81
|
+
ids.each(&block)
|
82
82
|
else
|
83
83
|
ids
|
84
84
|
end
|
@@ -98,4 +98,27 @@ module SoqlObjectDescribe
|
|
98
98
|
def field_names
|
99
99
|
fields.collect { |field| field['name'] }
|
100
100
|
end
|
101
|
+
|
102
|
+
# @return [Hash] List of accessors for an object and what they relate to
|
103
|
+
def accessors
|
104
|
+
return @attr_hash if @attr_hash
|
105
|
+
|
106
|
+
@attr_hash = {}
|
107
|
+
fields.each do |field|
|
108
|
+
@attr_hash[field['label'].unused_ruby_name.to_sym] = important_attributes_for(field)
|
109
|
+
end
|
110
|
+
@attr_hash
|
111
|
+
end
|
112
|
+
|
113
|
+
private
|
114
|
+
|
115
|
+
# @return [Hash] Important attributes for a field
|
116
|
+
def important_attributes_for(field)
|
117
|
+
important_attributes = { backend: field['name'],
|
118
|
+
label: field['label'],
|
119
|
+
type: field['type'] }
|
120
|
+
relationship_name = field['relationshipName']
|
121
|
+
important_attributes[:related_object] = relationship_name if relationship_name
|
122
|
+
important_attributes
|
123
|
+
end
|
101
124
|
end
|
@@ -85,11 +85,9 @@ module LeapSalesforce
|
|
85
85
|
private
|
86
86
|
|
87
87
|
# Execute block as admin user, raising error if User class is not defined
|
88
|
-
def admin_query_user
|
88
|
+
def admin_query_user(&block)
|
89
89
|
if defined? ::User
|
90
|
-
Users.execute_as_if_present key: :admin
|
91
|
-
yield
|
92
|
-
end
|
90
|
+
Users.execute_as_if_present key: :admin, &block
|
93
91
|
else
|
94
92
|
raise LeapSalesforce::SetupError, "'User' class must be defined " \
|
95
93
|
" to check presence of user in environment #{LeapSalesforce.environment}"
|
@@ -60,11 +60,11 @@ module LeapSalesforce
|
|
60
60
|
alias [] where
|
61
61
|
|
62
62
|
# Iterate through each user, narrowing on filter if provided
|
63
|
-
def each(filter = nil)
|
63
|
+
def each(filter = nil, &block)
|
64
64
|
if filter
|
65
|
-
where({**filter, all: true}).each
|
65
|
+
where({ **filter, all: true }).each(&block)
|
66
66
|
else
|
67
|
-
list.each
|
67
|
+
list.each(&block)
|
68
68
|
end
|
69
69
|
end
|
70
70
|
|
@@ -92,11 +92,11 @@ module LeapSalesforce
|
|
92
92
|
# Execute block as user matching filter if that user is present
|
93
93
|
# If user is not present the current user will be used
|
94
94
|
# @return [Object] Result of block
|
95
|
-
def execute_as_if_present(user_filter)
|
95
|
+
def execute_as_if_present(user_filter, &block)
|
96
96
|
raise ArgumentError, 'Pass block to :execute_as_if_present method' unless block_given?
|
97
97
|
|
98
98
|
if any? user_filter
|
99
|
-
execute_as(user_filter)
|
99
|
+
execute_as(user_filter, &block)
|
100
100
|
else
|
101
101
|
LeapSalesforce.logger.warn "No user found user filter #{user_filter}, using '#{LeapSalesforce.api_user}'"
|
102
102
|
yield
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leap_salesforce
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- IQA
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-01-
|
12
|
+
date: 2021-01-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|