Commit 8e720312dfc739c80df6b09e2508d6fb7633a5b5

Authored by Daniela Feitosa
1 parent 5cd25bf8

Replacing rev by version

app/controllers/public/content_viewer_controller.rb
... ... @@ -7,7 +7,7 @@ class ContentViewerController < ApplicationController
7 7  
8 8 def view_page
9 9 path = params[:page].join('/')
10   - @version = params[:rev]
  10 + @version = params[:version]
11 11  
12 12 if path.blank?
13 13 @page = profile.home_page
... ...
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
1 1 <h3><%= _('Versions') %></h3>
2 2 <ul class='article-versions'>
3 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 5 <% end %>
6 6 <ul>
... ...
test/functional/cms_controller_test.rb
... ... @@ -1719,6 +1719,23 @@ class CmsControllerTest &lt; 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 &lt; 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 &lt; 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
... ...