zendesk_apps_support 1.1.4 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MGU4ZDQ2YzkxOWEzNmM2NjJjNDNiZmYzODZjOTdhNmM5MGE3YjA4ZQ==
5
+ data.tar.gz: !binary |-
6
+ OGU3MTU0YmJhNDQzODEzMWZhODA0ZmU2YWYxOWYwZWM0OGQ3ZTBkYw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZWNlZWNjZDg3NzNlNDIxNjc5OWRhZWFlMzBkMWQ3OTUyOGM1MWZlOTYyNjJl
10
+ NWQ3MjQ5ODJiYzFiNzRmOWZiOTE3ZGY4N2Y1OTZhY2U2ZjdiMzJjYTk1MTky
11
+ YjEwNGJjYmNkOTk0NzJlN2ViZTRmMjJjMWVlNzIyNTY0NWMxZjI=
12
+ data.tar.gz: !binary |-
13
+ MGQ0Njk5YmIxMTMzYmU3YTdiYzNkN2VmMTMyNmIzOWU4NjEyZDk2ZGY2NWVm
14
+ MzFhZTUzNmMyMGM1NjAwMWEyZTg1MGM5NzNkMTVjMDA4MWE0YTI4NjEyZjQx
15
+ Zjg5ZjE1ZmZkMzcwYTE4MDJkNjFhYmZjYWNmY2QwODkwMzFhZDY=
@@ -35,3 +35,6 @@ en:
35
35
  not_json: ! '%{file} is not valid JSON. %{errors}'
36
36
  not_json_object: ! '%{file} is not a JSON object.'
37
37
  stylesheet_error: ! 'Sass error: %{sass_error}'
38
+ invalid_type_parameter:
39
+ one: ! '%{invalid_types} is an invalid parameter type.'
40
+ other: ! '%{invalid_types} are invalid parameter types.'
@@ -87,3 +87,11 @@ parts:
87
87
  key: "txt.apps.admin.error.app_build.stylesheet_error"
88
88
  title: "App builder job: invalid stylesheet syntax"
89
89
  value: "Sass error: %{sass_error}"
90
+ - translation:
91
+ key: "txt.apps.admin.error.app_build.invalid_type_parameter.one"
92
+ title: "App builder job: single invalid parameter type error"
93
+ value: "%{invalid_types} is an invalid parameter type."
94
+ - translation:
95
+ key: "txt.apps.admin.error.app_build.invalid_type_parameter.other"
96
+ title: "App builder job: multiple invalid parameter types error"
97
+ value: "%{invalid_types} are invalid parameter types."
@@ -12,7 +12,7 @@ module ZendeskAppsSupport
12
12
  end
13
13
 
14
14
  def app_asset_url(name)
15
- "#{@url_prefix}/#{name}"
15
+ "#{@url_prefix}#{name}"
16
16
  end
17
17
 
18
18
  private
@@ -5,7 +5,8 @@ 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 user_sidebar ).freeze
9
+ TYPES_AVAILABLE = %W(text password checkbox url number multiline hidden).freeze
9
10
 
10
11
  class <<self
11
12
  def call(package)
@@ -21,6 +22,7 @@ module ZendeskAppsSupport
21
22
  errors << invalid_location_error(manifest)
22
23
  errors << parameters_error(manifest)
23
24
  errors << invalid_hidden_parameter_error(manifest)
25
+ errors << invalid_type_error(manifest)
24
26
  errors.compact!
25
27
  end
26
28
  rescue MultiJson::DecodeError => e
@@ -83,6 +85,22 @@ module ZendeskAppsSupport
83
85
  end
84
86
  end
85
87
 
88
+ def invalid_type_error(manifest)
89
+ return unless manifest['parameters'].kind_of?(Array)
90
+
91
+ invalid_types = []
92
+
93
+ manifest["parameters"].each do |parameter|
94
+ parameter_type = parameter.fetch("type", '')
95
+
96
+ invalid_types << parameter_type unless TYPES_AVAILABLE.include?(parameter_type)
97
+ end
98
+
99
+ if invalid_types.any?
100
+ ValidationError.new(:invalid_type_parameter, :invalid_types => invalid_types.join(', '), :count => invalid_types.length)
101
+ end
102
+ end
103
+
86
104
  end
