responders 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +1 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +39 -43
- data/Rakefile +0 -18
- data/lib/responders.rb +6 -2
- data/lib/responders/http_cache_responder.rb +1 -3
- data/lib/responders/version.rb +1 -1
- data/responders.gemspec +21 -0
- data/test/http_cache_responder_test.rb +23 -5
- data/test/locales/en.yml +23 -0
- data/test/test_helper.rb +9 -10
- data/test/views/addresses/create.js.erb +1 -0
- data/test/views/addresses/edit.html.erb +1 -0
- data/test/views/addresses/new.html.erb +1 -0
- metadata +20 -11
data/CHANGELOG.rdoc
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
== 0.6
|
2
2
|
|
3
|
+
* HTTP Cache is no longer triggered for collections
|
3
4
|
* :js now sets the flash.now by default, instead of flash
|
4
5
|
* Renamed responders_install generator to responders:install
|
5
6
|
* Added CollectionResponder which allows you to always redirect to the collection path (index action) after POST/PUT/DELETE
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,52 +1,35 @@
|
|
1
|
-
|
2
|
-
remote: /
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
|
5
|
-
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.0)
|
6
|
+
actionpack (= 3.0.0)
|
6
7
|
mail (~> 2.2.5)
|
7
|
-
actionpack (3.0.0
|
8
|
-
activemodel (= 3.0.0
|
9
|
-
activesupport (= 3.0.0
|
8
|
+
actionpack (3.0.0)
|
9
|
+
activemodel (= 3.0.0)
|
10
|
+
activesupport (= 3.0.0)
|
10
11
|
builder (~> 2.1.2)
|
11
12
|
erubis (~> 2.6.6)
|
12
13
|
i18n (~> 0.4.1)
|
13
14
|
rack (~> 1.2.1)
|
14
|
-
rack-mount (~> 0.6.
|
15
|
+
rack-mount (~> 0.6.12)
|
15
16
|
rack-test (~> 0.5.4)
|
16
|
-
tzinfo (~> 0.3.
|
17
|
-
activemodel (3.0.0
|
18
|
-
activesupport (= 3.0.0
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.0)
|
19
|
+
activesupport (= 3.0.0)
|
19
20
|
builder (~> 2.1.2)
|
20
21
|
i18n (~> 0.4.1)
|
21
|
-
activerecord (3.0.0
|
22
|
-
activemodel (= 3.0.0
|
23
|
-
activesupport (= 3.0.0
|
24
|
-
arel (~> 0.
|
25
|
-
tzinfo (~> 0.3.
|
26
|
-
activeresource (3.0.0
|
27
|
-
activemodel (= 3.0.0
|
28
|
-
activesupport (= 3.0.0
|
29
|
-
activesupport (3.0.0
|
30
|
-
|
31
|
-
|
32
|
-
actionpack (= 3.0.0.beta4)
|
33
|
-
activerecord (= 3.0.0.beta4)
|
34
|
-
activeresource (= 3.0.0.beta4)
|
35
|
-
activesupport (= 3.0.0.beta4)
|
36
|
-
bundler (>= 1.0.0.beta.10)
|
37
|
-
railties (= 3.0.0.beta4)
|
38
|
-
railties (3.0.0.beta4)
|
39
|
-
actionpack (= 3.0.0.beta4)
|
40
|
-
activesupport (= 3.0.0.beta4)
|
41
|
-
rake (>= 0.8.3)
|
42
|
-
thor (~> 0.14.0)
|
43
|
-
|
44
|
-
GEM
|
45
|
-
remote: http://rubygems.org/
|
46
|
-
specs:
|
47
|
-
abstract (1.0.0)
|
48
|
-
arel (0.4.0)
|
49
|
-
activesupport (>= 3.0.0.beta)
|
22
|
+
activerecord (3.0.0)
|
23
|
+
activemodel (= 3.0.0)
|
24
|
+
activesupport (= 3.0.0)
|
25
|
+
arel (~> 1.0.0)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.0)
|
28
|
+
activemodel (= 3.0.0)
|
29
|
+
activesupport (= 3.0.0)
|
30
|
+
activesupport (3.0.0)
|
31
|
+
arel (1.0.1)
|
32
|
+
activesupport (~> 3.0.0)
|
50
33
|
builder (2.1.2)
|
51
34
|
columnize (0.3.1)
|
52
35
|
erubis (2.6.6)
|
@@ -62,10 +45,23 @@ GEM
|
|
62
45
|
rake
|
63
46
|
polyglot (0.3.1)
|
64
47
|
rack (1.2.1)
|
65
|
-
rack-mount (0.6.
|
48
|
+
rack-mount (0.6.13)
|
66
49
|
rack (>= 1.0.0)
|
67
50
|
rack-test (0.5.4)
|
68
51
|
rack (>= 1.0)
|
52
|
+
rails (3.0.0)
|
53
|
+
actionmailer (= 3.0.0)
|
54
|
+
actionpack (= 3.0.0)
|
55
|
+
activerecord (= 3.0.0)
|
56
|
+
activeresource (= 3.0.0)
|
57
|
+
activesupport (= 3.0.0)
|
58
|
+
bundler (~> 1.0.0)
|
59
|
+
railties (= 3.0.0)
|
60
|
+
railties (3.0.0)
|
61
|
+
actionpack (= 3.0.0)
|
62
|
+
activesupport (= 3.0.0)
|
63
|
+
rake (>= 0.8.4)
|
64
|
+
thor (~> 0.14.0)
|
69
65
|
rake (0.8.7)
|
70
66
|
ruby-debug (0.10.3)
|
71
67
|
columnize (>= 0.1)
|
@@ -75,12 +71,12 @@ GEM
|
|
75
71
|
thor (0.14.0)
|
76
72
|
treetop (1.4.8)
|
77
73
|
polyglot (>= 0.3.1)
|
78
|
-
tzinfo (0.3.
|
74
|
+
tzinfo (0.3.23)
|
79
75
|
|
80
76
|
PLATFORMS
|
81
77
|
ruby
|
82
78
|
|
83
79
|
DEPENDENCIES
|
84
80
|
mocha
|
85
|
-
rails
|
81
|
+
rails (= 3.0.0)
|
86
82
|
ruby-debug
|
data/Rakefile
CHANGED
@@ -23,21 +23,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
23
23
|
rdoc.rdoc_files.include('README.rdoc')
|
24
24
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
25
|
end
|
26
|
-
|
27
|
-
begin
|
28
|
-
require 'jeweler'
|
29
|
-
Jeweler::Tasks.new do |s|
|
30
|
-
s.name = "responders"
|
31
|
-
s.version = Responders::VERSION.dup
|
32
|
-
s.summary = "A set of Rails 3 responders to dry up your application"
|
33
|
-
s.email = "contact@plataformatec.com.br"
|
34
|
-
s.homepage = "http://github.com/plataformatec/responders"
|
35
|
-
s.description = "A set of Rails 3 responders to dry up your application"
|
36
|
-
s.authors = ['José Valim']
|
37
|
-
s.files = FileList["[A-Z]*", "lib/**/*", "init.rb"]
|
38
|
-
end
|
39
|
-
|
40
|
-
Jeweler::GemcutterTasks.new
|
41
|
-
rescue LoadError
|
42
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install jeweler"
|
43
|
-
end
|
data/lib/responders.rb
CHANGED
@@ -9,7 +9,11 @@ module Responders
|
|
9
9
|
|
10
10
|
class Railtie < ::Rails::Railtie
|
11
11
|
config.responders = ActiveSupport::OrderedOptions.new
|
12
|
-
config.
|
12
|
+
if config.respond_to?(:app_generators)
|
13
|
+
config.app_generators.scaffold_controller = :responders_controller
|
14
|
+
else
|
15
|
+
config.generators.scaffold_controller = :responders_controller
|
16
|
+
end
|
13
17
|
|
14
18
|
# Add load paths straight to I18n, so engines and application can overwrite it.
|
15
19
|
require 'active_support/i18n'
|
@@ -21,4 +25,4 @@ module Responders
|
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
24
|
-
end
|
28
|
+
end
|
@@ -22,9 +22,7 @@ module Responders
|
|
22
22
|
protected
|
23
23
|
|
24
24
|
def do_http_cache!
|
25
|
-
timestamp =
|
26
|
-
resource.updated_at.try(:utc) if resource.respond_to?(:updated_at)
|
27
|
-
end.compact.max
|
25
|
+
timestamp = resource.updated_at.try(:utc) if resource.respond_to?(:updated_at)
|
28
26
|
|
29
27
|
controller.response.last_modified ||= timestamp if timestamp
|
30
28
|
|
data/lib/responders/version.rb
CHANGED
data/responders.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "responders/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "responders"
|
7
|
+
s.version = Responders::VERSION.dup
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.summary = "A set of Rails 3 responders to dry up your application"
|
10
|
+
s.email = "contact@plataformatec.com.br"
|
11
|
+
s.homepage = "http://github.com/plataformatec/responders"
|
12
|
+
s.description = "A set of Rails 3 responders to dry up your application"
|
13
|
+
s.authors = ['José Valim']
|
14
|
+
|
15
|
+
s.rubyforge_project = "responders"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
end
|
@@ -17,6 +17,10 @@ class HttpCacheController < ApplicationController
|
|
17
17
|
respond_with [Address.new(Time.utc(2009)), Address.new(Time.utc(2008))]
|
18
18
|
end
|
19
19
|
|
20
|
+
def changing_collection
|
21
|
+
respond_with Address.all
|
22
|
+
end
|
23
|
+
|
20
24
|
def not_persisted
|
21
25
|
model = Address.new(Time.utc(2009))
|
22
26
|
model.persisted = false
|
@@ -82,13 +86,27 @@ class HttpCacheResponderTest < ActionController::TestCase
|
|
82
86
|
assert_equal 200, @response.status
|
83
87
|
end
|
84
88
|
|
85
|
-
def
|
89
|
+
def test_does_not_set_cache_for_collection
|
86
90
|
get :collection
|
87
|
-
|
88
|
-
|
91
|
+
|
92
|
+
assert_nil @response.headers["Last-Modified"]
|
93
|
+
assert_not_nil @response.headers["ETag"]
|
89
94
|
assert_equal 200, @response.status
|
90
95
|
end
|
91
96
|
|
97
|
+
def test_does_not_return_not_modified_if_collection_has_changed
|
98
|
+
#First request. Returns 2 items
|
99
|
+
Address.stubs(:all).returns [Address.new(Time.utc(2009)), Address.new(Time.utc(2008))]
|
100
|
+
get :changing_collection
|
101
|
+
|
102
|
+
#Second request. Returns 1 item, simulating scenario where a address was deleted
|
103
|
+
Address.stubs(:all).returns [Address.new(Time.utc(2009))]
|
104
|
+
@request.env["HTTP_IF_MODIFIED_SINCE"] = @response.headers["Last-Modified"]
|
105
|
+
get :changing_collection
|
106
|
+
|
107
|
+
assert_not_equal 304, @response.status
|
108
|
+
end
|
109
|
+
|
92
110
|
def test_work_with_an_empty_array
|
93
111
|
get :empty
|
94
112
|
assert_nil @response.headers["Last-Modified"]
|
@@ -96,8 +114,8 @@ class HttpCacheResponderTest < ActionController::TestCase
|
|
96
114
|
assert_equal 200, @response.status
|
97
115
|
end
|
98
116
|
|
99
|
-
def
|
100
|
-
get :
|
117
|
+
def test_it_does_not_set_body_etag_for_single_resource
|
118
|
+
get :single
|
101
119
|
assert_nil @response.headers["ETag"]
|
102
120
|
end
|
103
121
|
|
data/test/locales/en.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
en:
|
2
|
+
flash:
|
3
|
+
actions:
|
4
|
+
create:
|
5
|
+
success: "Resource created with success"
|
6
|
+
failure: "Resource could not be created"
|
7
|
+
with_block:
|
8
|
+
success: "Resource with block created with success"
|
9
|
+
addresses:
|
10
|
+
update:
|
11
|
+
success: "Nice! %{resource_name} was updated with success!"
|
12
|
+
failure: "Oh no! We could not update your address!"
|
13
|
+
destroy:
|
14
|
+
success: "Successfully deleted the address at %{reference}"
|
15
|
+
notice: "Successfully deleted the chosen address at %{reference}"
|
16
|
+
admin:
|
17
|
+
actions:
|
18
|
+
create:
|
19
|
+
notice: "Admin created address with success"
|
20
|
+
addresses:
|
21
|
+
update:
|
22
|
+
notice: "Admin updated address with success"
|
23
|
+
|
data/test/test_helper.rb
CHANGED
@@ -13,25 +13,24 @@ require 'action_controller'
|
|
13
13
|
require 'active_model'
|
14
14
|
require 'rails/railtie'
|
15
15
|
|
16
|
-
|
17
|
-
respond_to :html, :xml
|
18
|
-
end
|
19
|
-
|
20
|
-
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
16
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
21
17
|
require 'responders'
|
22
18
|
|
23
|
-
I18n.load_path << File.
|
19
|
+
I18n.load_path << File.expand_path('../locales/en.yml', __FILE__)
|
24
20
|
I18n.reload!
|
25
21
|
|
26
|
-
ActionController::Base.view_paths = File.join(File.dirname(__FILE__), 'views')
|
27
|
-
|
28
22
|
Responders::Routes = ActionDispatch::Routing::RouteSet.new
|
29
23
|
Responders::Routes.draw do
|
30
24
|
match '/admin/:action', :controller => "admin/addresses"
|
31
25
|
match '/:controller(/:action(/:id))'
|
32
26
|
end
|
33
27
|
|
34
|
-
ActionController::Base
|
28
|
+
class ApplicationController < ActionController::Base
|
29
|
+
include Responders::Routes.url_helpers
|
30
|
+
|
31
|
+
self.view_paths = File.join(File.dirname(__FILE__), 'views')
|
32
|
+
respond_to :html, :xml
|
33
|
+
end
|
35
34
|
|
36
35
|
class ActiveSupport::TestCase
|
37
36
|
setup do
|
@@ -64,4 +63,4 @@ class Address < Model
|
|
64
63
|
end
|
65
64
|
|
66
65
|
class User < Model
|
67
|
-
end
|
66
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
create.js.erb
|
@@ -0,0 +1 @@
|
|
1
|
+
edit.html.erb
|
@@ -0,0 +1 @@
|
|
1
|
+
new.html.erb
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: responders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
5
|
-
prerelease:
|
4
|
+
hash: 1
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 6
|
9
|
-
-
|
10
|
-
version: 0.6.
|
9
|
+
- 3
|
10
|
+
version: 0.6.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Jos\xC3\xA9 Valim"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2011-05-07 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -25,8 +25,8 @@ executables: []
|
|
25
25
|
|
26
26
|
extensions: []
|
27
27
|
|
28
|
-
extra_rdoc_files:
|
29
|
-
|
28
|
+
extra_rdoc_files: []
|
29
|
+
|
30
30
|
files:
|
31
31
|
- CHANGELOG.rdoc
|
32
32
|
- Gemfile
|
@@ -45,18 +45,23 @@ files:
|
|
45
45
|
- lib/responders/http_cache_responder.rb
|
46
46
|
- lib/responders/locales/en.yml
|
47
47
|
- lib/responders/version.rb
|
48
|
+
- responders.gemspec
|
48
49
|
- test/collection_responder_test.rb
|
49
50
|
- test/controller_method_test.rb
|
50
51
|
- test/flash_responder_test.rb
|
51
52
|
- test/http_cache_responder_test.rb
|
53
|
+
- test/locales/en.yml
|
52
54
|
- test/test_helper.rb
|
55
|
+
- test/views/addresses/create.js.erb
|
56
|
+
- test/views/addresses/edit.html.erb
|
57
|
+
- test/views/addresses/new.html.erb
|
53
58
|
has_rdoc: true
|
54
59
|
homepage: http://github.com/plataformatec/responders
|
55
60
|
licenses: []
|
56
61
|
|
57
62
|
post_install_message:
|
58
|
-
rdoc_options:
|
59
|
-
|
63
|
+
rdoc_options: []
|
64
|
+
|
60
65
|
require_paths:
|
61
66
|
- lib
|
62
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -79,8 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
84
|
version: "0"
|
80
85
|
requirements: []
|
81
86
|
|
82
|
-
rubyforge_project:
|
83
|
-
rubygems_version: 1.3
|
87
|
+
rubyforge_project: responders
|
88
|
+
rubygems_version: 1.5.3
|
84
89
|
signing_key:
|
85
90
|
specification_version: 3
|
86
91
|
summary: A set of Rails 3 responders to dry up your application
|
@@ -89,4 +94,8 @@ test_files:
|
|
89
94
|
- test/controller_method_test.rb
|
90
95
|
- test/flash_responder_test.rb
|
91
96
|
- test/http_cache_responder_test.rb
|
97
|
+
- test/locales/en.yml
|
92
98
|
- test/test_helper.rb
|
99
|
+
- test/views/addresses/create.js.erb
|
100
|
+
- test/views/addresses/edit.html.erb
|
101
|
+
- test/views/addresses/new.html.erb
|