Commit 8e720312dfc739c80df6b09e2508d6fb7633a5b5
1 parent
5cd25bf8
Exists in
master
and in
28 other branches
Replacing rev by version
Showing
7 changed files
with
23 additions
and
6 deletions
Show diff stats
app/controllers/public/content_viewer_controller.rb
@@ -7,7 +7,7 @@ class ContentViewerController < ApplicationController | @@ -7,7 +7,7 @@ class ContentViewerController < ApplicationController | ||
7 | 7 | ||
8 | def view_page | 8 | def view_page |
9 | path = params[:page].join('/') | 9 | path = params[:page].join('/') |
10 | - @version = params[:rev] | 10 | + @version = params[:version] |
11 | 11 | ||
12 | if path.blank? | 12 | if path.blank? |
13 | @page = profile.home_page | 13 | @page = profile.home_page |
app/helpers/application_helper.rb
@@ -1403,7 +1403,7 @@ module ApplicationHelper | @@ -1403,7 +1403,7 @@ module ApplicationHelper | ||
1403 | end | 1403 | end |
1404 | 1404 | ||
1405 | def display_article_versions(article, version = nil) | 1405 | def display_article_versions(article, version = nil) |
1406 | - content_tag('ul', article.versions.map {|v| link_to("r#{v.version}", @page.url.merge(:rev => v.version))}) | 1406 | + content_tag('ul', article.versions.map {|v| link_to("r#{v.version}", @page.url.merge(:version => v.version))}) |
1407 | end | 1407 | end |
1408 | 1408 | ||
1409 | end | 1409 | end |
app/models/article.rb
@@ -655,7 +655,7 @@ class Article < ActiveRecord::Base | @@ -655,7 +655,7 @@ class Article < ActiveRecord::Base | ||
655 | (params[:npage] ? "-npage-#{params[:npage]}" : '') + | 655 | (params[:npage] ? "-npage-#{params[:npage]}" : '') + |
656 | (params[:year] ? "-year-#{params[:year]}" : '') + | 656 | (params[:year] ? "-year-#{params[:year]}" : '') + |
657 | (params[:month] ? "-month-#{params[:month]}" : '') + | 657 | (params[:month] ? "-month-#{params[:month]}" : '') + |
658 | - (params[:rev] ? "-rev-#{params[:rev]}" : '') | 658 | + (params[:version] ? "-version-#{params[:version]}" : '') |
659 | 659 | ||
660 | end | 660 | end |
661 | 661 |
app/views/content_viewer/_article_versions.rhtml
1 | <h3><%= _('Versions') %></h3> | 1 | <h3><%= _('Versions') %></h3> |
2 | <ul class='article-versions'> | 2 | <ul class='article-versions'> |
3 | <% @page.versions.each do |v| %> | 3 | <% @page.versions.each do |v| %> |
4 | - <li><%= link_to("#{v.version}", @page.url.merge(:rev => v.version)) %></li> | 4 | + <li><%= link_to("#{v.version}", @page.url.merge(:version => v.version)) %></li> |
5 | <% end %> | 5 | <% end %> |
6 | <ul> | 6 | <ul> |
test/functional/cms_controller_test.rb
@@ -1719,6 +1719,23 @@ class CmsControllerTest < ActionController::TestCase | @@ -1719,6 +1719,23 @@ class CmsControllerTest < ActionController::TestCase | ||
1719 | assert_redirected_to '/' | 1719 | assert_redirected_to '/' |
1720 | end | 1720 | end |
1721 | 1721 | ||
1722 | + should 'edit article with content from older version' do | ||
1723 | + article = profile.articles.create(:name => 'first version') | ||
1724 | + article.name = 'second version'; article.save | ||
1725 | + | ||
1726 | + get :edit, :profile => profile.identifier, :id => article.id, :version => 1 | ||
1727 | + assert_equal 'second version', Article.find(article.id).name | ||
1728 | + assert_equal 'first version', assigns(:article).name | ||
1729 | + end | ||
1730 | + | ||
1731 | + should 'save article with content from older version' do | ||
1732 | + article = profile.articles.create(:name => 'first version') | ||
1733 | + article.name = 'second version'; article.save | ||
1734 | + | ||
1735 | + post :edit, :profile => profile.identifier, :id => article.id, :version => 1 | ||
1736 | + assert_equal 'first version', Article.find(article.id).name | ||
1737 | + end | ||
1738 | + | ||
1722 | protected | 1739 | protected |
1723 | 1740 | ||
1724 | # FIXME this is to avoid adding an extra dependency for a proper JSON parser. | 1741 | # FIXME this is to avoid adding an extra dependency for a proper JSON parser. |
test/functional/content_viewer_controller_test.rb
@@ -384,7 +384,7 @@ class ContentViewerControllerTest < ActionController::TestCase | @@ -384,7 +384,7 @@ class ContentViewerControllerTest < ActionController::TestCase | ||
384 | page = profile.articles.create!(:name => 'myarticle', :body => 'test article') | 384 | page = profile.articles.create!(:name => 'myarticle', :body => 'test article') |
385 | page.body = 'test article edited'; page.save | 385 | page.body = 'test article edited'; page.save |
386 | 386 | ||
387 | - get :view_page, :profile => profile.identifier, :page => [ 'myarticle' ], :rev => 1 | 387 | + get :view_page, :profile => profile.identifier, :page => [ 'myarticle' ], :version => 1 |
388 | 388 | ||
389 | assert_equal 1, assigns(:page).version | 389 | assert_equal 1, assigns(:page).version |
390 | end | 390 | end |
test/unit/article_test.rb
@@ -742,7 +742,7 @@ class ArticleTest < ActiveSupport::TestCase | @@ -742,7 +742,7 @@ class ArticleTest < ActiveSupport::TestCase | ||
742 | 742 | ||
743 | should 'use revision number to compose cache key' do | 743 | should 'use revision number to compose cache key' do |
744 | a = fast_create(Article, :name => 'Versioned article', :profile_id => profile.id) | 744 | a = fast_create(Article, :name => 'Versioned article', :profile_id => profile.id) |
745 | - assert_match(/-rev-2/,a.cache_key(:rev => 2)) | 745 | + assert_match(/-rev-2/,a.cache_key(:version => 2)) |
746 | end | 746 | end |
747 | 747 | ||
748 | should 'not be highlighted by default' do | 748 | should 'not be highlighted by default' do |