summaryrefslogtreecommitdiffstats
path: root/lib/models
diff options
context:
space:
mode:
authorRyan Swanson <ryan.swanson@theice.com>2016-05-26 14:30:29 -0400
committerRyan Swanson <ryan.swanson@theice.com>2016-05-26 14:30:29 -0400
commit465e8d6c0adfe69f696fafa7486541aac55298fe (patch)
tree9d74bf28ccc1dfdcc38f2666f4459b44452a00bf /lib/models
parent7b915428f7b780e49b641639c6ba7166132ac87c (diff)
downloadgitbook-465e8d6c0adfe69f696fafa7486541aac55298fe.zip
gitbook-465e8d6c0adfe69f696fafa7486541aac55298fe.tar.gz
gitbook-465e8d6c0adfe69f696fafa7486541aac55298fe.tar.bz2
Fixed two issues for handling git URLs for plugins that are published to git repositories rather than on npmjs.org.
Fixed issue in pluginDependency to dereference 'name' and 'version' using Immutable Map.get(...) accessors since config values are now wrapped by Immutable.fromJS(...) in config.js > setValue(...). Added associated unit test. Fixed issue in resolveVersion where a plugin may be using a git URL rather than a semver for the version portion of the plugin config definition. In addition, refactored the resolveVersion function into a new module to allow for unit testing. Added associated unit test.
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/__tests__/pluginDependency.js48
-rw-r--r--lib/models/pluginDependency.js4
2 files changed, 35 insertions, 17 deletions
diff --git a/lib/models/__tests__/pluginDependency.js b/lib/models/__tests__/pluginDependency.js
index 0b105e9..cb04cf2 100644
--- a/lib/models/__tests__/pluginDependency.js
+++ b/lib/models/__tests__/pluginDependency.js
@@ -42,21 +42,39 @@ describe('PluginDependency', function() {
expect(plugin.getVersion()).toBe('git+ssh://samy@github.com/GitbookIO/plugin-ga.git');
});
});
- });
- describe('listToArray', function() {
- var list = PluginDependency.listToArray(Immutable.List([
- PluginDependency.createFromString('hello@1.0.0'),
- PluginDependency.createFromString('noversion'),
- PluginDependency.createFromString('-disabled')
- ]));
-
- expect(list).toEqual([
- 'hello@1.0.0',
- 'noversion',
- '-disabled'
- ]);
- });
-});
+ describe('listToArray', function() {
+ it('must create an array from a list of plugin dependencies', function() {
+ var list = PluginDependency.listToArray(Immutable.List([
+ PluginDependency.createFromString('hello@1.0.0'),
+ PluginDependency.createFromString('noversion'),
+ PluginDependency.createFromString('-disabled')
+ ]));
+
+ expect(list).toEqual([
+ 'hello@1.0.0',
+ 'noversion',
+ '-disabled'
+ ]);
+ });
+ });
+ describe('listFromArray', function() {
+ it('must create an array from a list of plugin dependencies', function() {
+ var arr = Immutable.fromJS([
+ 'hello@1.0.0',
+ {
+ 'name': 'plugin-ga',
+ 'version': 'git+ssh://samy@github.com/GitbookIO/plugin-ga.git'
+ }
+ ]);
+ var list = PluginDependency.listFromArray(arr);
+ expect(list.first().getName()).toBe('hello');
+ expect(list.first().getVersion()).toBe('1.0.0');
+ expect(list.last().getName()).toBe('plugin-ga');
+ expect(list.last().getVersion()).toBe('git+ssh://samy@github.com/GitbookIO/plugin-ga.git');
+ });
+ });
+ });
+});
diff --git a/lib/models/pluginDependency.js b/lib/models/pluginDependency.js
index 3502468..99f6f91 100644
--- a/lib/models/pluginDependency.js
+++ b/lib/models/pluginDependency.js
@@ -95,8 +95,8 @@ PluginDependency.listFromArray = function(arr) {
return PluginDependency.createFromString(entry);
} else {
return PluginDependency({
- name: entry.name,
- version: entry.version
+ name: entry.get('name'),
+ version: entry.get('version')
});
}
})