lhs 16.1.4 → 16.1.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4d0c9693012ec5fe38601976c89443114654f6a59de9a875c5a713ae2e01b0c
4
- data.tar.gz: c23ed566bdfc10840fc0dfd7e0be0b8475a558669424f44e081da7ed3c38fbc6
3
+ metadata.gz: 4a37f6839d542b64f7985aa457544f300c36802a812d5b313a33ae3d35f9fd99
4
+ data.tar.gz: 4c00a48d6d2810e18237f36d80aedafb57af16fe04ab5204a6025b747e32bdf0
5
5
  SHA512:
6
- metadata.gz: d67775a51aac4da7cd8024932b7f03b521277f6128bab375673ff464bbd300a294d06c9fc6ef8b6f599f519f2aab92552aefa4bf58497ef22462df3778800d09
7
- data.tar.gz: b4f7cc36403f8fcfbdb93864f231a40949b74946e1a26a0632fba8d1ccce3a25265093d81ea2ba02840b5ac87d9f15e12376921232ddd2c44d9b33bc28744d8a
6
+ metadata.gz: d31442efdfaf1e8d9be0134346baf24c3a5d9808dc965a21c9ef76ba63da572df53069c04277330a9b35013fc0ba876ad3c15337327ac19ee8e54422d4cab93a
7
+ data.tar.gz: 0ea81e97b307717fee4200e8fbe521dc6df685f4c1f31c9aab9b5a07d1861f364d760044a7f2eb2b8a37670e3ef09e1bb53a9d66a86c435b6d27dff07b92d243
data/README.md CHANGED
@@ -1709,6 +1709,9 @@ lhs.errors.attributes.<attribute_name>.<error_code>
1709
1709
  e.g. lhs.errors.attributes.name.unsupported_property_value
1710
1710
 
1711
1711
  lhs.errors.fallback_message
1712
+
1713
+ lhs.errors.records.<record_name>.attributes.<collection>.<attribute_name>.<error_code>
1714
+ e.g. lhs.errors.records.appointment_proposal.attributes.appointments.date_time.date_property_not_in_future
1712
1715
  ```
1713
1716
 
1714
1717
  ##### Validation error types: errors vs. warnings
@@ -8,6 +8,10 @@ if [ ! -f ~/.rubies/$RUBY/bin/bundle ]; then
8
8
  gem install bundler
9
9
  fi
10
10
 
11
+ # install bundler v. 1.17.3 in order to be able to run the tests with
12
+ # ACTIVESUPPORT=4 because rails (= 4.2.0) depends on bundler (< 2.0, >= 1.3.0)
13
+ gem install bundler:1.17.3
14
+
11
15
  sed "s/^source 'https:\/\/rubygems\.intra\.local\.ch'*/source 'http\:\/\/52.29.7.59:9292'/g" Gemfile > Gemfile.tmp
12
16
  mv Gemfile.tmp Gemfile
13
17
 
@@ -29,9 +33,14 @@ CACHE_SIGNATURE_FILE="/tmp/bundle_cache_signature_${DIGEST}"
29
33
 
30
34
  if [ ! -f $CACHE_SIGNATURE_FILE ] ; then
31
35
  if [ ! -z ${ACTIVESUPPORT:-} ]; then
32
- echo "BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle install"
33
- BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle install
34
- else
36
+ if [ ! -z ${BUNDLER:-} ]; then
37
+ echo "BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle $BUNDLER install"
38
+ BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle $BUNDLER install
39
+ else
40
+ echo "BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle install"
41
+ BUNDLE_GEMFILE=Gemfile.activesupport$ACTIVESUPPORT bundle install
42
+ fi
43
+ else
35
44
  echo "bundle install"
36
45
  bundle install
37
46
  fi
@@ -14,6 +14,7 @@ rspec-active-support-v4:
14
14
  task_defaults:
15
15
  environment_variables:
16
16
  ACTIVESUPPORT: '4'
17
+ BUNDLER: '_1.17.3_'
17
18
  max_trials: 2
18
19
  dispatch_storm_delay_duration: 1 Seconds
19
20
  include:
@@ -86,7 +86,7 @@ module LHS::Problems
86
86
  end
87
87
 
88
88
  def find_translated_message(attribute, message, problem_type)
89
- normalized_attribute = attribute.to_s.underscore
89
+ normalized_attribute = attribute.to_s.underscore.gsub(/\.[\d+\.]/, '')
90
90
  normalized_message = message.to_s.underscore
91
91
  messages = []
92
92
  messages = messages_for_record(normalized_attribute, normalized_message, problem_type) if record
@@ -1,3 +1,3 @@
1
1
  module LHS
2
- VERSION = '16.1.4'
2
+ VERSION = '16.1.5'
3
3
  end
@@ -194,4 +194,62 @@ describe LHS::Item do
194
194
  expect(errors[:name]).to eq ['UNSUPPORTED_PROPERTY_VALUE']
195
195
  end
196
196
  end
197
+
198
+ context 'error translation for nested record' do
199
+ before do
200
+ class AppointmentProposal < LHS::Record
201
+ endpoint 'http://dataste/appointment_proposals'
202
+ endpoint 'http://dataste/appointment_proposals/{id}'
203
+
204
+ has_many :appointments
205
+ end
206
+
207
+ class Appointment < LHS::Record
208
+ end
209
+
210
+ stub_request(:get, 'http://dataste/appointment_proposals/1')
211
+ .to_return(body: {
212
+ appointments: [
213
+ { 'date_time' => '13.12.2018' },
214
+ { 'date_time' => '18.10.2028' }
215
+ ]
216
+ }.to_json)
217
+
218
+ stub_request(:post, 'http://dataste/appointment_proposals')
219
+ .to_return(
220
+ status: 400,
221
+ body: {
222
+ field_errors: [{
223
+ 'code' => 'DATE_PROPERTY_NOT_IN_FUTURE',
224
+ 'path' => ['appointments', 0, 'date_time']
225
+ }]
226
+ }.to_json
227
+ )
228
+ end
229
+
230
+ let(:translation) do
231
+ %q{
232
+ lhs:
233
+ errors:
234
+ records:
235
+ appointment_proposal:
236
+ attributes:
237
+ appointments:
238
+ date_time:
239
+ date_property_not_in_future: 'You cannot select a date in the past.'
240
+ }
241
+ end
242
+
243
+ it 'translates errors automatically when they are around' do
244
+ appointment_proposal = AppointmentProposal.find(1)
245
+ appointment_proposal.update(
246
+ 'appointments_attributes' => {
247
+ '0' => { 'date_time' => '13.12.2018' },
248
+ '1' => { 'date_time' => '18.10.2028' }
249
+ }
250
+ )
251
+ expect(appointment_proposal.appointments[0].errors[:date_time]).to eql(['You cannot select a date in the past.'])
252
+ expect(appointment_proposal.appointments[1].errors[:date_time]).to eql([])
253
+ end
254
+ end
197
255
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lhs
3
3
  version: !ruby/object:Gem::Version
4
- version: 16.1.4
4
+ version: 16.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - https://github.com/local-ch/lhs/graphs/contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-09 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel