notified.collect(&:mail)
end
+ # Return true if the content is the current page content
+ def current_version?
+ true
+ end
+
class Version
belongs_to :page, :class_name => '::WikiPage', :foreign_key => 'page_id'
belongs_to :author, :class_name => '::User', :foreign_key => 'author_id'
page.project
end
+ # Return true if the content is the current page content
+ def current_version?
+ page.content.version == self.version
+ end
+
# Returns the previous version or nil
def previous
@previous ||= WikiContent::Version.find(:first,
<div class="contextual">
<% if @editable %>
-<%= link_to_if_authorized(l(:button_edit), {:action => 'edit', :id => @page.title}, :class => 'icon icon-edit', :accesskey => accesskey(:edit)) if @content.version == @page.content.version %>
+<%= link_to_if_authorized(l(:button_edit), {:action => 'edit', :id => @page.title}, :class => 'icon icon-edit', :accesskey => accesskey(:edit)) if @content.current_version? %>
<%= watcher_tag(@page, User.current) %>
<%= link_to_if_authorized(l(:button_lock), {:action => 'protect', :id => @page.title, :protected => 1}, :method => :post, :class => 'icon icon-lock') if !@page.protected? %>
<%= link_to_if_authorized(l(:button_unlock), {:action => 'protect', :id => @page.title, :protected => 0}, :method => :post, :class => 'icon icon-unlock') if @page.protected? %>
-<%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') if @content.version == @page.content.version %>
+<%= link_to_if_authorized(l(:button_rename), {:action => 'rename', :id => @page.title}, :class => 'icon icon-move') if @content.current_version? %>
<%= link_to_if_authorized(l(:button_delete), {:action => 'destroy', :id => @page.title}, :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
-<%= link_to_if_authorized(l(:button_rollback), {:action => 'edit', :id => @page.title, :version => @content.version }, :class => 'icon icon-cancel') if @content.version < @page.content.version %>
+<%= link_to_if_authorized(l(:button_rollback), {:action => 'edit', :id => @page.title, :version => @content.version }, :class => 'icon icon-cancel') unless @content.current_version? %>
<% end %>
<%= link_to_if_authorized(l(:label_history), {:action => 'history', :id => @page.title}, :class => 'icon icon-history') %>
</div>
<%= wiki_page_breadcrumb(@page) %>
-<% if @content.version != @page.content.version %>
+<% unless @content.current_version? %>
<p>
<%= link_to(("\xc2\xab " + l(:label_previous)),
:action => 'show', :id => @page.title, :project_id => @page.project,
@WHATEVER@
Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in.
+
+ Cras ipsum felis, ultrices at porttitor vel, faucibus eu nunc.
h2. Heading 2
version: 2
author_id: 1
comments:
+wiki_content_versions_006:
+ data: |-
+ h1. Title
+
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas sed libero.
+
+ h2. Heading 1
+
+ @WHATEVER@
+
+ Maecenas sed elit sit amet mi accumsan vestibulum non nec velit. Proin porta tincidunt lorem, consequat rhoncus dolor fermentum in.
+
+ h2. Heading 2
+
+ Morbi facilisis accumsan orci non pharetra.
+ updated_on: 2007-03-08 00:18:07 +01:00
+ page_id: 11
+ wiki_content_id: 11
+ id: 6
+ version: 3
+ author_id: 1
+ comments:
page.reload
assert_equal 500.kilobyte, page.content.text.size
end
+
+ def test_current_version
+ content = WikiContent.find(11)
+ assert_equal true, content.current_version?
+ assert_equal true, content.versions.first(:order => 'version DESC').current_version?
+ assert_equal false, content.versions.first(:order => 'version ASC').current_version?
+ end
end