Hello community,

here is the log from the commit of package rubygem-jbuilder for 
openSUSE:Factory checked in at 2015-06-16 14:05:54
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-jbuilder (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-jbuilder.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-jbuilder"

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-jbuilder/rubygem-jbuilder.changes        
2015-05-19 23:48:47.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-jbuilder.new/rubygem-jbuilder.changes   
2015-06-16 14:06:10.000000000 +0200
@@ -1,0 +2,15 @@
+Tue Jun 16 04:32:15 UTC 2015 - co...@suse.com
+
+- updated to version 2.3.0
+ see installed CHANGELOG.md
+
+  2.3.0
+  -----
+  
+  * [Add new in-place partial invocation 
support](https://github.com/rails/jbuilder/commit/1feda7ee605c136e59fb4de970f4674de518e6de)
+  * [Add implicit partial rendering for 
AM::Models](https://github.com/rails/jbuilder/commit/4d5bf7d0ea92765adb7be36834e84f9855a061df)
+  * [Generate API controller if Rails API option is 
enabled](https://github.com/rails/jbuilder/commit/db68f6bd327cf42b47ef22d455fb5721a8c2cf5f)
+  * [JBuilder's templates have less priority than app 
templates](https://github.com/rails/jbuilder/commit/7c1a5f25603ec1f4e51fba3dbba9db23726a5d69)
+  * [Add AC::Helpers module to jbuilder for api only 
apps](https://github.com/rails/jbuilder/commit/7cf1d1eb7d125caf38309b5427952030011c1aa0)
+
+-------------------------------------------------------------------

Old:
----
  jbuilder-2.2.16.gem

New:
----
  jbuilder-2.3.0.gem

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

Other differences:
------------------
++++++ rubygem-jbuilder.spec ++++++
--- /var/tmp/diff_new_pack.niRWIq/_old  2015-06-16 14:06:10.000000000 +0200
+++ /var/tmp/diff_new_pack.niRWIq/_new  2015-06-16 14:06:10.000000000 +0200
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-jbuilder
-Version:        2.2.16
+Version:        2.3.0
 Release:        0
 %define mod_name jbuilder
 %define mod_full_name %{mod_name}-%{version}

++++++ jbuilder-2.2.16.gem -> jbuilder-2.3.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/.travis.yml new/.travis.yml
--- old/.travis.yml     2015-05-18 06:31:21.000000000 +0200
+++ new/.travis.yml     2015-06-15 09:21:03.000000000 +0200
@@ -16,6 +16,7 @@
   - gemfiles/rails_4_0.gemfile
   - gemfiles/rails_4_1.gemfile
   - gemfiles/rails_4_2.gemfile
+  - gemfiles/rails_edge.gemfile
 
 matrix:
   allow_failures:
@@ -23,6 +24,17 @@
     - rvm: rbx
     - rvm: ruby-head
   fast_finish: true
+  exclude:
+    - rvm: 1.9
+      gemfile: gemfiles/rails_edge.gemfile
+    - rvm: 2.0
+      gemfile: gemfiles/rails_edge.gemfile
+    - rvm: 2.1
+      gemfile: gemfiles/rails_edge.gemfile
+    - rvm: jruby-19mode
+      gemfile: gemfiles/rails_edge.gemfile
+    - rvm: rbx
+      gemfile: gemfiles/rails_edge.gemfile
 
 notifications:
   email: false
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Appraisals new/Appraisals
--- old/Appraisals      2015-05-18 06:31:21.000000000 +0200
+++ new/Appraisals      2015-06-15 09:21:03.000000000 +0200
@@ -1,32 +1,43 @@
 appraise "rails-3-0" do
   gem "test-unit"
-  gem "railties",   "~> 3.0.0"
-  gem "actionpack", "~> 3.0.0"
+  gem "railties",    "~> 3.0.0"
+  gem "actionpack",  "~> 3.0.0"
+  gem "activemodel", "~> 3.0.0"
 end
 
 appraise "rails-3-1" do
   gem "test-unit"
-  gem "railties",   "~> 3.1.0"
-  gem "actionpack", "~> 3.1.0"
+  gem "railties",    "~> 3.1.0"
+  gem "actionpack",  "~> 3.1.0"
+  gem "activemodel", "~> 3.1.0"
 end
 
 appraise "rails-3-2" do
   gem "test-unit"
-  gem "railties",   "~> 3.2.0"
-  gem "actionpack", "~> 3.2.0"
+  gem "railties",    "~> 3.2.0"
+  gem "actionpack",  "~> 3.2.0"
+  gem "activemodel", "~> 3.2.0"
 end
 
 appraise "rails-4-0" do
-  gem "railties",   "~> 4.0.0"
-  gem "actionpack", "~> 4.0.0"
+  gem "railties",    "~> 4.0.0"
+  gem "actionpack",  "~> 4.0.0"
+  gem "activemodel", "~> 4.0.0"
 end
 
 appraise "rails-4-1" do
-  gem "railties",   "~> 4.1.0"
-  gem "actionpack", "~> 4.1.0"
+  gem "railties",    "~> 4.1.0"
+  gem "actionpack",  "~> 4.1.0"
+  gem "activemodel", "~> 4.1.0"
 end
 
 appraise "rails-4-2" do
-  gem "railties",   "~> 4.2.0"
-  gem "actionpack", "~> 4.2.0"
+  gem "railties",    "~> 4.2.0"
+  gem "actionpack",  "~> 4.2.0"
+  gem "activemodel", "~> 4.2.0"
+end
+
+appraise "rails-edge" do
+  gem "rails", github: "rails/rails"
+  gem "arel", github: "rails/arel"
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    2015-05-18 06:31:21.000000000 +0200
+++ new/CHANGELOG.md    2015-06-15 09:21:03.000000000 +0200
@@ -1,5 +1,14 @@
 # Changelog
 
+2.3.0
+-----
+
+* [Add new in-place partial invocation 
support](https://github.com/rails/jbuilder/commit/1feda7ee605c136e59fb4de970f4674de518e6de)
+* [Add implicit partial rendering for 
AM::Models](https://github.com/rails/jbuilder/commit/4d5bf7d0ea92765adb7be36834e84f9855a061df)
+* [Generate API controller if Rails API option is 
enabled](https://github.com/rails/jbuilder/commit/db68f6bd327cf42b47ef22d455fb5721a8c2cf5f)
+* [JBuilder's templates have less priority than app 
templates](https://github.com/rails/jbuilder/commit/7c1a5f25603ec1f4e51fba3dbba9db23726a5d69)
+* [Add AC::Helpers module to jbuilder for api only 
apps](https://github.com/rails/jbuilder/commit/7cf1d1eb7d125caf38309b5427952030011c1aa0)
+
 2.2.16
 ------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/Gemfile new/Gemfile
--- old/Gemfile 2015-05-18 06:31:21.000000000 +0200
+++ new/Gemfile 2015-06-15 09:21:03.000000000 +0200
@@ -5,3 +5,4 @@
 gem "rake"
 gem "mocha", require: false
 gem "appraisal"
+gem "pry"
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gemfiles/rails_3_0.gemfile 
new/gemfiles/rails_3_0.gemfile
--- old/gemfiles/rails_3_0.gemfile      2015-05-18 06:31:21.000000000 +0200
+++ new/gemfiles/rails_3_0.gemfile      2015-06-15 09:21:03.000000000 +0200
@@ -5,8 +5,10 @@
 gem "rake"
 gem "mocha", :require => false
 gem "appraisal"
+gem "pry"
 gem "test-unit"
 gem "railties", "~> 3.0.0"
 gem "actionpack", "~> 3.0.0"
+gem "activemodel", "~> 3.0.0"
 
 gemspec :path => "../"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gemfiles/rails_3_1.gemfile 
new/gemfiles/rails_3_1.gemfile
--- old/gemfiles/rails_3_1.gemfile      2015-05-18 06:31:21.000000000 +0200
+++ new/gemfiles/rails_3_1.gemfile      2015-06-15 09:21:03.000000000 +0200
@@ -5,8 +5,10 @@
 gem "rake"
 gem "mocha", :require => false
 gem "appraisal"
+gem "pry"
 gem "test-unit"
 gem "railties", "~> 3.1.0"
 gem "actionpack", "~> 3.1.0"
+gem "activemodel", "~> 3.1.0"
 
 gemspec :path => "../"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gemfiles/rails_3_2.gemfile 
new/gemfiles/rails_3_2.gemfile
--- old/gemfiles/rails_3_2.gemfile      2015-05-18 06:31:21.000000000 +0200
+++ new/gemfiles/rails_3_2.gemfile      2015-06-15 09:21:03.000000000 +0200
@@ -5,8 +5,10 @@
 gem "rake"
 gem "mocha", :require => false
 gem "appraisal"
+gem "pry"
 gem "test-unit"
 gem "railties", "~> 3.2.0"
 gem "actionpack", "~> 3.2.0"
+gem "activemodel", "~> 3.2.0"
 
 gemspec :path => "../"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gemfiles/rails_4_0.gemfile 
new/gemfiles/rails_4_0.gemfile
--- old/gemfiles/rails_4_0.gemfile      2015-05-18 06:31:21.000000000 +0200
+++ new/gemfiles/rails_4_0.gemfile      2015-06-15 09:21:03.000000000 +0200
@@ -5,7 +5,9 @@
 gem "rake"
 gem "mocha", :require => false
 gem "appraisal"
+gem "pry"
 gem "railties", "~> 4.0.0"
 gem "actionpack", "~> 4.0.0"
+gem "activemodel", "~> 4.0.0"
 
 gemspec :path => "../"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gemfiles/rails_4_1.gemfile 
new/gemfiles/rails_4_1.gemfile
--- old/gemfiles/rails_4_1.gemfile      2015-05-18 06:31:21.000000000 +0200
+++ new/gemfiles/rails_4_1.gemfile      2015-06-15 09:21:03.000000000 +0200
@@ -5,7 +5,9 @@
 gem "rake"
 gem "mocha", :require => false
 gem "appraisal"
+gem "pry"
 gem "railties", "~> 4.1.0"
 gem "actionpack", "~> 4.1.0"
+gem "activemodel", "~> 4.1.0"
 
 gemspec :path => "../"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/gemfiles/rails_4_2.gemfile 
new/gemfiles/rails_4_2.gemfile
--- old/gemfiles/rails_4_2.gemfile      2015-05-18 06:31:21.000000000 +0200
+++ new/gemfiles/rails_4_2.gemfile      2015-06-15 09:21:03.000000000 +0200
@@ -5,7 +5,9 @@
 gem "rake"
 gem "mocha", :require => false
 gem "appraisal"
+gem "pry"
 gem "railties", "~> 4.2.0"
 gem "actionpack", "~> 4.2.0"
+gem "activemodel", "~> 4.2.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-06-15 09:21:03.000000000 +0200
@@ -0,0 +1,11 @@
+# This file was generated by Appraisal
+
+source "https://rubygems.org";
+
+gem "rake"
+gem "mocha", :require => false
+gem "appraisal"
+gem "rails", :github => "rails/rails"
+gem "arel", :github => "rails/arel"
+
+gemspec :path => "../"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/jbuilder.gemspec new/jbuilder.gemspec
--- old/jbuilder.gemspec        2015-05-18 06:31:21.000000000 +0200
+++ new/jbuilder.gemspec        2015-06-15 09:21:03.000000000 +0200
@@ -1,6 +1,6 @@
 Gem::Specification.new do |s|
   s.name     = 'jbuilder'
-  s.version  = '2.2.16'
+  s.version  = '2.3.0'
   s.authors  = ['David Heinemeier Hansson', 'Pavel Pravosud']
   s.email    = ['da...@37signals.com', 'pa...@pravosud.com']
   s.summary  = 'Create JSON structures via a Builder-style DSL'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/lib/generators/rails/scaffold_controller_generator.rb 
new/lib/generators/rails/scaffold_controller_generator.rb
--- old/lib/generators/rails/scaffold_controller_generator.rb   2015-05-18 
06:31:21.000000000 +0200
+++ new/lib/generators/rails/scaffold_controller_generator.rb   2015-06-15 
09:21:03.000000000 +0200
@@ -4,7 +4,7 @@
 module Rails
   module Generators
     class ScaffoldControllerGenerator
-      source_paths.unshift File.expand_path('../templates', __FILE__)
+      source_paths << File.expand_path('../templates', __FILE__)
 
       hook_for :jbuilder, default: true
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/generators/rails/templates/api_controller.rb 
new/lib/generators/rails/templates/api_controller.rb
--- old/lib/generators/rails/templates/api_controller.rb        1970-01-01 
01:00:00.000000000 +0100
+++ new/lib/generators/rails/templates/api_controller.rb        2015-06-15 
09:21:03.000000000 +0200
@@ -0,0 +1,63 @@
+<% if namespaced? -%>
+require_dependency "<%= namespaced_file_path %>/application_controller"
+
+<% end -%>
+<% module_namespacing do -%>
+class <%= controller_class_name %>Controller < ApplicationController
+  before_action :set_<%= singular_table_name %>, only: [:show, :update, 
:destroy]
+
+  # GET <%= route_url %>
+  # GET <%= route_url %>.json
+  def index
+    @<%= plural_table_name %> = <%= orm_class.all(class_name) %>
+  end
+
+  # GET <%= route_url %>/1
+  # GET <%= route_url %>/1.json
+  def show
+  end
+
+  # POST <%= route_url %>
+  # POST <%= route_url %>.json
+  def create
+    @<%= singular_table_name %> = <%= orm_class.build(class_name, 
"#{singular_table_name}_params") %>
+
+    if @<%= orm_instance.save %>
+      render :show, status: :created, location: <%= "@#{singular_table_name}" 
%>
+    else
+      render json: <%= "@#{orm_instance.errors}" %>, status: 
:unprocessable_entity
+    end
+  end
+
+  # PATCH/PUT <%= route_url %>/1
+  # PATCH/PUT <%= route_url %>/1.json
+  def update
+    if @<%= orm_instance.update("#{singular_table_name}_params") %>
+      render :show, status: :ok, location: <%= "@#{singular_table_name}" %>
+    else
+      render json: <%= "@#{orm_instance.errors}" %>, status: 
:unprocessable_entity
+    end
+  end
+
+  # DELETE <%= route_url %>/1
+  # DELETE <%= route_url %>/1.json
+  def destroy
+    @<%= orm_instance.destroy %>
+  end
+
+  private
+    # Use callbacks to share common setup or constraints between actions.
+    def set_<%= singular_table_name %>
+      @<%= singular_table_name %> = <%= orm_class.find(class_name, 
"params[:id]") %>
+    end
+
+    # Never trust parameters from the scary internet, only allow the white 
list through.
+    def <%= "#{singular_table_name}_params" %>
+      <%- if attributes_names.empty? -%>
+      params[<%= ":#{singular_table_name}" %>]
+      <%- else -%>
+      params.require(<%= ":#{singular_table_name}" %>).permit(<%= 
attributes_names.map { |name| ":#{name}" }.join(', ') %>)
+      <%- end -%>
+    end
+end
+<% end -%>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/jbuilder/jbuilder_template.rb 
new/lib/jbuilder/jbuilder_template.rb
--- old/lib/jbuilder/jbuilder_template.rb       2015-05-18 06:31:21.000000000 
+0200
+++ new/lib/jbuilder/jbuilder_template.rb       2015-06-15 09:21:03.000000000 
+0200
@@ -11,37 +11,14 @@
 
   def initialize(context, *args)
     @context = context
-    super(*args)
+    super *args
   end
 
-  def partial!(name_or_options, locals = {})
-    case name_or_options
-    when ::Hash
-      # partial! partial: 'name', foo: 'bar'
-      options = name_or_options
+  def partial!(*args)
+    if args.one? && _is_active_model?(args.first)
+      _render_active_model_partial args.first
     else
-      # partial! 'name', locals: {foo: 'bar'}
-      if locals.one? && (locals.keys.first == :locals)
-        options = locals.merge(partial: name_or_options)
-      else
-        options = { partial: name_or_options, locals: locals }
-      end
-      # partial! 'name', foo: 'bar'
-      as = locals.delete(:as)
-      options[:as] = as if as.present?
-      options[:collection] = locals[:collection] if locals.key?(:collection)
-    end
-
-    _render_partial_with_options options
-  end
-
-  def array!(collection = [], *attributes)
-    options = attributes.extract_options!
-
-    if options.key?(:partial)
-      partial! options[:partial], options.merge(collection: collection)
-    else
-      super
+      _render_explicit_partial *args
     end
   end
 
@@ -78,7 +55,27 @@
     condition ? cache!(*args, &::Proc.new) : yield
   end
 
-  protected
+  def array!(collection = [], *args)
+    options = args.first
+
+    if args.one? && _partial_options?(options)
+      partial! options.merge(collection: collection)
+    else
+      super
+    end
+  end
+
+  def set!(name, object = BLANK, *args)
+    options = args.first
+
+    if args.one? && _partial_options?(options)
+      _set_inline_partial name, object, options
+    else
+      super
+    end
+  end
+
+  private
 
   def _render_partial_with_options(options)
     options.reverse_merge! locals: {}
@@ -111,8 +108,6 @@
     ::ActiveSupport::Cache.expand_cache_key(key, :jbuilder)
   end
 
-  private
-
   def _fragment_name_with_digest(key, options)
     if @context.respond_to?(:cache_fragment_name)
       # Current compatibility, fragment_name_with_digest is private again and 
cache_fragment_name
@@ -126,10 +121,50 @@
     end
   end
 
-  def _mapable_arguments?(value, *args)
-    return true if super
-    options = args.last
-    ::Hash === options && options.key?(:as)
+  def _partial_options?(options)
+    ::Hash === options && options.key?(:as) && options.key?(:partial)
+  end
+
+  def _is_active_model?(object)
+    object.class.respond_to?(:model_name) && 
object.respond_to?(:to_partial_path)
+  end
+
+  def _set_inline_partial(name, object, options)
+    value = if object.nil?
+      []
+    elsif _is_collection?(object)
+      _scope{ _render_partial_with_options options.merge(collection: object) }
+    else
+      locals = ::Hash[options[:as], object]
+      _scope{ _render_partial options.merge(locals: locals) }
+    end
+
+    set! name, value
+  end
+
+  def _render_explicit_partial(name_or_options, locals = {})
+    case name_or_options
+    when ::Hash
+      # partial! partial: 'name', foo: 'bar'
+      options = name_or_options
+    else
+      # partial! 'name', locals: {foo: 'bar'}
+      if locals.one? && (locals.keys.first == :locals)
+        options = locals.merge(partial: name_or_options)
+      else
+        options = { partial: name_or_options, locals: locals }
+      end
+      # partial! 'name', foo: 'bar'
+      as = locals.delete(:as)
+      options[:as] = as if as.present?
+      options[:collection] = locals[:collection] if locals.key?(:collection)
+    end
+
+    _render_partial_with_options options
+  end
+
+  def _render_active_model_partial(object)
+    @context.render object, json: self
   end
 end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/jbuilder/railtie.rb new/lib/jbuilder/railtie.rb
--- old/lib/jbuilder/railtie.rb 2015-05-18 06:31:21.000000000 +0200
+++ new/lib/jbuilder/railtie.rb 2015-06-15 09:21:03.000000000 +0200
@@ -12,6 +12,8 @@
       if app.config.respond_to?(:api_only) && app.config.api_only
         ActiveSupport.on_load :action_controller do
           include ActionView::Rendering
+          include ActionController::Helpers
+          include ActionController::ImplicitRender
         end
       end
     end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/jbuilder.rb new/lib/jbuilder.rb
--- old/lib/jbuilder.rb 2015-05-18 06:31:21.000000000 +0200
+++ new/lib/jbuilder.rb 2015-06-15 09:21:03.000000000 +0200
@@ -23,6 +23,7 @@
   end
 
   BLANK = Blank.new
+  NON_ENUMERABLES = [ ::Struct, ::OpenStruct ].to_set
 
   def set!(key, value = BLANK, *args)
     result = if ::Kernel.block_given?
@@ -46,7 +47,7 @@
         # { "age": 32 }
         value
       end
-    elsif _mapable_arguments?(value, *args)
+    elsif _is_collection?(value)
       # json.comments @post.comments, :content, :created_at
       # { "comments": [ { "content": "hello", "created_at": "..." }, { 
"content": "world", "created_at": "..." } ] }
       _scope{ array! value, *args }
@@ -59,8 +60,13 @@
     _set_value key, result
   end
 
-  alias_method :method_missing, :set!
-  private :method_missing
+  def method_missing(*args)
+    if ::Kernel.block_given?
+      set! *args, &::Proc.new
+    else
+      set! *args
+    end
+  end
 
   # Specifies formatting to be applied to the key. Passing in a name of a 
function
   # will cause that function to be called on the key.  So :upcase will upper 
case
@@ -301,13 +307,17 @@
     @attributes, @key_formatter = parent_attributes, parent_formatter
   end
 
-  def _mapable_arguments?(value, *args)
-    value.respond_to?(:map)
+  def _is_collection?(object)
+    _object_respond_to?(object, :map, :count) && NON_ENUMERABLES.none?{ 
|klass| klass === object }
   end
 
   def _blank?(value=@attributes)
     BLANK == value
   end
+
+  def _object_respond_to?(object, *methods)
+    methods.all?{ |m| object.respond_to?(m) }
+  end
 end
 
 require 'jbuilder/railtie' if defined?(Rails)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2015-05-18 06:31:21.000000000 +0200
+++ new/metadata        2015-06-15 09:21:03.000000000 +0200
@@ -1,7 +1,7 @@
 --- !ruby/object:Gem::Specification
 name: jbuilder
 version: !ruby/object:Gem::Version
-  version: 2.2.16
+  version: 2.3.0
 platform: ruby
 authors:
 - David Heinemeier Hansson
@@ -9,7 +9,7 @@
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2015-05-18 00:00:00.000000000 Z
+date: 2015-06-15 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: activesupport
@@ -67,9 +67,11 @@
 - gemfiles/rails_4_0.gemfile
 - gemfiles/rails_4_1.gemfile
 - gemfiles/rails_4_2.gemfile
+- gemfiles/rails_edge.gemfile
 - jbuilder.gemspec
 - lib/generators/rails/jbuilder_generator.rb
 - lib/generators/rails/scaffold_controller_generator.rb
+- lib/generators/rails/templates/api_controller.rb
 - lib/generators/rails/templates/controller.rb
 - lib/generators/rails/templates/index.json.jbuilder
 - lib/generators/rails/templates/show.json.jbuilder
@@ -85,6 +87,7 @@
 - test/jbuilder_generator_test.rb
 - test/jbuilder_template_test.rb
 - test/jbuilder_test.rb
+- test/scaffold_api_controller_generator_test.rb
 - test/scaffold_controller_generator_test.rb
 - test/test_helper.rb
 homepage: https://github.com/rails/jbuilder
@@ -116,5 +119,6 @@
 - test/jbuilder_generator_test.rb
 - test/jbuilder_template_test.rb
 - test/jbuilder_test.rb
+- test/scaffold_api_controller_generator_test.rb
 - test/scaffold_controller_generator_test.rb
 - test/test_helper.rb
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/jbuilder_template_test.rb 
new/test/jbuilder_template_test.rb
--- old/test/jbuilder_template_test.rb  2015-05-18 06:31:21.000000000 +0200
+++ new/test/jbuilder_template_test.rb  2015-06-15 09:21:03.000000000 +0200
@@ -1,16 +1,17 @@
-require 'test_helper'
-require 'mocha/setup'
-require 'action_view'
-require 'action_view/testing/resolvers'
-require 'active_support/cache'
-require 'jbuilder/jbuilder_template'
+require "test_helper"
+require "mocha/setup"
+require "active_model"
+require "action_view"
+require "action_view/testing/resolvers"
+require "active_support/cache"
+require "jbuilder/jbuilder_template"
 
 BLOG_POST_PARTIAL = <<-JBUILDER
   json.extract! blog_post, :id, :body
   json.author do
-    name = blog_post.author_name.split(nil, 2)
-    json.first_name name[0]
-    json.last_name  name[1]
+    first_name, last_name = blog_post.author_name.split(nil, 2)
+    json.first_name first_name
+    json.last_name last_name
   end
 JBUILDER
 
@@ -18,14 +19,37 @@
   json.extract! collection, :id, :name
 JBUILDER
 
+RACER_PARTIAL = <<-JBUILDER
+  json.extract! racer, :id, :name
+JBUILDER
+
+class Racer
+  extend ActiveModel::Naming
+  include ActiveModel::Conversion
+
+  def initialize(id, name)
+    @id, @name = id, name
+  end
+
+  attr_reader :id, :name
+end
+
+
 BlogPost = Struct.new(:id, :body, :author_name)
 Collection = Struct.new(:id, :name)
-blog_authors = [ 'David Heinemeier Hansson', 'Pavel Pravosud' ].cycle
-BLOG_POST_COLLECTION = 10.times.map{ |i| BlogPost.new(i+1, "post body #{i+1}", 
blog_authors.next) }
-COLLECTION_COLLECTION = 5.times.map{ |i| Collection.new(i+1, "collection 
#{i+1}") }
+blog_authors = [ "David Heinemeier Hansson", "Pavel Pravosud" ].cycle
+BLOG_POST_COLLECTION = Array.new(10){ |i| BlogPost.new(i+1, "post body 
#{i+1}", blog_authors.next) }
+COLLECTION_COLLECTION = Array.new(5){ |i| Collection.new(i+1, "collection 
#{i+1}") }
 
 ActionView::Template.register_template_handler :jbuilder, JbuilderHandler
 
+PARTIALS = {
+  "_partial.json.jbuilder"  => "foo ||= 'hello'; json.content foo",
+  "_blog_post.json.jbuilder" => BLOG_POST_PARTIAL,
+  "racers/_racer.json.jbuilder" => RACER_PARTIAL,
+  "_collection.json.jbuilder" => COLLECTION_PARTIAL
+}
+
 module Rails
   def self.cache
     @cache ||= ActiveSupport::Cache::MemoryStore.new
@@ -38,18 +62,15 @@
     Rails.cache.clear
   end
 
-  def partials
-    {
-      '_partial.json.jbuilder'  => 'foo ||= "hello"; json.content foo',
-      '_blog_post.json.jbuilder' => BLOG_POST_PARTIAL,
-      '_collection.json.jbuilder' => COLLECTION_PARTIAL
-    }
-  end
-
-  def render_jbuilder(source)
+  def jbuild(source)
     @rendered = []
-    lookup_context.view_paths = 
[ActionView::FixtureResolver.new(partials.merge('test.json.jbuilder' => 
source))]
-    ActionView::Template.new(source, 'test', JbuilderHandler, :virtual_path => 
'test').render(self, {}).strip
+    partials = PARTIALS.clone
+    partials["test.json.jbuilder"] = source
+    resolver = ActionView::FixtureResolver.new(partials)
+    lookup_context.view_paths = [resolver]
+    template = ActionView::Template.new(source, "test", JbuilderHandler, 
virtual_path: "test")
+    json = template.render(self, {}).strip
+    MultiJson.load(json)
   end
 
   def undef_context_methods(*names)
@@ -60,284 +81,303 @@
     end
   end
 
-  def assert_collection_rendered(json, context = nil)
-    result = MultiJson.load(json)
+  def assert_collection_rendered(result, context = nil)
     result = result.fetch(context) if context
 
     assert_equal 10, result.length
     assert_equal Array, result.class
-    assert_equal 'post body 5',        result[4]['body']
-    assert_equal 'Heinemeier Hansson', result[2]['author']['last_name']
-    assert_equal 'Pavel',              result[5]['author']['first_name']
+    assert_equal "post body 5",        result[4]["body"]
+    assert_equal "Heinemeier Hansson", result[2]["author"]["last_name"]
+    assert_equal "Pavel",              result[5]["author"]["first_name"]
   end
 
-  test 'rendering' do
-    json = render_jbuilder <<-JBUILDER
-      json.content 'hello'
+  test "rendering" do
+    result = jbuild(<<-JBUILDER)
+      json.content "hello"
     JBUILDER
 
-    assert_equal 'hello', MultiJson.load(json)['content']
+    assert_equal "hello", result["content"]
   end
 
-  test 'key_format! with parameter' do
-    json = render_jbuilder <<-JBUILDER
-      json.key_format! :camelize => [:lower]
-      json.camel_style 'for JS'
+  test "key_format! with parameter" do
+    result = jbuild(<<-JBUILDER)
+      json.key_format! camelize: [:lower]
+      json.camel_style "for JS"
     JBUILDER
 
-    assert_equal ['camelStyle'], MultiJson.load(json).keys
+    assert_equal ["camelStyle"], result.keys
   end
 
-  test 'key_format! propagates to child elements' do
-    json = render_jbuilder <<-JBUILDER
+  test "key_format! propagates to child elements" do
+    result = jbuild(<<-JBUILDER)
       json.key_format! :upcase
-      json.level1 'one'
+      json.level1 "one"
       json.level2 do
-        json.value 'two'
+        json.value "two"
       end
     JBUILDER
 
-    result = MultiJson.load(json)
-    assert_equal 'one', result['LEVEL1']
-    assert_equal 'two', result['LEVEL2']['VALUE']
+    assert_equal "one", result["LEVEL1"]
+    assert_equal "two", result["LEVEL2"]["VALUE"]
   end
 
-  test 'partial! renders partial' do
-    json = render_jbuilder <<-JBUILDER
-      json.partial! 'partial'
+  test "partial! renders partial" do
+    result = jbuild(<<-JBUILDER)
+      json.partial! "partial"
     JBUILDER
 
-    assert_equal 'hello', MultiJson.load(json)['content']
+    assert_equal "hello", result["content"]
   end
 
-  test 'partial! + locals via :locals option' do
-    json = render_jbuilder <<-JBUILDER
-      json.partial! 'partial', locals: { foo: 'howdy' }
+  test "partial! + locals via :locals option" do
+    result = jbuild(<<-JBUILDER)
+      json.partial! "partial", locals: { foo: "howdy" }
     JBUILDER
 
-    assert_equal 'howdy', MultiJson.load(json)['content']
+    assert_equal "howdy", result["content"]
   end
 
-  test 'partial! + locals without :locals key' do
-    json = render_jbuilder <<-JBUILDER
-      json.partial! 'partial', foo: 'goodbye'
+  test "partial! + locals without :locals key" do
+    result = jbuild(<<-JBUILDER)
+      json.partial! "partial", foo: "goodbye"
     JBUILDER
 
-    assert_equal 'goodbye', MultiJson.load(json)['content']
+    assert_equal "goodbye", result["content"]
   end
 
-  test 'partial! renders collections' do
-    json = render_jbuilder <<-JBUILDER
-      json.partial! 'blog_post', :collection => BLOG_POST_COLLECTION, :as => 
:blog_post
+  test "partial! renders collections" do
+    result = jbuild(<<-JBUILDER)
+      json.partial! "blog_post", collection: BLOG_POST_COLLECTION, as: 
:blog_post
     JBUILDER
 
-    assert_collection_rendered json
+    assert_collection_rendered result
   end
 
-  test 'partial! renders collections when as argument is a string' do
-    json = render_jbuilder <<-JBUILDER
-      json.partial! 'blog_post', collection: BLOG_POST_COLLECTION, as: 
"blog_post"
+  test "partial! renders collections when as argument is a string" do
+    result = jbuild(<<-JBUILDER)
+      json.partial! "blog_post", collection: BLOG_POST_COLLECTION, as: 
"blog_post"
     JBUILDER
 
-    assert_collection_rendered json
+    assert_collection_rendered result
   end
 
-  test 'partial! renders collections as collections' do
-    json = render_jbuilder <<-JBUILDER
-      json.partial! 'collection', collection: COLLECTION_COLLECTION, as: 
:collection
+  test "partial! renders collections as collections" do
+    result = jbuild(<<-JBUILDER)
+      json.partial! "collection", collection: COLLECTION_COLLECTION, as: 
:collection
     JBUILDER
 
-    assert_equal 5, MultiJson.load(json).length
+    assert_equal 5, result.length
   end
 
-  test 'partial! renders as empty array for nil-collection' do
-    json = render_jbuilder <<-JBUILDER
-      json.partial! 'blog_post', :collection => nil, :as => :blog_post
+  test "partial! renders as empty array for nil-collection" do
+    result = jbuild(<<-JBUILDER)
+      json.partial! "blog_post", collection: nil, as: :blog_post
     JBUILDER
 
-    assert_equal '[]', json
+    assert_equal [], result
   end
 
-  test 'partial! renders collection (alt. syntax)' do
-    json = render_jbuilder <<-JBUILDER
-      json.partial! :partial => 'blog_post', :collection => 
BLOG_POST_COLLECTION, :as => :blog_post
+  test "partial! renders collection (alt. syntax)" do
+    result = jbuild(<<-JBUILDER)
+      json.partial! partial: "blog_post", collection: BLOG_POST_COLLECTION, 
as: :blog_post
     JBUILDER
 
-    assert_collection_rendered json
+    assert_collection_rendered result
   end
 
-  test 'partial! renders as empty array for nil-collection (alt. syntax)' do
-    json = render_jbuilder <<-JBUILDER
-      json.partial! :partial => 'blog_post', :collection => nil, :as => 
:blog_post
+  test "partial! renders as empty array for nil-collection (alt. syntax)" do
+    result = jbuild(<<-JBUILDER)
+      json.partial! partial: "blog_post", collection: nil, as: :blog_post
     JBUILDER
 
-    assert_equal '[]', json
+    assert_equal [], result
   end
 
-  test 'render array of partials' do
-    json = render_jbuilder <<-JBUILDER
-      json.array! BLOG_POST_COLLECTION, :partial => 'blog_post', :as => 
:blog_post
+  test "render array of partials" do
+    result = jbuild(<<-JBUILDER)
+      json.array! BLOG_POST_COLLECTION, partial: "blog_post", as: :blog_post
     JBUILDER
 
-    assert_collection_rendered json
+    assert_collection_rendered result
   end
 
-  test 'render array of partials as empty array with nil-collection' do
-    json = render_jbuilder <<-JBUILDER
-      json.array! nil, :partial => 'blog_post', :as => :blog_post
+  test "render array of partials as empty array with nil-collection" do
+    result = jbuild(<<-JBUILDER)
+      json.array! nil, partial: "blog_post", as: :blog_post
     JBUILDER
 
-    assert_equal '[]', json
+    assert_equal [], result
   end
 
-  test 'render array if partials as a value' do
-    json = render_jbuilder <<-JBUILDER
-      json.posts BLOG_POST_COLLECTION, :partial => 'blog_post', :as => 
:blog_post
+  test "render array of partials as a value" do
+    result = jbuild(<<-JBUILDER)
+      json.posts BLOG_POST_COLLECTION, partial: "blog_post", as: :blog_post
     JBUILDER
 
-    assert_collection_rendered json, 'posts'
+    assert_collection_rendered result, "posts"
   end
 
-  test 'render as empty array if partials as a nil value' do
-    json = render_jbuilder <<-JBUILDER
-      json.posts nil, :partial => 'blog_post', :as => :blog_post
+  test "render as empty array if partials as a nil value" do
+    result = jbuild <<-JBUILDER
+      json.posts nil, partial: "blog_post", as: :blog_post
     JBUILDER
 
-    assert_equal '{"posts":[]}', json
+    assert_equal [], result["posts"]
   end
 
-  test 'cache an empty block' do
+  test "cache an empty block" do
     undef_context_methods :fragment_name_with_digest, :cache_fragment_name
 
-    render_jbuilder <<-JBUILDER
-      json.cache! 'nothing' do
+    jbuild <<-JBUILDER
+      json.cache! "nothing" do
       end
     JBUILDER
 
-    json = nil
+    result = nil
 
     assert_nothing_raised do
-      json = render_jbuilder <<-JBUILDER
-        json.foo 'bar'
-        json.cache! 'nothing' do
+      result = jbuild(<<-JBUILDER)
+        json.foo "bar"
+        json.cache! "nothing" do
         end
       JBUILDER
     end
 
-    assert_equal 'bar', MultiJson.load(json)['foo']
+    assert_equal "bar", result["foo"]
   end
 
-  test 'fragment caching a JSON object' do
+  test "fragment caching a JSON object" do
     undef_context_methods :fragment_name_with_digest, :cache_fragment_name
 
-    render_jbuilder <<-JBUILDER
-      json.cache! 'cachekey' do
-        json.name 'Cache'
+    jbuild <<-JBUILDER
+      json.cache! "cachekey" do
+        json.name "Cache"
       end
     JBUILDER
 
-    json = render_jbuilder <<-JBUILDER
-      json.cache! 'cachekey' do
-        json.name 'Miss'
+    result = jbuild(<<-JBUILDER)
+      json.cache! "cachekey" do
+        json.name "Miss"
       end
     JBUILDER
 
-    parsed = MultiJson.load(json)
-    assert_equal 'Cache', parsed['name']
+    assert_equal "Cache", result["name"]
   end
 
-  test 'conditionally fragment caching a JSON object' do
+  test "conditionally fragment caching a JSON object" do
     undef_context_methods :fragment_name_with_digest, :cache_fragment_name
 
-    render_jbuilder <<-JBUILDER
-      json.cache_if! true, 'cachekey' do
-        json.test1 'Cache'
+    jbuild <<-JBUILDER
+      json.cache_if! true, "cachekey" do
+        json.test1 "Cache"
       end
-      json.cache_if! false, 'cachekey' do
-        json.test2 'Cache'
+      json.cache_if! false, "cachekey" do
+        json.test2 "Cache"
       end
     JBUILDER
 
-    json = render_jbuilder <<-JBUILDER
-      json.cache_if! true, 'cachekey' do
-        json.test1 'Miss'
+    result = jbuild(<<-JBUILDER)
+      json.cache_if! true, "cachekey" do
+        json.test1 "Miss"
       end
-      json.cache_if! false, 'cachekey' do
-        json.test2 'Miss'
+      json.cache_if! false, "cachekey" do
+        json.test2 "Miss"
       end
     JBUILDER
 
-    parsed = MultiJson.load(json)
-    assert_equal 'Cache', parsed['test1']
-    assert_equal 'Miss', parsed['test2']
+    assert_equal "Cache", result["test1"]
+    assert_equal "Miss", result["test2"]
   end
 
-  test 'fragment caching deserializes an array' do
+  test "fragment caching deserializes an array" do
     undef_context_methods :fragment_name_with_digest, :cache_fragment_name
 
-    render_jbuilder <<-JBUILDER
-      json.cache! 'cachekey' do
+    jbuild <<-JBUILDER
+      json.cache! "cachekey" do
         json.array! %w[a b c]
       end
     JBUILDER
 
-    json = render_jbuilder <<-JBUILDER
-      json.cache! 'cachekey' do
+    result = jbuild(<<-JBUILDER)
+      json.cache! "cachekey" do
         json.array! %w[1 2 3]
       end
     JBUILDER
 
-    parsed = MultiJson.load(json)
-    assert_equal %w[a b c], parsed
+    assert_equal %w[a b c], result
   end
 
-  test 'fragment caching works with previous version of cache digests' do
+  test "fragment caching works with previous version of cache digests" do
     undef_context_methods :cache_fragment_name
 
     @context.expects :fragment_name_with_digest
 
-    render_jbuilder <<-JBUILDER
-      json.cache! 'cachekey' do
-        json.name 'Cache'
+    jbuild <<-JBUILDER
+      json.cache! "cachekey" do
+        json.name "Cache"
       end
     JBUILDER
   end
 
-  test 'fragment caching works with current cache digests' do
+  test "fragment caching works with current cache digests" do
     undef_context_methods :fragment_name_with_digest
 
     @context.expects :cache_fragment_name
     ActiveSupport::Cache.expects :expand_cache_key
 
-    render_jbuilder <<-JBUILDER
-      json.cache! 'cachekey' do
-        json.name 'Cache'
+    jbuild <<-JBUILDER
+      json.cache! "cachekey" do
+        json.name "Cache"
       end
     JBUILDER
   end
 
-  test 'current cache digest option accepts options' do
+  test "current cache digest option accepts options" do
     undef_context_methods :fragment_name_with_digest
 
-    @context.expects(:cache_fragment_name).with('cachekey', skip_digest: true)
+    @context.expects(:cache_fragment_name).with("cachekey", skip_digest: true)
     ActiveSupport::Cache.expects :expand_cache_key
 
-    render_jbuilder <<-JBUILDER
-      json.cache! 'cachekey', skip_digest: true do
-        json.name 'Cache'
+    jbuild <<-JBUILDER
+      json.cache! "cachekey", skip_digest: true do
+        json.name "Cache"
       end
     JBUILDER
   end
 
-  test 'does not perform caching when controller.perform_caching is false' do
+  test "does not perform caching when controller.perform_caching is false" do
     controller.perform_caching = false
-    render_jbuilder <<-JBUILDER
-      json.cache! 'cachekey' do
-        json.name 'Cache'
+
+    jbuild <<-JBUILDER
+      json.cache! "cachekey" do
+        json.name "Cache"
       end
     JBUILDER
 
-    assert_equal Rails.cache.inspect[/entries=(\d+)/, 1], '0'
+    assert_equal Rails.cache.inspect[/entries=(\d+)/, 1], "0"
+  end
+
+  test "invokes templates via params via set!" do
+    @post = BLOG_POST_COLLECTION.first
+
+    result = jbuild(<<-JBUILDER)
+      json.post @post, partial: "blog_post", as: :blog_post
+    JBUILDER
+
+    assert_equal 1, result["post"]["id"]
+    assert_equal "post body 1", result["post"]["body"]
+    assert_equal "David", result["post"]["author"]["first_name"]
   end
 
+  test "invokes templates implicitly for ActiveModel objects" do
+    @racer = Racer.new(123, "Chris Harris")
+
+    result = jbuild(<<-JBUILDER)
+      json.partial! @racer
+    JBUILDER
+
+    assert_equal %w[id name], result.keys
+    assert_equal 123, result["id"]
+    assert_equal "Chris Harris", result["name"]
+  end
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/jbuilder_test.rb new/test/jbuilder_test.rb
--- old/test/jbuilder_test.rb   2015-05-18 06:31:21.000000000 +0200
+++ new/test/jbuilder_test.rb   2015-06-15 09:21:03.000000000 +0200
@@ -13,9 +13,7 @@
     @collection = collection
   end
 
-  def map(&block)
-    @collection.map(&block)
-  end
+  delegate :map, :count, to: :@collection
 end
 
 class VeryBasicWrapper < BasicObject
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/test/scaffold_api_controller_generator_test.rb 
new/test/scaffold_api_controller_generator_test.rb
--- old/test/scaffold_api_controller_generator_test.rb  1970-01-01 
01:00:00.000000000 +0100
+++ new/test/scaffold_api_controller_generator_test.rb  2015-06-15 
09:21:03.000000000 +0200
@@ -0,0 +1,46 @@
+require 'test_helper'
+require 'rails/generators/test_case'
+require 'generators/rails/scaffold_controller_generator'
+
+if Rails::VERSION::MAJOR > 4
+
+  class ScaffoldApiControllerGeneratorTest < Rails::Generators::TestCase
+    tests Rails::Generators::ScaffoldControllerGenerator
+    arguments %w(Post title body:text --api)
+    destination File.expand_path('../tmp', __FILE__)
+    setup :prepare_destination
+
+    test 'controller content' do
+      run_generator
+
+      assert_file 'app/controllers/posts_controller.rb' do |content|
+        assert_instance_method :index, content do |m|
+          assert_match /@posts = Post\.all/, m
+        end
+
+        assert_instance_method :show, content do |m|
+          assert m.blank?
+        end
+
+        assert_instance_method :create, content do |m|
+          assert_match /@post = Post\.new\(post_params\)/, m
+          assert_match /@post\.save/, m
+          assert_match /render :show, status: :created, location: @post/, m
+          assert_match /render json: @post\.errors, status: 
:unprocessable_entity/, m
+        end
+
+        assert_instance_method :update, content do |m|
+          assert_match /render :show, status: :ok, location: @post/, m
+          assert_match /render json: @post.errors, status: 
:unprocessable_entity/, m
+        end
+
+        assert_instance_method :destroy, content do |m|
+          assert_match /@post\.destroy/, m
+        end
+
+        assert_match(/def post_params/, content)
+        assert_match(/params\.require\(:post\)\.permit\(:title, :body\)/, 
content)
+      end
+    end
+  end
+end


Reply via email to