Hello community,

here is the log from the commit of package rubygem-js-routes for 
openSUSE:Factory checked in at 2015-09-27 08:39:35
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-js-routes (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-js-routes.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-js-routes"

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-js-routes/rubygem-js-routes.changes      
2015-08-07 00:24:35.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-js-routes.new/rubygem-js-routes.changes 
2015-09-27 08:38:57.000000000 +0200
@@ -1,0 +2,16 @@
+Tue Sep 15 04:30:38 UTC 2015 - co...@suse.com
+
+- updated to version 1.1.2
+ see installed CHANGELOG.md
+
+  ## v1.1.1
+  
+  * Bugfix regression in serialisation on blank strings caused by 
[#155](https://github.com/railsware/js-routes/pull/155/files)
+
+-------------------------------------------------------------------
+Fri Sep 11 04:29:02 UTC 2015 - co...@suse.com
+
+- updated to version 1.1.1
+ see installed CHANGELOG.md
+
+-------------------------------------------------------------------

Old:
----
  js-routes-1.1.0.gem

New:
----
  js-routes-1.1.2.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-js-routes.spec ++++++
--- /var/tmp/diff_new_pack.99vsY4/_old  2015-09-27 08:38:57.000000000 +0200
+++ /var/tmp/diff_new_pack.99vsY4/_new  2015-09-27 08:38:57.000000000 +0200
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-js-routes
-Version:        1.1.0
+Version:        1.1.2
 Release:        0
 %define mod_name js-routes
 %define mod_full_name %{mod_name}-%{version}

++++++ js-routes-1.1.0.gem -> js-routes-1.1.2.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    2015-08-05 10:59:04.000000000 +0200
+++ new/CHANGELOG.md    2015-09-14 16:16:33.000000000 +0200
@@ -1,5 +1,9 @@
 ## master
 
+## v1.1.1
+
+* Bugfix regression in serialisation on blank strings caused by 
[#155](https://github.com/railsware/js-routes/pull/155/files)
+
 ## v1.1.0
 
 * Ensure routes are loaded, prior to generating them 
[#148](https://github.com/railsware/js-routes/pull/148)
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/js_routes/version.rb new/lib/js_routes/version.rb
--- old/lib/js_routes/version.rb        2015-08-05 10:59:04.000000000 +0200
+++ new/lib/js_routes/version.rb        2015-09-14 16:16:33.000000000 +0200
@@ -1,3 +1,3 @@
 class JsRoutes
-  VERSION = "1.1.0"
+  VERSION = "1.1.2"
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/routes.js new/lib/routes.js
--- old/lib/routes.js   2015-08-05 10:59:04.000000000 +0200
+++ new/lib/routes.js   2015-09-14 16:16:33.000000000 +0200
@@ -1,12 +1,11 @@
 /*
 File generated by js-routes GEM_VERSION
 Based on Rails routes of APP_CLASS
-*/
-
+ */
 
 (function() {
   var NodeTypes, ParameterMissing, Utils, createGlobalJsRoutesObject, 
defaults, root,
-    __hasProp = {}.hasOwnProperty;
+    hasProp = {}.hasOwnProperty;
 
   root = typeof exports !== "undefined" && exports !== null ? exports : this;
 
@@ -25,12 +24,11 @@
 
   Utils = {
     default_serializer: function(object, prefix) {
-      var element, i, key, prop, s, _i, _len;
-
+      var element, i, j, key, len, prop, s;
       if (prefix == null) {
         prefix = null;
       }
-      if (!object) {
+      if (object == null) {
         return "";
       }
       if (!prefix && !(this.get_object_type(object) === "object")) {
@@ -39,27 +37,29 @@
       s = [];
       switch (this.get_object_type(object)) {
         case "array":
-          for (i = _i = 0, _len = object.length; _i < _len; i = ++_i) {
+          for (i = j = 0, len = object.length; j < len; i = ++j) {
             element = object[i];
             s.push(this.default_serializer(element, prefix + "[]"));
           }
           break;
         case "object":
           for (key in object) {
-            if (!__hasProp.call(object, key)) continue;
+            if (!hasProp.call(object, key)) continue;
             prop = object[key];
-            if (!(prop != null)) {
-              continue;
+            if ((prop == null) && (prefix != null)) {
+              prop = "";
             }
-            if (prefix != null) {
-              key = "" + prefix + "[" + key + "]";
+            if (prop != null) {
+              if (prefix != null) {
+                key = prefix + "[" + key + "]";
+              }
+              s.push(this.default_serializer(prop, key));
             }
-            s.push(this.default_serializer(prop, key));
           }
           break;
         default:
-          if (object) {
-            s.push("" + (encodeURIComponent(prefix.toString())) + "=" + 
(encodeURIComponent(object.toString())));
+          if (object != null) {
+            s.push((encodeURIComponent(prefix.toString())) + "=" + 
(encodeURIComponent(object.toString())));
           }
       }
       if (!s.length) {
@@ -67,39 +67,34 @@
       }
       return s.join("&");
     },
+    custom_serializer: SERIALIZER,
     serialize: function(object) {
-      var custom_serializer;
-
-      custom_serializer = SERIALIZER;
-      if (custom_serializer) {
-        return custom_serializer(object);
+      if ((this.custom_serializer != null) && 
this.get_object_type(this.custom_serializer) === "function") {
+        return this.custom_serializer(object);
       } else {
         return this.default_serializer(object);
       }
     },
     clean_path: function(path) {
       var last_index;
-
       path = path.split("://");
       last_index = path.length - 1;
       path[last_index] = path[last_index].replace(/\/+/g, "/");
       return path.join("://");
     },
     set_default_url_options: function(optional_parts, options) {
-      var i, part, _i, _len, _results;
-
-      _results = [];
-      for (i = _i = 0, _len = optional_parts.length; _i < _len; i = ++_i) {
+      var i, j, len, part, results;
+      results = [];
+      for (i = j = 0, len = optional_parts.length; j < len; i = ++j) {
         part = optional_parts[i];
         if (!options.hasOwnProperty(part) && 
defaults.default_url_options.hasOwnProperty(part)) {
-          _results.push(options[part] = defaults.default_url_options[part]);
+          results.push(options[part] = defaults.default_url_options[part]);
         }
       }
-      return _results;
+      return results;
     },
     extract_anchor: function(options) {
       var anchor;
-
       anchor = "";
       if (options.hasOwnProperty("anchor")) {
         anchor = "#" + options.anchor;
@@ -109,7 +104,6 @@
     },
     extract_trailing_slash: function(options) {
       var trailing_slash;
-
       trailing_slash = false;
       if (defaults.default_url_options.hasOwnProperty("trailing_slash")) {
         trailing_slash = defaults.default_url_options.trailing_slash;
@@ -122,7 +116,6 @@
     },
     extract_options: function(number_of_params, args) {
       var last_el;
-
       last_el = args[args.length - 1];
       if (args.length > number_of_params || ((last_el != null) && "object" === 
this.get_object_type(last_el) && !this.look_like_serialized_model(last_el))) {
         return args.pop();
@@ -135,7 +128,6 @@
     },
     path_identifier: function(object) {
       var property;
-
       if (object === 0) {
         return "0";
       }
@@ -159,23 +151,21 @@
     },
     clone: function(obj) {
       var attr, copy, key;
-
       if ((obj == null) || "object" !== this.get_object_type(obj)) {
         return obj;
       }
       copy = obj.constructor();
       for (key in obj) {
-        if (!__hasProp.call(obj, key)) continue;
+        if (!hasProp.call(obj, key)) continue;
         attr = obj[key];
         copy[key] = attr;
       }
       return copy;
     },
     prepare_parameters: function(required_parameters, actual_parameters, 
options) {
-      var i, result, val, _i, _len;
-
+      var i, j, len, result, val;
       result = this.clone(options) || {};
-      for (i = _i = 0, _len = required_parameters.length; _i < _len; i = ++_i) 
{
+      for (i = j = 0, len = required_parameters.length; j < len; i = ++j) {
         val = required_parameters[i];
         if (i < actual_parameters.length) {
           result[val] = actual_parameters[i];
@@ -185,7 +175,6 @@
     },
     build_path: function(required_parameters, optional_parts, route, args) {
       var anchor, opts, parameters, result, trailing_slash, url, url_params;
-
       args = Array.prototype.slice.call(args);
       opts = this.extract_options(required_parameters.length, args);
       if (args.length > required_parameters.length) {
@@ -208,7 +197,6 @@
     },
     visit: function(route, parameters, optional) {
       var left, left_part, right, right_part, type, value;
-
       if (optional == null) {
         optional = false;
       }
@@ -225,7 +213,7 @@
         case NodeTypes.CAT:
           left_part = this.visit(left, parameters, optional);
           right_part = this.visit(right, parameters, optional);
-          if (optional && !(left_part && right_part)) {
+          if (optional && (((left[0] === NodeTypes.SYMBOL || left[0] === 
NodeTypes.CAT) && !left_part) || ((right[0] === NodeTypes.SYMBOL || right[0] 
=== NodeTypes.CAT) && !right_part))) {
             return "";
           }
           return "" + left_part + right_part;
@@ -247,7 +235,6 @@
     },
     build_path_spec: function(route, wildcard) {
       var left, right, type;
-
       if (wildcard == null) {
         wildcard = false;
       }
@@ -276,7 +263,6 @@
     },
     visit_globbing: function(route, parameters, optional) {
       var left, right, type, value;
-
       type = route[0], left = route[1], right = route[2];
       if (left.replace(/^\*/i, "") !== left) {
         route[1] = left = left.replace(/^\*/i, "");
@@ -297,16 +283,14 @@
     },
     get_prefix: function() {
       var prefix;
-
       prefix = defaults.prefix;
       if (prefix !== "") {
-        prefix = (prefix.match("/$") ? prefix : "" + prefix + "/");
+        prefix = (prefix.match("/$") ? prefix : prefix + "/");
       }
       return prefix;
     },
     route: function(required_parts, optional_parts, route_spec) {
       var path_fn;
-
       path_fn = function() {
         return Utils.build_path(required_parts, optional_parts, route_spec, 
arguments);
       };
@@ -318,15 +302,14 @@
     },
     _classToTypeCache: null,
     _classToType: function() {
-      var name, _i, _len, _ref;
-
+      var j, len, name, ref;
       if (this._classToTypeCache != null) {
         return this._classToTypeCache;
       }
       this._classToTypeCache = {};
-      _ref = "Boolean Number String Function Array Date RegExp Object 
Error".split(" ");
-      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-        name = _ref[_i];
+      ref = "Boolean Number String Function Array Date RegExp Object 
Error".split(" ");
+      for (j = 0, len = ref.length; j < len; j++) {
+        name = ref[j];
         this._classToTypeCache["[object " + name + "]"] = name.toLowerCase();
       }
       return this._classToTypeCache;
@@ -348,10 +331,8 @@
 
   createGlobalJsRoutesObject = function() {
     var namespace;
-
     namespace = function(mainRoot, namespaceString) {
       var current, parts;
-
       parts = (namespaceString ? namespaceString.split(".") : []);
       if (!parts.length) {
         return;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/routes.js.coffee new/lib/routes.js.coffee
--- old/lib/routes.js.coffee    2015-08-05 10:59:04.000000000 +0200
+++ new/lib/routes.js.coffee    2015-09-14 16:16:33.000000000 +0200
@@ -16,7 +16,7 @@
 Utils =
 
   default_serializer: (object, prefix = null) ->
-    return ""  unless object
+    return "" unless object?
     if !prefix and !(@get_object_type(object) is "object")
       throw new Error("Url parameters should be a javascript hash")
 
@@ -26,20 +26,24 @@
         for element, i in object
           s.push @default_serializer(element, prefix + "[]")
       when "object"
-        for own key, prop of object when prop?
-          key = "#{prefix}[#{key}]" if prefix?
-          s.push @default_serializer(prop, key)
+        for own key, prop of object
+          if !prop? and prefix?
+            prop = ""
+
+          if prop?
+            key = "#{prefix}[#{key}]" if prefix?
+            s.push @default_serializer(prop, key)
       else
-        if object
+        if object?
           s.push 
"#{encodeURIComponent(prefix.toString())}=#{encodeURIComponent(object.toString())}"
 
     return "" unless s.length
     s.join("&")
 
+  custom_serializer: SERIALIZER
   serialize: (object) ->
-    custom_serializer = SERIALIZER
-    if custom_serializer
-      custom_serializer(object)
+    if @custom_serializer? and @get_object_type(@custom_serializer) is 
"function"
+      @custom_serializer(object)
     else
       @default_serializer(object)
 
@@ -155,7 +159,8 @@
       when NodeTypes.CAT
         left_part = @visit(left, parameters, optional)
         right_part = @visit(right, parameters, optional)
-        return "" if optional and not (left_part and right_part)
+        return "" if optional and (((left[0]  == NodeTypes.SYMBOL or left[0]  
== NodeTypes.CAT) and not left_part) or
+                                   ((right[0] == NodeTypes.SYMBOL or right[0] 
== NodeTypes.CAT) and not right_part))
         "#{left_part}#{right_part}"
       when NodeTypes.SYMBOL
         value = parameters[left]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2015-08-05 10:59:04.000000000 +0200
+++ new/metadata        2015-09-14 16:16:33.000000000 +0200
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: js-routes
 version: !ruby/object:Gem::Version
-  version: 1.1.0
+  version: 1.1.2
 platform: ruby
 authors:
 - Bogdan Gusiev
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2015-08-05 00:00:00.000000000 Z
+date: 2015-09-14 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: railties
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/js_routes/default_serializer_spec.rb 
new/spec/js_routes/default_serializer_spec.rb
--- old/spec/js_routes/default_serializer_spec.rb       2015-08-05 
10:59:04.000000000 +0200
+++ new/spec/js_routes/default_serializer_spec.rb       2015-09-14 
16:16:33.000000000 +0200
@@ -5,8 +5,8 @@
   end
 
   it "should provide this method" do
-    expect(evaljs("Routes.default_serializer({a: 1, b: [2,3], c: {d: 4, e: 
5}})")).to eq(
-      "a=1&b%5B%5D=2&b%5B%5D=3&c%5Bd%5D=4&c%5Be%5D=5"
+    expect(evaljs("Routes.default_serializer({a: 1, b: [2,3], c: {d: 4, e: 5}, 
f: ''})")).to eq(
+      "a=1&b%5B%5D=2&b%5B%5D=3&c%5Bd%5D=4&c%5Be%5D=5&f="
     )
   end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/js_routes/generated_javascript_spec.rb 
new/spec/js_routes/generated_javascript_spec.rb
--- old/spec/js_routes/generated_javascript_spec.rb     2015-08-05 
10:59:04.000000000 +0200
+++ new/spec/js_routes/generated_javascript_spec.rb     2015-09-14 
16:16:33.000000000 +0200
@@ -11,7 +11,7 @@
     subject { JsRoutes.generate }
 
     it "should set the default serializer when none is configured" do
-      is_expected.to match(%r(serialize: function\(object\) {\s+var 
custom_serializer;\s+custom_serializer = null;\s+if \(custom_serializer\) 
{\s+return custom_serializer\(object\);\s+} else {\s+return 
this.default_serializer\(object\);\s+}\s+},))
+      is_expected.to match(%r(custom_serializer: null,\s+serialize: 
function\(object\) {\s+if \(\(this\.custom_serializer != null\) && 
this.get_object_type\(this\.custom_serializer\) === \"function\"\) {\s+return 
this\.custom_serializer\(object\);\s+} else {\s+return 
this\.default_serializer\(object\);\s+}\s+},))
     end
 
     it "should include a comment in the header" do
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/js_routes/options_spec.rb 
new/spec/js_routes/options_spec.rb
--- old/spec/js_routes/options_spec.rb  2015-08-05 10:59:04.000000000 +0200
+++ new/spec/js_routes/options_spec.rb  2015-09-14 16:16:33.000000000 +0200
@@ -14,20 +14,29 @@
   let(:_warnings) { true }
 
   context "when serializer is specified" do
+    # define custom serializer
+    # this is a nonsense serializer, which always returns foo=bar
+    # for all inputs
+    let(:_presetup){ %q(function myCustomSerializer(object, prefix) { return 
"foo=bar"; }) }
     let(:_options) { {:serializer => "myCustomSerializer"} }
 
     it "should set configurable serializer" do
-      # define custom serializer
-      # this is a nonsense serializer, which always returns foo=bar
-      # for all inputs
-      evaljs(%q(function myCustomSerializer(object, prefix) { return 
"foo=bar"; }))
-
       # expect the nonsense serializer above to have appened foo=bar
       # to the end of the path
       expect(evaljs(%q(Routes.inboxes_path()))).to eql("/inboxes?foo=bar")
     end
   end
 
+  context "when serializer is specified, but not function" do
+    let(:_presetup){ %q(var myCustomSerializer = 1) }
+    let(:_options) { {:serializer => "myCustomSerializer"} }
+
+    it "should set configurable serializer" do
+      # expect to use default
+      expect(evaljs(%q(Routes.inboxes_path({a: 1})))).to eql("/inboxes?a=1")
+    end
+  end
+
   context "when exclude is specified" do
 
     let(:_options) { {:exclude => /^admin_/} }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/js_routes/rails_routes_compatibility_spec.rb 
new/spec/js_routes/rails_routes_compatibility_spec.rb
--- old/spec/js_routes/rails_routes_compatibility_spec.rb       2015-08-05 
10:59:04.000000000 +0200
+++ new/spec/js_routes/rails_routes_compatibility_spec.rb       2015-09-14 
16:16:33.000000000 +0200
@@ -74,6 +74,10 @@
     expect(evaljs("Routes.json_only_path({format: 'json'})")).to 
eq(routes.json_only_path(:format => 'json'))
   end
 
+  it "should serialize object with empty string value" do
+    expect(evaljs("Routes.inboxes_path({a: '', b: 1})")).to 
eq(routes.inboxes_path(:a => '', :b => 1))
+  end
+
   it "should support utf-8 route" do
     expect(evaljs("Routes.hello_path()")).to eq(routes.hello_path)
   end
@@ -141,9 +145,8 @@
       expect(evaljs("Routes.search_path({q: 'hello'})")).to 
eq(routes.search_path(:q => 'hello'))
     end
 
-    it "should ignore null parameters" do
-      pending
-      expect(evaljs("Routes.inboxes_path({hello: {world: null}})")).to 
eq(routes.inboxes_path(:hello => {world: nil}))
+    it "should support nested object null parameters" do
+      expect(evaljs("Routes.inboxes_path({hello: {world: null}})")).to 
eq(routes.inboxes_path(:hello => {:world => nil}))
     end
   end
 
@@ -179,6 +182,11 @@
         expect(evaljs("Routes.things_path({optional_id: 5})")).to 
eq(routes.things_path(:optional_id => 5))
       end
 
+      context "on nested optional parts" do
+        it "should include everything that is not optional" do
+          expect(evaljs("Routes.classic_path({controller: 'classic', action: 
'edit'})")).to eq(routes.classic_path(controller: :classic, action: :edit))
+        end
+      end
     end
   end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/spec_helper.rb new/spec/spec_helper.rb
--- old/spec/spec_helper.rb     2015-08-05 10:59:04.000000000 +0200
+++ new/spec/spec_helper.rb     2015-09-14 16:16:33.000000000 +0200
@@ -97,6 +97,8 @@
       resources :things
     end
 
+    get "/:controller(/:action(/:id))" => "classic#classic", :as => :classic
+
     get "/other_optional/(:optional_id)" => "foo#foo", :as => :foo
 
     get 'books/*section/:title' => 'books#show', :as => :book


Reply via email to