87
105
  end
88
106
  end
data/spec/package_spec.rb CHANGED
@@ -39,7 +39,7 @@ describe ZendeskAppsSupport::Package do
39
39
 
40
40
  describe 'readified_js' do
41
41
  it 'should generate js ready for installation' do
42
- js = @package.readified_js(nil, 0, 'http://localhost:4567')
42
+ js = @package.readified_js(nil, 0, 'http://localhost:4567/')
43
43
  expected =<<HERE
44
44
  (function() {
45
45
  with( require('apps/framework/app_scope') ) {
@@ -61,7 +61,7 @@ describe ZendeskAppsSupport::Package do
61
61
  ZendeskApps["ABC"] = ZendeskApps.defineApp(source)
62
62
  .reopenClass({ location: "ticket_sidebar" })
63
63
  .reopen({
64
- assetUrlPrefix: "http://localhost:4567",
64
+ assetUrlPrefix: "http://localhost:4567/",
65
65
  appClassName: "app-0",
66
66
  author: {
67
67
  name: "John Smith",
@@ -101,7 +101,7 @@ describe ZendeskAppsSupport::Validations::Manifest do
101
101
  parameter_hash = {
102
102
  'parameters' => {
103
103
  'name' => 'a parameter',
104
- 'type' => 'string'
104
+ 'type' => 'text'
105
105
  }
106
106
  }
107
107
 
@@ -113,7 +113,7 @@ describe ZendeskAppsSupport::Validations::Manifest do
113
113
  parameter_hash = {
114
114
  'parameters' => [{
115
115
  'name' => 'a parameter',
116
- 'type' => 'string'
116
+ 'type' => 'text'
117
117
  }]
118
118
  }
119
119
 
@@ -131,11 +131,11 @@ describe ZendeskAppsSupport::Validations::Manifest do
131
131
  'parameters' => [
132
132
  {
133
133
  'name' => 'url',
134
- 'type' => 'string'
134
+ 'type' => 'text'
135
135
  },
136
136
  {
137
137
  'name' => 'url',
138
- 'type' => 'string'
138
+ 'type' => 'text'
139
139
  }
140
140
  ]
141
141
  }
@@ -143,5 +143,35 @@ describe ZendeskAppsSupport::Validations::Manifest do
143
143
  errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(parameter_hash))
144
144
  errors.map(&:to_s).should == ['Duplicate app parameters defined: ["url"]']
145
145
  end
146
+
147
+ it 'has an error when the parameter type is not valid' do
148
+ parameter_hash = {
149
+ 'parameters' =>
150
+ [
151
+ {
152
+ 'name' => 'should be number',
153
+ 'type' => 'integer'
154
+ }
155
+ ]
156
+ }
157
+ errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(default_required_params.merge(parameter_hash)))
158
+
159
+ expect(errors.count).to eq 1
160
+ expect(errors.first.to_s).to eq "integer is an invalid parameter type."
161
+ end
162
+
163
+ it "doesn't have an error with a correct parameter type" do
164
+ parameter_hash = {
165
+ 'parameters' =>
166
+ [
167
+ {
168
+ 'name' => 'valid type',
169
+ 'type' => 'number'
170
+ }
171
+ ]
172
+ }
173
+ errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(default_required_params.merge(parameter_hash)))
174
+ expect(errors).to be_empty
175
+ end
146
176
  end
147
- end
177
+ end
metadata CHANGED
@@ -1,8 +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
5
- prerelease:
4
+ version: 1.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - James A. Rosen
@@ -11,12 +10,11 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2013-05-16 00:00:00.000000000 Z
13
+ date: 2013-07-12 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: i18n
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
19
  - - ! '>='
22
20
  - !ruby/object:Gem::Version
@@ -24,7 +22,6 @@ dependencies:
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
26
  - - ! '>='
30
27
  - !ruby/object:Gem::Version
@@ -32,7 +29,6 @@ dependencies:
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: multi_json
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
33
  - - ! '>='
38
34
  - !ruby/object:Gem::Version
@@ -40,7 +36,6 @@ dependencies:
40
36
  type: :runtime
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
40
  - - ! '>='
46
41
  - !ruby/object:Gem::Version
@@ -48,7 +43,6 @@ dependencies:
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: sass
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
47
  - - ! '>='
54
48
  - !ruby/object:Gem::Version
@@ -56,7 +50,6 @@ dependencies:
56
50
  type: :runtime
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
54
  - - ! '>='
62
55
  - !ruby/object:Gem::Version
@@ -64,7 +57,6 @@ dependencies:
64
57
  - !ruby/object:Gem::Dependency
65
58
  name: json
66
59
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
60
  requirements:
69
61
  - - ~>
70
62
  - !ruby/object:Gem::Version
@@ -72,7 +64,6 @@ dependencies:
72
64
  type: :runtime
73
65
  prerelease: false
74
66
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
67
  requirements:
77
68
  - - ~>
78
69
  - !ruby/object:Gem::Version
@@ -80,7 +71,6 @@ dependencies:
80
71
  - !ruby/object:Gem::Dependency
81
72
  name: erubis
82
73
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
74
  requirements:
85
75
  - - ! '>='
86
76
  - !ruby/object:Gem::Version
@@ -88,7 +78,6 @@ dependencies:
88
78
  type: :runtime
89
79
  prerelease: false
90
80
  version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
81
  requirements:
93
82
  - - ! '>='
94
83
  - !ruby/object:Gem::Version
@@ -96,7 +85,6 @@ dependencies:
96
85
  - !ruby/object:Gem::Dependency
97
86
  name: jshintrb
98
87
  requirement: !ruby/object:Gem::Requirement
99
- none: false
100
88
  requirements:
101
89
  - - '='
102
90
  - !ruby/object:Gem::Version
@@ -104,7 +92,6 @@ dependencies:
104
92
  type: :runtime
105
93
  prerelease: false
106
94
  version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
95
  requirements:
109
96
  - - '='
110
97
  - !ruby/object:Gem::Version
@@ -112,7 +99,6 @@ dependencies:
112
99
  - !ruby/object:Gem::Dependency
113
100
  name: rspec
114
101
  requirement: !ruby/object:Gem::Requirement
115
- none: false
116
102
  requirements:
117
103
  - - ! '>='
118
104
  - !ruby/object:Gem::Version
@@ -120,7 +106,6 @@ dependencies:
120
106
  type: :development
121
107
  prerelease: false
122
108
  version_requirements: !ruby/object:Gem::Requirement
123
- none: false
124
109
  requirements:
125
110
  - - ! '>='
126
111
  - !ruby/object:Gem::Version
@@ -173,27 +158,26 @@ files:
173
158
  homepage: http://github.com/zendesk/zendesk_apps_support
174
159
  licenses:
175
160
  - Apache License Version 2.0
161
+ metadata: {}
176
162
  post_install_message:
177
163
  rdoc_options: []
178
164
  require_paths:
179
165
  - lib
180
166
  required_ruby_version: !ruby/object:Gem::Requirement
181
- none: false
182
167
  requirements:
183
168
  - - ! '>='
184
169
  - !ruby/object:Gem::Version
185
170
  version: '0'
186
171
  required_rubygems_version: !ruby/object:Gem::Requirement
187
- none: false
188
172
  requirements:
189
173
  - - ! '>='
190
174
  - !ruby/object:Gem::Version
191
175
  version: 1.3.6
192
176
  requirements: []
193
177
  rubyforge_project:
194
- rubygems_version: 1.8.25
178
+ rubygems_version: 2.0.3
195
179
  signing_key:
196
- specification_version: 3
180
+ specification_version: 4
197
181
  summary: Support to help you develop Zendesk Apps.
198
182
  test_files:
199
183
  - spec/app/app.css