responders 0.4.6 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
 - data/lib/responders/flash_responder.rb +6 -1
 - data/lib/responders/version.rb +1 -1
 - data/test/flash_responder_test.rb +8 -0
 - metadata +3 -3
 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -29,7 +29,7 @@ begin 
     | 
|
| 
       29 
29 
     | 
    
         
             
              require 'jeweler'
         
     | 
| 
       30 
30 
     | 
    
         
             
              Jeweler::Tasks.new do |s|
         
     | 
| 
       31 
31 
     | 
    
         
             
                s.name = "responders"
         
     | 
| 
       32 
     | 
    
         
            -
                s.version = Responders::VERSION
         
     | 
| 
      
 32 
     | 
    
         
            +
                s.version = Responders::VERSION.dup
         
     | 
| 
       33 
33 
     | 
    
         
             
                s.summary = "A set of Rails 3 responders to dry up your application"
         
     | 
| 
       34 
34 
     | 
    
         
             
                s.email = "contact@plataformatec.com.br"
         
     | 
| 
       35 
35 
     | 
    
         
             
                s.homepage = "http://github.com/plataformatec/responders"
         
     | 
| 
         @@ -93,6 +93,11 @@ module Responders 
     | 
|
| 
       93 
93 
     | 
    
         
             
                  super
         
     | 
| 
       94 
94 
     | 
    
         
             
                end
         
     | 
| 
       95 
95 
     | 
    
         | 
| 
      
 96 
     | 
    
         
            +
                def to_js
         
     | 
| 
      
 97 
     | 
    
         
            +
                  set_flash_message! if set_flash_message?
         
     | 
| 
      
 98 
     | 
    
         
            +
                  to_format
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
       96 
101 
     | 
    
         
             
              protected
         
     | 
| 
       97 
102 
     | 
    
         | 
| 
       98 
103 
     | 
    
         
             
                def set_flash_message!
         
     | 
| 
         @@ -119,7 +124,7 @@ module Responders 
     | 
|
| 
       119 
124 
     | 
    
         
             
                end
         
     | 
| 
       120 
125 
     | 
    
         | 
| 
       121 
126 
     | 
    
         
             
                def set_flash_now?
         
     | 
| 
       122 
     | 
    
         
            -
                  (@flash_now == true) || (has_errors? ? @flash_now == :on_failure : @flash_now == :on_success)
         
     | 
| 
      
 127 
     | 
    
         
            +
                  (@flash_now == true) || (has_errors? ? @flash_now == :on_failure : @flash_now == :on_success) || (format == :js)
         
     | 
| 
       123 
128 
     | 
    
         
             
                end
         
     | 
| 
       124 
129 
     | 
    
         | 
| 
       125 
130 
     | 
    
         
             
                def set_flash_message? #:nodoc:
         
     | 
    
        data/lib/responders/version.rb
    CHANGED
    
    
| 
         @@ -16,6 +16,7 @@ end 
     | 
|
| 
       16 
16 
     | 
    
         
             
            class AddressesController < ApplicationController
         
     | 
| 
       17 
17 
     | 
    
         
             
              before_filter :set_resource
         
     | 
| 
       18 
18 
     | 
    
         
             
              self.responder = FlashResponder
         
     | 
| 
      
 19 
     | 
    
         
            +
              respond_to :js, :only => :create
         
     | 
| 
       19 
20 
     | 
    
         | 
| 
       20 
21 
     | 
    
         
             
              def action
         
     | 
| 
       21 
22 
     | 
    
         
             
                options = params.slice(:flash, :flash_now)
         
     | 
| 
         @@ -107,6 +108,13 @@ class FlashResponderTest < ActionController::TestCase 
     | 
|
| 
       107 
108 
     | 
    
         
             
                assert_equal "Resource with block created with success", flash[:success]
         
     | 
| 
       108 
109 
     | 
    
         
             
              end
         
     | 
| 
       109 
110 
     | 
    
         | 
| 
      
 111 
     | 
    
         
            +
              def test_sets_now_flash_message_on_javascript_requests
         
     | 
| 
      
 112 
     | 
    
         
            +
                @now = {}
         
     | 
| 
      
 113 
     | 
    
         
            +
                @controller.flash.expects(:now).returns(@now)
         
     | 
| 
      
 114 
     | 
    
         
            +
                post :create, :format => :js
         
     | 
| 
      
 115 
     | 
    
         
            +
                assert_equal "Resource created with success", @now[:success]
         
     | 
| 
      
 116 
     | 
    
         
            +
              end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
       110 
118 
     | 
    
         
             
              def test_sets_flash_message_can_be_set_to_now
         
     | 
| 
       111 
119 
     | 
    
         
             
                @now = {}
         
     | 
| 
       112 
120 
     | 
    
         
             
                @controller.flash.expects(:now).returns(@now)
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version 
     | 
|
| 
       5 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              - 0
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 4
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
              version: 0.4. 
     | 
| 
      
 8 
     | 
    
         
            +
              - 7
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.4.7
         
     | 
| 
       10 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       11 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       12 
12 
     | 
    
         
             
            - "Jos\xC3\xA9 Valim"
         
     | 
| 
         @@ -14,7 +14,7 @@ autorequire: 
     | 
|
| 
       14 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       15 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
            date: 2010-03 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2010-04-03 00:00:00 +02:00
         
     | 
| 
       18 
18 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       19 
19 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       20 
20 
     | 
    
         |