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 +4 -4
- data/README.md +3 -0
- data/cider-ci/bin/bundle +12 -3
- data/cider-ci/jobs/rspec-activesupport-4.yml +1 -0
- data/lib/lhs/problems/base.rb +1 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/item/translate_errors_spec.rb +58 -0
- 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: 4a37f6839d542b64f7985aa457544f300c36802a812d5b313a33ae3d35f9fd99
|
4
|
+
data.tar.gz: 4c00a48d6d2810e18237f36d80aedafb57af16fe04ab5204a6025b747e32bdf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/cider-ci/bin/bundle
CHANGED
@@ -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
|
-
|
33
|
-
|
34
|
-
|
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
|
data/lib/lhs/problems/base.rb
CHANGED
@@ -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
|
data/lib/lhs/version.rb
CHANGED
@@ -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
|
+
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-
|
11
|
+
date: 2019-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|