zendesk_apps_support 1.12.0 → 1.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/zendesk_apps_support/app_file.rb +1 -1
- data/lib/zendesk_apps_support/package.rb +1 -1
- metadata +3 -51
- data/spec/app/app.css +0 -6
- data/spec/app/app.js +0 -12
- data/spec/app/assets/logo-small.png +0 -0
- data/spec/app/assets/logo.png +0 -0
- data/spec/app/manifest.json +0 -11
- data/spec/app/templates/layout.hdbs +0 -11
- data/spec/app/translations/en.json +0 -5
- data/spec/app_file_spec.rb +0 -27
- data/spec/app_version_spec.rb +0 -61
- data/spec/build_translation_spec.rb +0 -90
- data/spec/i18n_spec.rb +0 -22
- data/spec/package_spec.rb +0 -84
- data/spec/spec_helper.rb +0 -3
- data/spec/validations/fixture/invalid_en.json +0 -20
- data/spec/validations/fixture/requirements.json +0 -22
- data/spec/validations/fixture/valid_en.json +0 -21
- data/spec/validations/jshint_error_spec.rb +0 -17
- data/spec/validations/manifest_spec.rb +0 -219
- data/spec/validations/requirements_spec.rb +0 -23
- data/spec/validations/source_spec.rb +0 -21
- data/spec/validations/stylesheets_spec.rb +0 -34
- data/spec/validations/templates_spec.rb +0 -13
- data/spec/validations/translations_spec.rb +0 -83
- data/spec/validations/validation_serialization_spec.rb +0 -96
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98a8a5e9ae9adf2d6f9ff72b7245bcda107eaa99
|
4
|
+
data.tar.gz: 917035d5d9622e79422d82faf385819a1ca90650
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c67cbc1a9d897390b1f74985008eec6f97370a8271b883021a03a67dc5e194bd676011fbfb8dae8ee363192d094b52cd2ad5182c58051a853e6c01667443eab
|
7
|
+
data.tar.gz: 24d926b6e780372cd93b94bf7b08e6d116ac73518763d2eb8d44706fa1d92fe458ab38429b4d311bc4c5d7df76dad9ad27782f3216516ed8b23b9dc1f55e9e2f
|
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.
|
4
|
+
version: 1.13.0
|
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-
|
14
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: i18n
|
@@ -156,30 +156,6 @@ files:
|
|
156
156
|
- config/locales/translations/zendesk_apps_support.yml
|
157
157
|
- README.md
|
158
158
|
- LICENSE
|
159
|
-
- spec/app/app.css
|
160
|
-
- spec/app/app.js
|
161
|
-
- spec/app/assets/logo-small.png
|
162
|
-
- spec/app/assets/logo.png
|
163
|
-
- spec/app/manifest.json
|
164
|
-
- spec/app/templates/layout.hdbs
|
165
|
-
- spec/app/translations/en.json
|
166
|
-
- spec/app_file_spec.rb
|
167
|
-
- spec/app_version_spec.rb
|
168
|
-
- spec/build_translation_spec.rb
|
169
|
-
- spec/i18n_spec.rb
|
170
|
-
- spec/package_spec.rb
|
171
|
-
- spec/spec_helper.rb
|
172
|
-
- spec/validations/fixture/invalid_en.json
|
173
|
-
- spec/validations/fixture/requirements.json
|
174
|
-
- spec/validations/fixture/valid_en.json
|
175
|
-
- spec/validations/jshint_error_spec.rb
|
176
|
-
- spec/validations/manifest_spec.rb
|
177
|
-
- spec/validations/requirements_spec.rb
|
178
|
-
- spec/validations/source_spec.rb
|
179
|
-
- spec/validations/stylesheets_spec.rb
|
180
|
-
- spec/validations/templates_spec.rb
|
181
|
-
- spec/validations/translations_spec.rb
|
182
|
-
- spec/validations/validation_serialization_spec.rb
|
183
159
|
homepage: http://github.com/zendesk/zendesk_apps_support
|
184
160
|
licenses:
|
185
161
|
- Apache License Version 2.0
|
@@ -204,28 +180,4 @@ rubygems_version: 2.0.14
|
|
204
180
|
signing_key:
|
205
181
|
specification_version: 4
|
206
182
|
summary: Support to help you develop Zendesk Apps.
|
207
|
-
test_files:
|
208
|
-
- spec/app/app.css
|
209
|
-
- spec/app/app.js
|
210
|
-
- spec/app/assets/logo-small.png
|
211
|
-
- spec/app/assets/logo.png
|
212
|
-
- spec/app/manifest.json
|
213
|
-
- spec/app/templates/layout.hdbs
|
214
|
-
- spec/app/translations/en.json
|
215
|
-
- spec/app_file_spec.rb
|
216
|
-
- spec/app_version_spec.rb
|
217
|
-
- spec/build_translation_spec.rb
|
218
|
-
- spec/i18n_spec.rb
|
219
|
-
- spec/package_spec.rb
|
220
|
-
- spec/spec_helper.rb
|
221
|
-
- spec/validations/fixture/invalid_en.json
|
222
|
-
- spec/validations/fixture/requirements.json
|
223
|
-
- spec/validations/fixture/valid_en.json
|
224
|
-
- spec/validations/jshint_error_spec.rb
|
225
|
-
- spec/validations/manifest_spec.rb
|
226
|
-
- spec/validations/requirements_spec.rb
|
227
|
-
- spec/validations/source_spec.rb
|
228
|
-
- spec/validations/stylesheets_spec.rb
|
229
|
-
- spec/validations/templates_spec.rb
|
230
|
-
- spec/validations/translations_spec.rb
|
231
|
-
- spec/validations/validation_serialization_spec.rb
|
183
|
+
test_files: []
|
data/spec/app/app.css
DELETED
data/spec/app/app.js
DELETED
Binary file
|
data/spec/app/assets/logo.png
DELETED
Binary file
|
data/spec/app/manifest.json
DELETED
data/spec/app_file_spec.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
|
3
|
-
describe ZendeskAppsSupport::AppFile do
|
4
|
-
|
5
|
-
before do
|
6
|
-
package = mock('Package', :root => Pathname("spec/app/templates/"))
|
7
|
-
@file = ZendeskAppsSupport::AppFile.new(package, 'layout.hdbs')
|
8
|
-
end
|
9
|
-
|
10
|
-
describe '=~' do
|
11
|
-
it 'should test against the relative path of the file' do
|
12
|
-
@file.should =~ /layout/
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe 'read' do
|
17
|
-
it 'should read file content' do
|
18
|
-
@file.read.should =~ /<header>/
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
describe 'to_s' do
|
23
|
-
it 'should return file name' do
|
24
|
-
@file.to_s.should == 'layout.hdbs'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
data/spec/app_version_spec.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
|
3
|
-
describe ZendeskAppsSupport::AppVersion do
|
4
|
-
|
5
|
-
describe 'the current version' do
|
6
|
-
subject do
|
7
|
-
ZendeskAppsSupport::AppVersion.new(ZendeskAppsSupport::AppVersion::CURRENT)
|
8
|
-
end
|
9
|
-
|
10
|
-
it { should be_frozen }
|
11
|
-
it { should be_present }
|
12
|
-
it { should be_servable }
|
13
|
-
it { should be_valid_for_update }
|
14
|
-
it { should_not be_blank }
|
15
|
-
it { should_not be_deprecated }
|
16
|
-
it { should_not be_obsolete }
|
17
|
-
it { should == ZendeskAppsSupport::AppVersion.new(ZendeskAppsSupport::AppVersion::CURRENT) }
|
18
|
-
it { should_not == ZendeskAppsSupport::AppVersion.new('0.2') }
|
19
|
-
|
20
|
-
its(:to_s) { should == ZendeskAppsSupport::AppVersion::CURRENT }
|
21
|
-
its(:to_json) { should == ZendeskAppsSupport::AppVersion::CURRENT.to_json }
|
22
|
-
end
|
23
|
-
|
24
|
-
describe 'the deprecated version' do
|
25
|
-
subject do
|
26
|
-
ZendeskAppsSupport::AppVersion.new(ZendeskAppsSupport::AppVersion::DEPRECATED)
|
27
|
-
end
|
28
|
-
|
29
|
-
it { should be_frozen }
|
30
|
-
it { should be_present }
|
31
|
-
it { should be_servable }
|
32
|
-
it { should_not be_valid_for_update }
|
33
|
-
it { should_not be_blank }
|
34
|
-
it { should be_deprecated }
|
35
|
-
it { should_not be_obsolete }
|
36
|
-
it { should == ZendeskAppsSupport::AppVersion.new(ZendeskAppsSupport::AppVersion::DEPRECATED) }
|
37
|
-
it { should_not == ZendeskAppsSupport::AppVersion.new('0.2') }
|
38
|
-
|
39
|
-
its(:to_s) { should == ZendeskAppsSupport::AppVersion::DEPRECATED }
|
40
|
-
its(:to_json) { should == ZendeskAppsSupport::AppVersion::DEPRECATED.to_json }
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'a really old version' do
|
44
|
-
subject do
|
45
|
-
ZendeskAppsSupport::AppVersion.new('0.1')
|
46
|
-
end
|
47
|
-
|
48
|
-
it { should be_frozen }
|
49
|
-
it { should be_present }
|
50
|
-
it { should_not be_servable }
|
51
|
-
it { should_not be_valid_for_update }
|
52
|
-
it { should_not be_blank }
|
53
|
-
it { should_not be_deprecated }
|
54
|
-
it { should be_obsolete }
|
55
|
-
it { should == ZendeskAppsSupport::AppVersion.new('0.1') }
|
56
|
-
it { should_not == ZendeskAppsSupport::AppVersion.new('0.2') }
|
57
|
-
|
58
|
-
its(:to_s) { should == '0.1' }
|
59
|
-
its(:to_json) { should == '0.1'.to_json }
|
60
|
-
end
|
61
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
include ZendeskAppsSupport::BuildTranslation
|
3
|
-
|
4
|
-
describe ZendeskAppsSupport::BuildTranslation do
|
5
|
-
|
6
|
-
let(:en_json) {
|
7
|
-
{
|
8
|
-
"app" => {
|
9
|
-
"abc" => {
|
10
|
-
"title" => "description for abc field",
|
11
|
-
"value" => "value of abc"
|
12
|
-
}
|
13
|
-
},
|
14
|
-
"a" => {
|
15
|
-
"a1" => {
|
16
|
-
"title" => "description for a1 field",
|
17
|
-
"value" => "value of a1"
|
18
|
-
},
|
19
|
-
"b" => {
|
20
|
-
"b1" => {
|
21
|
-
"title" => "description for b1 field",
|
22
|
-
"value" => "value of b1"
|
23
|
-
}
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
describe '#to_flattened_namespaced_hash' do
|
30
|
-
|
31
|
-
context "not zendesk i18n format" do
|
32
|
-
it "should flatten hash without removing zendesk keys" do
|
33
|
-
expected = {
|
34
|
-
"app.abc.title" => "description for abc field",
|
35
|
-
"app.abc.value" => "value of abc",
|
36
|
-
"a.a1.title" => "description for a1 field",
|
37
|
-
"a.a1.value" => "value of a1",
|
38
|
-
"a.b.b1.title" => "description for b1 field",
|
39
|
-
"a.b.b1.value" => "value of b1"
|
40
|
-
}
|
41
|
-
|
42
|
-
to_flattened_namespaced_hash(en_json).should == expected
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'zendesk i18n format' do
|
47
|
-
context 'flatten value keys' do
|
48
|
-
it "should flatten hash by removing zendesk title keys" do
|
49
|
-
expected = {
|
50
|
-
"app.abc" => "value of abc",
|
51
|
-
"a.a1" => "value of a1",
|
52
|
-
"a.b.b1" => "value of b1"
|
53
|
-
}
|
54
|
-
|
55
|
-
to_flattened_namespaced_hash(en_json, I18N_VALUE_KEY).should == expected
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'flatten title keys' do
|
60
|
-
it "should flatten hash by removing zendesk value keys" do
|
61
|
-
expected = {
|
62
|
-
"app.abc" => "description for abc field",
|
63
|
-
"a.a1" => "description for a1 field",
|
64
|
-
"a.b.b1" => "description for b1 field"
|
65
|
-
}
|
66
|
-
|
67
|
-
to_flattened_namespaced_hash(en_json, I18N_TITLE_KEY).should == expected
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
describe '#remove_zendesk_keys' do
|
75
|
-
it "should remove zendesk translation keys" do
|
76
|
-
expected = {
|
77
|
-
"app" => {
|
78
|
-
"abc" => "value of abc"
|
79
|
-
},
|
80
|
-
"a" => {
|
81
|
-
"a1" => "value of a1",
|
82
|
-
"b" => {
|
83
|
-
"b1" => "value of b1"
|
84
|
-
}
|
85
|
-
}
|
86
|
-
}
|
87
|
-
remove_zendesk_keys(en_json).should == expected
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
data/spec/i18n_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
require 'pathname'
|
3
|
-
|
4
|
-
describe ZendeskAppsSupport::I18n do
|
5
|
-
|
6
|
-
it 'should translate error messages' do
|
7
|
-
key_prefix = ZendeskAppsSupport::Validations::ValidationError::KEY_PREFIX
|
8
|
-
ZendeskAppsSupport::I18n.t("#{key_prefix}.missing_manifest").should == 'Could not find manifest.json'
|
9
|
-
end
|
10
|
-
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'translations' do
|
14
|
-
|
15
|
-
it 'should be up-to-date' do
|
16
|
-
project_root = Pathname.new(File.expand_path('../../', __FILE__))
|
17
|
-
zendesk_version = project_root.join('config/locales/translations/zendesk_apps_support.yml')
|
18
|
-
standard_version = project_root.join('config/locales/en.yml')
|
19
|
-
File.mtime(zendesk_version).to_i.should be <= File.mtime(standard_version).to_i
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
data/spec/package_spec.rb
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
|
3
|
-
describe ZendeskAppsSupport::Package do
|
4
|
-
|
5
|
-
before do
|
6
|
-
@package = ZendeskAppsSupport::Package.new('spec/app')
|
7
|
-
end
|
8
|
-
|
9
|
-
describe 'files' do
|
10
|
-
it 'should return all the files within the app folder excluding files in tmp folder' do
|
11
|
-
@package.files.map(&:relative_path).should =~ %w(app.css app.js assets/logo-small.png assets/logo.png manifest.json templates/layout.hdbs translations/en.json)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
describe 'template_files' do
|
16
|
-
it 'should return all the files in the templates folder within the app folder' do
|
17
|
-
@package.template_files.map(&:relative_path).should == %w(templates/layout.hdbs)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'translation_files' do
|
22
|
-
it 'should return all the files in the translations folder within the app folder' do
|
23
|
-
@package.translation_files.map(&:relative_path).should == %w(translations/en.json)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe 'manifest_json' do
|
28
|
-
it 'should return manifest json' do
|
29
|
-
manifest = @package.manifest_json
|
30
|
-
manifest[:name].should == 'ABC'
|
31
|
-
manifest[:author][:name].should == 'John Smith'
|
32
|
-
manifest[:author][:email].should == 'john@example.com'
|
33
|
-
manifest[:defaultLocale].should == 'en'
|
34
|
-
manifest[:private].should == true
|
35
|
-
manifest[:location].should == 'ticket_sidebar'
|
36
|
-
manifest[:frameworkVersion].should == '0.5'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe 'readified_js' do
|
41
|
-
it 'should generate js ready for installation' do
|
42
|
-
js = @package.readified_js(nil, 0, 'http://localhost:4567/')
|
43
|
-
expected =<<HERE
|
44
|
-
(function() {
|
45
|
-
with( require('apps/framework/app_scope') ) {
|
46
|
-
|
47
|
-
var source = (function() {
|
48
|
-
|
49
|
-
return {
|
50
|
-
events: {
|
51
|
-
'app.activated':'doSomething'
|
52
|
-
},
|
53
|
-
|
54
|
-
doSomething: function() {
|
55
|
-
}
|
56
|
-
};
|
57
|
-
|
58
|
-
}());
|
59
|
-
;
|
60
|
-
|
61
|
-
ZendeskApps["ABC"] = ZendeskApps.defineApp(source)
|
62
|
-
.reopenClass({ location: "ticket_sidebar" })
|
63
|
-
.reopen({
|
64
|
-
assetUrlPrefix: "http://localhost:4567/",
|
65
|
-
appClassName: "app-0",
|
66
|
-
author: {
|
67
|
-
name: "John Smith",
|
68
|
-
email: "john@example.com"
|
69
|
-
},
|
70
|
-
translations: {"app":{\"name\":\"Buddha Machine\"}},
|
71
|
-
templates: {"layout":"<style>\\n.app-0 header .logo {\\n background-image: url(\\"http://localhost:4567/logo-small.png\\"); }\\n.app-0 h1 {\\n color: red; }\\n .app-0 h1 span {\\n color: green; }\\n</style>\\n<header>\\n <span class=\\"logo\\"/>\\n <h3>{{setting \\"name\\"}}</h3>\\n</header>\\n<section data-main/>\\n<footer>\\n <a href=\\"mailto:{{author.email}}\\">\\n {{author.name}}\\n </a>\\n</footer>\\n</div>"},
|
72
|
-
frameworkVersion: "0.5"
|
73
|
-
});
|
74
|
-
|
75
|
-
}
|
76
|
-
|
77
|
-
ZendeskApps["ABC"].install({"id": 0, "app_id": 0, "settings": {\"title\":\"ABC\"}});
|
78
|
-
|
79
|
-
}());
|
80
|
-
HERE
|
81
|
-
js.should == expected
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"app": {
|
3
|
-
"package" : "my_app",
|
4
|
-
"abc" : {
|
5
|
-
"title" : "description for abc field",
|
6
|
-
"value" : "value of abc"
|
7
|
-
}
|
8
|
-
},
|
9
|
-
"a": {
|
10
|
-
"a1": {
|
11
|
-
"title": "description for a1 field",
|
12
|
-
"value": "value of a1"
|
13
|
-
},
|
14
|
-
"b": {
|
15
|
-
"b1": {
|
16
|
-
"value": "value of b1"
|
17
|
-
}
|
18
|
-
}
|
19
|
-
}
|
20
|
-
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"targets": {
|
3
|
-
"jira_story_target": {
|
4
|
-
"title": "blah",
|
5
|
-
"type": "jira_target",
|
6
|
-
"active": true,
|
7
|
-
"target_url": "http://example.org"
|
8
|
-
}
|
9
|
-
},
|
10
|
-
|
11
|
-
"triggers": {
|
12
|
-
"submit_trigger": {
|
13
|
-
"title": "whatever",
|
14
|
-
"position": "whatever",
|
15
|
-
"active": true,
|
16
|
-
"conditions": {
|
17
|
-
"all": [{ "field": "status", "operator": "less_than", "value": "solved" }]
|
18
|
-
},
|
19
|
-
"actions" : []
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"app": {
|
3
|
-
"package" : "my_app",
|
4
|
-
"abc" : {
|
5
|
-
"title" : "description for abc field",
|
6
|
-
"value" : "value of abc"
|
7
|
-
}
|
8
|
-
},
|
9
|
-
"a": {
|
10
|
-
"a1": {
|
11
|
-
"title": "description for a1 field",
|
12
|
-
"value": "value of a1"
|
13
|
-
},
|
14
|
-
"b": {
|
15
|
-
"b1": {
|
16
|
-
"title": "description for b1 field",
|
17
|
-
"value": "value of b1"
|
18
|
-
}
|
19
|
-
}
|
20
|
-
}
|
21
|
-
}
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
|
3
|
-
describe ZendeskAppsSupport::Validations::JSHintValidationError do
|
4
|
-
|
5
|
-
let(:filename) { 'foo.js' }
|
6
|
-
|
7
|
-
context 'with nil errors' do
|
8
|
-
|
9
|
-
let(:errors) { [ nil, { 'line' => 12, 'reason' => 'eval is evil' }, nil ] }
|
10
|
-
let(:error) { ZendeskAppsSupport::Validations::JSHintValidationError.new(filename, errors) }
|
11
|
-
|
12
|
-
it 'ignores nil errors' do
|
13
|
-
error.to_s.should =~ /eval is evil/
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
@@ -1,219 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
describe ZendeskAppsSupport::Validations::Manifest do
|
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
|
-
|
15
|
-
def create_package(parameter_hash)
|
16
|
-
params = default_required_params(parameter_hash)
|
17
|
-
manifest = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(params))
|
18
|
-
mock('Package', :files => [manifest], :has_location? => true)
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should have an error when manifest.json is missing' do
|
22
|
-
files = [mock('AppFile', :relative_path => 'abc.json')]
|
23
|
-
package = mock('Package', :files => files)
|
24
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
25
|
-
|
26
|
-
errors.first().to_s.should eql 'Could not find manifest.json'
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'should have an error when required field is missing' do
|
30
|
-
manifest = mock('AppFile', :relative_path => 'manifest.json', :read => "{}")
|
31
|
-
package = mock('Package', :files => [manifest], :has_location? => true)
|
32
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
33
|
-
|
34
|
-
errors.first().to_s.should eql 'Missing required fields in manifest: author, defaultLocale, frameworkVersion'
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'should have an error when the defaultLocale is invalid' do
|
38
|
-
manifest = { 'defaultLocale' => 'pt-BR-1' }
|
39
|
-
manifest_file = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(manifest))
|
40
|
-
package = mock('Package', :files => [manifest_file], :has_location? => true)
|
41
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
42
|
-
|
43
|
-
locale_error = errors.find { |e| e.to_s =~ /default locale/ }
|
44
|
-
locale_error.should_not be_nil
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'should have an error when the translation file is missing for the defaultLocale' do
|
48
|
-
manifest = { 'defaultLocale' => 'pt' }
|
49
|
-
manifest_file = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(manifest))
|
50
|
-
translation_files = mock('AppFile', :relative_path => 'translations/en.json')
|
51
|
-
package = mock('Package', :files => [manifest_file], :has_location? => true, :translation_files => [translation_files])
|
52
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
53
|
-
|
54
|
-
locale_error = errors.find { |e| e.to_s =~ /Missing translation file/ }
|
55
|
-
locale_error.should_not be_nil
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should have an error when the location is invalid' do
|
59
|
-
manifest = { 'location' => ['ticket_sidebar', 'a_invalid_location'] }
|
60
|
-
manifest_file = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(manifest))
|
61
|
-
package = mock('Package', :files => [manifest_file], :has_location? => true)
|
62
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
63
|
-
|
64
|
-
locations_error = errors.find { |e| e.to_s =~ /invalid location/ }
|
65
|
-
locations_error.should_not be_nil
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'should have an error when there are duplicate locations' do
|
69
|
-
manifest = { 'location' => ['ticket_sidebar', 'ticket_sidebar'] }
|
70
|
-
manifest_file = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(manifest))
|
71
|
-
package = mock('Package', :files => [manifest_file], :has_location? => true)
|
72
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
73
|
-
|
74
|
-
locations_error = errors.find { |e| e.to_s =~ /duplicate/ }
|
75
|
-
locations_error.should_not be_nil
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'should have an error when the version is not supported' do
|
79
|
-
manifest = { 'frameworkVersion' => '0.7' }
|
80
|
-
manifest_file = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(manifest))
|
81
|
-
package = mock('Package', :files => [manifest_file], :has_location? => true)
|
82
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
83
|
-
|
84
|
-
version_error = errors.find { |e| e.to_s =~ /not a valid framework version/ }
|
85
|
-
version_error.should_not be_nil
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'should have an error when a hidden parameter is set to required' do
|
89
|
-
manifest = {
|
90
|
-
'parameters' => [
|
91
|
-
'name' => 'a parameter',
|
92
|
-
'type' => 'hidden',
|
93
|
-
'required' => true
|
94
|
-
]
|
95
|
-
}
|
96
|
-
|
97
|
-
manifest_file = mock('AppFile', :relative_path => 'manifest.json', :read => JSON.dump(manifest))
|
98
|
-
package = mock('Package', :files => [manifest_file], :has_location? => true)
|
99
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
100
|
-
|
101
|
-
hidden_params_error = errors.find { |e| e.to_s =~ /set to hidden and cannot be required/ }
|
102
|
-
hidden_params_error.should_not be_nil
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'should have an error when manifest is not a valid json' do
|
106
|
-
manifest = mock('AppFile', :relative_path => 'manifest.json', :read => "}")
|
107
|
-
package = mock('Package', :files => [manifest], :has_location? => true)
|
108
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(package)
|
109
|
-
|
110
|
-
errors.first().to_s.should =~ /^manifest is not proper JSON/
|
111
|
-
end
|
112
|
-
|
113
|
-
it "should have an error when required oauth fields are missing" do
|
114
|
-
oauth_hash = {
|
115
|
-
"oauth" => {}
|
116
|
-
}
|
117
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(default_required_params.merge(oauth_hash)))
|
118
|
-
oauth_error = errors.find { |e| e.to_s =~ /oauth field/ }
|
119
|
-
oauth_error.to_s.should == "Missing required oauth fields in manifest: client_id, client_secret, authorize_uri, access_token_uri"
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'with invalid parameters' do
|
123
|
-
|
124
|
-
before do
|
125
|
-
ZendeskAppsSupport::Validations::Manifest.stub(:default_locale_error)
|
126
|
-
ZendeskAppsSupport::Validations::Manifest.stub(:invalid_location_error)
|
127
|
-
ZendeskAppsSupport::Validations::Manifest.stub(:invalid_version_error)
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'has an error when the app parameters are not an array' do
|
131
|
-
parameter_hash = {
|
132
|
-
'parameters' => {
|
133
|
-
'name' => 'a parameter',
|
134
|
-
'type' => 'text'
|
135
|
-
}
|
136
|
-
}
|
137
|
-
|
138
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(parameter_hash))
|
139
|
-
errors.map(&:to_s).should == ['App parameters must be an array.']
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'has an error when there is a parameter called "name"' do
|
143
|
-
parameter_hash = {
|
144
|
-
'parameters' => [{
|
145
|
-
'name' => 'name',
|
146
|
-
'type' => 'text'
|
147
|
-
}]
|
148
|
-
}
|
149
|
-
|
150
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(parameter_hash))
|
151
|
-
errors.map(&:to_s).should == ["Can't call a parameter 'name'"]
|
152
|
-
end
|
153
|
-
|
154
|
-
it "doesn't have an error with an array of app parameters" do
|
155
|
-
parameter_hash = {
|
156
|
-
'parameters' => [{
|
157
|
-
'name' => 'a parameter',
|
158
|
-
'type' => 'text'
|
159
|
-
}]
|
160
|
-
}
|
161
|
-
|
162
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(parameter_hash))
|
163
|
-
errors.should be_empty
|
164
|
-
end
|
165
|
-
|
166
|
-
it 'behaves when the manifest does not have parameters' do
|
167
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(default_required_params))
|
168
|
-
errors.should be_empty
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'shows error when duplicate parameters are defined' do
|
172
|
-
parameter_hash = {
|
173
|
-
'parameters' => [
|
174
|
-
{
|
175
|
-
'name' => 'url',
|
176
|
-
'type' => 'text'
|
177
|
-
},
|
178
|
-
{
|
179
|
-
'name' => 'url',
|
180
|
-
'type' => 'text'
|
181
|
-
}
|
182
|
-
]
|
183
|
-
}
|
184
|
-
|
185
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(parameter_hash))
|
186
|
-
errors.map(&:to_s).should == ['Duplicate app parameters defined: ["url"]']
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'has an error when the parameter type is not valid' do
|
190
|
-
parameter_hash = {
|
191
|
-
'parameters' =>
|
192
|
-
[
|
193
|
-
{
|
194
|
-
'name' => 'should be number',
|
195
|
-
'type' => 'integer'
|
196
|
-
}
|
197
|
-
]
|
198
|
-
}
|
199
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(default_required_params.merge(parameter_hash)))
|
200
|
-
|
201
|
-
expect(errors.count).to eq 1
|
202
|
-
expect(errors.first.to_s).to eq "integer is an invalid parameter type."
|
203
|
-
end
|
204
|
-
|
205
|
-
it "doesn't have an error with a correct parameter type" do
|
206
|
-
parameter_hash = {
|
207
|
-
'parameters' =>
|
208
|
-
[
|
209
|
-
{
|
210
|
-
'name' => 'valid type',
|
211
|
-
'type' => 'number'
|
212
|
-
}
|
213
|
-
]
|
214
|
-
}
|
215
|
-
errors = ZendeskAppsSupport::Validations::Manifest.call(create_package(default_required_params.merge(parameter_hash)))
|
216
|
-
expect(errors).to be_empty
|
217
|
-
end
|
218
|
-
end
|
219
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe ZendeskAppsSupport::Validations::Requirements do
|
5
|
-
|
6
|
-
it 'creates an error when the file is not valid JSON' do
|
7
|
-
requirements = mock('AppFile', :relative_path => 'requirements.json', :read => "{")
|
8
|
-
package = mock('Package', :files => [requirements])
|
9
|
-
errors = ZendeskAppsSupport::Validations::Requirements.call(package)
|
10
|
-
|
11
|
-
errors.first.key.should == :requirements_not_json
|
12
|
-
end
|
13
|
-
|
14
|
-
it "creates no error when the file is valid JSON" do
|
15
|
-
requirements = mock('AppFile', :relative_path => 'requirements.json',
|
16
|
-
:read => read_fixture_file('requirements.json'))
|
17
|
-
package = mock('Package', :files => [requirements])
|
18
|
-
errors = ZendeskAppsSupport::Validations::Requirements.call(package)
|
19
|
-
|
20
|
-
expect(errors).to be_empty
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
|
3
|
-
describe ZendeskAppsSupport::Validations::Source do
|
4
|
-
|
5
|
-
it 'should have an error when app.js is missing' do
|
6
|
-
files = [mock('AppFile', :relative_path => 'abc.js')]
|
7
|
-
package = mock('Package', :files => files)
|
8
|
-
errors = ZendeskAppsSupport::Validations::Source.call(package)
|
9
|
-
|
10
|
-
errors.first().to_s.should eql 'Could not find app.js'
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'should have a jslint error when missing semicolon' do
|
14
|
-
source = mock('AppFile', :relative_path => 'app.js', :read => "var a = 1")
|
15
|
-
package = mock('Package', :files => [source])
|
16
|
-
errors = ZendeskAppsSupport::Validations::Source.call(package)
|
17
|
-
|
18
|
-
errors.first().to_s.should eql "JSHint error in app.js: \n L1: Missing semicolon."
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
|
3
|
-
describe ZendeskAppsSupport::Validations::Stylesheets do
|
4
|
-
it 'does not return errors if there is no custom css' do
|
5
|
-
|
6
|
-
package = stub(:customer_css => "")
|
7
|
-
ZendeskAppsSupport::Validations::Stylesheets.call(package).should be_empty
|
8
|
-
end
|
9
|
-
|
10
|
-
it 'does not return errors for valid css' do
|
11
|
-
valid_css = <<-CSS
|
12
|
-
.my-class {
|
13
|
-
border: solid 1px black;
|
14
|
-
}
|
15
|
-
CSS
|
16
|
-
package = stub(:customer_css => valid_css)
|
17
|
-
|
18
|
-
errors = ZendeskAppsSupport::Validations::Stylesheets.call(package)
|
19
|
-
errors.should be_empty
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'returns style sheet validation error for invalid css' do
|
23
|
-
invalid_css = <<-CSS
|
24
|
-
.my-class {
|
25
|
-
border: }
|
26
|
-
}
|
27
|
-
CSS
|
28
|
-
package = stub(:customer_css => invalid_css)
|
29
|
-
|
30
|
-
errors = ZendeskAppsSupport::Validations::Stylesheets.call(package)
|
31
|
-
errors.count.should == 1
|
32
|
-
errors.first.to_s.should match /Sass error: Invalid CSS after.*/
|
33
|
-
end
|
34
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
|
3
|
-
describe ZendeskAppsSupport::Validations::Templates do
|
4
|
-
|
5
|
-
it 'should have a jslint error when missing semicolon' do
|
6
|
-
template = mock('AppFile', :relative_path => 'layout.hdbs', :read => "<style>")
|
7
|
-
package = mock('Package', :template_files => [template])
|
8
|
-
errors = ZendeskAppsSupport::Validations::Templates.call(package)
|
9
|
-
|
10
|
-
errors.first().to_s.should eql "<style> tag in layout.hdbs. Use an app.css file instead."
|
11
|
-
end
|
12
|
-
|
13
|
-
end
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
require 'spec_helper'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
|
6
|
-
describe ZendeskAppsSupport::Validations::Translations do
|
7
|
-
|
8
|
-
let(:package) { mock('Package', :files => translation_files) }
|
9
|
-
subject { ZendeskAppsSupport::Validations::Translations.call(package) }
|
10
|
-
|
11
|
-
context 'when there are no translation files' do
|
12
|
-
let(:translation_files) { [] }
|
13
|
-
it 'should be valid' do
|
14
|
-
subject.should be_empty
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'when there is file with invalid JSON' do
|
19
|
-
let(:translation_files) do
|
20
|
-
[mock('AppFile', :relative_path => 'translations/en.json', :read => '}')]
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'should report the error' do
|
24
|
-
subject.length.should == 1
|
25
|
-
subject[0].to_s.should =~ /JSON/
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'when there is file with JSON representing a non-Object' do
|
30
|
-
let(:translation_files) do
|
31
|
-
[mock('AppFile', :relative_path => 'translations/en.json', :read => '"foo bar"')]
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should report the error' do
|
35
|
-
subject.length.should == 1
|
36
|
-
subject[0].to_s.should =~ /JSON/
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'when there is a file with an invalid locale for a name' do
|
41
|
-
let(:translation_files) do
|
42
|
-
[mock('AppFile', :relative_path => 'translations/en-US-1.json', :read => '{}')]
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should report the error' do
|
46
|
-
subject.length.should == 1
|
47
|
-
subject[0].to_s.should =~ /locale/
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'when there is a file with a valid locale containing valid JSON' do
|
52
|
-
let(:translation_files) do
|
53
|
-
[mock('AppFile', :relative_path => 'translations/en-US.json', :read => '{}')]
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should be valid' do
|
57
|
-
subject.length.should == 0
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'validate translation format when "package" is defined inside "app"' do
|
62
|
-
context 'all the leaf nodes have defined "title" and "value"' do
|
63
|
-
let(:translation_files) do
|
64
|
-
[mock('AppFile', :relative_path => 'translations/en-US.json', :read => read_fixture_file("valid_en.json"))]
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'should be valid' do
|
68
|
-
subject.length.should == 0
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'when the "title" field is not defined on one leaf node' do
|
73
|
-
let(:translation_files) do
|
74
|
-
[mock('AppFile', :relative_path => 'translations/en-US.json', :read => read_fixture_file("invalid_en.json"))]
|
75
|
-
end
|
76
|
-
|
77
|
-
it 'should be invalid' do
|
78
|
-
subject.length.should == 1
|
79
|
-
subject[0].to_s.should =~ /is invalid for translation/
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
@@ -1,96 +0,0 @@
|
|
1
|
-
require 'zendesk_apps_support'
|
2
|
-
require 'json'
|
3
|
-
|
4
|
-
describe ZendeskAppsSupport::Validations::ValidationError do
|
5
|
-
|
6
|
-
ValidationError = ZendeskAppsSupport::Validations::ValidationError
|
7
|
-
|
8
|
-
it 'symbolizes the keys in its data' do
|
9
|
-
error = ValidationError.new(:foo, 'bar' => 'baz')
|
10
|
-
error.data[:bar].should == 'baz'
|
11
|
-
end
|
12
|
-
|
13
|
-
describe '#to_json' do
|
14
|
-
let(:key) { 'foo.bar' }
|
15
|
-
let(:data) { { 'baz' => 'quux' } }
|
16
|
-
let(:error) { ValidationError.new(key, data) }
|
17
|
-
subject { error.to_json }
|
18
|
-
|
19
|
-
it do
|
20
|
-
should == {
|
21
|
-
'class' => error.class.to_s,
|
22
|
-
'key' => error.key,
|
23
|
-
'data' => error.data
|
24
|
-
}.to_json
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
describe '.from_hash' do
|
29
|
-
|
30
|
-
subject { ValidationError.from_hash(hash) }
|
31
|
-
|
32
|
-
context 'for a generic error' do
|
33
|
-
let(:hash) do
|
34
|
-
{
|
35
|
-
'class' => 'ZendeskAppsSupport::Validations::ValidationError',
|
36
|
-
'key' => 'foo.bar.baz',
|
37
|
-
'data' => { 'quux' => 'yargle' }
|
38
|
-
}
|
39
|
-
end
|
40
|
-
|
41
|
-
it { should be_a(ValidationError) }
|
42
|
-
|
43
|
-
its(:key) { should == 'foo.bar.baz' }
|
44
|
-
|
45
|
-
its(:data) { should == { :quux => 'yargle' } }
|
46
|
-
its(:data) { should}
|
47
|
-
end
|
48
|
-
|
49
|
-
context 'for a JSHint error' do
|
50
|
-
let(:hash) do
|
51
|
-
{
|
52
|
-
'class' => 'ZendeskAppsSupport::Validations::JSHintValidationError',
|
53
|
-
'file' => 'foo.js',
|
54
|
-
'jshint_errors' => [ { 'line' => 55, 'reason' => 'Yuck' } ]
|
55
|
-
}
|
56
|
-
end
|
57
|
-
|
58
|
-
it { should be_a(ZendeskAppsSupport::Validations::JSHintValidationError) }
|
59
|
-
|
60
|
-
its(:key) { should == :jshint }
|
61
|
-
|
62
|
-
its(:jshint_errors) do
|
63
|
-
should == [ { 'line' => 55, 'reason' => 'Yuck' } ]
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'for a non-ValidationError hash' do
|
68
|
-
let(:hash) do
|
69
|
-
{
|
70
|
-
:foo => 'bar'
|
71
|
-
}
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'raises a DeserializationError' do
|
75
|
-
lambda { subject }.should raise_error(ValidationError::DeserializationError)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
describe '.from_json' do
|
82
|
-
|
83
|
-
it 'decodes a JSON hash and passes it to .from_hash' do
|
84
|
-
ValidationError.should_receive(:from_hash).with('foo' => 'bar')
|
85
|
-
ValidationError.from_json(MultiJson.encode({ 'foo' => 'bar' }))
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'raises a DeserializationError when passed non-JSON' do
|
89
|
-
lambda {
|
90
|
-
ValidationError.from_json('}}}')
|
91
|
-
}.should raise_error(ValidationError::DeserializationError)
|
92
|
-
end
|
93
|
-
|
94
|
-
end
|
95
|
-
|
96
|
-
end
|