versioncake 0.1.0 → 0.2.0
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/.gitignore +2 -1
- data/Gemfile.lock +3 -15
- data/README.md +33 -31
- data/Rakefile +3 -17
- data/lib/versioncake/version.rb +1 -1
- data/{spec → test}/fixtures/partials/_versioned.erb +0 -0
- data/{spec → test}/fixtures/partials/_versioned.v1.erb +0 -0
- data/{spec → test}/fixtures/partials/_versioned.v2.erb +0 -0
- data/{spec → test}/fixtures/partials/_versioned.v3.erb +0 -0
- data/{spec → test}/fixtures/partials/another_versioned_partial.erb +0 -0
- data/{spec → test}/fixtures/partials/another_versioned_partial.v1.erb +0 -0
- data/{spec → test}/fixtures/templates/unversioned.html.erb +0 -0
- data/{spec → test}/fixtures/templates/versioned.html.erb +0 -0
- data/{spec → test}/fixtures/templates/versioned.v1.html.erb +0 -0
- data/{spec → test}/fixtures/templates/versioned.v2.html.erb +0 -0
- data/{spec → test}/fixtures/templates/versioned.v3.html.erb +0 -0
- data/test/template/render_test.rb +34 -0
- data/test/test_helper.rb +3 -18
- data/versioncake.gemspec +7 -4
- metadata +65 -65
- data/spec/app/controllers/renders_controller.rb +0 -4
- data/spec/app/views/renders/index.html.erb +0 -1
- data/spec/app/views/renders/index.v1.html.erb +0 -1
- data/spec/app/views/renders/index.v2.html.erb +0 -1
- data/spec/config/application.rb +0 -13
- data/spec/config/database.yml +0 -4
- data/spec/config/routes.rb +0 -3
- data/spec/config.ru +0 -0
- data/spec/db/test.sqlite3 +0 -0
- data/spec/script/rails +0 -0
- data/spec/spec_helper.rb +0 -27
- data/spec/template/render_spec.rb +0 -34
- data/spec/template/resolver_spec.rb +0 -12
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,6 +2,9 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
versioncake (0.1.0)
|
5
|
+
actionpack (>= 3.0)
|
6
|
+
activesupport (>= 3.0)
|
7
|
+
railties (>= 3.0)
|
5
8
|
|
6
9
|
GEM
|
7
10
|
remote: http://rubygems.org/
|
@@ -29,7 +32,6 @@ GEM
|
|
29
32
|
multi_json (~> 1.0)
|
30
33
|
arel (3.0.2)
|
31
34
|
builder (3.0.0)
|
32
|
-
diff-lcs (1.1.3)
|
33
35
|
erubis (2.7.0)
|
34
36
|
hike (1.2.1)
|
35
37
|
i18n (0.6.1)
|
@@ -56,19 +58,6 @@ GEM
|
|
56
58
|
rake (0.9.2.2)
|
57
59
|
rdoc (3.12)
|
58
60
|
json (~> 1.4)
|
59
|
-
rspec (2.11.0)
|
60
|
-
rspec-core (~> 2.11.0)
|
61
|
-
rspec-expectations (~> 2.11.0)
|
62
|
-
rspec-mocks (~> 2.11.0)
|
63
|
-
rspec-core (2.11.1)
|
64
|
-
rspec-expectations (2.11.2)
|
65
|
-
diff-lcs (~> 1.1.3)
|
66
|
-
rspec-mocks (2.11.2)
|
67
|
-
rspec-rails (2.11.0)
|
68
|
-
actionpack (>= 3.0)
|
69
|
-
activesupport (>= 3.0)
|
70
|
-
railties (>= 3.0)
|
71
|
-
rspec (~> 2.11.0)
|
72
61
|
sprockets (2.1.3)
|
73
62
|
hike (~> 1.2)
|
74
63
|
rack (~> 1.0)
|
@@ -90,7 +79,6 @@ DEPENDENCIES
|
|
90
79
|
multi_json
|
91
80
|
rack
|
92
81
|
rake
|
93
|
-
rspec-rails
|
94
82
|
sqlite3
|
95
83
|
test-unit
|
96
84
|
tzinfo
|
data/README.md
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
# Version Cake [](http://travis-ci.org/bwillis/versioncake)
|
2
2
|
|
3
|
-
|
3
|
+
Co-authored by Ben Willis ([@bwillis](https://github.com/bwillis/)) and Jim Jones ([@aantix](https://github.com/aantix)).
|
4
4
|
|
5
|
-
|
5
|
+
Version Cake is an unobtrusive way to version views in your Rails app.
|
6
|
+
|
7
|
+
We were tired of urls with version numbers, namespacing controllers with versions, and bumping all resources everytime we supported a new version. Simply configure your supported version numbers, create a versioned view if you need one and let versioncake render the requested version or gracefully degrade to the latest supported view version.
|
8
|
+
|
9
|
+
## Install
|
6
10
|
|
7
11
|
```
|
8
12
|
gem install versioncake
|
@@ -10,22 +14,26 @@ gem install versioncake
|
|
10
14
|
|
11
15
|
## How to use
|
12
16
|
|
13
|
-
###
|
17
|
+
### Configuration
|
14
18
|
|
15
|
-
You need to define the supported versions in your Rails application.rb file as
|
16
|
-
```view_versions```. Use this config to set the range of supported API
|
17
|
-
versions that can be served:
|
19
|
+
You need to define the supported versions in your Rails application.rb file as `view_versions`. Use this config to set the range of supported API versions that can be served:
|
18
20
|
|
19
21
|
```ruby
|
20
22
|
config.view_versions = [1,3,4,5] # or (1...5)
|
21
|
-
#config.view_version_extraction_strategy = :http_parameter # options = :http_header, :http_accept_parameter, :query_parameter, custom Proc
|
22
23
|
```
|
24
|
+
You can also define the way to extract the version. The `view_version_extraction_strategy` allows you to set one of the default strategies or provide a proc to set your own. You can also pass it a prioritized array of the strategies.
|
25
|
+
```ruby
|
26
|
+
config.view_version_extraction_strategy = :http_parameter # [:http_header, :http_accept_parameter, :query_parameter]
|
27
|
+
```
|
28
|
+
These are the default strategies:
|
29
|
+
- **http_header**: Api version HTTP header ie. ```API-Version: 1```
|
30
|
+
- **http_accept_parameter**: HTTP Accept header ie. ```Accept: application/xml; version=1``` [why do this?](http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http#i_want_my_api_to_be_versioned)
|
31
|
+
- **query_parameter**: version in the url query parameter, for testing or to override for special case ie. ```http://localhost:3000/posts.json?api_version=1```
|
32
|
+
- **custom**: `lambda {|request| request.headers["HTTP_X_API_VERSION"].to_i }` takes the request object and must return an integer
|
23
33
|
|
24
34
|
### Version your views
|
25
35
|
|
26
|
-
When a client makes a request to your controller the latest version of the
|
27
|
-
view will be rendered. The latest version is determined by naming the template
|
28
|
-
or partial with a version number that you configured to support.
|
36
|
+
When a client makes a request to your controller the latest version of the view will be rendered. The latest version is determined by naming the template or partial with a version number that you configured to support.
|
29
37
|
|
30
38
|
```
|
31
39
|
- app/views/posts
|
@@ -39,37 +47,31 @@ or partial with a version number that you configured to support.
|
|
39
47
|
- _form.html.erb
|
40
48
|
```
|
41
49
|
|
42
|
-
If you start supporting a newer version, v3 for instance,
|
43
|
-
|
44
|
-
|
50
|
+
If you start supporting a newer version, v3 for instance, you do not have to copy posts/show.v2 to posts/show.v3. By default, the request for v3 or higher will gracefully degrade to the view that is the newest, supported version, in this case posts/show.v2.
|
51
|
+
|
52
|
+
### Controller
|
53
|
+
|
54
|
+
You don't need to do anything special in your controller, but if you find that you want to perform some tasks for a specific version you can use `requested_version` and `latest_version`. This may be updated in the [near future](https://github.com/bwillis/versioncake/issues/1).
|
45
55
|
|
46
56
|
### Client requests
|
47
57
|
|
48
|
-
When a client makes a request it will automatically receive the latest supported
|
49
|
-
version of the view. The client can also request for a specific version by one of three
|
50
|
-
strategies configured by ``view_version_extraction_strategy``:
|
58
|
+
When a client makes a request it will automatically receive the latest supported version of the view. The client can also request for a specific version by one of the strategies configured by ``view_version_extraction_strategy``.
|
51
59
|
|
52
|
-
|
53
|
-
- http_accept_parameter: HTTP Accept header ie. ```Accept: application/xml; version=1```
|
54
|
-
- http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http#i_want_my_api_to_be_versioned
|
55
|
-
- query_parameter: version in the url query parameter ie. ```http://localhost:3000/posts.json?api_version=1```
|
60
|
+
# Related Material
|
56
61
|
|
57
|
-
|
58
|
-
takes a single parameter of the current request and must return an integer.
|
62
|
+
## Libraries
|
59
63
|
|
60
|
-
|
61
|
-
|
62
|
-
```
|
64
|
+
- https://github.com/bploetz/versionist
|
65
|
+
- https://github.com/filtersquad/rocket_pants
|
63
66
|
|
64
|
-
##
|
67
|
+
## Discussions
|
65
68
|
|
66
|
-
|
67
|
-
|
68
|
-
3. Log the version requested in the logs
|
69
|
+
- [Steve Klabnik on how to version in a resful way](http://blog.steveklabnik.com/posts/2011-07-03-nobody-understands-rest-or-http#i_want_my_api_to_be_versioned)
|
70
|
+
- [Rails API project disucssion on versioning](https://github.com/spastorino/rails-api/issues/8)
|
69
71
|
|
70
|
-
#
|
72
|
+
# Questions?
|
71
73
|
|
72
|
-
|
74
|
+
Create a bug/enhancement/question on github or contact [aantix](https://github.com/aantix) or [bwillis](https://github.com/bwillis) through github.
|
73
75
|
|
74
76
|
# License
|
75
77
|
|
data/Rakefile
CHANGED
@@ -1,31 +1,17 @@
|
|
1
|
-
require
|
1
|
+
require 'bundler/gem_tasks'
|
2
2
|
|
3
3
|
require 'rake/dsl_definition'
|
4
|
-
require
|
4
|
+
require 'bundler'
|
5
5
|
Bundler.setup
|
6
6
|
|
7
|
-
require "rspec"
|
8
|
-
require "rspec/core/rake_task"
|
9
7
|
require 'rake/testtask'
|
10
8
|
|
11
|
-
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
12
|
-
|
13
9
|
Bundler::GemHelper.install_tasks
|
14
10
|
|
15
|
-
task :default => :
|
16
|
-
|
17
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
18
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
19
|
-
end
|
20
|
-
|
21
|
-
$: << "."
|
22
|
-
$: << "./test"
|
11
|
+
task :default => :test
|
23
12
|
|
24
13
|
Rake::TestTask.new do |i|
|
25
|
-
#i.libs << '.'
|
26
14
|
i.libs << 'test'
|
27
15
|
i.test_files = FileList['test/**/*_test.rb']
|
28
|
-
#i.test_files = FileList['test/test_*.rb']
|
29
|
-
#i.test_files = FileList.new('test/**/*_test.rb')
|
30
16
|
i.verbose = true
|
31
17
|
end
|
data/lib/versioncake/version.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
|
3
|
+
class VersionRenderTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
def setup
|
6
|
+
path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH)
|
7
|
+
view_paths = ActionView::PathSet.new([path])
|
8
|
+
@view = ActionView::Base.new(view_paths)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_regression_renders_unversioned_template
|
12
|
+
@view.lookup_context.versions = [:v0]
|
13
|
+
assert_equal "template", @view.render(:template => "templates/versioned")
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_render_template_defaults_to_latest_template_version
|
17
|
+
assert_equal "template v3", @view.render(:template => "templates/versioned")
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_render_template_with_parameter_version_override
|
21
|
+
assert_equal "template v1", @view.render(:template => "templates/versioned", :versions => :v1)
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_render_template_with_legacy_version
|
25
|
+
@view.lookup_context.versions = [:v2]
|
26
|
+
assert_equal "template v2", @view.render(:template => "templates/versioned")
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_render_template_gracefully_degrades
|
30
|
+
@view.lookup_context.versions = [:v4,:v3,:v2,:v1]
|
31
|
+
assert_equal "template v3", @view.render(:template => "templates/versioned")
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
data/test/test_helper.rb
CHANGED
@@ -9,24 +9,9 @@ require 'rails/all'
|
|
9
9
|
require 'rails/test_help'
|
10
10
|
require 'test/unit'
|
11
11
|
|
12
|
-
|
13
12
|
require File.expand_path('../config/application', __FILE__)
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
root = File.expand_path(File.dirname(__FILE__))
|
19
|
-
|
20
|
-
class ActiveSupport::TestCase
|
21
|
-
# Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
|
22
|
-
#
|
23
|
-
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
24
|
-
# -- they do not yet inherit this setting
|
25
|
-
fixtures :all
|
26
|
-
|
27
|
-
# Add more helper methods to be used by all tests here...
|
28
|
-
end
|
29
|
-
|
30
|
-
RendersTest::Application.initialize!
|
14
|
+
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
|
15
|
+
FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
|
31
16
|
|
32
|
-
|
17
|
+
RendersTest::Application.initialize!
|
data/versioncake.gemspec
CHANGED
@@ -11,13 +11,16 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.summary = %q{Easily render versions of your rails views.}
|
12
12
|
s.description = %q{Render versioned views automagically based on the clients requested version.}
|
13
13
|
|
14
|
-
#s.rubyforge_project = ""
|
15
|
-
|
16
14
|
s.files = `git ls-files`.split("\n")
|
17
|
-
s.test_files = `git ls-files -- {test
|
15
|
+
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
18
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
17
|
s.require_paths = ["lib"]
|
20
18
|
|
21
|
-
s.
|
19
|
+
s.add_dependency('actionpack', '>= 3.0')
|
20
|
+
s.add_dependency('activesupport', '>= 3.0')
|
21
|
+
s.add_dependency('railties', '>= 3.0')
|
22
|
+
|
23
|
+
s.add_development_dependency "test-unit"
|
22
24
|
s.add_development_dependency "mocha"
|
25
|
+
|
23
26
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: versioncake
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,10 +10,58 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-09-
|
13
|
+
date: 2012-09-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: actionpack
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '3.0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '3.0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: activesupport
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '3.0'
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '3.0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: railties
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: test-unit
|
17
65
|
requirement: !ruby/object:Gem::Requirement
|
18
66
|
none: false
|
19
67
|
requirements:
|
@@ -66,30 +114,6 @@ files:
|
|
66
114
|
- lib/versioncake/action_view/template.rb
|
67
115
|
- lib/versioncake/action_view/versions.rb
|
68
116
|
- lib/versioncake/version.rb
|
69
|
-
- spec/app/controllers/renders_controller.rb
|
70
|
-
- spec/app/views/renders/index.html.erb
|
71
|
-
- spec/app/views/renders/index.v1.html.erb
|
72
|
-
- spec/app/views/renders/index.v2.html.erb
|
73
|
-
- spec/config.ru
|
74
|
-
- spec/config/application.rb
|
75
|
-
- spec/config/database.yml
|
76
|
-
- spec/config/routes.rb
|
77
|
-
- spec/db/test.sqlite3
|
78
|
-
- spec/fixtures/partials/_versioned.erb
|
79
|
-
- spec/fixtures/partials/_versioned.v1.erb
|
80
|
-
- spec/fixtures/partials/_versioned.v2.erb
|
81
|
-
- spec/fixtures/partials/_versioned.v3.erb
|
82
|
-
- spec/fixtures/partials/another_versioned_partial.erb
|
83
|
-
- spec/fixtures/partials/another_versioned_partial.v1.erb
|
84
|
-
- spec/fixtures/templates/unversioned.html.erb
|
85
|
-
- spec/fixtures/templates/versioned.html.erb
|
86
|
-
- spec/fixtures/templates/versioned.v1.html.erb
|
87
|
-
- spec/fixtures/templates/versioned.v2.html.erb
|
88
|
-
- spec/fixtures/templates/versioned.v3.html.erb
|
89
|
-
- spec/script/rails
|
90
|
-
- spec/spec_helper.rb
|
91
|
-
- spec/template/render_spec.rb
|
92
|
-
- spec/template/resolver_spec.rb
|
93
117
|
- test/app/controllers/renders_controller.rb
|
94
118
|
- test/app/views/renders/index.html.erb
|
95
119
|
- test/app/views/renders/index.v1.html.erb
|
@@ -99,8 +123,20 @@ files:
|
|
99
123
|
- test/config/database.yml
|
100
124
|
- test/config/routes.rb
|
101
125
|
- test/db/test.sqlite3
|
126
|
+
- test/fixtures/partials/_versioned.erb
|
127
|
+
- test/fixtures/partials/_versioned.v1.erb
|
128
|
+
- test/fixtures/partials/_versioned.v2.erb
|
129
|
+
- test/fixtures/partials/_versioned.v3.erb
|
130
|
+
- test/fixtures/partials/another_versioned_partial.erb
|
131
|
+
- test/fixtures/partials/another_versioned_partial.v1.erb
|
132
|
+
- test/fixtures/templates/unversioned.html.erb
|
133
|
+
- test/fixtures/templates/versioned.html.erb
|
134
|
+
- test/fixtures/templates/versioned.v1.html.erb
|
135
|
+
- test/fixtures/templates/versioned.v2.html.erb
|
136
|
+
- test/fixtures/templates/versioned.v3.html.erb
|
102
137
|
- test/functional/renders_controller_test.rb
|
103
138
|
- test/script/rails
|
139
|
+
- test/template/render_test.rb
|
104
140
|
- test/test_helper.rb
|
105
141
|
- versioncake.gemspec
|
106
142
|
homepage: https://github.com/bwillis/versioncake
|
@@ -123,44 +159,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
159
|
version: '0'
|
124
160
|
requirements: []
|
125
161
|
rubyforge_project:
|
126
|
-
rubygems_version: 1.8.
|
162
|
+
rubygems_version: 1.8.24
|
127
163
|
signing_key:
|
128
164
|
specification_version: 3
|
129
165
|
summary: Easily render versions of your rails views.
|
130
|
-
test_files:
|
131
|
-
- spec/app/controllers/renders_controller.rb
|
132
|
-
- spec/app/views/renders/index.html.erb
|
133
|
-
- spec/app/views/renders/index.v1.html.erb
|
134
|
-
- spec/app/views/renders/index.v2.html.erb
|
135
|
-
- spec/config.ru
|
136
|
-
- spec/config/application.rb
|
137
|
-
- spec/config/database.yml
|
138
|
-
- spec/config/routes.rb
|
139
|
-
- spec/db/test.sqlite3
|
140
|
-
- spec/fixtures/partials/_versioned.erb
|
141
|
-
- spec/fixtures/partials/_versioned.v1.erb
|
142
|
-
- spec/fixtures/partials/_versioned.v2.erb
|
143
|
-
- spec/fixtures/partials/_versioned.v3.erb
|
144
|
-
- spec/fixtures/partials/another_versioned_partial.erb
|
145
|
-
- spec/fixtures/partials/another_versioned_partial.v1.erb
|
146
|
-
- spec/fixtures/templates/unversioned.html.erb
|
147
|
-
- spec/fixtures/templates/versioned.html.erb
|
148
|
-
- spec/fixtures/templates/versioned.v1.html.erb
|
149
|
-
- spec/fixtures/templates/versioned.v2.html.erb
|
150
|
-
- spec/fixtures/templates/versioned.v3.html.erb
|
151
|
-
- spec/script/rails
|
152
|
-
- spec/spec_helper.rb
|
153
|
-
- spec/template/render_spec.rb
|
154
|
-
- spec/template/resolver_spec.rb
|
155
|
-
- test/app/controllers/renders_controller.rb
|
156
|
-
- test/app/views/renders/index.html.erb
|
157
|
-
- test/app/views/renders/index.v1.html.erb
|
158
|
-
- test/app/views/renders/index.v2.html.erb
|
159
|
-
- test/config.ru
|
160
|
-
- test/config/application.rb
|
161
|
-
- test/config/database.yml
|
162
|
-
- test/config/routes.rb
|
163
|
-
- test/db/test.sqlite3
|
164
|
-
- test/functional/renders_controller_test.rb
|
165
|
-
- test/script/rails
|
166
|
-
- test/test_helper.rb
|
166
|
+
test_files: []
|
@@ -1 +0,0 @@
|
|
1
|
-
index.html.erb
|
@@ -1 +0,0 @@
|
|
1
|
-
index.v1.html.erb
|
@@ -1 +0,0 @@
|
|
1
|
-
index.v2.html.erb
|
data/spec/config/application.rb
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
module RendersTest
|
2
|
-
class Application < Rails::Application
|
3
|
-
config.encoding = "utf-8"
|
4
|
-
config.filter_parameters += [:password]
|
5
|
-
config.active_support.escape_html_entities_in_json = true
|
6
|
-
config.active_record.whitelist_attributes = true
|
7
|
-
config.assets.enabled = true
|
8
|
-
config.assets.version = '1.0'
|
9
|
-
config.active_support.deprecation = :stderr
|
10
|
-
config.view_versions = (1..4)
|
11
|
-
config.view_version_extraction_strategy = :http_header
|
12
|
-
end
|
13
|
-
end
|
data/spec/config/database.yml
DELETED
data/spec/config/routes.rb
DELETED
data/spec/config.ru
DELETED
File without changes
|
data/spec/db/test.sqlite3
DELETED
File without changes
|
data/spec/script/rails
DELETED
File without changes
|
data/spec/spec_helper.rb
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'bundler'
|
2
|
-
Bundler.require
|
3
|
-
|
4
|
-
require 'versioncake'
|
5
|
-
require 'rspec'
|
6
|
-
require 'rails/all'
|
7
|
-
require 'rspec/rails'
|
8
|
-
require 'config/application'
|
9
|
-
|
10
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
11
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
12
|
-
|
13
|
-
ENV["RAILS_ENV"] ||= 'test'
|
14
|
-
|
15
|
-
root = File.expand_path(File.dirname(__FILE__))
|
16
|
-
|
17
|
-
# Initialize the application
|
18
|
-
RendersTest::Application.initialize!
|
19
|
-
|
20
|
-
RSpec.configure do |config|
|
21
|
-
config.mock_with :mocha
|
22
|
-
end
|
23
|
-
|
24
|
-
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
|
25
|
-
FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
|
26
|
-
|
27
|
-
Dir.glob(File.dirname(__FILE__) + "/app/controllers/**/*").each{|f| require(f) if File.file?(f)}
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "RenderTestCases" do
|
4
|
-
|
5
|
-
before do
|
6
|
-
path = ActionView::FileSystemResolver.new(FIXTURE_LOAD_PATH)
|
7
|
-
view_paths = ActionView::PathSet.new([path])
|
8
|
-
@view = ActionView::Base.new(view_paths,{})
|
9
|
-
end
|
10
|
-
|
11
|
-
it "renders the unversioned template (regression)" do
|
12
|
-
@view.lookup_context.versions = [:v0]
|
13
|
-
@view.render(:template => "templates/versioned").should == "template"
|
14
|
-
end
|
15
|
-
|
16
|
-
it "renders the latest version of the template" do
|
17
|
-
@view.render(:template => "templates/versioned").should == "template v3"
|
18
|
-
end
|
19
|
-
|
20
|
-
it "renders the overridden version of the template" do
|
21
|
-
@view.render(:template => "templates/versioned", :versions => :v1).should == "template v1"
|
22
|
-
end
|
23
|
-
|
24
|
-
it "renders the legacy version of the template" do
|
25
|
-
@view.lookup_context.versions = [:v2]
|
26
|
-
@view.render(:template => "templates/versioned").should == "template v2"
|
27
|
-
end
|
28
|
-
|
29
|
-
it "renders the latest available version of the requested template" do
|
30
|
-
@view.lookup_context.versions = [:v4,:v3,:v2,:v1]
|
31
|
-
@view.render(:template => "templates/versioned").should == "template v3"
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Resolver" do
|
4
|
-
|
5
|
-
it "extracts the correct handler and format from a versioned template" do
|
6
|
-
resolver = ActionView::PathResolver.new
|
7
|
-
handler, format = resolver.send "extract_handler_and_format", "/some/path/to/app/views/index.v1.xml.builder", nil
|
8
|
-
handler.class.should == ActionView::Template::Handlers::Builder
|
9
|
-
format.should == "application/xml"
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|