Hello community,

here is the log from the commit of package rubygem-responders for 
openSUSE:Factory checked in at 2016-06-14 23:06:40
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-responders (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-responders.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-responders"

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-responders/rubygem-responders.changes    
2016-04-28 16:56:39.000000000 +0200
+++ 
/work/SRC/openSUSE:Factory/.rubygem-responders.new/rubygem-responders.changes   
    2016-06-14 23:06:41.000000000 +0200
@@ -1,0 +2,13 @@
+Sat Apr 30 04:41:34 UTC 2016 - [email protected]
+
+- updated to version 2.2.0
+ see installed CHANGELOG.md
+
+  ## 2.2.0
+  
+  * Added the `verify_request_format!` method, that can be used as a 
`before_action`
+    callback to prevent your actions from being invoked when the controller 
does
+    not respond to the request mime type, preventing the execution of complex
+    queries or creating/deleting records from your app.
+
+-------------------------------------------------------------------

Old:
----
  responders-2.1.2.gem

New:
----
  responders-2.2.0.gem

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

Other differences:
------------------
++++++ rubygem-responders.spec ++++++
--- /var/tmp/diff_new_pack.dMMRYU/_old  2016-06-14 23:06:41.000000000 +0200
+++ /var/tmp/diff_new_pack.dMMRYU/_new  2016-06-14 23:06:41.000000000 +0200
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-responders
-Version:        2.1.2
+Version:        2.2.0
 Release:        0
 %define mod_name responders
 %define mod_full_name %{mod_name}-%{version}

++++++ responders-2.1.2.gem -> responders-2.2.0.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/CHANGELOG.md new/CHANGELOG.md
--- old/CHANGELOG.md    2016-03-21 15:20:44.000000000 +0100
+++ new/CHANGELOG.md    2016-04-29 19:47:31.000000000 +0200
@@ -1,3 +1,10 @@
+## 2.2.0
+
+* Added the `verify_request_format!` method, that can be used as a 
`before_action`
+  callback to prevent your actions from being invoked when the controller does
+  not respond to the request mime type, preventing the execution of complex
+  queries or creating/deleting records from your app.
+
 ## 2.1.2
 
 * Fix rendering when using `ActionController::API`. (by @eLod)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/README.md new/README.md
--- old/README.md       2016-03-21 15:20:44.000000000 +0100
+++ new/README.md       2016-04-29 19:47:31.000000000 +0200
@@ -17,7 +17,7 @@
     $ bundle install
     $ rails g responders:install
 
-If you are including this gem to support backwards compatibilty for responders 
in previous releases of Rails, you only need to include the gem and bundle. 
+If you are including this gem to support backwards compatibilty for responders 
in previous releases of Rails, you only need to include the gem and bundle.
 
     $ bundle install
 
@@ -188,7 +188,7 @@
 
     config.app_generators.scaffold_controller :responders_controller
 
-#Failure handling
+## Failure handling
 
 Responders don't use `valid?` to check for errors in models to figure out if
 the request was successfull or not, and relies on your controllers to call
@@ -216,6 +216,29 @@
 end
 ```
 
+## Verifying request formats
+
+`respond_with` will raise an `ActionController::UnknownFormat` if the request
+mime type was not configured through the class level `respond_to`, but the
+action will still be executed and any side effects (like creating a new record)
+will still occur. To raise the `UnknownFormat` exception before your action
+is invoked you can set the `verify_request_format!` method as a `before_action`
+on your controller.
+
+```ruby
+class WidgetsController < ApplicationController
+  respond_to :json
+  before_action :verify_request_format!
+
+  # POST /widgets.html won't reach the `create` action.
+  def create
+    widget = Widget.create(widget_params)
+    respond_with widget
+  end
+end
+
+```
+
 ## Examples
 
 Want more examples ? Check out this blog posts:
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/action_controller/respond_with.rb 
new/lib/action_controller/respond_with.rb
--- old/lib/action_controller/respond_with.rb   2016-03-21 15:20:44.000000000 
+0100
+++ new/lib/action_controller/respond_with.rb   2016-04-29 19:47:31.000000000 
+0200
@@ -40,14 +40,14 @@
         only_actions   = Array(options.delete(:only)).map(&:to_s)
         except_actions = Array(options.delete(:except)).map(&:to_s)
 
-        new = mimes_for_respond_to.dup
+        hash = mimes_for_respond_to.dup
         mimes.each do |mime|
           mime = mime.to_sym
-          new[mime]          = {}
-          new[mime][:only]   = only_actions   unless only_actions.empty?
-          new[mime][:except] = except_actions unless except_actions.empty?
+          hash[mime]          = {}
+          hash[mime][:only]   = only_actions   unless only_actions.empty?
+          hash[mime][:except] = except_actions unless except_actions.empty?
         end
-        self.mimes_for_respond_to = new.freeze
+        self.mimes_for_respond_to = hash.freeze
       end
 
       # Clear all mime types in <tt>respond_to</tt>.
@@ -193,7 +193,7 @@
           "formats your controller responds to in the class level."
       end
 
-      mimes = collect_mimes_from_class_level()
+      mimes = collect_mimes_from_class_level
       collector = ActionController::MimeResponds::Collector.new(mimes, 
request.variant)
       block.call(collector) if block_given?
 
@@ -208,7 +208,24 @@
       end
     end
 
-  protected
+    protected
+
+    # Before action callback that can be used to prevent requests that do not
+    # match the mime types defined through <tt>respond_to</tt> from being 
executed.
+    #
+    #   class PeopleController < ApplicationController
+    #     respond_to :html, :xml, :json
+    #
+    #     before_action :verify_request_format!
+    #   end
+    def verify_request_format!
+      mimes = collect_mimes_from_class_level
+      collector = ActionController::MimeResponds::Collector.new(mimes, 
request.variant)
+
+      unless collector.negotiate_format(request)
+        raise ActionController::UnknownFormat
+      end
+    end
 
     # Collect mimes declared in the class method respond_to valid for the
     # current action.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/responders/version.rb 
new/lib/responders/version.rb
--- old/lib/responders/version.rb       2016-03-21 15:20:44.000000000 +0100
+++ new/lib/responders/version.rb       2016-04-29 19:47:31.000000000 +0200
@@ -1,3 +1,3 @@
 module Responders
-  VERSION = "2.1.2".freeze
+  VERSION = "2.2.0".freeze
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        2016-03-21 15:20:44.000000000 +0100
+++ new/metadata        2016-04-29 19:47:31.000000000 +0200
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: responders
 version: !ruby/object:Gem::Version
-  version: 2.1.2
+  version: 2.2.0
 platform: ruby
 authors:
 - José Valim
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2016-03-21 00:00:00.000000000 Z
+date: 2016-04-29 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: railties


Reply via email to