leap_salesforce 0.2.19 → 0.2.20

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 860e70700f38ef5c8d3d91d818f62133a6c510cc938c08a5d7a88b612b362c52
4
- data.tar.gz: 06e4e60b1c79e909cd3664f8130b4d060712e11e9d68a92b9e69f6eff691dc4a
3
+ metadata.gz: 0c70dd0657bbf1cffadbb3c53fd9e85e8076de8a6470aef5dee1a394951a7412
4
+ data.tar.gz: a3377b6b50bd1c867bcb682899406ac841ab541e6ff639b3a5af0b13a98acf40
5
5
  SHA512:
6
- metadata.gz: edccc57873db055416189cbbad1f68351e861e63d5cb754822b2192591149948a44334d2340f6f70e65b76dfa0a9ffdf7b9abc9ba9ff1f508785aefc1fd04055
7
- data.tar.gz: e16efec11ca65a52f3015fe32bad973aa40a102d39ad57068234f0820c6de78047ee3651b440a3a4e2ad1da19be0882e58acb5ac3def8f63c23b49d4465ec34b
6
+ metadata.gz: c8dc0a944ece51f830a5d0e233454e4469236f1c76615632ab84d51c8a306bfcb4728a5e717f5b6f8569c8162edadcd92d3abfb3f9a65c78b2c8d0b863203c53
7
+ data.tar.gz: 2c62bf82d52a138b673bddad8a99745d508939b1972df37769006c1a855b962361e1aa03569fad0c2253a1362226f2a159e48dd51f13156e2754affa10237f3a
data/.gitlab-ci.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  include:
2
2
  - template: Code-Quality.gitlab-ci.yml
3
+ - template: Dependency-Scanning.gitlab-ci.yml
3
4
 
4
5
  image: ruby:2.6
5
6
 
@@ -8,12 +9,48 @@ stages:
8
9
  - deploy
9
10
 
10
11
  variables:
12
+ LICENSE_MANAGEMENT_SETUP_CMD: bundle install
11
13
  password: $password
12
14
  client_id: $client_id
13
15
  client_secret: $client_secret
14
16
  SERVER_KEY_PASSWORD: $SERVER_KEY_PASSWORD
15
17
  LANG: 'UTF-8'
16
18
 
19
+ test:
20
+ stage: test
21
+ script:
22
+ # Decrypt server key
23
+ - openssl aes-256-cbc -d -md md5 -in assets/server.key.enc -out assets/server.key -k $SERVER_KEY_PASSWORD
24
+ - ls -la assets
25
+ - install_jq
26
+ - install_salesforce_cli
27
+ # Integrated test
28
+ - ruby -v
29
+ - which ruby
30
+ - gem install bundler rake
31
+ - bundle install
32
+ - sfdx force:auth:jwt:grant --clientid "$SF_CONSUMER_KEY" --jwtkeyfile assets/server.key --username "$SF_USERNAME" --setdefaultdevhubusername --setalias HubOrg
33
+ - bundle exec rake check_oauth # Check OAuth
34
+ - bundle exec rake leaps:create_soql_objects
35
+ - bundle exec rake leaps:create_enums
36
+ - bundle exec rake
37
+ artifacts:
38
+ paths:
39
+ - coverage/
40
+
41
+ pages:
42
+ stage: deploy
43
+ dependencies:
44
+ - test
45
+ script:
46
+ - mv coverage/ public
47
+ artifacts:
48
+ paths:
49
+ - public
50
+ expire_in: 30 days
51
+ only:
52
+ - master
53
+
17
54
  .sfdx_helpers: &sfdx_helpers |
18
55
 
19
56
  # Function to install the Salesforce CLI.
@@ -586,39 +623,5 @@ variables:
586
623
  done
587
624
  }
588
625
 
