zendesk_apps_support 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
data/config/locales/en.yml
CHANGED
@@ -27,6 +27,7 @@ en:
|
|
27
27
|
invalid_hidden_parameter:
|
28
28
|
one: ! '%{invalid_params} is set to hidden and cannot be required.'
|
29
29
|
other: ! '%{invalid_params} are set to hidden and cannot be required.'
|
30
|
+
parameters_not_an_array: App Parameters must be an array.
|
30
31
|
translation:
|
31
32
|
invalid_locale: ! '%{file} is not a valid locale. Only two- and three-letter
|
32
33
|
ISO 639 language codes are allowed.'
|
@@ -63,6 +63,10 @@ parts:
|
|
63
63
|
key: "txt.apps.admin.error.app_build.invalid_hidden_parameter.other"
|
64
64
|
title: "App builder job: hidden parameters set to required"
|
65
65
|
value: "%{invalid_params} are set to hidden and cannot be required."
|
66
|
+
- translation:
|
67
|
+
key: "txt.apps.admin.error.app_build.parameters_not_an_array"
|
68
|
+
title: "App builder job: app parameters must be an array"
|
69
|
+
value: "App parameters must be an array."
|
66
70
|
- translation:
|
67
71
|
key: "txt.apps.admin.error.app_build.translation.invalid_locale"
|
68
72
|
title: "App builder job: invalid locale file name"
|
@@ -19,6 +19,7 @@ module ZendeskAppsSupport
|
|
19
19
|
errors << missing_keys_error(manifest)
|
20
20
|
errors << default_locale_error(manifest, package)
|
21
21
|
errors << invalid_location_error(manifest)
|
22
|
+
errors << parameters_must_be_an_array(manifest)
|
22
23
|
errors << invalid_hidden_parameter_error(manifest)
|
23
24
|
errors.compact!
|
24
25
|
end
|
@@ -28,6 +29,14 @@ module ZendeskAppsSupport
|
|
28
29
|
|
29
30
|
private
|
30
31
|
|
32
|
+
def parameters_must_be_an_array(manifest)
|
33
|
+
return unless manifest['parameters']
|
34
|
+
|
35
|
+
unless manifest['parameters'].kind_of?(Array)
|
36
|
+
ValidationError.new(:parameters_not_an_array)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
31
40
|
def missing_keys_error(manifest)
|
32
41
|
missing = REQUIRED_MANIFEST_FIELDS.select do |key|
|
33
42
|
manifest[key].nil?
|
@@ -3,6 +3,15 @@ require 'json'
|
|
3
3
|
|
4
4
|
describe ZendeskAppsSupport::Validations::Manifest do
|
5
5
|
|
6
|
+
def default_required_params(overrides = {})
|
7
|
+
valid_fields = ZendeskAppsSupport::Validations::Manifest::REQUIRED_MANIFEST_FIELDS.inject({}) do |fields, name|
|
8
|
+
fields[name] = name
|
9
|
+
fields
|
10
|
+
end
|
11
|
+
|
12
|
+
valid_fields.merge(overrides)
|
13
|
+
end
|
14
|
+
|
6
15
|
it 'should have an error when manifest.json is missing' do
|
7
16
|
files = [mock('AppFile', :relative_path => 'abc.json')]
|
8
17
|
package = mock('Package', :files => files)
|
@@ -74,4 +83,52 @@ describe ZendeskAppsSupport::Validations::Manifest do
|
|
74
83
|
|
75
84
|
errors.first().to_s.should =~ /^manifest is not proper JSON/
|
76
85
|
end
|
86
|
+
|
87
|
+
context 'with invalid parameter type' do
|
88
|
+
|
89
|
+
before do
|
90
|
+
ZendeskAppsSupport::Validations::Manifest.stub(:default_locale_error)
|
91
|
+
ZendeskAppsSupport::Validations::Manifest.stub(:invalid_location_error)
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'has an error when the app parameters are not an array' do
|
95
|
+
parameter_hash = {
|
96
|
+
'parameters' => {
|
97
|
+
'name' => 'a parameter',
|
98
|
+
'type' => 'string'
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
params = default_required_params(parameter_hash)
|
103
|
+
manifest = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(params))
|
104
|
+
package = mock('Package', :files => [manifest])
|
105
|
+
|
106
|
+
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
107
|
+
errors.map(&:to_s).should == ['App Parameters must be an array.']
|
108
|
+
end
|
109
|
+
|
110
|
+
it "doesn't have an error with an array of app parameters" do
|
111
|
+
parameter_hash = {
|
112
|
+
'parameters' => [{
|
113
|
+
'name' => 'a parameter',
|
114
|
+
'type' => 'string'
|
115
|
+
}]
|
116
|
+
}
|
117
|
+
|
118
|
+
params = default_required_params(parameter_hash)
|
119
|
+
manifest = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(params))
|
120
|
+
package = mock('Package', :files => [manifest])
|
121
|
+
|
122
|
+
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
123
|
+
errors.should be_empty
|
124
|
+
end
|
125
|
+
|
126
|
+
it 'behaves when the manifest does not have parameters' do
|
127
|
+
manifest = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(default_required_params))
|
128
|
+
package = mock('Package', :files => [manifest])
|
129
|
+
|
130
|
+
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
131
|
+
errors.should be_empty
|
132
|
+
end
|
133
|
+
end
|
77
134
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zendesk_apps_support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-04-
|
14
|
+
date: 2013-04-22 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: i18n
|