redmine_plugins_helper 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/init.rb +1 -0
- data/lib/redmine_plugins_helper/fix_migrations.rb +4 -17
- data/lib/redmine_plugins_helper/migrate.rb +20 -1
- data/lib/redmine_plugins_helper/patches/redmine/plugin_migration_context.rb +33 -0
- data/lib/redmine_plugins_helper/patches/test_case_patch.rb +9 -0
- data/lib/redmine_plugins_helper/test_config.rb +26 -0
- data/lib/redmine_plugins_helper/version.rb +1 -1
- data/lib/tasks/redmine_plugins_helper.rake +18 -2
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c5acbf0a858ce536f4b65fd9c319523cedd80aadcd71b6ce68443942c9e7440
|
4
|
+
data.tar.gz: 55e96888d080f7cfbff7c57232ecd19837e4fd53e1ec7b15bc19277e9d92a869
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8658e8317504d5b42ff3b8f5800e1aa39869d15b5d57361c0e91b48fad7ce7397e0f7b43f2f58d0fdf73c89542cf9eb16225e77e3113c6939e114fea2fa374bb
|
7
|
+
data.tar.gz: 87be5244759daea494a385a9cc888d74c8dcf3192d5237713aadf94b7e135509e058b07728b19c7cc2b9008eeaf1d795468caf165b9e8e6dadb9d19237b50113
|
data/init.rb
CHANGED
@@ -13,6 +13,7 @@ end
|
|
13
13
|
|
14
14
|
Rails.configuration.to_prepare do
|
15
15
|
require_dependency 'redmine_plugins_helper/patches/redmine/plugin_patch'
|
16
|
+
require_dependency 'redmine_plugins_helper/patches/redmine/plugin_migration_context'
|
16
17
|
::Redmine::Plugin.registered_plugins.values.each(&:add_assets_paths)
|
17
18
|
::Redmine::Plugin.registered_plugins.values.each(&:load_initializers)
|
18
19
|
end
|
@@ -30,31 +30,18 @@ module RedminePluginsHelper
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def database_version?(version)
|
33
|
-
|
34
|
-
select exists(
|
35
|
-
select 1
|
36
|
-
from #{ActiveRecord::Migrator.schema_migrations_table_name}
|
37
|
-
where version=#{ActiveRecord::Base.sanitize(version)}
|
38
|
-
)
|
39
|
-
EOS
|
40
|
-
r.getvalue(0, 0) == 't'
|
33
|
+
::ActiveRecord::SchemaMigration.where(version: version).any?
|
41
34
|
end
|
42
35
|
|
43
36
|
def remove_plugin_version(source_version)
|
44
37
|
Rails.logger.info("Removing #{source_version}")
|
45
|
-
::ActiveRecord::
|
46
|
-
delete from #{ActiveRecord::Migrator.schema_migrations_table_name}
|
47
|
-
where version=#{ActiveRecord::Base.sanitize(source_version)}
|
48
|
-
EOS
|
38
|
+
::ActiveRecord::SchemaMigration.find_by(version: source_version).destroy!
|
49
39
|
end
|
50
40
|
|
51
41
|
def move_plugin_version(source_version, target_version)
|
52
42
|
Rails.logger.info("Moving #{source_version} to plugin \"#{target_version}\"")
|
53
|
-
::ActiveRecord::
|
54
|
-
update
|
55
|
-
set version=#{ActiveRecord::Base.sanitize(target_version)}
|
56
|
-
where version=#{ActiveRecord::Base.sanitize(source_version)}
|
57
|
-
EOS
|
43
|
+
::ActiveRecord::SchemaMigration.find_by(version: source_version)
|
44
|
+
.update!(version: target_version)
|
58
45
|
end
|
59
46
|
|
60
47
|
def local_version(timestamp)
|
@@ -1,19 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module RedminePluginsHelper
|
2
4
|
class Migrate
|
3
|
-
|
5
|
+
attr_reader :plugin_name, :migration_version
|
6
|
+
|
7
|
+
def initialize(plugin_name, migration_version)
|
8
|
+
@plugin_name = plugin_name
|
9
|
+
@migration_version = migration_version
|
4
10
|
run
|
5
11
|
end
|
6
12
|
|
7
13
|
private
|
8
14
|
|
9
15
|
def run
|
16
|
+
if plugin_name.present?
|
17
|
+
run_version
|
18
|
+
else
|
19
|
+
run_all
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def run_all
|
10
24
|
versions_sorted.each do |v|
|
11
25
|
migrate_plugin_version(v)
|
12
26
|
end
|
13
27
|
end
|
14
28
|
|
29
|
+
def run_version
|
30
|
+
::Redmine::Plugin.migrate(plugin_name, migration_version)
|
31
|
+
end
|
32
|
+
|
15
33
|
def migrate_plugin_version(v)
|
16
34
|
return if migrated?(v)
|
35
|
+
|
17
36
|
::Redmine::Plugin.registered_plugins[v[:plugin]].migrate(v[:timestamp])
|
18
37
|
end
|
19
38
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'redmine/plugin'
|
4
|
+
|
5
|
+
module RedminePluginsHelper
|
6
|
+
module Patches
|
7
|
+
module Redmine
|
8
|
+
module PluginMigrationContextPatch
|
9
|
+
extend ActiveSupport::Concern
|
10
|
+
|
11
|
+
def get_all_versions
|
12
|
+
plugin.present? ? plugin.migrations : super
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def plugin
|
18
|
+
@plugin ||= begin
|
19
|
+
::Redmine::Plugin.registered_plugins.values.find do |plugin|
|
20
|
+
::File.join(plugin.directory, 'db', 'migrate') == migrations_paths
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if ::Redmine::Plugin.const_defined?('MigrationContext')
|
30
|
+
::Redmine::Plugin::MigrationContext.prepend(
|
31
|
+
::RedminePluginsHelper::Patches::Redmine::PluginMigrationContextPatch
|
32
|
+
)
|
33
|
+
end
|
@@ -7,6 +7,9 @@ module RedminePluginsHelper
|
|
7
7
|
|
8
8
|
included do
|
9
9
|
extend ClassMethods
|
10
|
+
include InstanceMethods
|
11
|
+
setup { the_test_config.before_each }
|
12
|
+
teardown { the_test_config.after_each }
|
10
13
|
end
|
11
14
|
|
12
15
|
module ClassMethods
|
@@ -19,6 +22,12 @@ module RedminePluginsHelper
|
|
19
22
|
fixtures(*files)
|
20
23
|
end
|
21
24
|
end
|
25
|
+
|
26
|
+
module InstanceMethods
|
27
|
+
def the_test_config
|
28
|
+
@the_test_config ||= ::RedminePluginsHelper::TestConfig.new
|
29
|
+
end
|
30
|
+
end
|
22
31
|
end
|
23
32
|
end
|
24
33
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module RedminePluginsHelper
|
2
|
+
class TestConfig
|
3
|
+
def before_each
|
4
|
+
mailer_setup
|
5
|
+
end
|
6
|
+
|
7
|
+
def after_each
|
8
|
+
mailer_teadown
|
9
|
+
end
|
10
|
+
|
11
|
+
def mailer_setup
|
12
|
+
unless @mailer_perform_deliveries_changed
|
13
|
+
@mailer_perform_deliveries_changed = true
|
14
|
+
@mailer_perform_deliveries_was_enabled = ::ActionMailer::Base.perform_deliveries
|
15
|
+
end
|
16
|
+
::ActionMailer::Base.perform_deliveries = false
|
17
|
+
end
|
18
|
+
|
19
|
+
def mailer_teadown
|
20
|
+
return unless @mailer_perform_deliveries_changed
|
21
|
+
|
22
|
+
::ActionMailer::Base.perform_deliveries = @mailer_perform_deliveries_was_enabled
|
23
|
+
@mailer_perform_deliveries_changed = false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -17,8 +17,24 @@ namespace :redmine do
|
|
17
17
|
namespace :plugins do
|
18
18
|
desc 'Migrates installed plugins.'
|
19
19
|
task migrate: :environment do
|
20
|
-
|
21
|
-
|
20
|
+
name = ENV['NAME']
|
21
|
+
version = nil
|
22
|
+
version_string = ENV['VERSION']
|
23
|
+
if version_string
|
24
|
+
if version_string =~ /^\d+$/
|
25
|
+
version = version_string.to_i
|
26
|
+
abort 'The VERSION argument requires a plugin NAME.' if name.nil?
|
27
|
+
else
|
28
|
+
abort "Invalid VERSION #{version_string} given."
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
begin
|
33
|
+
RedminePluginsHelper::Migrate.new(name, version)
|
34
|
+
Rake::Task['db:schema:dump'].invoke
|
35
|
+
rescue Redmine::PluginNotFound
|
36
|
+
abort "Plugin #{name} was not found."
|
37
|
+
end
|
22
38
|
end
|
23
39
|
|
24
40
|
namespace :migrate do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine_plugins_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- 0.
|
7
|
+
- 0.7.0
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sass-rails
|
@@ -40,10 +40,12 @@ files:
|
|
40
40
|
- lib/redmine_plugins_helper/hooks/add_assets.rb
|
41
41
|
- lib/redmine_plugins_helper/migrate.rb
|
42
42
|
- lib/redmine_plugins_helper/migrations.rb
|
43
|
+
- lib/redmine_plugins_helper/patches/redmine/plugin_migration_context.rb
|
43
44
|
- lib/redmine_plugins_helper/patches/redmine/plugin_patch.rb
|
44
45
|
- lib/redmine_plugins_helper/patches/test_case_patch.rb
|
45
46
|
- lib/redmine_plugins_helper/settings.rb
|
46
47
|
- lib/redmine_plugins_helper/status_migrations.rb
|
48
|
+
- lib/redmine_plugins_helper/test_config.rb
|
47
49
|
- lib/redmine_plugins_helper/version.rb
|
48
50
|
- lib/tasks/redmine_plugins_helper.rake
|
49
51
|
homepage:
|
@@ -64,8 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
64
66
|
- !ruby/object:Gem::Version
|
65
67
|
version: '0'
|
66
68
|
requirements: []
|
67
|
-
|
68
|
-
rubygems_version: 2.7.7
|
69
|
+
rubygems_version: 3.0.8
|
69
70
|
signing_key:
|
70
71
|
specification_version: 4
|
71
72
|
summary: Helper for Redmine plugins
|