589
- test:
590
- stage: test
591
- script:
592
- - *sfdx_helpers
593
- # Decrypt server key
594
- - openssl aes-256-cbc -d -md md5 -in assets/server.key.enc -out assets/server.key -k $SERVER_KEY_PASSWORD
595
- - ls -la assets
596
- # Install jq
597
- - apt update && apt -y install jq
598
- - install_salesforce_cli
599
- # Integrated test
600
- - ruby -v
601
- - which ruby
602
- - gem install bundler rake
603
- - bundle install
604
- - sfdx force:auth:jwt:grant --clientid "$SF_CONSUMER_KEY" --jwtkeyfile assets/server.key --username "$SF_USERNAME" --setdefaultdevhubusername --setalias HubOrg
605
- - bundle exec rake check_oauth
606
- - bundle exec rake leaps:create_soql_objects
607
- - bundle exec rake leaps:create_enums
608
- - bundle exec rake
609
- artifacts:
610
- paths:
611
- - coverage/
612
-
613
- pages:
614
- stage: deploy
615
- dependencies:
616
- - test
617
- script:
618
- - mv coverage/ public
619
- artifacts:
620
- paths:
621
- - public
622
- expire_in: 30 days
623
- only:
624
- - master
626
+ before_script:
627
+ - *sfdx_helpers
data/ChangeLog CHANGED
@@ -1,3 +1,7 @@
1
+ Version 0.2.20
2
+ * Enhancement
3
+ * Make it easier to get any record from a table
4
+
1
5
  Version 0.2.19
2
6
  * Enhancement
3
7
  * Where suburl is passed into SoqlData, take part from 'sobjects' onwards to make using a path obtained from
data/README.md CHANGED
@@ -5,9 +5,6 @@ from Salesforce and creates the foundation for API tests.
5
5
 
6
6
  In the future it will also planned to be used to create page objects based on metadata to support UI testing.
7
7
 
