From 882764d49e5b9976f665b11167dac1c04fb55811 Mon Sep 17 00:00:00 2001 From: MAEDA Go Date: Sun, 4 Apr 2021 21:45:46 +0900 Subject: [PATCH 1/2] Remove WikiContent::Version --- app/helpers/application_helper.rb | 4 ++-- app/models/user.rb | 2 +- app/models/wiki_content.rb | 4 ---- lib/redmine.rb | 2 +- lib/redmine/wiki_formatting/macros.rb | 2 +- test/integration/api_test/wiki_pages_test.rb | 12 ++++++------ test/unit/activity_test.rb | 2 +- test/unit/project_test.rb | 2 +- test/unit/user_test.rb | 2 +- test/unit/wiki_page_test.rb | 2 +- 10 files changed, 15 insertions(+), 19 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7c77a14df..fdf405557 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -976,7 +976,7 @@ module ApplicationHelper wiki_page = link_project.wiki.find_page(page) url = if anchor.present? && wiki_page.present? && - (obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version)) && + (obj.is_a?(WikiContent) || obj.is_a?(WikiContentVersion)) && obj.page == wiki_page "##{anchor}" else @@ -1330,7 +1330,7 @@ module ApplicationHelper anchor = sanitize_anchor_name(item) # used for single-file wiki export if options[:wiki_links] == :anchor && (obj.is_a?(WikiContent) || - obj.is_a?(WikiContent::Version)) + obj.is_a?(WikiContentVersion)) anchor = "#{obj.page.title}_#{anchor}" end @heading_anchors[anchor] ||= 0 diff --git a/app/models/user.rb b/app/models/user.rb index a3d2449d2..cc1841a61 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -948,7 +948,7 @@ class User < Principal Token.where('user_id = ?', id).delete_all Watcher.where('user_id = ?', id).delete_all WikiContent.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) - WikiContent::Version.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) + WikiContentVersion.where(['author_id = ?', id]).update_all(['author_id = ?', substitute.id]) end # Singleton class method is public diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb index 7758caf2c..be891e864 100644 --- a/app/models/wiki_content.rb +++ b/app/models/wiki_content.rb @@ -98,8 +98,4 @@ class WikiContent < ActiveRecord::Base Mailer.deliver_wiki_content_updated(self) end end - - # For backward compatibility - # TODO: remove it in Redmine 5 - Version = WikiContentVersion end diff --git a/lib/redmine.rb b/lib/redmine.rb index ee9aece1a..0265d18d9 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -420,7 +420,7 @@ Redmine::Activity.map do |activity| activity.register :news activity.register :documents, :class_name => %w(Document Attachment) activity.register :files, :class_name => 'Attachment' - activity.register :wiki_edits, :class_name => 'WikiContent::Version', :default => false + activity.register :wiki_edits, :class_name => 'WikiContentVersion', :default => false activity.register :messages, :default => false activity.register :time_entries, :default => false end diff --git a/lib/redmine/wiki_formatting/macros.rb b/lib/redmine/wiki_formatting/macros.rb index f0ac94e20..e5f196306 100644 --- a/lib/redmine/wiki_formatting/macros.rb +++ b/lib/redmine/wiki_formatting/macros.rb @@ -202,7 +202,7 @@ module Redmine page = nil if args.size > 0 page = Wiki.find_page(args.first.to_s, :project => @project) - elsif obj.is_a?(WikiContent) || obj.is_a?(WikiContent::Version) + elsif obj.is_a?(WikiContent) || obj.is_a?(WikiContentVersion) page = obj.page else raise t(:error_childpages_macro_no_argument) diff --git a/test/integration/api_test/wiki_pages_test.rb b/test/integration/api_test/wiki_pages_test.rb index 73fd74137..1977b843b 100644 --- a/test/integration/api_test/wiki_pages_test.rb +++ b/test/integration/api_test/wiki_pages_test.rb @@ -104,7 +104,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base test "PUT /projects/:project_id/wiki/:title.xml should update wiki page" do assert_no_difference 'WikiPage.count' do - assert_difference 'WikiContent::Version.count' do + assert_difference 'WikiContentVersion.count' do put( '/projects/ecookbook/wiki/CookBook_documentation.xml', :params => { @@ -128,7 +128,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base test "PUT /projects/:project_id/wiki/:title.xml with current versino should update wiki page" do assert_no_difference 'WikiPage.count' do - assert_difference 'WikiContent::Version.count' do + assert_difference 'WikiContentVersion.count' do put( '/projects/ecookbook/wiki/CookBook_documentation.xml', :params => { @@ -153,7 +153,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base test "PUT /projects/:project_id/wiki/:title.xml with stale version should respond with 409" do assert_no_difference 'WikiPage.count' do - assert_no_difference 'WikiContent::Version.count' do + assert_no_difference 'WikiContentVersion.count' do put( '/projects/ecookbook/wiki/CookBook_documentation.xml', :params => { @@ -172,7 +172,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base test "PUT /projects/:project_id/wiki/:title.xml should create the page if it does not exist" do assert_difference 'WikiPage.count' do - assert_difference 'WikiContent::Version.count' do + assert_difference 'WikiContentVersion.count' do put( '/projects/ecookbook/wiki/New_page_from_API.xml', :params => { @@ -200,7 +200,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base set_tmp_attachments_directory attachment = Attachment.create!(:file => uploaded_test_file("testfile.txt", "text/plain"), :author_id => 2) assert_difference 'WikiPage.count' do - assert_difference 'WikiContent::Version.count' do + assert_difference 'WikiContentVersion.count' do put( '/projects/ecookbook/wiki/New_page_from_API.xml', :params => { @@ -228,7 +228,7 @@ class Redmine::ApiTest::WikiPagesTest < Redmine::ApiTest::Base test "PUT /projects/:project_id/wiki/:title.xml with parent" do assert_difference 'WikiPage.count' do - assert_difference 'WikiContent::Version.count' do + assert_difference 'WikiContentVersion.count' do put( '/projects/ecookbook/wiki/New_subpage_from_API.xml', :params => { diff --git a/test/unit/activity_test.rb b/test/unit/activity_test.rb index 8f6ee879d..d411a967d 100644 --- a/test/unit/activity_test.rb +++ b/test/unit/activity_test.rb @@ -128,7 +128,7 @@ class ActivityTest < ActiveSupport::TestCase end def test_event_group_for_wiki_content_version - content = WikiContent::Version.find(1) + content = WikiContentVersion.find(1) assert_equal content.page, content.event_group end diff --git a/test/unit/project_test.rb b/test/unit/project_test.rb index b154e6b90..2c23feb83 100644 --- a/test/unit/project_test.rb +++ b/test/unit/project_test.rb @@ -287,7 +287,7 @@ class ProjectTest < ActiveSupport::TestCase assert_equal 0, Wiki.count assert_equal 0, WikiPage.count assert_equal 0, WikiContent.count - assert_equal 0, WikiContent::Version.count + assert_equal 0, WikiContentVersion.count assert_equal 0, Project.connection.select_all("SELECT * FROM projects_trackers").count assert_equal 0, Project.connection.select_all("SELECT * FROM custom_fields_projects").count assert_equal 0, CustomValue.where(:customized_type => ['Project', 'Issue', 'TimeEntry', 'Version']).count diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index ab1fe56ab..c395bb310 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -425,7 +425,7 @@ class UserTest < ActiveSupport::TestCase :start_page => 'Start')) ) wiki_content.text = 'bar' - assert_difference 'WikiContent::Version.count' do + assert_difference 'WikiContentVersion.count' do wiki_content.save! end diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb index e6d1f604d..765747388 100644 --- a/test/unit/wiki_page_test.rb +++ b/test/unit/wiki_page_test.rb @@ -199,7 +199,7 @@ class WikiPageTest < ActiveSupport::TestCase end def test_diff_for_page_with_deleted_version_should_pick_the_previous_available_version - WikiContent::Version.find_by_page_id_and_version(1, 2).destroy + WikiContentVersion.find_by_page_id_and_version(1, 2).destroy page = WikiPage.find(1) diff = page.diff(3) -- 2.29.2