active_interaction 3.1.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +1 -1
- data/lib/active_interaction.rb +7 -2
- data/lib/active_interaction/concerns/runnable.rb +2 -2
- data/lib/active_interaction/locale/pt-BR.yml +23 -0
- data/lib/active_interaction/version.rb +1 -1
- data/spec/active_interaction/concerns/runnable_spec.rb +44 -4
- data/spec/active_interaction/errors_spec.rb +7 -0
- data/spec/active_interaction/i18n_spec.rb +28 -17
- data/spec/active_interaction/modules/validation_spec.rb +2 -1
- data/spec/spec_helper.rb +5 -3
- metadata +6 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9002b84bec6ce71116bd2f797632fd473e47de9
|
4
|
+
data.tar.gz: 13ec78e97adc867930f6c1c392f73e68fdc7cc15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd8360a22da901c3e60fa56d58bfb7318645ef42ebb17c7b4c32e7893e45eb37d49a33383f1f3bef3c9bf8c062be298cc3a1fba9056194994d4410fc7a49eab3
|
7
|
+
data.tar.gz: 87e22933a0e425d6af9e58d82d0248fd9db17012544a923ce423e260d04b174d55a369caea3998a422a2018d73d429039ef8c8817ab9e602963a2997ee3264c7
|
data/CONTRIBUTING.md
CHANGED
@@ -8,6 +8,6 @@
|
|
8
8
|
|
9
9
|
# Code Style
|
10
10
|
|
11
|
-
Running the tests using `rake` (with no args)
|
11
|
+
Running the tests using `rake` (with no args) will also check for style issues in the code. Ideally all submissions would pass these checks. If the code style is causing issues (particularly the method or class size) we can work with you to correct it. Don't let it stop you from contributing.
|
12
12
|
|
13
13
|
[fork]: https://github.com/orgsync/active_interaction/fork
|
data/lib/active_interaction.rb
CHANGED
@@ -50,5 +50,10 @@ require 'active_interaction/base'
|
|
50
50
|
|
51
51
|
require 'active_interaction/backports'
|
52
52
|
|
53
|
-
I18n.load_path.unshift(
|
54
|
-
|
53
|
+
I18n.load_path.unshift(
|
54
|
+
*Dir.glob(
|
55
|
+
File.expand_path(
|
56
|
+
File.join(%w[active_interaction locale *.yml]), File.dirname(__FILE__)
|
57
|
+
)
|
58
|
+
)
|
59
|
+
)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
pt-BR:
|
2
|
+
active_interaction:
|
3
|
+
errors:
|
4
|
+
messages:
|
5
|
+
invalid: é inválido
|
6
|
+
invalid_nested: possui um valor aninhado inválido (%{name} => %{value})
|
7
|
+
invalid_type: não é um(a) %{type} válido(a)
|
8
|
+
missing: é obrigatório
|
9
|
+
types:
|
10
|
+
array: array
|
11
|
+
boolean: boolean
|
12
|
+
date: date
|
13
|
+
date_time: date time
|
14
|
+
decimal: decimal
|
15
|
+
file: file
|
16
|
+
float: float
|
17
|
+
hash: hash
|
18
|
+
integer: integer
|
19
|
+
interface: interface
|
20
|
+
object: object
|
21
|
+
string: string
|
22
|
+
symbol: symbol
|
23
|
+
time: time
|
@@ -51,10 +51,7 @@ describe ActiveInteraction::Runnable do
|
|
51
51
|
it type do
|
52
52
|
has_run = false
|
53
53
|
|
54
|
-
klass.set_callback name, type,
|
55
|
-
has_run = true
|
56
|
-
block.call unless block.nil?
|
57
|
-
}
|
54
|
+
klass.set_callback name, type, -> { has_run = true }
|
58
55
|
|
59
56
|
klass.run
|
60
57
|
expect(has_run).to be_truthy
|
@@ -65,6 +62,49 @@ describe ActiveInteraction::Runnable do
|
|
65
62
|
|
66
63
|
include_examples 'set_callback examples', :validate
|
67
64
|
include_examples 'set_callback examples', :execute
|
65
|
+
|
66
|
+
context 'execute with composed interaction' do
|
67
|
+
class InnerInteraction
|
68
|
+
include ActiveInteraction::Runnable
|
69
|
+
|
70
|
+
def execute
|
71
|
+
errors.add(:base)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
class OuterInteraction
|
76
|
+
include ActiveInteraction::Runnable
|
77
|
+
|
78
|
+
def execute
|
79
|
+
compose(InnerInteraction)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'around' do
|
84
|
+
it 'is yielded errors from composed interactions' do
|
85
|
+
block_result = nil
|
86
|
+
OuterInteraction.set_callback :execute, :around do |_, block|
|
87
|
+
block_result = block.call
|
88
|
+
end
|
89
|
+
|
90
|
+
OuterInteraction.run
|
91
|
+
expect(block_result).to be_an(ActiveInteraction::Errors)
|
92
|
+
expect(block_result).to include(:base)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'after' do
|
97
|
+
it 'is yielded errors from composed interactions' do
|
98
|
+
has_run = false
|
99
|
+
OuterInteraction.set_callback :execute, :after do
|
100
|
+
has_run = true
|
101
|
+
end
|
102
|
+
|
103
|
+
OuterInteraction.run
|
104
|
+
expect(has_run).to be_truthy
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
68
108
|
end
|
69
109
|
end
|
70
110
|
|
@@ -113,6 +113,13 @@ describe ActiveInteraction::Errors do
|
|
113
113
|
it 'does not raise an error' do
|
114
114
|
expect { errors.merge!(other) }.to_not raise_error
|
115
115
|
end
|
116
|
+
|
117
|
+
it 'merges messages' do
|
118
|
+
message = SecureRandom.hex
|
119
|
+
other.add(:base, message)
|
120
|
+
errors.merge!(other)
|
121
|
+
expect(errors.messages[:base]).to include message
|
122
|
+
end
|
116
123
|
end
|
117
124
|
end
|
118
125
|
end
|
@@ -4,10 +4,9 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe ActiveInteraction do
|
6
6
|
context 'I18n.load_path' do
|
7
|
-
it 'contains localization file paths
|
8
|
-
expect(
|
9
|
-
|
10
|
-
).to match %r{active_interaction/locale/en.yml\z}
|
7
|
+
it 'contains localization file paths' do
|
8
|
+
expect(I18n.load_path)
|
9
|
+
.to include a_string_ending_with('active_interaction/locale/en.yml')
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -25,7 +24,14 @@ describe I18nInteraction do
|
|
25
24
|
.const_get(:CLASSES)
|
26
25
|
.map { |slug, _| slug.to_s }
|
27
26
|
|
28
|
-
shared_examples 'translation' do
|
27
|
+
shared_examples 'translation' do |locale|
|
28
|
+
before do
|
29
|
+
@locale = I18n.locale
|
30
|
+
I18n.locale = locale
|
31
|
+
end
|
32
|
+
|
33
|
+
after { I18n.locale = @locale }
|
34
|
+
|
29
35
|
context 'types' do
|
30
36
|
TYPES.each do |type|
|
31
37
|
it "has a translation for #{type}" do
|
@@ -61,18 +67,28 @@ describe I18nInteraction do
|
|
61
67
|
end
|
62
68
|
|
63
69
|
context 'english' do
|
64
|
-
include_examples 'translation'
|
70
|
+
include_examples 'translation', :en
|
71
|
+
end
|
65
72
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
73
|
+
context 'brazilian portuguese' do
|
74
|
+
include_examples 'translation', :'pt-BR'
|
75
|
+
end
|
70
76
|
|
71
|
-
|
77
|
+
context 'french' do
|
78
|
+
include_examples 'translation', :fr
|
72
79
|
end
|
73
80
|
|
74
81
|
context 'hsilgne' do
|
75
|
-
|
82
|
+
before do
|
83
|
+
# This must appear before including the translation examples so that the
|
84
|
+
# locale is available before it is assigned.
|
85
|
+
locale = :hsilgne
|
86
|
+
unless I18n.locale_available?(locale)
|
87
|
+
I18n.config.available_locales = I18n.config.available_locales + [locale]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
include_examples 'translation', :hsilgne
|
76
92
|
|
77
93
|
before do
|
78
94
|
I18n.backend.store_translations('hsilgne',
|
@@ -86,11 +102,6 @@ describe I18nInteraction do
|
|
86
102
|
},
|
87
103
|
types: TYPES.each_with_object({}) { |e, a| a[e] = e.reverse }
|
88
104
|
})
|
89
|
-
|
90
|
-
@locale = I18n.locale
|
91
|
-
I18n.locale = 'hsilgne'
|
92
105
|
end
|
93
|
-
|
94
|
-
after { I18n.locale = @locale }
|
95
106
|
end
|
96
107
|
end
|
@@ -47,7 +47,8 @@ describe ActiveInteraction::Validation do
|
|
47
47
|
|
48
48
|
it 'returns an :invalid_type error' do
|
49
49
|
type = I18n.translate(
|
50
|
-
"#{ActiveInteraction::Base.i18n_scope}.types.#{filter.class.slug}"
|
50
|
+
"#{ActiveInteraction::Base.i18n_scope}.types.#{filter.class.slug}"
|
51
|
+
)
|
51
52
|
|
52
53
|
expect(result).to eql [[filter.name, :invalid_type, type: type]]
|
53
54
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
# Disable code coverage for JRuby because it always reports 0% coverage.
|
4
|
+
if RUBY_ENGINE != 'jruby'
|
5
|
+
require 'coveralls'
|
6
|
+
Coveralls.wear!
|
7
|
+
end
|
5
8
|
|
6
9
|
require 'i18n'
|
7
10
|
if I18n.config.respond_to?(:enforce_available_locales)
|
8
11
|
I18n.config.enforce_available_locales = true
|
9
|
-
I18n.config.available_locales = %w[en hsilgne]
|
10
12
|
end
|
11
13
|
|
12
14
|
require 'active_interaction'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_interaction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Lasseigne
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-05-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -87,34 +87,6 @@ dependencies:
|
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '0.8'
|
90
|
-
- !ruby/object:Gem::Dependency
|
91
|
-
name: guard-rspec
|
92
|
-
requirement: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - "~>"
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '4.6'
|
97
|
-
type: :development
|
98
|
-
prerelease: false
|
99
|
-
version_requirements: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - "~>"
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '4.6'
|
104
|
-
- !ruby/object:Gem::Dependency
|
105
|
-
name: guard-rubocop
|
106
|
-
requirement: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - "~>"
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '1.2'
|
111
|
-
type: :development
|
112
|
-
prerelease: false
|
113
|
-
version_requirements: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - "~>"
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '1.2'
|
118
90
|
- !ruby/object:Gem::Dependency
|
119
91
|
name: kramdown
|
120
92
|
requirement: !ruby/object:Gem::Requirement
|
@@ -163,14 +135,14 @@ dependencies:
|
|
163
135
|
requirements:
|
164
136
|
- - "~>"
|
165
137
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
138
|
+
version: 0.40.0
|
167
139
|
type: :development
|
168
140
|
prerelease: false
|
169
141
|
version_requirements: !ruby/object:Gem::Requirement
|
170
142
|
requirements:
|
171
143
|
- - "~>"
|
172
144
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
145
|
+
version: 0.40.0
|
174
146
|
- !ruby/object:Gem::Dependency
|
175
147
|
name: yard
|
176
148
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,6 +202,7 @@ files:
|
|
230
202
|
- lib/active_interaction/grouped_input.rb
|
231
203
|
- lib/active_interaction/locale/en.yml
|
232
204
|
- lib/active_interaction/locale/fr.yml
|
205
|
+
- lib/active_interaction/locale/pt-BR.yml
|
233
206
|
- lib/active_interaction/modules/input_processor.rb
|
234
207
|
- lib/active_interaction/modules/validation.rb
|
235
208
|
- lib/active_interaction/version.rb
|
@@ -300,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
273
|
version: '0'
|
301
274
|
requirements: []
|
302
275
|
rubyforge_project:
|
303
|
-
rubygems_version: 2.6.
|
276
|
+
rubygems_version: 2.6.4
|
304
277
|
signing_key:
|
305
278
|
specification_version: 4
|
306
279
|
summary: Manage application specific business logic.
|