Hello community, here is the log from the commit of package rubygem-js-routes for openSUSE:Factory checked in at 2015-08-07 00:24:32 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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-04-25 11:25:46.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-js-routes.new/rubygem-js-routes.changes 2015-08-07 00:24:35.000000000 +0200 @@ -1,0 +2,19 @@ +Thu Aug 6 04:30:03 UTC 2015 - [email protected] + +- updated to version 1.1.0 + see installed CHANGELOG.md + + ## v1.1.0 + + * Ensure routes are loaded, prior to generating them [#148](https://github.com/railsware/js-routes/pull/148) + * Use `flat_map` rather than `map{...}.flatten` [#149](https://github.com/railsware/js-routes/pull/149) + * URL escape routes.rb url to fix bad URI(is not URI?) error [#150](https://github.com/railsware/js-routes/pull/150) + * Fix for rails 5 - test rails-edge on travis allowing failure [#151](https://github.com/railsware/js-routes/pull/151) + * Adds `serializer` option [#155](https://github.com/railsware/js-routes/pull/155/files) + + ## v1.0.1 + + * Support sprockets-3 + * Performance optimization of include/exclude options + +------------------------------------------------------------------- Old: ---- js-routes-1.0.1.gem New: ---- js-routes-1.1.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-js-routes.spec ++++++ --- /var/tmp/diff_new_pack.o0ZHPF/_old 2015-08-07 00:24:36.000000000 +0200 +++ /var/tmp/diff_new_pack.o0ZHPF/_new 2015-08-07 00:24:36.000000000 +0200 @@ -24,7 +24,7 @@ # Name: rubygem-js-routes -Version: 1.0.1 +Version: 1.1.0 Release: 0 %define mod_name js-routes %define mod_full_name %{mod_name}-%{version} ++++++ js-routes-1.0.1.gem -> js-routes-1.1.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/.travis.yml new/.travis.yml --- old/.travis.yml 2015-04-17 11:13:09.000000000 +0200 +++ new/.travis.yml 2015-08-05 10:59:04.000000000 +0200 @@ -13,10 +13,10 @@ gemfile: - gemfiles/rails32.gemfile - gemfiles/rails40.gemfile - - gemfiles/rails41.gemfile - - gemfiles/rails42.gemfile - gemfiles/rails40_sprockets3.gemfile + - gemfiles/rails41.gemfile - gemfiles/rails41_sprockets3.gemfile + - gemfiles/rails42.gemfile - gemfiles/rails42_sprockets3.gemfile sudo: false @@ -30,7 +30,12 @@ - master matrix: + include: + - gemfile: gemfiles/rails_edge.gemfile + rvm: 2.2 allow_failures: - rvm: jruby-19mode - rvm: ruby-head - rvm: jruby-head + - gemfile: gemfiles/rails_edge.gemfile + rvm: 2.2 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Appraisals new/Appraisals --- old/Appraisals 2015-04-17 11:13:09.000000000 +0200 +++ new/Appraisals 2015-08-05 10:59:04.000000000 +0200 @@ -3,7 +3,7 @@ gem 'tzinfo' end -{rails40: '4.0.5', rails41: '4.1.1', rails42: '4.2.0'}.each do |rails, version| +{rails40: '4.0.5', rails41: '4.1.1', rails42: '4.2.1'}.each do |rails, version| appraise "#{rails}" do gem "railties", "~> #{version}" gem "sprockets", "< 3" @@ -14,3 +14,8 @@ gem "sprockets", "~> 3.0" end end + +appraise "rails-edge" do + gem "railties", github: 'rails/rails' + gem "sprockets", "~> 3.0" +end \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md --- old/CHANGELOG.md 2015-04-17 11:13:09.000000000 +0200 +++ new/CHANGELOG.md 2015-08-05 10:59:04.000000000 +0200 @@ -1,5 +1,18 @@ ## master +## v1.1.0 + +* Ensure routes are loaded, prior to generating them [#148](https://github.com/railsware/js-routes/pull/148) +* Use `flat_map` rather than `map{...}.flatten` [#149](https://github.com/railsware/js-routes/pull/149) +* URL escape routes.rb url to fix bad URI(is not URI?) error [#150](https://github.com/railsware/js-routes/pull/150) +* Fix for rails 5 - test rails-edge on travis allowing failure [#151](https://github.com/railsware/js-routes/pull/151) +* Adds `serializer` option [#155](https://github.com/railsware/js-routes/pull/155/files) + +## v1.0.1 + +* Support sprockets-3 +* Performance optimization of include/exclude options + ## v1.0.0 * Add the compact mode [#125](https://github.com/railsware/js-routes/pull/125) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/Readme.md new/Readme.md --- old/Readme.md 2015-04-17 11:13:09.000000000 +0200 +++ new/Readme.md 2015-08-05 10:59:04.000000000 +0200 @@ -69,6 +69,10 @@ * `compact` (version > 0.9.9) - Remove `_path` suffix in path routes(`*_url` routes stay untouched if they were enabled) * Default: false * Sample route call when option is set to true: Routes.users() => `/users` +* `serializer` (version >= 1.1.0) - Puts a JS function here that serializes a Javascript Hash object into URL paramters: `{a: 1, b: 2} => "a=1&b=2"`. + * Default: `nil`. Uses built-in serializer + * Example: `jQuery.param` - use jQuery's serializer algorithm. You can attach serialize function from your favorite AJAX framework. + * Example: `MyApp.custom_serialize` - use completely custom serializer of your application. ### Very Advanced Setup @@ -91,7 +95,7 @@ #= require application/routes ``` -In order to generate the routes to a string: +In order to generate the routes JS code to a string: ```ruby routes_js = JsRoutes.generate(options) Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gemfiles/rails42.gemfile new/gemfiles/rails42.gemfile --- old/gemfiles/rails42.gemfile 2015-04-17 11:13:09.000000000 +0200 +++ new/gemfiles/rails42.gemfile 2015-08-05 10:59:04.000000000 +0200 @@ -2,7 +2,7 @@ source "http://rubygems.org" -gem "railties", "~> 4.2.0" +gem "railties", "~> 4.2.1" gem "sprockets", "< 3" gemspec :path => "../" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gemfiles/rails42_sprockets3.gemfile new/gemfiles/rails42_sprockets3.gemfile --- old/gemfiles/rails42_sprockets3.gemfile 2015-04-17 11:13:09.000000000 +0200 +++ new/gemfiles/rails42_sprockets3.gemfile 2015-08-05 10:59:04.000000000 +0200 @@ -2,7 +2,7 @@ source "http://rubygems.org" -gem "railties", "~> 4.2.0" +gem "railties", "~> 4.2.1" gem "sprockets", "~> 3.0" gemspec :path => "../" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gemfiles/rails_edge.gemfile new/gemfiles/rails_edge.gemfile --- old/gemfiles/rails_edge.gemfile 1970-01-01 01:00:00.000000000 +0100 +++ new/gemfiles/rails_edge.gemfile 2015-08-05 10:59:04.000000000 +0200 @@ -0,0 +1,8 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "railties", :github => "rails/rails" +gem "sprockets", "~> 3.0" + +gemspec :path => "../" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/js-routes.gemspec new/js-routes.gemspec --- old/js-routes.gemspec 2015-04-17 11:13:09.000000000 +0200 +++ new/js-routes.gemspec 2015-08-05 10:59:04.000000000 +0200 @@ -30,6 +30,9 @@ if defined?(JRUBY_VERSION) s.add_development_dependency(%q<therubyrhino>, [">= 2.0.4"]) else + if RUBY_VERSION >= "2.0.0" + s.add_development_dependency(%q<byebug>) + end s.add_development_dependency(%q<therubyracer>, [">= 0.12.1"]) end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/js_routes/engine.rb new/lib/js_routes/engine.rb --- old/lib/js_routes/engine.rb 2015-04-17 11:13:09.000000000 +0200 +++ new/lib/js_routes/engine.rb 2015-08-05 10:59:04.000000000 +0200 @@ -14,7 +14,7 @@ # only sprockets >= 3.0 if Rails.application.assets.respond_to?(:depend_on) - Rails.application.assets.depend_on "file-digest://#{routes}" + Rails.application.assets.depend_on Rack::Utils.escape("file-digest://#{routes}") end end end 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-04-17 11:13:09.000000000 +0200 +++ new/lib/js_routes/version.rb 2015-08-05 10:59:04.000000000 +0200 @@ -1,3 +1,3 @@ class JsRoutes - VERSION = "1.0.1" + VERSION = "1.1.0" end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/js_routes.rb new/lib/js_routes.rb --- old/lib/js_routes.rb 2015-04-17 11:13:09.000000000 +0200 +++ new/lib/js_routes.rb 2015-08-05 10:59:04.000000000 +0200 @@ -19,7 +19,8 @@ url_links: nil, camel_case: false, default_url_options: {}, - compact: false + compact: false, + serializer: nil } NODE_TYPES = { @@ -57,6 +58,11 @@ end def generate(opts = {}) + # Ensure routes are loaded. If they're not, load them. + if Rails.application.routes.named_routes.routes.keys.empty? + Rails.application.reload_routes! + end + new(opts).generate end @@ -93,10 +99,13 @@ def generate js = File.read(File.dirname(__FILE__) + "/routes.js") + js.gsub!("GEM_VERSION", JsRoutes::VERSION) + js.gsub!("APP_CLASS", Rails.application.class.to_s) js.gsub!("NAMESPACE", @options[:namespace]) js.gsub!("DEFAULT_URL_OPTIONS", json(@options[:default_url_options].merge(deprecated_default_format))) js.gsub!("PREFIX", @options[:prefix] || "") js.gsub!("NODE_TYPES", json(NODE_TYPES)) + js.gsub!("SERIALIZER", @options[:serializer] || "null") js.gsub!("ROUTES", js_routes) end @@ -124,7 +133,7 @@ protected def js_routes - js_routes = Rails.application.routes.named_routes.routes.sort_by(&:to_s).map do |_, route| + js_routes = Rails.application.routes.named_routes.routes.sort_by(&:to_s).flat_map do |_, route| rails_engine_app = get_app_from_route(route) if rails_engine_app.respond_to?(:superclass) && rails_engine_app.superclass == Rails::Engine && !route.path.anchored rails_engine_app.routes.named_routes.map do |_, engine_route| @@ -133,7 +142,7 @@ else build_route_if_match(route) end - end.flatten.compact + end.compact "{\n" + js_routes.join(",\n") + "}\n" end @@ -157,7 +166,7 @@ def any_match?(route, parent_route, matchers) full_route = [parent_route.try(:name), route.name].compact.join('_') - + matchers = Array(matchers) matchers.any? {|regex| full_route =~ regex} end @@ -165,7 +174,7 @@ def build_js(route, parent_route) name = [parent_route.try(:name), route.name].compact parent_spec = parent_route.try(:path).try(:spec) - required_parts, optional_parts = route.required_parts.clone, route.optional_parts.clone + required_parts, optional_parts = route.required_parts.clone, (route.parts-route.required_parts) optional_parts.push(required_parts.delete :format) if required_parts.include?(:format) route_name = generate_route_name(name, (:path unless @options[:compact])) url_link = generate_url_link(name, route_name, required_parts, route) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/routes.js new/lib/routes.js --- old/lib/routes.js 2015-04-17 11:13:09.000000000 +0200 +++ new/lib/routes.js 2015-08-05 10:59:04.000000000 +0200 @@ -1,3 +1,9 @@ +/* +File generated by js-routes GEM_VERSION +Based on Rails routes of APP_CLASS +*/ + + (function() { var NodeTypes, ParameterMissing, Utils, createGlobalJsRoutesObject, defaults, root, __hasProp = {}.hasOwnProperty; @@ -18,8 +24,8 @@ NodeTypes = NODE_TYPES; Utils = { - serialize: function(object, prefix) { - var element, i, key, prop, result, s, _i, _len; + default_serializer: function(object, prefix) { + var element, i, key, prop, s, _i, _len; if (prefix == null) { prefix = null; @@ -30,16 +36,12 @@ if (!prefix && !(this.get_object_type(object) === "object")) { throw new Error("Url parameters should be a javascript hash"); } - if (root.jQuery) { - result = root.jQuery.param(object); - return (!result ? "" : result); - } s = []; switch (this.get_object_type(object)) { case "array": for (i = _i = 0, _len = object.length; _i < _len; i = ++_i) { element = object[i]; - s.push(this.serialize(element, prefix + "[]")); + s.push(this.default_serializer(element, prefix + "[]")); } break; case "object": @@ -52,7 +54,7 @@ if (prefix != null) { key = "" + prefix + "[" + key + "]"; } - s.push(this.serialize(prop, key)); + s.push(this.default_serializer(prop, key)); } break; default: @@ -65,6 +67,16 @@ } return s.join("&"); }, + serialize: function(object) { + var custom_serializer; + + custom_serializer = SERIALIZER; + if (custom_serializer) { + return custom_serializer(object); + } else { + return this.default_serializer(object); + } + }, clean_path: function(path) { var last_index; @@ -351,6 +363,9 @@ namespace(root, "NAMESPACE"); root.NAMESPACE = ROUTES; root.NAMESPACE.options = defaults; + root.NAMESPACE.default_serializer = function(object, prefix) { + return Utils.default_serializer(object, prefix); + }; return root.NAMESPACE; }; 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-04-17 11:13:09.000000000 +0200 +++ new/lib/routes.js.coffee 2015-08-05 10:59:04.000000000 +0200 @@ -1,3 +1,7 @@ +### +File generated by js-routes GEM_VERSION +Based on Rails routes of APP_CLASS +### # root is this root = (exports ? this) @@ -11,24 +15,20 @@ Utils = - serialize: (object, prefix = null) -> + default_serializer: (object, prefix = null) -> return "" unless object if !prefix and !(@get_object_type(object) is "object") throw new Error("Url parameters should be a javascript hash") - if root.jQuery - result = root.jQuery.param(object) - return (if not result then "" else result) - s = [] switch @get_object_type(object) when "array" for element, i in object - s.push @serialize(element, prefix + "[]") + s.push @default_serializer(element, prefix + "[]") when "object" for own key, prop of object when prop? key = "#{prefix}[#{key}]" if prefix? - s.push @serialize(prop, key) + s.push @default_serializer(prop, key) else if object s.push "#{encodeURIComponent(prefix.toString())}=#{encodeURIComponent(object.toString())}" @@ -36,6 +36,13 @@ return "" unless s.length s.join("&") + serialize: (object) -> + custom_serializer = SERIALIZER + if custom_serializer + custom_serializer(object) + else + @default_serializer(object) + clean_path: (path) -> path = path.split("://") last_index = path.length - 1 @@ -273,6 +280,8 @@ namespace(root, "NAMESPACE") root.NAMESPACE = ROUTES root.NAMESPACE.options = defaults + root.NAMESPACE.default_serializer = (object, prefix) -> + Utils.default_serializer(object, prefix) root.NAMESPACE # Set up Routes appropriately for the environment. if typeof define is "function" and define.amd @@ -280,4 +289,4 @@ define [], -> createGlobalJsRoutesObject() else # Browser globals - createGlobalJsRoutesObject() \ No newline at end of file + createGlobalJsRoutesObject() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2015-04-17 11:13:09.000000000 +0200 +++ new/metadata 2015-08-05 10:59:04.000000000 +0200 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: js-routes version: !ruby/object:Gem::Version - version: 1.0.1 + version: 1.1.0 platform: ruby authors: - Bogdan Gusiev autorequire: bindir: bin cert_chain: [] -date: 2015-04-17 00:00:00.000000000 Z +date: 2015-08-05 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: railties @@ -109,6 +109,20 @@ - !ruby/object:Gem::Version version: 0.5.2 - !ruby/object:Gem::Dependency + name: byebug + requirement: !ruby/object:Gem::Requirement + requirements: + - - ">=" + - !ruby/object:Gem::Version + version: '0' + type: :development + prerelease: false + version_requirements: !ruby/object:Gem::Requirement + requirements: + - - ">=" + - !ruby/object:Gem::Version + version: '0' +- !ruby/object:Gem::Dependency name: therubyracer requirement: !ruby/object:Gem::Requirement requirements: @@ -149,6 +163,7 @@ - gemfiles/rails41_sprockets3.gemfile - gemfiles/rails42.gemfile - gemfiles/rails42_sprockets3.gemfile +- gemfiles/rails_edge.gemfile - js-routes.gemspec - lib/js-routes.rb - lib/js_routes.rb @@ -160,6 +175,7 @@ - spec/dummy/app/assets/javascripts/.gitkeep - spec/dummy/config/routes.rb - spec/js_routes/amd_compatibility_spec.rb +- spec/js_routes/default_serializer_spec.rb - spec/js_routes/generated_javascript_spec.rb - spec/js_routes/options_spec.rb - spec/js_routes/rails_routes_compatibility_spec.rb 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 1970-01-01 01:00:00.000000000 +0100 +++ new/spec/js_routes/default_serializer_spec.rb 2015-08-05 10:59:04.000000000 +0200 @@ -0,0 +1,13 @@ +describe JsRoutes, "#default_serializer" do + + before(:each) do + evaljs(JsRoutes.generate({})) + 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" + ) + end + +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-04-17 11:13:09.000000000 +0200 +++ new/spec/js_routes/generated_javascript_spec.rb 2015-08-05 10:59:04.000000000 +0200 @@ -9,6 +9,18 @@ describe "generated js" do 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+},)) + end + + it "should include a comment in the header" do + app_class = "App" + + is_expected.to include("File generated by js-routes #{JsRoutes::VERSION}") + is_expected.to include("Based on Rails routes of #{app_class}") + end + it "should call route function for each route" do is_expected.to include("inboxes_path: Utils.route(") end 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-04-17 11:13:09.000000000 +0200 +++ new/spec/js_routes/options_spec.rb 2015-08-05 10:59:04.000000000 +0200 @@ -13,6 +13,21 @@ let(:_options) { {} } let(:_warnings) { true } + context "when serializer is specified" do + 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 exclude is specified" do let(:_options) { {:exclude => /^admin_/} } @@ -292,11 +307,11 @@ context "when only host option is specified" do let(:_options) { { :url_links => true, :default_url_options => {:host => "example.com"} } } - + it "uses the specified host, defaults protocol to http, defaults port to 80 (leaving it blank)" do expect(evaljs("Routes.inbox_url(1)")).to eq("http://example.com#{routes.inbox_path(1)}") end - + it "does not override protocol when specified in route" do expect(evaljs("Routes.new_session_url()")).to eq("https://example.com#{routes.new_session_path}") end @@ -316,7 +331,7 @@ it "uses the specified protocol and host, defaults port to 80 (leaving it blank)" do expect(evaljs("Routes.inbox_url(1)")).to eq("ftp://example.com#{routes.inbox_path(1)}") end - + it "does not override protocol when specified in route" do expect(evaljs("Routes.new_session_url()")).to eq("https://example.com#{routes.new_session_path}") end @@ -340,11 +355,11 @@ it "does not override protocol when specified in route" do expect(evaljs("Routes.new_session_url()")).to eq("https://example.com:3000#{routes.new_session_path}") end - + it "does not override host, protocol, or port when host is specified in route" do expect(evaljs("Routes.sso_url()")).to eq(routes.sso_url) end - + it "does not override port when specified in route" do expect(evaljs("Routes.portals_url()")).to eq("http://example.com:8080#{routes.portals_path}") end @@ -397,7 +412,7 @@ example.run end end - + let(:_options) { { :compact => true, :url_links => "http://localhost" } } it "should not strip urls" do expect(evaljs("Routes.inbox(1)")).to eq(routes.inbox_path(1)) 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-04-17 11:13:09.000000000 +0200 +++ new/spec/js_routes/rails_routes_compatibility_spec.rb 2015-08-05 10:59:04.000000000 +0200 @@ -147,45 +147,6 @@ end end - context "when jQuery is present" do - before do - evaljs("window.jQuery = {};") - jscontext[:parameterizeFunc] = lambda {|object| _value.to_param} - evaljs("window.jQuery.param = parameterizeFunc") - end - - shared_examples_for "serialization" do - it "should support serialization of objects" do - expect(evaljs("window.jQuery.param(#{_value.to_json})")).to eq(_value.to_param) - expect(evaljs("Routes.inboxes_path(#{_value.to_json})")).to eq(routes.inboxes_path(_value)) - expect(evaljs("Routes.inbox_path(1, #{_value.to_json})")).to eq(routes.inbox_path(1, _value)) - end - end - context "when parameters is a hash" do - let(:_value) do - {:a => {:b => 'c'}, :q => [1,2]} - end - it_should_behave_like 'serialization' - end - context "when parameters is null" do - let(:_value) do - {:hello => {world: nil}} - end - it_should_behave_like 'serialization' - end - context "when parameters is null" do - let(:_value) do - nil - end - - before do - pending("This test is invalid for nil/null and jruby #{JRUBY_VERSION}") if defined?(JRUBY_VERSION) && '1.7.13' == JRUBY_VERSION - end - - it_should_behave_like 'serialization' - end - end - context "using optional path fragments" do context "including not optional parts" do it "should include everything that is not optional" do @@ -204,17 +165,11 @@ expect(evaljs("Routes.thing_path(null, 5)")).to eq(routes.thing_path(nil, 5)) end - # Fail for rails 4.2. Reason: https://github.com/rails/rails/issues/12178 it "should treat undefined as non-given optional part" do - # TODO: remove me after release of rails 4.2.1 (change Appraisals to "~> 4.2.1") - pending("This test is invalid for rails 4.2. Reason: https://github.com/rails/rails/issues/12178") if [4, 2, 0] == [Rails::VERSION::MAJOR, Rails::VERSION::MINOR, Rails::VERSION::TINY] expect(evaljs("Routes.thing_path(5, {optional_id: undefined})")).to eq(routes.thing_path(5, :optional_id => nil)) end - # Fail for rails 4.2. Reason: https://github.com/rails/rails/issues/12178 it "should treat null as non-given optional part" do - # TODO: remove me after release of rails 4.2.1 (change Appraisals to "~> 4.2.1") - pending("This test is invalid for rails 4.2. Reason: https://github.com/rails/rails/issues/12178") if [4, 2, 0] == [Rails::VERSION::MAJOR, Rails::VERSION::MINOR, Rails::VERSION::TINY] expect(evaljs("Routes.thing_path(5, {optional_id: null})")).to eq(routes.thing_path(5, :optional_id => nil)) 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-04-17 11:13:09.000000000 +0200 +++ new/spec/spec_helper.rb 2015-08-05 10:59:04.000000000 +0200 @@ -135,7 +135,9 @@ config.before(:all) do # compile all js files begin Dir["#{File.expand_path(File.join(File.dirname(__FILE__), "..", "lib"))}/**/*.coffee"].each do |coffee| - File.open(coffee.gsub(/\.coffee$/, ""), 'w') {|f| f.write(CoffeeScript.compile(File.read(coffee))) } + File.open(coffee.gsub(/\.coffee$/, ""), 'w') do |f| + f.write(CoffeeScript.compile(File.read(coffee)).lstrip) + end end # compile all js files end draw_routes
