zendesk_apps_support 1.1.1 → 1.1.2

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.
@@ -19,6 +19,8 @@ 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
+ missing_translation_file: ! 'Missing translation file for locale ''%{defaultLocale}''.
23
+ Please read: http://developer.zendesk.com/documentation/apps/i18n.html'
22
24
  invalid_location:
23
25
  one: ! '%{invalid_locations} in an invalid location.'
24
26
  other: ! '%{invalid_locations} are invalid locations.'
@@ -43,6 +43,10 @@ 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.missing_translation_file"
48
+ title: "App builder job: missing translation file"
49
+ value: "Missing translation file for locale '%{defaultLocale}'. Please read: http://developer.zendesk.com/documentation/apps/i18n.html"
46
50
  - translation:
47
51
  key: "txt.apps.admin.error.app_build.invalid_location.one"
48
52
  title: "App builder job: invalid locations"
@@ -5,25 +5,25 @@ 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 new_ticket_sidebar ).freeze
8
+ LOCATIONS_AVAILABLE = %w( nav_bar ticket_sidebar new_ticket_sidebar ).freeze
9
9
 
10
10
  class <<self
11
11
  def call(package)
12
12
  manifest = package.files.find { |f| f.relative_path == 'manifest.json' }
13
13
 
14
- return [ ValidationError.new(:missing_manifest) ] unless manifest
14
+ return [ValidationError.new(:missing_manifest)] unless manifest
15
15
 
16
16
  manifest = MultiJson.load(manifest.read)
17
17
 
18
18
  [].tap do |errors|
19
19
  errors << missing_keys_error(manifest)
20
- errors << default_locale_error(manifest)
20
+ errors << default_locale_error(manifest, package)
21
21
  errors << invalid_location_error(manifest)
22
22
  errors << invalid_hidden_parameter_error(manifest)
23
23
  errors.compact!
24
24
  end
25
25
  rescue MultiJson::DecodeError => e
26
- return [ ValidationError.new(:manifest_not_json, :errors => e) ]
26
+ return [ValidationError.new(:manifest_not_json, :errors => e)]
27
27
  end
28
28
 
29
29
  private
@@ -38,10 +38,14 @@ module ZendeskAppsSupport
38
38
  end
39
39
  end
40
40
 
41
- def default_locale_error(manifest)
41
+ def default_locale_error(manifest, package)
42
42
  default_locale = manifest['defaultLocale']
43
- if !default_locale.nil? && default_locale !~ /^[a-z]{2,3}$/
44
- ValidationError.new(:invalid_default_locale, :defaultLocale => default_locale)
43
+ if !default_locale.nil?
44
+ if default_locale !~ /^[a-z]{2,3}$/
45
+ ValidationError.new(:invalid_default_locale, :defaultLocale => default_locale)
46
+ elsif package.translation_files.detect { |file| file.relative_path == "translations/#{default_locale}.json" }.nil?
47
+ ValidationError.new(:missing_translation_file, :defaultLocale => default_locale)
48
+ end
45
49
  end
46
50
  end
47
51
 
@@ -29,6 +29,17 @@ 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 translation file is missing for the defaultLocale' do
33
+ manifest = { 'defaultLocale' => 'pt' }
34
+ manifest_file = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(manifest))
35
+ translation_files = mock('AppFile', :relative_path => 'translations/en.json')
36
+ package = mock('Package', :files => [manifest_file], :translation_files => [translation_files])
37
+ errors = ZendeskAppsSupport::Validations::Manifest.call(package)
38
+
39
+ locale_error = errors.find { |e| e.to_s =~ /Missing translation file/ }
40
+ locale_error.should_not be_nil
41
+ end
42
+
32
43
  it 'should have an error when the location is invalid' do
33
44
  manifest = { 'location' => ['ticket_sidebar', 'a_invalid_location'] }
34
45
  manifest_file = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(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.1.1
4
+ version: 1.1.2
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-11 00:00:00.000000000 Z
14
+ date: 2013-04-15 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: i18n