8
- [![Build Status](https://gitlab.com/leap-dojo/leap_salesforce/badges/master/build.svg)](https://gitlab.com/leap-dojo/leap_salesforce/pipelines)
9
- [![Coverage](https://gitlab.com/leap-dojo/leap_salesforce/badges/master/coverage.svg)](https://leap-dojo.gitlab.io/leap_salesforce)
10
-
11
8
  ## Is this for you?
12
9
 
13
10
  This `gem` is an open source library aimed at making integrated test automation
@@ -6,19 +6,27 @@ module LeapSalesforce
6
6
  # @return [String] Location of leap_salesforce YAML file
7
7
  LEAP_CONFIG_FILE = '.leap_salesforce.yml'
8
8
  class << self
9
+ # Set LeapSalesforce property if it exists
10
+ def set_leaps_property(key, value)
11
+ if LeapSalesforce.respond_to? "#{key}="
12
+ if %w[SF_CONSUMER_KEY client_id client_secret password].include? key
13
+ LeapSalesforce.logger.warn "Secret key '#{key}' should be in non version" \
14
+ " controlled #{LeapSalesforce::CREDENTIAL_FILE} not in #{LEAP_CONFIG_FILE}"
15
+ end
16
+ LeapSalesforce.send("#{key}=", value)
17
+ else
18
+ LeapSalesforce.logger.warn "No property for '#{key}' from '#{LEAP_CONFIG_FILE}'"
19
+ end
20
+ end
21
+
22
+ # Load configuration file and set properties based on it
9
23
  def load_config_file
10
24
  if File.exist? LEAP_CONFIG_FILE
11
25
  leap_config = YAML.load_file LEAP_CONFIG_FILE
12
26
  LeapSalesforce.soql_objects = leap_config.delete('soql_objects')
13
- leap_config.each do |key, value|
14
- if %w[SF_CONSUMER_KEY client_id client_secret password].include? key
15
- LeapSalesforce.logger.warn "Secret key '#{key}' should be in non version" \
16
- " controlled #{LeapSalesforce::CREDENTIAL_FILE} not in #{LEAP_CONFIG_FILE}"
17
- end
18
- LeapSalesforce.send("#{key}=", value)
19
- end
27
+ leap_config.each { |key, value| set_leaps_property(key, value) }
20
28
  else
21
- LeapSalesforce.logger.warn "No config file found at #{LEAP_CONFIG_FILE} for Leap Salesforce"
29
+ LeapSalesforce.logger.warn "No config file found at '#{LEAP_CONFIG_FILE}' for Leap Salesforce"
22
30
  end
23
31
  end
24
32
  end
@@ -18,6 +18,8 @@ module SoqlGlobalObjectData
18
18
 
19
19
  # Find the data for a single SoqlObject using the calling class's table.
20
20
  # Will get the latest created date.
21
+ # @example Get any contact
22
+ # Contact.find
21
23
  # @example Get a contact where LastName is 'Bob' using backend name
22
24
  # Contact.find(LastName: 'Bob')
23
25
  # @example Get a contact that includes 'Test' in their first name (using ruby accessor name)
@@ -27,7 +29,7 @@ module SoqlGlobalObjectData
27
29
  # @param [Hash] lookup Key value pair unique to Salesforce to query for
28
30
  # @option lookup [Boolean] :teardown Whether to remove id after scenario finished
29
31
  # @return [< SoqlData] Instance of itself storing reference to found object
30
- def find(lookup)
32
+ def find(lookup = {})
31
33
  id_lookup = soql.lookup_id lookup
32
34
  lookup.key?(:Id) ? id_lookup : soql.data_from_url(id_lookup['$..url'], lookup)
33
35
  end
@@ -53,7 +55,7 @@ module SoqlGlobalObjectData
53
55
  end
54
56
 
55
57
  # @return [Boolean] Whether any result for lookup
56
- def any?(lookup)
58
+ def any?(lookup = {})
57
59
  soql.lookup_id(lookup)[:totalSize] != 0
58
60
  end
59
61
 
@@ -64,7 +66,7 @@ module SoqlGlobalObjectData
64
66
  # @param [Hash] lookup Key value pair unique to Salesforce to query for
65
67
  # @yield [id] Perform block for each id returned. The 'id' parameter in a block represents an id matching the query
66
68
  # @return [Array] List of ids matching criteria. Only used if no block given
67
- def ids_where(lookup)
69
+ def ids_where(lookup = {})
68
70
  lookup[:limit] ||= nil # Don't limit results returned
69
71
  SoqlHandler.new("Each Id where #{self}").use
70
72
  results = soql.query soql.soql_id(lookup), wait: false
@@ -87,6 +89,13 @@ module SoqlGlobalObjectData
87
89
 
88
90
  alias each_with where
89
91
 
92
+ # Return list of objects (matching criteria if passed)
93
+ # @param [Hash] lookup Key value pair unique to Salesforce to query for. Leave empty for all
94
+ # @return [Array] List of all soql objects
95
+ def list(lookup = {})
96
+ where(lookup)
97
+ end
98
+
90
99
  # Remove all ids from table that match lookup criteria
91
100
  # @param [Hash] lookup Key value pair unique to Salesforce to query for
92
101
  def delete_ids_with(lookup)
@@ -41,6 +41,8 @@ module LeapSalesforce
41
41
  # @return [String] Username of User interpreted by ERB (in email address format).
42
42
  # Use ERB to define users that can vary according to environment
43
43
  def username
44
+ raise LeapSalesforce::SetupError, "User #{inspect} has no username" if @username.nil? || @username.empty?
45
+
44
46
  ERB.new(@username).result(binding)
45
47
  end
46
48
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module LeapSalesforce
4
4
  # @return [String] Version of leap salesforce
5
- VERSION = '0.2.19'
5
+ VERSION = '0.2.20'
6
6
  end
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: 0.2.19
4
+ version: 0.2.20
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: 2020-01-05 00:00:00.000000000 Z
12
+ date: 2020-01-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler