kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
3.8 KiB
113 lines
3.8 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
12 years ago
|
# OpenProject is a project management system.
|
||
10 years ago
|
# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)
|
||
14 years ago
|
#
|
||
18 years ago
|
# This program is free software; you can redistribute it and/or
|
||
12 years ago
|
# modify it under the terms of the GNU General Public License version 3.
|
||
14 years ago
|
#
|
||
11 years ago
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# as published by the Free Software Foundation; either version 2
|
||
|
# of the License, or (at your option) any later version.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program; if not, write to the Free Software
|
||
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
10 years ago
|
require 'legacy_spec_helper'
|
||
18 years ago
|
|
||
11 years ago
|
describe WikiContent, type: :model do
|
||
12 years ago
|
fixtures :all
|
||
18 years ago
|
|
||
11 years ago
|
before do
|
||
18 years ago
|
@wiki = Wiki.find(1)
|
||
|
@page = @wiki.pages.first
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should create' do
|
||
10 years ago
|
page = WikiPage.new(wiki: @wiki, title: 'Page')
|
||
|
page.content = WikiContent.new(text: 'Content text', author: User.find(1), comments: 'My comment')
|
||
18 years ago
|
assert page.save
|
||
|
page.reload
|
||
14 years ago
|
|
||
18 years ago
|
content = page.content
|
||
|
assert_kind_of WikiContent, content
|
||
|
assert_equal 1, content.version
|
||
|
assert_equal 1, content.versions.length
|
||
10 years ago
|
assert_equal 'Content text', content.text
|
||
|
assert_equal 'My comment', content.versions.last.notes
|
||
18 years ago
|
assert_equal User.find(1), content.author
|
||
11 years ago
|
assert_equal content.text, content.versions.last.data.text
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should create should send email notification' do
|
||
16 years ago
|
Setting.notified_events = ['wiki_content_added']
|
||
9 years ago
|
|
||
10 years ago
|
page = WikiPage.new(wiki: @wiki, title: 'A new page')
|
||
|
page.content = WikiContent.new(text: 'Content text', author: User.find(1), comments: 'My comment')
|
||
16 years ago
|
assert page.save
|
||
11 years ago
|
|
||
14 years ago
|
assert_equal 2, ActionMailer::Base.deliveries.size
|
||
16 years ago
|
end
|
||
18 years ago
|
|
||
11 years ago
|
it 'should update' do
|
||
18 years ago
|
content = @page.content
|
||
|
version_count = content.version
|
||
10 years ago
|
content.text = 'My new content'
|
||
18 years ago
|
assert content.save
|
||
|
content.reload
|
||
10 years ago
|
assert_equal version_count + 1, content.version
|
||
|
assert_equal version_count + 1, content.versions.length
|
||
18 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should update should send email notification' do
|
||
16 years ago
|
Setting.notified_events = ['wiki_content_updated']
|
||
9 years ago
|
|
||
16 years ago
|
content = @page.content
|
||
10 years ago
|
content.text = 'My new content'
|
||
16 years ago
|
assert content.save
|
||
11 years ago
|
|
||
14 years ago
|
assert_equal 2, ActionMailer::Base.deliveries.size
|
||
16 years ago
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should fetch history' do
|
||
11 years ago
|
wiki_content_journal = FactoryGirl.build(:wiki_content_journal,
|
||
11 years ago
|
journable_id: @page.content.id)
|
||
11 years ago
|
wiki_content_journal.data.page_id = @page.id
|
||
10 years ago
|
wiki_content_journal.data.text = ''
|
||
11 years ago
|
|
||
|
@page.content.journals << wiki_content_journal
|
||
14 years ago
|
assert !@page.content.journals.empty?
|
||
|
@page.content.journals.each do |journal|
|
||
11 years ago
|
assert_kind_of String, journal.data.text
|
||
18 years ago
|
end
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
it 'should large text should not be truncated to 64k' do
|
||
10 years ago
|
page = WikiPage.new(wiki: @wiki, title: 'Big page')
|
||
|
page.content = WikiContent.new(text: 'a' * 500.kilobyte, author: User.find(1))
|
||
15 years ago
|
assert page.save
|
||
|
page.reload
|
||
|
assert_equal 500.kilobyte, page.content.text.size
|
||
|
end
|
||
14 years ago
|
|
||
11 years ago
|
specify 'new WikiContent is version 0' do
|
||
10 years ago
|
page = WikiPage.new(wiki: @wiki, title: 'Page')
|
||
|
page.content = WikiContent.new(text: 'Content text', author: User.find(1), comments: 'My comment')
|
||
14 years ago
|
|
||
|
assert_equal 0, page.content.version
|
||
|
end
|
||
18 years ago
|
end
|