zendesk_apps_support 1.13.1 → 1.13.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2865d2a5904f7c81d33e611b0e81577782e8c7b1
4
- data.tar.gz: 50cb5050e1c0fd28fcaf2585391bfc1efc32f1a6
3
+ metadata.gz: 3055335096394934cafc9c548907e1cfaaab976e
4
+ data.tar.gz: bed1c6bdc27453eaea089516fe98e9ba453f578c
5
5
  SHA512:
6
- metadata.gz: 2ee743704a038fd5df2b1ad62c3c24615bbd5760a8144e27d3db8d11e2ec9112856c9dc5223f93ce50afd788d99cc4c75286c690d8abb55fd9633432a1f0a522
7
- data.tar.gz: b7c048132f56b68db4487c06773c64f817ede39be34be846aca38c4c6567ce2a5c4627595cabcd21c189a7b05d093eaad1dd12301bc0ac7cecde2eb40689e2a5
6
+ metadata.gz: d2185231043764b8709eb2d1289f4562e6aafeb76c4b917d5c39e93accd5dbfdcddeaa1bf206974412ad70bf84b7422e1d8ae0a63d3b14b778155138e1f18736
7
+ data.tar.gz: 61abb816e118e9e30fe4edd535df19ce2e53a1f8aa0fff48f0b8a2222fae7a006190a85a13c3e5b8ae8783a55b61bcbbbfa88d7b0271847a55aaf03c7901c6a3
@@ -26,7 +26,7 @@ module ZendeskAppsSupport
26
26
  errors << Validations::Package.call(self)
27
27
  errors << Validations::Translations.call(self)
28
28
 
29
- if has_location?
29
+ if has_js?
30
30
  errors << Validations::Source.call(self)
31
31
  errors << Validations::Templates.call(self)
32
32
  errors << Validations::Stylesheets.call(self)
@@ -101,8 +101,12 @@ module ZendeskAppsSupport
101
101
  customer_css = File.exist?(css_file) ? File.read(css_file) : ""
102
102
  end
103
103
 
104
+ def has_js?
105
+ file_exists?("app.js")
106
+ end
107
+
104
108
  def has_manifest?
105
- File.exist?(File.join(root, "manifest.json"))
109
+ file_exists?("manifest.json")
106
110
  end
107
111
 
108
112
  def has_location?
@@ -110,7 +114,7 @@ module ZendeskAppsSupport
110
114
  end
111
115
 
112
116
  def has_requirements?
113
- File.exist?(File.join(root, "requirements.json"))
117
+ file_exists?("requirements.json")
114
118
  end
115
119
 
116
120
  def is_requirements_only?
@@ -149,6 +153,10 @@ module ZendeskAppsSupport
149
153
  files
150
154
  end
151
155
 
156
+ def file_exists?(path)
157
+ File.exist?(File.join(root, path))
158
+ end
159
+
152
160
  def read_file(path)
153
161
  file_path = File.join(root, path)
154
162
  File.read(File.join(root, path))
@@ -4,7 +4,7 @@ module ZendeskAppsSupport
4
4
  module Validations
5
5
  module Manifest
6
6
 
7
- REQUIRED_MANIFEST_FIELDS = %w( author defaultLocale frameworkVersion ).freeze
7
+ REQUIRED_MANIFEST_FIELDS = %w( author defaultLocale ).freeze
8
8
  OAUTH_REQUIRED_FIELDS = %w( client_id client_secret authorize_uri access_token_uri ).freeze
9
9
  LOCATIONS_AVAILABLE = %w( top_bar nav_bar ticket_sidebar new_ticket_sidebar user_sidebar ).freeze
10
10
  TYPES_AVAILABLE = %W( text password checkbox url number multiline hidden ).freeze
@@ -19,16 +19,18 @@ module ZendeskAppsSupport
19
19
  [].tap do |errors|
20
20
  errors << missing_keys_error(manifest)
21
21
  errors << default_locale_error(manifest, package)
22
- errors << invalid_version_error(manifest, package)
23
22
  errors << oauth_error(manifest)
24
23
  errors << parameters_error(manifest)
25
24
  errors << invalid_hidden_parameter_error(manifest)
26
25
  errors << invalid_type_error(manifest)
27
26
  errors << name_as_parameter_name_error(manifest)
28
27
 
29
- if package.has_location?
28
+ if package.has_js?
29
+ errors << missing_location_error(package)
30
30
  errors << invalid_location_error(manifest)
31
31
  errors << duplicate_location_error(manifest)
32
+ errors << missing_framework_version(manifest)
33
+ errors << invalid_version_error(manifest, package)
32
34
  end
33
35
  errors.compact!
34
36
  end
@@ -70,9 +72,7 @@ module ZendeskAppsSupport
70
72
  manifest[key].nil?
71
73
  end
72
74
 
73
- if missing.any?
74
- ValidationError.new('manifest_keys.missing', :missing_keys => missing.join(', '), :count => missing.length)
75
- end
75
+ missing_keys_validation_error(missing) if missing.any?
76
76
  end
77
77
 
78
78
  def default_locale_error(manifest, package)
@@ -86,6 +86,10 @@ module ZendeskAppsSupport
86
86
  end
87
87
  end
88
88
 
89
+ def missing_location_error(package)
90
+ missing_keys_validation_error(['location']) unless package.has_location?
91
+ end
92
+
89
93
  def invalid_location_error(manifest)
90
94
  invalid_locations = [*manifest['location']] - LOCATIONS_AVAILABLE
91
95
  unless invalid_locations.empty?
@@ -102,6 +106,10 @@ module ZendeskAppsSupport
102
106
  end
103
107
  end
104
108
 
109
+ def missing_framework_version(manifest)
110
+ missing_keys_validation_error(['frameworkVersion']) if manifest['frameworkVersion'].nil?
111
+ end
112
+
105
113
  def invalid_version_error(manifest, package)
106
114
  valid_to_serve = AppVersion::TO_BE_SERVED
107
115
  target_version = manifest['frameworkVersion']
@@ -151,6 +159,12 @@ module ZendeskAppsSupport
151
159
  end
152
160
  end
153
161
 
162
+ private
163
+
164
+ def missing_keys_validation_error(missing_keys)
165
+ ValidationError.new('manifest_keys.missing', :missing_keys => missing_keys.join(', '), :count => missing_keys.length)
166
+ end
167
+
154
168
  end
155
169
  end
156
170
  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.13.1
4
+ version: 1.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James A. Rosen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-02-10 00:00:00.000000000 Z
14
+ date: 2014-02-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: i18n