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
app/helpers/application_helper.rb
... | ... | @@ -1403,7 +1403,7 @@ module ApplicationHelper |
1403 | 1403 | end |
1404 | 1404 | |
1405 | 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 | 1407 | end |
1408 | 1408 | |
1409 | 1409 | end | ... | ... |
app/models/article.rb
... | ... | @@ -655,7 +655,7 @@ class Article < ActiveRecord::Base |
655 | 655 | (params[:npage] ? "-npage-#{params[:npage]}" : '') + |
656 | 656 | (params[:year] ? "-year-#{params[:year]}" : '') + |
657 | 657 | (params[:month] ? "-month-#{params[:month]}" : '') + |
658 | - (params[:rev] ? "-rev-#{params[:rev]}" : '') | |
658 | + (params[:version] ? "-version-#{params[:version]}" : '') | |
659 | 659 | |
660 | 660 | end |
661 | 661 | ... | ... |
app/views/content_viewer/_article_versions.rhtml
test/functional/cms_controller_test.rb
... | ... | @@ -1719,6 +1719,23 @@ class CmsControllerTest < ActionController::TestCase |
1719 | 1719 | assert_redirected_to '/' |
1720 | 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 | 1739 | protected |
1723 | 1740 | |
1724 | 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 | 384 | page = profile.articles.create!(:name => 'myarticle', :body => 'test article') |
385 | 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 | 389 | assert_equal 1, assigns(:page).version |
390 | 390 | end | ... | ... |
test/unit/article_test.rb
... | ... | @@ -742,7 +742,7 @@ class ArticleTest < ActiveSupport::TestCase |
742 | 742 | |
743 | 743 | should 'use revision number to compose cache key' do |
744 | 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 | 746 | end |
747 | 747 | |
748 | 748 | should 'not be highlighted by default' do | ... | ... |