Commit 1f9eda4e authored by Tim Felgentreff's avatar Tim Felgentreff

update tests to work with the new data model, where neccessary

parent 81e97d23
...@@ -19,8 +19,14 @@ require "digest/md5" ...@@ -19,8 +19,14 @@ require "digest/md5"
class Attachment < ActiveRecord::Base class Attachment < ActiveRecord::Base
belongs_to :container, :polymorphic => true belongs_to :container, :polymorphic => true
# FIXME: Remove these once the Versions, Documents and Projects themselves can provide file events
belongs_to :version, :foreign_key => "container_id"
belongs_to :document, :foreign_key => "container_id"
belongs_to :project, :foreign_key => "container_id"
belongs_to :author, :class_name => "User", :foreign_key => "author_id" belongs_to :author, :class_name => "User", :foreign_key => "author_id"
validates_presence_of :container, :filename, :author validates_presence_of :container, :filename, :author
validates_length_of :filename, :maximum => 255 validates_length_of :filename, :maximum => 255
validates_length_of :disk_filename, :maximum => 255 validates_length_of :disk_filename, :maximum => 255
...@@ -31,16 +37,24 @@ class Attachment < ActiveRecord::Base ...@@ -31,16 +37,24 @@ class Attachment < ActiveRecord::Base
:id => o.versioned_id, :filename => o.filename } :id => o.versioned_id, :filename => o.filename }
end), end),
:activity_type => 'files', :activity_type => 'files',
:activity_permission => :view_files :activity_permission => :view_files,
:activity_find_options => { :include => { :version => :project } }
acts_as_activity :type => 'documents', :permission => :view_documents acts_as_activity :type => 'documents', :permission => :view_documents,
:find_options => { :include => { :document => :project } }
# This method is called on save by the AttachmentJournal in order to
# decide which kind of activity we are dealing with. When that activity
# is retrieved later, we don't need to check the container_type in
# SQL anymore as that will be just the one we have specified here.
def activity_type def activity_type
case container_type case container_type
when "Document" when "Document"
"documents" "documents"
when "Version" when "Version"
"files" "files"
when "Project"
"files"
else else
super super
end end
......
...@@ -774,6 +774,14 @@ class Issue < ActiveRecord::Base ...@@ -774,6 +774,14 @@ class Issue < ActiveRecord::Base
and i.project_id=#{project.id} and i.project_id=#{project.id}
group by s.id, s.is_closed, j.id") group by s.id, s.is_closed, j.id")
end end
IssueJournal.class_eval do
# Shortcut
def new_status
if details.keys.include? 'status_id'
(newval = details['status_id'].last) ? IssueStatus.find_by_id(newval.to_i) : nil
end
end
end
end end
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
...@@ -20,25 +20,25 @@ class MailHandler < ActionMailer::Base ...@@ -20,25 +20,25 @@ class MailHandler < ActionMailer::Base
class UnauthorizedAction < StandardError; end class UnauthorizedAction < StandardError; end
class MissingInformation < StandardError; end class MissingInformation < StandardError; end
attr_reader :email, :user attr_reader :email, :user
def self.receive(email, options={}) def self.receive(email, options={})
@@handler_options = options.dup @@handler_options = options.dup
@@handler_options[:issue] ||= {} @@handler_options[:issue] ||= {}
@@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip) if @@handler_options[:allow_override].is_a?(String) @@handler_options[:allow_override] = @@handler_options[:allow_override].split(',').collect(&:strip) if @@handler_options[:allow_override].is_a?(String)
@@handler_options[:allow_override] ||= [] @@handler_options[:allow_override] ||= []
# Project needs to be overridable if not specified # Project needs to be overridable if not specified
@@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project) @@handler_options[:allow_override] << 'project' unless @@handler_options[:issue].has_key?(:project)
# Status overridable by default # Status overridable by default
@@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status) @@handler_options[:allow_override] << 'status' unless @@handler_options[:issue].has_key?(:status)
@@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false) @@handler_options[:no_permission_check] = (@@handler_options[:no_permission_check].to_s == '1' ? true : false)
super email super email
end end
# Processes incoming emails # Processes incoming emails
# Returns the created object (eg. an issue, a message) or false # Returns the created object (eg. an issue, a message) or false
def receive(email) def receive(email)
...@@ -77,13 +77,13 @@ class MailHandler < ActionMailer::Base ...@@ -77,13 +77,13 @@ class MailHandler < ActionMailer::Base
User.current = @user User.current = @user
dispatch dispatch
end end
private private
MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@} MESSAGE_ID_RE = %r{^<redmine\.([a-z0-9_]+)\-(\d+)\.\d+@}
ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]} ISSUE_REPLY_SUBJECT_RE = %r{\[[^\]]*#(\d+)\]}
MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]} MESSAGE_REPLY_SUBJECT_RE = %r{\[[^\]]*msg(\d+)\]}
def dispatch def dispatch
headers = [email.in_reply_to, email.references].flatten.compact headers = [email.in_reply_to, email.references].flatten.compact
if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE} if headers.detect {|h| h.to_s =~ MESSAGE_ID_RE}
...@@ -112,7 +112,7 @@ class MailHandler < ActionMailer::Base ...@@ -112,7 +112,7 @@ class MailHandler < ActionMailer::Base
logger.error "MailHandler: unauthorized attempt from #{user}" if logger logger.error "MailHandler: unauthorized attempt from #{user}" if logger
false false
end end
# Creates a new issue # Creates a new issue
def receive_issue def receive_issue
project = target_project project = target_project
...@@ -153,7 +153,7 @@ class MailHandler < ActionMailer::Base ...@@ -153,7 +153,7 @@ class MailHandler < ActionMailer::Base
logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info logger.info "MailHandler: issue ##{issue.id} created by #{user}" if logger && logger.info
issue issue
end end
def target_project def target_project
# TODO: other ways to specify project: # TODO: other ways to specify project:
# * parse the email To field # * parse the email To field
...@@ -162,14 +162,14 @@ class MailHandler < ActionMailer::Base ...@@ -162,14 +162,14 @@ class MailHandler < ActionMailer::Base
raise MissingInformation.new('Unable to determine target project') if target.nil? raise MissingInformation.new('Unable to determine target project') if target.nil?
target target
end end
# Adds a note to an existing issue # Adds a note to an existing issue
def receive_issue_reply(issue_id) def receive_issue_reply(issue_id)
status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status))) status = (get_keyword(:status) && IssueStatus.find_by_name(get_keyword(:status)))
due_date = get_keyword(:due_date, :override => true) due_date = get_keyword(:due_date, :override => true)
start_date = get_keyword(:start_date, :override => true) start_date = get_keyword(:start_date, :override => true)
assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true))) assigned_to = (get_keyword(:assigned_to, :override => true) && find_user_from_keyword(get_keyword(:assigned_to, :override => true)))
issue = Issue.find_by_id(issue_id) issue = Issue.find_by_id(issue_id)
return unless issue return unless issue
# check permission # check permission
...@@ -188,16 +188,16 @@ class MailHandler < ActionMailer::Base ...@@ -188,16 +188,16 @@ class MailHandler < ActionMailer::Base
issue.start_date = start_date if start_date issue.start_date = start_date if start_date
issue.due_date = due_date if due_date issue.due_date = due_date if due_date
issue.assigned_to = assigned_to if assigned_to issue.assigned_to = assigned_to if assigned_to
issue.save! issue.save!
logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info logger.info "MailHandler: issue ##{issue.id} updated by #{user}" if logger && logger.info
journal journal
end end
# Reply will be added to the issue # Reply will be added to the issue
def receive_journal_reply(journal_id) def receive_journal_reply(journal_id)
journal = Journal.find_by_id(journal_id) journal = Journal.find_by_id(journal_id)
if journal && journal.versioned.is_a? Issue if journal and journal.versioned.is_a? Issue
receive_issue_reply(journal.versioned_id) receive_issue_reply(journal.versioned_id)
end end
end end
...@@ -207,11 +207,11 @@ class MailHandler < ActionMailer::Base ...@@ -207,11 +207,11 @@ class MailHandler < ActionMailer::Base
message = Message.find_by_id(message_id) message = Message.find_by_id(message_id)
if message if message
message = message.root message = message.root
unless @@handler_options[:no_permission_check] unless @@handler_options[:no_permission_check]
raise UnauthorizedAction unless user.allowed_to?(:add_messages, message.project) raise UnauthorizedAction unless user.allowed_to?(:add_messages, message.project)
end end
if !message.locked? if !message.locked?
reply = Message.new(:subject => email.subject.gsub(%r{^.*msg\d+\]}, '').strip, reply = Message.new(:subject => email.subject.gsub(%r{^.*msg\d+\]}, '').strip,
:content => cleaned_up_text_body) :content => cleaned_up_text_body)
...@@ -225,7 +225,7 @@ class MailHandler < ActionMailer::Base ...@@ -225,7 +225,7 @@ class MailHandler < ActionMailer::Base
end end
end end
end end
def add_attachments(obj) def add_attachments(obj)
if email.has_attachments? if email.has_attachments?
email.attachments.each do |attachment| email.attachments.each do |attachment|
...@@ -236,7 +236,7 @@ class MailHandler < ActionMailer::Base ...@@ -236,7 +236,7 @@ class MailHandler < ActionMailer::Base
end end
end end
end end
# Adds To and Cc as watchers of the given object if the sender has the # Adds To and Cc as watchers of the given object if the sender has the
# appropriate permission # appropriate permission
def add_watchers(obj) def add_watchers(obj)
...@@ -248,7 +248,7 @@ class MailHandler < ActionMailer::Base ...@@ -248,7 +248,7 @@ class MailHandler < ActionMailer::Base
end end
end end
end end
def get_keyword(attr, options={}) def get_keyword(attr, options={})
@keywords ||= {} @keywords ||= {}
if @keywords.has_key?(attr) if @keywords.has_key?(attr)
...@@ -263,7 +263,7 @@ class MailHandler < ActionMailer::Base ...@@ -263,7 +263,7 @@ class MailHandler < ActionMailer::Base
end end
end end
end end
# Returns the text/plain part of the email # Returns the text/plain part of the email
# If not found (eg. HTML-only email), returns the body with tags removed # If not found (eg. HTML-only email), returns the body with tags removed
def plain_text_body def plain_text_body
...@@ -284,7 +284,7 @@ class MailHandler < ActionMailer::Base ...@@ -284,7 +284,7 @@ class MailHandler < ActionMailer::Base
@plain_text_body.strip! @plain_text_body.strip!
@plain_text_body @plain_text_body
end end
def cleaned_up_text_body def cleaned_up_text_body
cleanup_body(plain_text_body) cleanup_body(plain_text_body)
end end
...@@ -292,19 +292,19 @@ class MailHandler < ActionMailer::Base ...@@ -292,19 +292,19 @@ class MailHandler < ActionMailer::Base
def self.full_sanitizer def self.full_sanitizer
@full_sanitizer ||= HTML::FullSanitizer.new @full_sanitizer ||= HTML::FullSanitizer.new
end end
# Creates a user account for the +email+ sender # Creates a user account for the +email+ sender
def self.create_user_from_email(email) def self.create_user_from_email(email)
addr = email.from_addrs.to_a.first addr = email.from_addrs.to_a.first
if addr && !addr.spec.blank? if addr && !addr.spec.blank?
user = User.new user = User.new
user.mail = addr.spec user.mail = addr.spec
names = addr.name.blank? ? addr.spec.gsub(/@.*$/, '').split('.') : addr.name.split names = addr.name.blank? ? addr.spec.gsub(/@.*$/, '').split('.') : addr.name.split
user.firstname = names.shift user.firstname = names.shift
user.lastname = names.join(' ') user.lastname = names.join(' ')
user.lastname = '-' if user.lastname.blank? user.lastname = '-' if user.lastname.blank?
user.login = user.mail user.login = user.mail
user.password = ActiveSupport::SecureRandom.hex(5) user.password = ActiveSupport::SecureRandom.hex(5)
user.language = Setting.default_language user.language = Setting.default_language
...@@ -313,7 +313,7 @@ class MailHandler < ActionMailer::Base ...@@ -313,7 +313,7 @@ class MailHandler < ActionMailer::Base
end end
private private
# Removes the email body of text after the truncation configurations. # Removes the email body of text after the truncation configurations.
def cleanup_body(body) def cleanup_body(body)
delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\r\n]+/).reject(&:blank?).map {|s| Regexp.escape(s)} delimiters = Setting.mail_handler_body_delimiters.to_s.split(/[\r\n]+/).reject(&:blank?).map {|s| Regexp.escape(s)}
......
...@@ -19,6 +19,7 @@ class Mailer < ActionMailer::Base ...@@ -19,6 +19,7 @@ class Mailer < ActionMailer::Base
layout 'mailer' layout 'mailer'
helper :application helper :application
helper :issues helper :issues
helper :journals
helper :custom_fields helper :custom_fields
include ActionController::UrlWriter include ActionController::UrlWriter
......
...@@ -31,7 +31,8 @@ class Message < ActiveRecord::Base ...@@ -31,7 +31,8 @@ class Message < ActiveRecord::Base
else else
{:id => o.parent_id, :r => o.id, :anchor => "message-#{o.id}"} {:id => o.parent_id, :r => o.id, :anchor => "message-#{o.id}"}
end.reverse_merge :controller => 'messages', :action => 'show', :board_id => o.board_id end.reverse_merge :controller => 'messages', :action => 'show', :board_id => o.board_id
end) end),
:activity_find_options => { :include => { :board => :project } }
acts_as_searchable :columns => ['subject', 'content'], acts_as_searchable :columns => ['subject', 'content'],
:include => {:board => :project}, :include => {:board => :project},
......
...@@ -27,7 +27,8 @@ class WikiContent < ActiveRecord::Base ...@@ -27,7 +27,8 @@ class WikiContent < ActiveRecord::Base
:event_title => Proc.new {|o| "#{l(:label_wiki_edit)}: #{o.page.title} (##{o.version})"}, :event_title => Proc.new {|o| "#{l(:label_wiki_edit)}: #{o.page.title} (##{o.version})"},
:event_url => Proc.new {|o| {:controller => 'wiki', :id => o.page.wiki.project_id, :page => o.page.title, :version => o.version}}, :event_url => Proc.new {|o| {:controller => 'wiki', :id => o.page.wiki.project_id, :page => o.page.title, :version => o.version}},
:activity_type => 'wiki_edits', :activity_type => 'wiki_edits',
:activity_permission => :view_wiki_edits :activity_permission => :view_wiki_edits,
:activity_find_options => { :include => { :page => { :wiki => :project } } }
def activity_type def activity_type
'wiki_edits' 'wiki_edits'
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<ul> <ul>
<% for detail in @journal.details %> <% for detail in @journal.details %>
<li><%= show_detail(detail, true) %></li> <li><%= @journal.render_detail(detail, true) %></li>
<% end %> <% end %>
</ul> </ul>
......
<%= l(:text_issue_updated, :id => "##{@issue.id}", :author => @journal.user) %> <%= l(:text_issue_updated, :id => "##{@issue.id}", :author => @journal.user) %>
<% for detail in @journal.details -%> <% for detail in @journal.details -%>
<%= show_detail(detail, true) %> <%= @journal.render_detail(detail, true) %>
<% end -%> <% end -%>
<%= @journal.notes if @journal.notes? %> <%= @journal.notes if @journal.notes? %>
......
...@@ -2,7 +2,7 @@ class RenameCommentToComments < ActiveRecord::Migration ...@@ -2,7 +2,7 @@ class RenameCommentToComments < ActiveRecord::Migration
def self.up def self.up
rename_column(:comments, :comment, :comments) if ActiveRecord::Base.connection.columns(Comment.table_name).detect{|c| c.name == "comment"} rename_column(:comments, :comment, :comments) if ActiveRecord::Base.connection.columns(Comment.table_name).detect{|c| c.name == "comment"}
rename_column(:wiki_contents, :comment, :comments) if ActiveRecord::Base.connection.columns(WikiContent.table_name).detect{|c| c.name == "comment"} rename_column(:wiki_contents, :comment, :comments) if ActiveRecord::Base.connection.columns(WikiContent.table_name).detect{|c| c.name == "comment"}
rename_column(:wiki_content_versions, :comment, :comments) if ActiveRecord::Base.connection.columns(WikiContent.versioned_table_name).detect{|c| c.name == "comment"} rename_column(:wiki_content_versions, :comment, :comments) if ActiveRecord::Base.connection.columns("wiki_content_versions").detect{|c| c.name == "comment"}
rename_column(:time_entries, :comment, :comments) if ActiveRecord::Base.connection.columns(TimeEntry.table_name).detect{|c| c.name == "comment"} rename_column(:time_entries, :comment, :comments) if ActiveRecord::Base.connection.columns(TimeEntry.table_name).detect{|c| c.name == "comment"}
rename_column(:changesets, :comment, :comments) if ActiveRecord::Base.connection.columns(Changeset.table_name).detect{|c| c.name == "comment"} rename_column(:changesets, :comment, :comments) if ActiveRecord::Base.connection.columns(Changeset.table_name).detect{|c| c.name == "comment"}
end end
......
...@@ -36,13 +36,13 @@ module Redmine ...@@ -36,13 +36,13 @@ module Redmine
# Returns an array of available event types # Returns an array of available event types
def event_types def event_types
return @event_types unless @event_types.nil? return @event_types unless @event_types.nil?
@event_types = Redmine::Activity.available_event_types @event_types = Redmine::Activity.available_event_types
@event_types = @event_types.select do |o| if @project
permissions = constantized_providers(o).collect do |p| @event_types = @event_types.select do |o|
p.activity_provider_options[o].try(:[], :permission) permissions = constantized_providers(o).collect do |p|
end.compact p.activity_provider_options[o].try(:[], :permission)
if @project end.compact
return @user.allowed_to?("view_#{o}".to_sym, @project) if permissions.blank? return @user.allowed_to?("view_#{o}".to_sym, @project) if permissions.blank?
permissions.all? {|p| @user.allowed_to?(p, @project) } if @project permissions.all? {|p| @user.allowed_to?(p, @project) } if @project
end end
......
---
journal_details_001:
old_value: "1"
property: attr
id: 1
value: "2"
prop_key: status_id
journal_id: 1
journal_details_002:
old_value: "40"
property: attr
id: 2
value: "30"
prop_key: done_ratio
journal_id: 1
journal_details_003:
old_value: nil
property: attr
id: 3
value: "6"
prop_key: fixed_version_id
journal_id: 4
--- ---
journals_001: journals_001:
created_on: <%= 2.days.ago.to_date.to_s(:db) %>
notes: "Journal notes"
id: 1 id: 1
journalized_type: Issue type: "IssueJournal"
activity_type: "issues"
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
version: 1
user_id: 1 user_id: 1
journalized_id: 1 notes: "Journal notes"
journals_002: versioned_id: 1
created_on: <%= 1.days.ago.to_date.to_s(:db) %> changes: |
notes: "Some notes with Redmine links: #2, r2." ---
status_id:
- 1
- 2
done_ratio:
- 40
- 30
journals_002:
id: 2 id: 2
journalized_type: Issue type: "IssueJournal"
activity_type: "issues"
created_at: <%= 1.days.ago.to_date.to_s(:db) %>
version: 2
user_id: 2 user_id: 2
journalized_id: 1 notes: "Some notes with Redmine links: #2, r2."
journals_003: versioned_id: 1
created_on: <%= 1.days.ago.to_date.to_s(:db) %> changes: "--- {}"
notes: "A comment with inline image: !picture.jpg!" journals_003:
id: 3 id: 3
journalized_type: Issue type: "IssueJournal"
activity_type: "issues"
created_at: <%= 1.days.ago.to_date.to_s(:db) %>
version: 1
user_id: 2 user_id: 2
journalized_id: 2 notes: "A comment with inline image: !picture.jpg!"
journals_004: versioned_id: 2
created_on: <%= 1.days.ago.to_date.to_s(:db) %> changes: "--- {}"
notes: "A comment with a private version." journals_004:
id: 4 id: 4
journalized_type: Issue type: "IssueJournal"
activity_type: "issues"
created_at: <%= 1.days.ago.to_date.to_s(:db) %>
version: 1
user_id: 2
notes: "A comment with a private version."
versioned_id: 6
changes: |
---
fixed_version_id:
-
- 6
journals_005:
id: 5
type: "IssueJournal"
activity_type: "issues"
created_at: <%= 1.days.ago.to_date.to_s(:db) %>
version: 0
user_id: 1 user_id: 1
journalized_id: 6 notes:
versioned_id: 5
changes: "--- {}"
journals_006:
id: 6
type: "WikiContentJournal"
activity_type: "wiki_edits"
created_at: 2007-03-07 00:08:07 +01:00
version: 1
user_id: 2
notes: Page creation
versioned_id: 1
changes: |
---
compression: ""
data: |-
h1. CookBook documentation
Some [[documentation]] here...
journals_007:
id: 7
type: "WikiContentJournal"
activity_type: "wiki_edits"
created_at: 2007-03-07 00:08:34 +01:00
version: 2
user_id: 1
notes: Small update
versioned_id: 1
changes: |
---
compression: ""
data: |-
h1. CookBook documentation
Some updated [[documentation]] here...
journals_008:
id: 8
type: "WikiContentJournal"
activity_type: "wiki_edits"
created_at: 2007-03-07 00:10:51 +01:00
version: 3
user_id: 1
notes: ""
versioned_id: 1
changes: |
---
compression: ""
data: |-
h1. CookBook documentation
Some updated [[documentation]] here...
journals_009:
id: 9
type: "WikiContentJournal"
activity_type: "wiki_edits"
created_at: 2007-03-08 00:18:07 +01:00
version: 1
user_id: 1
notes:
versioned_id: 2
changes: |
---
data: |-
h1. Another page
This is a link to a ticket: #2
journals_010:
id: 10
type: "MessageJournal"
activity_type: "messages"
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
version: 1
user_id: 1
notes:
versioned_id: 5
changes: --- {}
journals_011:
id: 11
type: "AttachmentJournal"
activity_type: "files"
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
version: 1
user_id: 2
notes: "An attachment on a version"
versioned_id: 9
changes: --- {}
journals_012:
id: 12
type: "AttachmentJournal"
activity_type: "files"
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
version: 1
user_id: 2
notes: "An attachment on a project"
versioned_id: 8
changes: --- {}
journals_013:
id: 13
type: "AttachmentJournal"
activity_type: "files"
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
version: 1
user_id: 2
notes: "An attachment on an issue"
versioned_id: 7
changes: --- {}
journals_014:
id: 14
type: "AttachmentJournal"
activity_type: "documents"
created_at: <%= 2.days.ago.to_date.to_s(:db) %>
version: 1
user_id: 2
notes: "An attachment on a document"
versioned_id: 2
changes: --- {}
\ No newline at end of file
---
wiki_content_versions_001:
updated_on: 2007-03-07 00:08:07 +01:00
page_id: 1
id: 1
version: 1
author_id: 2
comments: Page creation
wiki_content_id: 1
compression: ""
data: |-
h1. CookBook documentation
Some [[documentation]] here...
wiki_content_versions_002:
updated_on: 2007-03-07 00:08:34 +01:00
page_id: 1
id: 2
version: 2
author_id: 1
comments: Small update
wiki_content_id: 1
compression: ""
data: |-
h1. CookBook documentation
Some updated [[documentation]] here...
wiki_content_versions_003:
updated_on: 2007-03-07 00:10:51 +01:00
page_id: 1
id: 3
version: 3
author_id: 1
comments: ""
wiki_content_id: 1
compression: ""
data: |-
h1. CookBook documentation
Some updated [[documentation]] here...
wiki_content_versions_004:
data: |-
h1. Another page
This is a link to a ticket: #2
updated_on: 2007-03-08 00:18:07 +01:00
page_id: 2
wiki_content_id: 2
id: 4
version: 1
author_id: 1
comments:
...@@ -9,10 +9,10 @@ wiki_contents_001: ...@@ -9,10 +9,10 @@ wiki_contents_001:
updated_on: 2007-03-07 00:10:51 +01:00 updated_on: 2007-03-07 00:10:51 +01:00
page_id: 1 page_id: 1
id: 1 id: 1
version: 3 lock_version: 3
author_id: 1 author_id: 1
comments: Gzip compression activated comments: Gzip compression activated
wiki_contents_002: wiki_contents_002:
text: |- text: |-
h1. Another page h1. Another page
...@@ -22,10 +22,10 @@ wiki_contents_002: ...@@ -22,10 +22,10 @@ wiki_contents_002:
updated_on: 2007-03-08 00:18:07 +01:00 updated_on: 2007-03-08 00:18:07 +01:00
page_id: 2 page_id: 2
id: 2 id: 2
version: 1 lock_version: 1
author_id: 1 author_id: 1
comments: comments:
wiki_contents_003: wiki_contents_003:
text: |- text: |-
h1. Start page h1. Start page
...@@ -33,10 +33,10 @@ wiki_contents_003: ...@@ -33,10 +33,10 @@ wiki_contents_003:
updated_on: 2007-03-08 00:18:07 +01:00 updated_on: 2007-03-08 00:18:07 +01:00
page_id: 3 page_id: 3
id: 3 id: 3
version: 1 lock_version: 1
author_id: 1 author_id: 1
comments: comments:
wiki_contents_004: wiki_contents_004:
text: |- text: |-
h1. Page with an inline image h1. Page with an inline image
...@@ -46,10 +46,10 @@ wiki_contents_004: ...@@ -46,10 +46,10 @@ wiki_contents_004:
updated_on: 2007-03-08 00:18:07 +01:00 updated_on: 2007-03-08 00:18:07 +01:00
page_id: 4 page_id: 4
id: 4 id: 4
version: 1 lock_version: 1
author_id: 1 author_id: 1
comments: comments:
wiki_contents_005: wiki_contents_005:
text: |- text: |-
h1. Child page 1 h1. Child page 1
...@@ -57,10 +57,10 @@ wiki_contents_005: ...@@ -57,10 +57,10 @@ wiki_contents_005:
updated_on: 2007-03-08 00:18:07 +01:00 updated_on: 2007-03-08 00:18:07 +01:00
page_id: 5 page_id: 5
id: 5 id: 5
version: 1 lock_version: 1
author_id: 1 author_id: 1
comments: comments:
wiki_contents_006: wiki_contents_006:
text: |- text: |-
h1. Child page 2 h1. Child page 2
...@@ -68,31 +68,30 @@ wiki_contents_006: ...@@ -68,31 +68,30 @@ wiki_contents_006:
updated_on: 2007-03-08 00:18:07 +01:00 updated_on: 2007-03-08 00:18:07 +01:00
page_id: 6 page_id: 6
id: 6 id: 6
version: 1 lock_version: 1
author_id: 1 author_id: 1
comments: comments:
wiki_contents_007: wiki_contents_007:
text: This is a child page text: This is a child page
updated_on: 2007-03-08 00:18:07 +01:00 updated_on: 2007-03-08 00:18:07 +01:00
page_id: 7 page_id: 7
id: 7 id: 7
version: 1 lock_version: 1
author_id: 1 author_id: 1
comments: comments:
wiki_contents_008: wiki_contents_008:
text: This is a parent page text: This is a parent page
updated_on: 2007-03-08 00:18:07 +01:00 updated_on: 2007-03-08 00:18:07 +01:00
page_id: 8 page_id: 8
id: 8 id: 8
version: 1 lock_version: 1
author_id: 1 author_id: 1
comments: comments:
wiki_contents_009: wiki_contents_009:
text: This is a child page text: This is a child page
updated_on: 2007-03-08 00:18:07 +01:00 updated_on: 2007-03-08 00:18:07 +01:00
page_id: 9 page_id: 9
id: 9 id: 9
version: 1 lock_version: 1
author_id: 1 author_id: 1
comments: comments:
\ No newline at end of file
This diff is collapsed.
...@@ -43,11 +43,10 @@ class IssuesControllerTransactionTest < ActionController::TestCase ...@@ -43,11 +43,10 @@ class IssuesControllerTransactionTest < ActionController::TestCase
:custom_fields_trackers, :custom_fields_trackers,
:time_entries, :time_entries,
:journals, :journals,
:journal_details,
:queries :queries
self.use_transactional_fixtures = false self.use_transactional_fixtures = false
def setup def setup
@controller = IssuesController.new @controller = IssuesController.new
@request = ActionController::TestRequest.new @request = ActionController::TestRequest.new
......
...@@ -22,8 +22,8 @@ require 'journals_controller' ...@@ -22,8 +22,8 @@ require 'journals_controller'
class JournalsController; def rescue_action(e) raise e end; end class JournalsController; def rescue_action(e) raise e end; end
class JournalsControllerTest < ActionController::TestCase class JournalsControllerTest < ActionController::TestCase
fixtures :projects, :users, :members, :member_roles, :roles, :issues, :journals, :journal_details, :enabled_modules fixtures :projects, :users, :members, :member_roles, :roles, :issues, :journals, :enabled_modules
def setup def setup
@controller = JournalsController.new @controller = JournalsController.new
@request = ActionController::TestRequest.new @request = ActionController::TestRequest.new
......
...@@ -22,7 +22,7 @@ require 'projects_controller' ...@@ -22,7 +22,7 @@ require 'projects_controller'
class ProjectsController; def rescue_action(e) raise e end; end class ProjectsController; def rescue_action(e) raise e end; end
class ProjectsControllerTest < ActionController::TestCase class ProjectsControllerTest < ActionController::TestCase
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details, fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals,
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
:attachments, :custom_fields, :custom_values, :time_entries :attachments, :custom_fields, :custom_values, :time_entries
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
...@@ -22,15 +22,15 @@ require 'wiki_controller' ...@@ -22,15 +22,15 @@ require 'wiki_controller'
class WikiController; def rescue_action(e) raise e end; end class WikiController; def rescue_action(e) raise e end; end
class WikiControllerTest < ActionController::TestCase class WikiControllerTest < ActionController::TestCase
fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :attachments fixtures :projects, :users, :roles, :members, :member_roles, :enabled_modules, :wikis, :wiki_pages, :wiki_contents, :journals, :attachments
def setup def setup
@controller = WikiController.new @controller = WikiController.new
@request = ActionController::TestRequest.new @request = ActionController::TestRequest.new
@response = ActionController::TestResponse.new @response = ActionController::TestResponse.new
User.current = nil User.current = nil
end end
def test_show_start_page def test_show_start_page
get :index, :id => 'ecookbook' get :index, :id => 'ecookbook'
assert_response :success assert_response :success
...@@ -43,7 +43,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -43,7 +43,7 @@ class WikiControllerTest < ActionController::TestCase
:child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' }, :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Page_with_an_inline_image' },
:content => 'Page with an inline image' } } :content => 'Page with an inline image' } }
end end
def test_show_page_with_name def test_show_page_with_name
get :index, :id => 1, :page => 'Another_page' get :index, :id => 1, :page => 'Another_page'
assert_response :success assert_response :success
...@@ -54,30 +54,30 @@ class WikiControllerTest < ActionController::TestCase ...@@ -54,30 +54,30 @@ class WikiControllerTest < ActionController::TestCase
assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3', assert_tag :tag => 'img', :attributes => { :src => '/attachments/download/3',
:alt => 'This is a logo' } :alt => 'This is a logo' }
end end
def test_show_with_sidebar def test_show_with_sidebar
page = Project.find(1).wiki.pages.new(:title => 'Sidebar') page = Project.find(1).wiki.pages.new(:title => 'Sidebar')
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
page.save! page.save!
get :index, :id => 1, :page => 'Another_page' get :index, :id => 1, :page => 'Another_page'
assert_response :success assert_response :success
assert_tag :tag => 'div', :attributes => {:id => 'sidebar'}, assert_tag :tag => 'div', :attributes => {:id => 'sidebar'},
:content => /Side bar content for test_show_with_sidebar/ :content => /Side bar content for test_show_with_sidebar/
end end
def test_show_unexistent_page_without_edit_right def test_show_unexistent_page_without_edit_right
get :index, :id => 1, :page => 'Unexistent page' get :index, :id => 1, :page => 'Unexistent page'
assert_response 404 assert_response 404
end end
def test_show_unexistent_page_with_edit_right def test_show_unexistent_page_with_edit_right
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :index, :id => 1, :page => 'Unexistent page' get :index, :id => 1, :page => 'Unexistent page'
assert_response :success assert_response :success
assert_template 'edit' assert_template 'edit'
end end
def test_create_page def test_create_page
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :edit, :id => 1, post :edit, :id => 1,
...@@ -91,7 +91,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -91,7 +91,7 @@ class WikiControllerTest < ActionController::TestCase
assert_not_nil page.content assert_not_nil page.content
assert_equal 'Created the page', page.content.comments assert_equal 'Created the page', page.content.comments
end end
def test_create_page_with_attachments def test_create_page_with_attachments
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference 'WikiPage.count' do assert_difference 'WikiPage.count' do
...@@ -108,7 +108,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -108,7 +108,7 @@ class WikiControllerTest < ActionController::TestCase
assert_equal 1, page.attachments.count assert_equal 1, page.attachments.count
assert_equal 'testfile.txt', page.attachments.first.filename assert_equal 'testfile.txt', page.attachments.first.filename
end end
def test_preview def test_preview
@request.session[:user_id] = 2 @request.session[:user_id] = 2
xhr :post, :preview, :id => 1, :page => 'CookBook_documentation', xhr :post, :preview, :id => 1, :page => 'CookBook_documentation',
...@@ -119,7 +119,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -119,7 +119,7 @@ class WikiControllerTest < ActionController::TestCase
assert_template 'common/_preview' assert_template 'common/_preview'
assert_tag :tag => 'strong', :content => /previewed text/ assert_tag :tag => 'strong', :content => /previewed text/
end end
def test_preview_new_page def test_preview_new_page
@request.session[:user_id] = 2 @request.session[:user_id] = 2
xhr :post, :preview, :id => 1, :page => 'New page', xhr :post, :preview, :id => 1, :page => 'New page',
...@@ -130,7 +130,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -130,7 +130,7 @@ class WikiControllerTest < ActionController::TestCase
assert_template 'common/_preview' assert_template 'common/_preview'
assert_tag :tag => 'h1', :content => /New page/ assert_tag :tag => 'h1', :content => /New page/
end end
def test_history def test_history
get :history, :id => 1, :page => 'CookBook_documentation' get :history, :id => 1, :page => 'CookBook_documentation'
assert_response :success assert_response :success
...@@ -148,7 +148,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -148,7 +148,7 @@ class WikiControllerTest < ActionController::TestCase
assert_equal 1, assigns(:versions).size assert_equal 1, assigns(:versions).size
assert_select "input[type=submit][name=commit]", false assert_select "input[type=submit][name=commit]", false
end end
def test_diff def test_diff
get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1 get :diff, :id => 1, :page => 'CookBook_documentation', :version => 2, :version_from => 1
assert_response :success assert_response :success
...@@ -156,7 +156,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -156,7 +156,7 @@ class WikiControllerTest < ActionController::TestCase
assert_tag :tag => 'span', :attributes => { :class => 'diff_in'}, assert_tag :tag => 'span', :attributes => { :class => 'diff_in'},
:content => /updated/ :content => /updated/
end end
def test_annotate def test_annotate
get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2 get :annotate, :id => 1, :page => 'CookBook_documentation', :version => 2
assert_response :success assert_response :success
...@@ -170,7 +170,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -170,7 +170,7 @@ class WikiControllerTest < ActionController::TestCase
:child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ }, :child => { :tag => 'td', :attributes => {:class => 'author'}, :content => /redMine Admin/ },
:child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ } :child => { :tag => 'td', :content => /Some updated \[\[documentation\]\] here/ }
end end
def test_rename_with_redirect def test_rename_with_redirect
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :rename, :id => 1, :page => 'Another_page', post :rename, :id => 1, :page => 'Another_page',
...@@ -193,13 +193,13 @@ class WikiControllerTest < ActionController::TestCase ...@@ -193,13 +193,13 @@ class WikiControllerTest < ActionController::TestCase
# Check that there's no redirects # Check that there's no redirects
assert_nil wiki.find_page('Another page') assert_nil wiki.find_page('Another page')
end end
def test_destroy_child def test_destroy_child
@request.session[:user_id] = 2 @request.session[:user_id] = 2
post :destroy, :id => 1, :page => 'Child_1' post :destroy, :id => 1, :page => 'Child_1'
assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index' assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
end end
def test_destroy_parent def test_destroy_parent
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_no_difference('WikiPage.count') do assert_no_difference('WikiPage.count') do
...@@ -208,7 +208,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -208,7 +208,7 @@ class WikiControllerTest < ActionController::TestCase
assert_response :success assert_response :success
assert_template 'destroy' assert_template 'destroy'
end end
def test_destroy_parent_with_nullify def test_destroy_parent_with_nullify
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference('WikiPage.count', -1) do assert_difference('WikiPage.count', -1) do
...@@ -217,7 +217,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -217,7 +217,7 @@ class WikiControllerTest < ActionController::TestCase
assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index' assert_redirected_to :action => 'special', :id => 'ecookbook', :page => 'Page_index'
assert_nil WikiPage.find_by_id(2) assert_nil WikiPage.find_by_id(2)
end end
def test_destroy_parent_with_cascade def test_destroy_parent_with_cascade
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference('WikiPage.count', -3) do assert_difference('WikiPage.count', -3) do
...@@ -227,7 +227,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -227,7 +227,7 @@ class WikiControllerTest < ActionController::TestCase
assert_nil WikiPage.find_by_id(2) assert_nil WikiPage.find_by_id(2)
assert_nil WikiPage.find_by_id(5) assert_nil WikiPage.find_by_id(5)
end end
def test_destroy_parent_with_reassign def test_destroy_parent_with_reassign
@request.session[:user_id] = 2 @request.session[:user_id] = 2
assert_difference('WikiPage.count', -1) do assert_difference('WikiPage.count', -1) do
...@@ -237,7 +237,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -237,7 +237,7 @@ class WikiControllerTest < ActionController::TestCase
assert_nil WikiPage.find_by_id(2) assert_nil WikiPage.find_by_id(2)
assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent assert_equal WikiPage.find(1), WikiPage.find_by_id(5).parent
end end
def test_page_index def test_page_index
get :special, :id => 'ecookbook', :page => 'Page_index' get :special, :id => 'ecookbook', :page => 'Page_index'
assert_response :success assert_response :success
...@@ -245,7 +245,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -245,7 +245,7 @@ class WikiControllerTest < ActionController::TestCase
pages = assigns(:pages) pages = assigns(:pages)
assert_not_nil pages assert_not_nil pages
assert_equal Project.find(1).wiki.pages.size, pages.size assert_equal Project.find(1).wiki.pages.size, pages.size
assert_tag :ul, :attributes => { :class => 'pages-hierarchy' }, assert_tag :ul, :attributes => { :class => 'pages-hierarchy' },
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' }, :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/CookBook_documentation' },
:content => 'CookBook documentation' }, :content => 'CookBook documentation' },
...@@ -256,12 +256,12 @@ class WikiControllerTest < ActionController::TestCase ...@@ -256,12 +256,12 @@ class WikiControllerTest < ActionController::TestCase
:child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' }, :child => { :tag => 'li', :child => { :tag => 'a', :attributes => { :href => '/projects/ecookbook/wiki/Another_page' },
:content => 'Another page' } } :content => 'Another page' } }
end end
def test_not_found def test_not_found
get :index, :id => 999 get :index, :id => 999
assert_response 404 assert_response 404
end end
def test_protect_page def test_protect_page
page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page') page = WikiPage.find_by_wiki_id_and_title(1, 'Another_page')
assert !page.protected? assert !page.protected?
...@@ -270,7 +270,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -270,7 +270,7 @@ class WikiControllerTest < ActionController::TestCase
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_page' assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'Another_page'
assert page.reload.protected? assert page.reload.protected?
end end
def test_unprotect_page def test_unprotect_page
page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation') page = WikiPage.find_by_wiki_id_and_title(1, 'CookBook_documentation')
assert page.protected? assert page.protected?
...@@ -279,7 +279,7 @@ class WikiControllerTest < ActionController::TestCase ...@@ -279,7 +279,7 @@ class WikiControllerTest < ActionController::TestCase
assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'CookBook_documentation' assert_redirected_to :action => 'index', :id => 'ecookbook', :page => 'CookBook_documentation'
assert !page.reload.protected? assert !page.reload.protected?
end end
def test_show_page_with_edit_link def test_show_page_with_edit_link
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :index, :id => 1 get :index, :id => 1
...@@ -287,15 +287,15 @@ class WikiControllerTest < ActionController::TestCase ...@@ -287,15 +287,15 @@ class WikiControllerTest < ActionController::TestCase
assert_template 'show' assert_template 'show'
assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } assert_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
end end
def test_show_page_without_edit_link def test_show_page_without_edit_link
@request.session[:user_id] = 4 @request.session[:user_id] = 4
get :index, :id => 1 get :index, :id => 1
assert_response :success assert_response :success
assert_template 'show' assert_template 'show'
assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' } assert_no_tag :tag => 'a', :attributes => { :href => '/projects/1/wiki/CookBook_documentation/edit' }
end end
def test_edit_unprotected_page def test_edit_unprotected_page
# Non members can edit unprotected wiki pages # Non members can edit unprotected wiki pages
@request.session[:user_id] = 4 @request.session[:user_id] = 4
...@@ -303,21 +303,21 @@ class WikiControllerTest < ActionController::TestCase ...@@ -303,21 +303,21 @@ class WikiControllerTest < ActionController::TestCase
assert_response :success assert_response :success
assert_template 'edit' assert_template 'edit'
end end
def test_edit_protected_page_by_nonmember def test_edit_protected_page_by_nonmember
# Non members can't edit protected wiki pages # Non members can't edit protected wiki pages
@request.session[:user_id] = 4 @request.session[:user_id] = 4
get :edit, :id => 1, :page => 'CookBook_documentation' get :edit, :id => 1, :page => 'CookBook_documentation'
assert_response 403 assert_response 403
end end
def test_edit_protected_page_by_member def test_edit_protected_page_by_member
@request.session[:user_id] = 2 @request.session[:user_id] = 2
get :edit, :id => 1, :page => 'CookBook_documentation' get :edit, :id => 1, :page => 'CookBook_documentation'
assert_response :success assert_response :success
assert_template 'edit' assert_template 'edit'
end end
def test_history_of_non_existing_page_should_return_404 def test_history_of_non_existing_page_should_return_404
get :history, :id => 1, :page => 'Unknown_page' get :history, :id => 1, :page => 'Unknown_page'
assert_response 404 assert_response 404
......
...@@ -39,7 +39,6 @@ class IssuesApiTest < ActionController::IntegrationTest ...@@ -39,7 +39,6 @@ class IssuesApiTest < ActionController::IntegrationTest
:custom_fields_trackers, :custom_fields_trackers,
:time_entries, :time_entries,
:journals, :journals,
:journal_details,
:queries :queries
def setup def setup
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
require "#{File.dirname(__FILE__)}/../test_helper" require "#{File.dirname(__FILE__)}/../test_helper"
class ProjectsApiTest < ActionController::IntegrationTest class ProjectsApiTest < ActionController::IntegrationTest
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details, fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals,
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages, :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
:attachments, :custom_fields, :custom_values, :time_entries :attachments, :custom_fields, :custom_values, :time_entries
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
...@@ -47,7 +47,7 @@ class ActiveSupport::TestCase ...@@ -47,7 +47,7 @@ class ActiveSupport::TestCase
self.use_instantiated_fixtures = false self.use_instantiated_fixtures = false
# Add more helper methods to be used by all tests here... # Add more helper methods to be used by all tests here...
def log_user(login, password) def log_user(login, password)
User.anonymous User.anonymous
get "/login" get "/login"
...@@ -57,7 +57,7 @@ class ActiveSupport::TestCase ...@@ -57,7 +57,7 @@ class ActiveSupport::TestCase
post "/login", :username => login, :password => password post "/login", :username => login, :password => password
assert_equal login, User.find(session[:user_id]).login assert_equal login, User.find(session[:user_id]).login
end end
def uploaded_test_file(name, mime) def uploaded_test_file(name, mime)
ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime) ActionController::TestUploadedFile.new(ActiveSupport::TestCase.fixture_path + "/files/#{name}", mime)
end end
...@@ -71,14 +71,14 @@ class ActiveSupport::TestCase ...@@ -71,14 +71,14 @@ class ActiveSupport::TestCase
file.stubs(:read).returns(false) file.stubs(:read).returns(false)
file file
end end
# Use a temporary directory for attachment related tests # Use a temporary directory for attachment related tests
def set_tmp_attachments_directory def set_tmp_attachments_directory
Dir.mkdir "#{RAILS_ROOT}/tmp/test" unless File.directory?("#{RAILS_ROOT}/tmp/test") Dir.mkdir "#{RAILS_ROOT}/tmp/test" unless File.directory?("#{RAILS_ROOT}/tmp/test")
Dir.mkdir "#{RAILS_ROOT}/tmp/test/attachments" unless File.directory?("#{RAILS_ROOT}/tmp/test/attachments") Dir.mkdir "#{RAILS_ROOT}/tmp/test/attachments" unless File.directory?("#{RAILS_ROOT}/tmp/test/attachments")
Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments" Attachment.storage_path = "#{RAILS_ROOT}/tmp/test/attachments"
end end
def with_settings(options, &block) def with_settings(options, &block)
saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].dup; h} saved_settings = options.keys.inject({}) {|h, k| h[k] = Setting[k].dup; h}
options.each {|k, v| Setting[k] = v} options.each {|k, v| Setting[k] = v}
...@@ -93,12 +93,12 @@ class ActiveSupport::TestCase ...@@ -93,12 +93,12 @@ class ActiveSupport::TestCase
# LDAP is not listening # LDAP is not listening
return nil return nil
end end
# Returns the path to the test +vendor+ repository # Returns the path to the test +vendor+ repository
def self.repository_path(vendor) def self.repository_path(vendor)
File.join(RAILS_ROOT.gsub(%r{config\/\.\.}, ''), "/tmp/test/#{vendor.downcase}_repository") File.join(RAILS_ROOT.gsub(%r{config\/\.\.}, ''), "/tmp/test/#{vendor.downcase}_repository")
end end
# Returns true if the +vendor+ test repository is configured # Returns true if the +vendor+ test repository is configured
def self.repository_configured?(vendor) def self.repository_configured?(vendor)
File.directory?(repository_path(vendor)) File.directory?(repository_path(vendor))
...@@ -144,21 +144,17 @@ class ActiveSupport::TestCase ...@@ -144,21 +144,17 @@ class ActiveSupport::TestCase
end end
should "use the new value's name" do should "use the new value's name" do
@detail = JournalDetail.generate!(:property => 'attr', @detail = IssueJournal.generate(:version => 1)
:old_value => @old_value.id, @detail.update_attribute(:changes, {prop_key => [@old_value.id, @new_value.id]}.to_yaml)
:value => @new_value.id,
:prop_key => prop_key) assert_match @new_value.name, @detail.render_detail(prop_key, true)
assert_match @new_value.name, show_detail(@detail, true)
end end
should "use the old value's name" do should "use the old value's name" do
@detail = JournalDetail.generate!(:property => 'attr', @detail = IssueJournal.generate(:version => 1)
:old_value => @old_value.id, @detail.update_attribute(:changes, {prop_key => [@old_value.id, @new_value.id]}.to_yaml)
:value => @new_value.id,
:prop_key => prop_key) assert_match @old_value.name, @detail.render_detail(prop_key, true)
assert_match @old_value.name, show_detail(@detail, true)
end end
end end
end end
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class ActivityTest < ActiveSupport::TestCase class ActivityTest < ActiveSupport::TestCase
fixtures :projects, :versions, :attachments, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details, fixtures :projects, :versions, :attachments, :users, :roles, :members, :member_roles, :issues, :journals,
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages :trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages
def setup def setup
...@@ -28,7 +28,6 @@ class ActivityTest < ActiveSupport::TestCase ...@@ -28,7 +28,6 @@ class ActivityTest < ActiveSupport::TestCase
def test_activity_without_subprojects def test_activity_without_subprojects
events = find_events(User.anonymous, :project => @project) events = find_events(User.anonymous, :project => @project)
assert_not_nil events assert_not_nil events
assert events.include?(Issue.find(1)) assert events.include?(Issue.find(1))
assert !events.include?(Issue.find(4)) assert !events.include?(Issue.find(4))
# subproject issue # subproject issue
...@@ -43,40 +42,40 @@ class ActivityTest < ActiveSupport::TestCase ...@@ -43,40 +42,40 @@ class ActivityTest < ActiveSupport::TestCase
# subproject issue # subproject issue
assert events.include?(Issue.find(5)) assert events.include?(Issue.find(5))
end end
def test_global_activity_anonymous def test_global_activity_anonymous
events = find_events(User.anonymous) events = find_events(User.anonymous)
assert_not_nil events assert_not_nil events
assert events.include?(Issue.find(1)) assert events.include?(Issue.find(1))
assert events.include?(Message.find(5)) assert events.include?(Message.find(5))
# Issue of a private project # Issue of a private project
assert !events.include?(Issue.find(4)) assert !events.include?(Issue.find(6))
end end
def test_global_activity_logged_user def test_global_activity_logged_user
events = find_events(User.find(2)) # manager events = find_events(User.find(2)) # manager
assert_not_nil events assert_not_nil events
assert events.include?(Issue.find(1)) assert events.include?(Issue.find(1))
# Issue of a private project the user belongs to # Issue of a private project the user belongs to
assert events.include?(Issue.find(4)) assert events.include?(Issue.find(6))
end end
def test_user_activity def test_user_activity
user = User.find(2) user = User.find(2)
events = Redmine::Activity::Fetcher.new(User.anonymous, :author => user).events(nil, nil, :limit => 10) events = Redmine::Activity::Fetcher.new(User.anonymous, :author => user).events(nil, nil, :limit => 10)
assert(events.size > 0) assert(events.size > 0)
assert(events.size <= 10) assert(events.size <= 10)
assert_nil(events.detect {|e| e.event_author != user}) assert_nil(events.detect {|e| e.event_author != user})
end end
def test_files_activity def test_files_activity
f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1)) f = Redmine::Activity::Fetcher.new(User.anonymous, :project => Project.find(1))
f.scope = ['files'] f.scope = ['files']
events = f.events events = f.events
assert_kind_of Array, events assert_kind_of Array, events
assert events.include?(Attachment.find_by_container_type_and_container_id('Project', 1)) assert events.include?(Attachment.find_by_container_type_and_container_id('Project', 1))
assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1)) assert events.include?(Attachment.find_by_container_type_and_container_id('Version', 1))
...@@ -85,8 +84,11 @@ class ActivityTest < ActiveSupport::TestCase ...@@ -85,8 +84,11 @@ class ActivityTest < ActiveSupport::TestCase
end end
private private
def find_events(user, options={}) def find_events(user, options={})
Redmine::Activity::Fetcher.new(user, options).events(Date.today - 30, Date.today + 1) events = Redmine::Activity::Fetcher.new(user, options).events(Date.today - 30, Date.today + 1)
# Because events are provided by the journals, but we want to test for
# their targets here, transform that
events.group_by(&:versioned).keys
end end
end end
This diff is collapsed.
...@@ -18,14 +18,14 @@ ...@@ -18,14 +18,14 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class JournalTest < ActiveSupport::TestCase class JournalTest < ActiveSupport::TestCase
fixtures :issues, :issue_statuses, :journals, :journal_details fixtures :issues, :issue_statuses, :journals
def setup def setup
@journal = Journal.find 1 @journal = IssueJournal.first
end end
def test_journalized_is_an_issue def test_journalized_is_an_issue
issue = @journal.issue issue = @journal.journalized
assert_kind_of Issue, issue assert_kind_of Issue, issue
assert_equal 1, issue.id assert_equal 1, issue.id
end end
...@@ -34,16 +34,16 @@ class JournalTest < ActiveSupport::TestCase ...@@ -34,16 +34,16 @@ class JournalTest < ActiveSupport::TestCase
status = @journal.new_status status = @journal.new_status
assert_not_nil status assert_not_nil status
assert_kind_of IssueStatus, status assert_kind_of IssueStatus, status
assert_equal 2, status.id assert_equal 2, status.id
end end
def test_create_should_send_email_notification def test_create_should_send_email_notification
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
issue = Issue.find(:first) issue = Issue.find(:first)
user = User.find(:first) user = User.find(:first)
journal = issue.init_journal(user, issue)
assert journal.save assert_equal 0, ActionMailer::Base.deliveries.size
issue.update_attribute(:subject, "New subject to trigger automatic journal entry")
assert_equal 1, ActionMailer::Base.deliveries.size assert_equal 1, ActionMailer::Base.deliveries.size
end end
......
...@@ -259,7 +259,7 @@ class MailHandlerTest < ActiveSupport::TestCase ...@@ -259,7 +259,7 @@ class MailHandlerTest < ActiveSupport::TestCase
# This email contains: 'Status: Resolved' # This email contains: 'Status: Resolved'
journal = submit_email('ticket_reply_with_status.eml') journal = submit_email('ticket_reply_with_status.eml')
assert journal.is_a?(Journal) assert journal.is_a?(Journal)
issue = Issue.find(journal.issue.id) issue = Issue.find(journal.journalized.id)
assert_equal User.find_by_login('jsmith'), journal.user assert_equal User.find_by_login('jsmith'), journal.user
assert_equal Issue.find(2), journal.journalized assert_equal Issue.find(2), journal.journalized
assert_match /This is reply/, journal.notes assert_match /This is reply/, journal.notes
......
...@@ -20,8 +20,8 @@ require File.dirname(__FILE__) + '/../test_helper' ...@@ -20,8 +20,8 @@ require File.dirname(__FILE__) + '/../test_helper'
class MailerTest < ActiveSupport::TestCase class MailerTest < ActiveSupport::TestCase
include Redmine::I18n include Redmine::I18n
include ActionController::Assertions::SelectorAssertions include ActionController::Assertions::SelectorAssertions
fixtures :projects, :enabled_modules, :issues, :users, :members, :member_roles, :roles, :documents, :attachments, :news, :tokens, :journals, :journal_details, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories fixtures :projects, :enabled_modules, :issues, :users, :members, :member_roles, :roles, :documents, :attachments, :news, :tokens, :journals, :changesets, :trackers, :issue_statuses, :enumerations, :messages, :boards, :repositories
def setup def setup
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
Setting.host_name = 'mydomain.foo' Setting.host_name = 'mydomain.foo'
......
...@@ -27,7 +27,6 @@ class SearchTest < ActiveSupport::TestCase ...@@ -27,7 +27,6 @@ class SearchTest < ActiveSupport::TestCase
:issues, :issues,
:trackers, :trackers,
:journals, :journals,
:journal_details,
:repositories, :repositories,
:changesets :changesets
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
...@@ -18,19 +18,19 @@ ...@@ -18,19 +18,19 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class WikiContentTest < ActiveSupport::TestCase class WikiContentTest < ActiveSupport::TestCase
fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions, :users fixtures :wikis, :wiki_pages, :wiki_contents, :journals, :users
def setup def setup
@wiki = Wiki.find(1) @wiki = Wiki.find(1)
@page = @wiki.pages.first @page = @wiki.pages.first
end end
def test_create def test_create
page = WikiPage.new(:wiki => @wiki, :title => "Page") page = WikiPage.new(:wiki => @wiki, :title => "Page")
page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment") page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment")
assert page.save assert page.save
page.reload page.reload
content = page.content content = page.content
assert_kind_of WikiContent, content assert_kind_of WikiContent, content
assert_equal 1, content.version assert_equal 1, content.version
...@@ -40,14 +40,14 @@ class WikiContentTest < ActiveSupport::TestCase ...@@ -40,14 +40,14 @@ class WikiContentTest < ActiveSupport::TestCase
assert_equal User.find(1), content.author assert_equal User.find(1), content.author
assert_equal content.text, content.versions.last.text assert_equal content.text, content.versions.last.text
end end
def test_create_should_send_email_notification def test_create_should_send_email_notification
Setting.notified_events = ['wiki_content_added'] Setting.notified_events = ['wiki_content_added']
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
page = WikiPage.new(:wiki => @wiki, :title => "A new page") page = WikiPage.new(:wiki => @wiki, :title => "A new page")
page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment") page.content = WikiContent.new(:text => "Content text", :author => User.find(1), :comments => "My comment")
assert page.save assert page.save
assert_equal 1, ActionMailer::Base.deliveries.size assert_equal 1, ActionMailer::Base.deliveries.size
end end
...@@ -60,26 +60,26 @@ class WikiContentTest < ActiveSupport::TestCase ...@@ -60,26 +60,26 @@ class WikiContentTest < ActiveSupport::TestCase
assert_equal version_count+1, content.version assert_equal version_count+1, content.version
assert_equal version_count+1, content.versions.length assert_equal version_count+1, content.versions.length
end end
def test_update_should_send_email_notification def test_update_should_send_email_notification
Setting.notified_events = ['wiki_content_updated'] Setting.notified_events = ['wiki_content_updated']
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
content = @page.content content = @page.content
content.text = "My new content" content.text = "My new content"
assert content.save assert content.save
assert_equal 1, ActionMailer::Base.deliveries.size assert_equal 1, ActionMailer::Base.deliveries.size
end end
def test_fetch_history def test_fetch_history
assert !@page.content.versions.empty? assert !@page.content.versions.empty?
@page.content.versions.each do |version| @page.content.versions.each do |version|
assert_kind_of String, version.text assert_kind_of String, version.text
end end
end end
def test_large_text_should_not_be_truncated_to_64k def test_large_text_should_not_be_truncated_to_64k
page = WikiPage.new(:wiki => @wiki, :title => "Big page") page = WikiPage.new(:wiki => @wiki, :title => "Big page")
page.content = WikiContent.new(:text => "a" * 500.kilobyte, :author => User.find(1)) page.content = WikiContent.new(:text => "a" * 500.kilobyte, :author => User.find(1))
assert page.save assert page.save
page.reload page.reload
......
...@@ -5,12 +5,12 @@ ...@@ -5,12 +5,12 @@
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
...@@ -18,51 +18,51 @@ ...@@ -18,51 +18,51 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class WikiPageTest < ActiveSupport::TestCase class WikiPageTest < ActiveSupport::TestCase
fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions fixtures :projects, :wikis, :wiki_pages, :wiki_contents, :journals
def setup def setup
@wiki = Wiki.find(1) @wiki = Wiki.find(1)
@page = @wiki.pages.first @page = @wiki.pages.first
end end
def test_create def test_create
page = WikiPage.new(:wiki => @wiki) page = WikiPage.new(:wiki => @wiki)
assert !page.save assert !page.save
assert_equal 1, page.errors.count assert_equal 1, page.errors.count
page.title = "Page" page.title = "Page"
assert page.save assert page.save
page.reload page.reload
assert !page.protected? assert !page.protected?
@wiki.reload @wiki.reload
assert @wiki.pages.include?(page) assert @wiki.pages.include?(page)
end end
def test_sidebar_should_be_protected_by_default def test_sidebar_should_be_protected_by_default
page = @wiki.find_or_new_page('sidebar') page = @wiki.find_or_new_page('sidebar')
assert page.new_record? assert page.new_record?
assert page.protected? assert page.protected?
end end
def test_find_or_new_page def test_find_or_new_page
page = @wiki.find_or_new_page("CookBook documentation") page = @wiki.find_or_new_page("CookBook documentation")
assert_kind_of WikiPage, page assert_kind_of WikiPage, page
assert !page.new_record? assert !page.new_record?
page = @wiki.find_or_new_page("Non existing page") page = @wiki.find_or_new_page("Non existing page")
assert_kind_of WikiPage, page assert_kind_of WikiPage, page
assert page.new_record? assert page.new_record?
end end
def test_parent_title def test_parent_title
page = WikiPage.find_by_title('Another_page') page = WikiPage.find_by_title('Another_page')
assert_nil page.parent_title assert_nil page.parent_title
page = WikiPage.find_by_title('Page_with_an_inline_image') page = WikiPage.find_by_title('Page_with_an_inline_image')
assert_equal 'CookBook documentation', page.parent_title assert_equal 'CookBook documentation', page.parent_title
end end
def test_assign_parent def test_assign_parent
page = WikiPage.find_by_title('Another_page') page = WikiPage.find_by_title('Another_page')
page.parent_title = 'CookBook documentation' page.parent_title = 'CookBook documentation'
...@@ -70,7 +70,7 @@ class WikiPageTest < ActiveSupport::TestCase ...@@ -70,7 +70,7 @@ class WikiPageTest < ActiveSupport::TestCase
page.reload page.reload
assert_equal WikiPage.find_by_title('CookBook_documentation'), page.parent assert_equal WikiPage.find_by_title('CookBook_documentation'), page.parent
end end
def test_unassign_parent def test_unassign_parent
page = WikiPage.find_by_title('Page_with_an_inline_image') page = WikiPage.find_by_title('Page_with_an_inline_image')
page.parent_title = '' page.parent_title = ''
...@@ -78,10 +78,10 @@ class WikiPageTest < ActiveSupport::TestCase ...@@ -78,10 +78,10 @@ class WikiPageTest < ActiveSupport::TestCase
page.reload page.reload
assert_nil page.parent assert_nil page.parent
end end
def test_parent_validation def test_parent_validation
page = WikiPage.find_by_title('CookBook_documentation') page = WikiPage.find_by_title('CookBook_documentation')
# A page that doesn't exist # A page that doesn't exist
page.parent_title = 'Unknown title' page.parent_title = 'Unknown title'
assert !page.save assert !page.save
...@@ -98,23 +98,26 @@ class WikiPageTest < ActiveSupport::TestCase ...@@ -98,23 +98,26 @@ class WikiPageTest < ActiveSupport::TestCase
page.parent_title = 'Another_page' page.parent_title = 'Another_page'
assert page.save assert page.save
end end
def test_destroy def test_destroy
page = WikiPage.find(1) page = WikiPage.find(1)
content_ids = WikiContent.find_all_by_page_id(1).collect(&:id)
page.destroy page.destroy
assert_nil WikiPage.find_by_id(1) assert_nil WikiPage.find_by_id(1)
# make sure that page content and its history are deleted # make sure that page content and its history are deleted
assert WikiContent.find_all_by_page_id(1).empty? assert WikiContent.find_all_by_page_id(1).empty?
assert WikiContent.versioned_class.find_all_by_page_id(1).empty? content_ids.each do |wiki_content_id|
assert WikiContent.journal_class.find_all_by_versioned_id(wiki_content_id).empty?
end
end end
def test_destroy_should_not_nullify_children def test_destroy_should_not_nullify_children
page = WikiPage.find(2) page = WikiPage.find(2)
child_ids = page.child_ids child_ids = page.child_ids
assert child_ids.any? assert child_ids.any?
page.destroy page.destroy
assert_nil WikiPage.find_by_id(2) assert_nil WikiPage.find_by_id(2)
children = WikiPage.find_all_by_id(child_ids) children = WikiPage.find_all_by_id(child_ids)
assert_equal child_ids.size, children.size assert_equal child_ids.size, children.size
children.each do |child| children.each do |child|
......
...@@ -7,12 +7,12 @@ ...@@ -7,12 +7,12 @@
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
...@@ -20,13 +20,13 @@ ...@@ -20,13 +20,13 @@
require File.dirname(__FILE__) + '/../test_helper' require File.dirname(__FILE__) + '/../test_helper'
class WikiTest < ActiveSupport::TestCase class WikiTest < ActiveSupport::TestCase
fixtures :wikis, :wiki_pages, :wiki_contents, :wiki_content_versions fixtures :wikis, :wiki_pages, :wiki_contents, :journals
def test_create def test_create
wiki = Wiki.new(:project => Project.find(2)) wiki = Wiki.new(:project => Project.find(2))
assert !wiki.save assert !wiki.save
assert_equal 1, wiki.errors.count assert_equal 1, wiki.errors.count
wiki.start_page = "Start page" wiki.start_page = "Start page"
assert wiki.save assert wiki.save
end end
...@@ -38,26 +38,26 @@ class WikiTest < ActiveSupport::TestCase ...@@ -38,26 +38,26 @@ class WikiTest < ActiveSupport::TestCase
@wiki.reload @wiki.reload
assert_equal "Another start page", @wiki.start_page assert_equal "Another start page", @wiki.start_page
end end
def test_titleize def test_titleize
assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES') assert_equal 'Page_title_with_CAPITALES', Wiki.titleize('page title with CAPITALES')
assert_equal 'テスト', Wiki.titleize('テスト') assert_equal 'テスト', Wiki.titleize('テスト')
end end
context "#sidebar" do context "#sidebar" do
setup do setup do
@wiki = Wiki.find(1) @wiki = Wiki.find(1)
end end
should "return nil if undefined" do should "return nil if undefined" do
assert_nil @wiki.sidebar assert_nil @wiki.sidebar
end end
should "return a WikiPage if defined" do should "return a WikiPage if defined" do
page = @wiki.pages.new(:title => 'Sidebar') page = @wiki.pages.new(:title => 'Sidebar')
page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar') page.content = WikiContent.new(:text => 'Side bar content for test_show_with_sidebar')
page.save! page.save!
assert_kind_of WikiPage, @wiki.sidebar assert_kind_of WikiPage, @wiki.sidebar
assert_equal 'Sidebar', @wiki.sidebar.title assert_equal 'Sidebar', @wiki.sidebar.title
end end
......
...@@ -68,11 +68,11 @@ module Redmine ...@@ -68,11 +68,11 @@ module Redmine
scope_options[:conditions] = cond.conditions scope_options[:conditions] = cond.conditions
if options[:limit] if options[:limit]
# id and creation time should be in same order in most cases # id and creation time should be in same order in most cases
scope_options[:order] = "#{table_name}.id DESC" scope_options[:order] = "#{journal_class.table_name}.id DESC"
scope_options[:limit] = options[:limit] scope_options[:limit] = options[:limit]
end end
with_scope(:find => scope_options) do journal_class.with_scope(:find => scope_options) do
journal_class.find(:all, provider_options[:find_options].dup) journal_class.find(:all, provider_options[:find_options].dup)
end end
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment