zendesk_apps_support 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
data/config/locales/en.yml
CHANGED
@@ -19,6 +19,12 @@ en:
|
|
19
19
|
style_in_template: <style> tag in %{template}. Use an app.css file instead.
|
20
20
|
invalid_default_locale: ! '%{defaultLocale} is not a valid default locale.
|
21
21
|
Only two- and three-letter ISO 639 language codes are allowed.'
|
22
|
+
invalid_location:
|
23
|
+
one: ! '%{invalid_locations} in an invalid location.'
|
24
|
+
other: ! '%{invalid_locations} are invalid locations.'
|
25
|
+
invalid_hidden_parameter:
|
26
|
+
one: ! '%{invalid_params} is set to hidden and cannot be required.'
|
27
|
+
other: ! '%{invalid_params} are set to hidden and cannot be required.'
|
22
28
|
translation:
|
23
29
|
invalid_locale: ! '%{file} is not a valid locale. Only two- and three-letter
|
24
30
|
ISO 639 language codes are allowed.'
|
@@ -43,6 +43,22 @@ parts:
|
|
43
43
|
key: "txt.apps.admin.error.app_build.invalid_default_locale"
|
44
44
|
title: "App builder job: invalid default locale"
|
45
45
|
value: "%{defaultLocale} is not a valid default locale. Only two- and three-letter ISO 639 language codes are allowed."
|
46
|
+
- translation:
|
47
|
+
key: "txt.apps.admin.error.app_build.invalid_location.one"
|
48
|
+
title: "App builder job: invalid locations"
|
49
|
+
value: "%{invalid_locations} in an invalid location."
|
50
|
+
- translation:
|
51
|
+
key: "txt.apps.admin.error.app_build.invalid_location.other"
|
52
|
+
title: "App builder job: invalid locations"
|
53
|
+
value: "%{invalid_locations} are invalid locations."
|
54
|
+
- translation:
|
55
|
+
key: "txt.apps.admin.error.app_build.invalid_hidden_parameter.one"
|
56
|
+
title: "App builder job: hidden parameters set to required"
|
57
|
+
value: "%{invalid_params} is set to hidden and cannot be required."
|
58
|
+
- translation:
|
59
|
+
key: "txt.apps.admin.error.app_build.invalid_hidden_parameter.other"
|
60
|
+
title: "App builder job: hidden parameters set to required"
|
61
|
+
value: "%{invalid_params} are set to hidden and cannot be required."
|
46
62
|
- translation:
|
47
63
|
key: "txt.apps.admin.error.app_build.translation.invalid_locale"
|
48
64
|
title: "App builder job: invalid locale file name"
|
@@ -5,6 +5,7 @@ module ZendeskAppsSupport
|
|
5
5
|
module Manifest
|
6
6
|
|
7
7
|
REQUIRED_MANIFEST_FIELDS = %w( author defaultLocale location frameworkVersion).freeze
|
8
|
+
LOCATIONS_AVAILABLE = %w( nav_bar ticket_sidebar ).freeze
|
8
9
|
|
9
10
|
class <<self
|
10
11
|
def call(package)
|
@@ -17,6 +18,8 @@ module ZendeskAppsSupport
|
|
17
18
|
[].tap do |errors|
|
18
19
|
errors << missing_keys_error(manifest)
|
19
20
|
errors << default_locale_error(manifest)
|
21
|
+
errors << invalid_location_error(manifest)
|
22
|
+
errors << invalid_hidden_parameter_error(manifest)
|
20
23
|
errors.compact!
|
21
24
|
end
|
22
25
|
rescue MultiJson::DecodeError => e
|
@@ -42,6 +45,25 @@ module ZendeskAppsSupport
|
|
42
45
|
end
|
43
46
|
end
|
44
47
|
|
48
|
+
def invalid_location_error(manifest)
|
49
|
+
invalid_locations = [*manifest['location']] - LOCATIONS_AVAILABLE
|
50
|
+
unless invalid_locations.empty?
|
51
|
+
ValidationError.new(:invalid_location, :invalid_locations => invalid_locations.join(', '), :count => invalid_locations.length)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def invalid_hidden_parameter_error(manifest)
|
56
|
+
invalid_params = []
|
57
|
+
|
58
|
+
if manifest.has_key?('parameters')
|
59
|
+
invalid_params = manifest['parameters'].select { |p| p['type'] == 'hidden' && p['required'] }.map { |p| p['name'] }
|
60
|
+
end
|
61
|
+
|
62
|
+
if invalid_params.any?
|
63
|
+
ValidationError.new(:invalid_hidden_parameter, :invalid_params => invalid_params.join(', '), :count => invalid_params.length)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
45
67
|
end
|
46
68
|
end
|
47
69
|
end
|
@@ -29,6 +29,33 @@ describe ZendeskAppsSupport::Validations::Manifest do
|
|
29
29
|
locale_error.should_not be_nil
|
30
30
|
end
|
31
31
|
|
32
|
+
it 'should have an error when the location is invalid' do
|
33
|
+
manifest = { 'location' => ['ticket_sidebar', 'a_invalid_location'] }
|
34
|
+
manifest_file = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(manifest))
|
35
|
+
package = mock('Package', :files => [manifest_file])
|
36
|
+
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
37
|
+
|
38
|
+
locations_error = errors.find { |e| e.to_s =~ /invalid location/ }
|
39
|
+
locations_error.should_not be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should have an error when a hidden parameter is set to required' do
|
43
|
+
manifest = {
|
44
|
+
'parameters' => [
|
45
|
+
'name' => 'a parameter',
|
46
|
+
'type' => 'hidden',
|
47
|
+
'required' => true
|
48
|
+
]
|
49
|
+
}
|
50
|
+
|
51
|
+
manifest_file = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(manifest))
|
52
|
+
package = mock('Package', :files => [manifest_file])
|
53
|
+
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
54
|
+
|
55
|
+
hidden_params_error = errors.find { |e| e.to_s =~ /set to hidden and cannot be required/ }
|
56
|
+
hidden_params_error.should_not be_nil
|
57
|
+
end
|
58
|
+
|
32
59
|
it 'should have an error when manifest is not a valid json' do
|
33
60
|
manifest = mock('AppFile', :relative_path => 'manifest.json', :read => "}")
|
34
61
|
package = mock('Package', :files => [manifest])
|
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.0
|
4
|
+
version: 1.1.0
|
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-
|
14
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: i18n
|
@@ -189,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
189
189
|
version: 1.3.6
|
190
190
|
requirements: []
|
191
191
|
rubyforge_project:
|
192
|
-
rubygems_version: 1.8.
|
192
|
+
rubygems_version: 1.8.25
|
193
193
|
signing_key:
|
194
194
|
specification_version: 3
|
195
195
|
summary: Support to help you develop Zendesk Apps.
|