redmine-installer 2.4.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,202 +0,0 @@
1
- require 'spec_helper'
2
-
3
- RSpec.describe RedmineInstaller::Upgrade, :install_first, command: 'upgrade' do
4
-
5
- it 'bad redmine root', args: [] do
6
- FileUtils.remove_entry(File.join(@redmine_root, 'app'))
7
- write(@redmine_root)
8
-
9
- expected_output("Redmine #{@redmine_root} is not valid.")
10
- end
11
-
12
- it 'upgrading with full backup' do
13
- # This should not be a problem because file still could be deleted
14
- unwritable_file = File.join(@redmine_root, 'unwritable_file')
15
- FileUtils.touch(unwritable_file)
16
- FileUtils.chmod(0400, unwritable_file)
17
-
18
- test_test_dir = File.join(@redmine_root, 'test_test')
19
- test_test_file = File.join(test_test_dir, 'test.txt')
20
- FileUtils.mkdir_p(test_test_dir)
21
- FileUtils.touch(test_test_file)
22
-
23
- expect(File.exist?(test_test_file)).to be_truthy
24
-
25
- expected_output('Path to redmine root:')
26
- write(@redmine_root)
27
-
28
- expected_output('Path to package:')
29
- write(package_v503)
30
-
31
- expected_output('Extracting redmine package')
32
- expected_output('Data backup')
33
-
34
- expected_output('‣ Full (redmine root and database)')
35
- select_choice
36
-
37
- expected_output('Where to save backup:')
38
- write(@backup_dir)
39
-
40
- expected_output('Files backuping')
41
- expected_output('Files backed up')
42
- expected_output('Database backuping')
43
- expected_output('Database backed up')
44
-
45
- expected_successful_upgrade
46
-
47
- expected_redmine_version('5.0.3')
48
-
49
- expect(File.exist?(test_test_file)).to be_falsey
50
-
51
- last_backup = Dir.glob(File.join(@backup_dir, '*')).sort.last
52
- backuped = Dir.glob(File.join(last_backup, '*'))
53
-
54
- expect(backuped.map{|f| File.zero?(f) }).to all(be_falsey)
55
- end
56
-
57
- it 'upgrade with no backup and files keeping', args: ['--keep', 'test_test'] do
58
- test_test_dir = File.join(@redmine_root, 'test_test')
59
- test_test_file = File.join(test_test_dir, 'test.txt')
60
- FileUtils.mkdir_p(test_test_dir)
61
- FileUtils.touch(test_test_file)
62
-
63
- expect(File.exist?(test_test_file)).to be_truthy
64
-
65
- wait_for_stdin_buffer
66
- write(@redmine_root)
67
-
68
- wait_for_stdin_buffer
69
- write(package_v503)
70
-
71
- wait_for_stdin_buffer
72
-
73
- go_down
74
- go_down
75
- expected_output('‣ Nothing')
76
- select_choice
77
-
78
- expected_output('Are you sure you dont want backup?')
79
- write('y')
80
-
81
- expected_successful_upgrade
82
-
83
- expected_redmine_version('5.0.3')
84
-
85
- expect(File.exist?(test_test_file)).to be_truthy
86
- end
87
-
88
- it 'copy files with symlink ', args: ['--copy-files-with-symlink'] do
89
- files_dir = File.join(@redmine_root, 'files')
90
- files = (0..10).map {|i| File.join(files_dir, "file_#{i}.txt") }
91
- FileUtils.touch(files)
92
-
93
- wait_for_stdin_buffer
94
- write(@redmine_root)
95
-
96
- wait_for_stdin_buffer
97
- write(package_v503)
98
-
99
- wait_for_stdin_buffer
100
-
101
- go_down
102
- go_down
103
- expected_output('‣ Nothing')
104
- select_choice
105
-
106
- expected_output('Are you sure you dont want backup?')
107
- write('y')
108
-
109
- expected_successful_upgrade
110
-
111
- expected_redmine_version('5.0.3')
112
-
113
- # Not bullet-prof but at least check if files are still there
114
- expect(Dir.glob(File.join(files_dir, '*.txt')).sort).to eq(files.sort)
115
- end
116
-
117
- it 'upgrade rys and modify bundle/index' do
118
- skip 'old version not supporting Ruby >3'
119
- wait_for_stdin_buffer
120
- write(@redmine_root)
121
-
122
- wait_for_stdin_buffer
123
- write(package_v345_rys)
124
-
125
- wait_for_stdin_buffer
126
-
127
- go_down
128
- go_down
129
- expected_output('‣ Nothing')
130
- select_choice
131
-
132
- expected_output('Are you sure you dont want backup?')
133
- write('y')
134
-
135
- expected_successful_upgrade
136
-
137
- expected_redmine_version('3.4.5')
138
-
139
- index = YAML.load_file(File.join(@redmine_root, '.bundle/plugin/index'))
140
-
141
- load_paths = index['load_paths']['rys-bundler']
142
- expect(load_paths.size).to eq(1)
143
-
144
- load_path = load_paths.first
145
- expect(load_path).to start_with(@redmine_root)
146
-
147
- plugin_paths = index['plugin_paths']['rys-bundler']
148
- expect(plugin_paths).to start_with(@redmine_root)
149
- end
150
-
151
- it 'upgrading something else' do
152
- wait_for_stdin_buffer
153
- write(@redmine_root)
154
-
155
- wait_for_stdin_buffer
156
- write(package_someting_else)
157
-
158
- wait_for_stdin_buffer
159
- expected_output('is not valid')
160
- end
161
-
162
- context 'missing plugins' do
163
-
164
- def upgrade_it(answer, result)
165
- # Create some plugins
166
- plugin_name = 'new_plugin'
167
- plugin_dir = File.join(@redmine_root, 'plugins', plugin_name)
168
- FileUtils.mkdir_p(plugin_dir)
169
- FileUtils.touch(File.join(plugin_dir, 'init.rb'))
170
-
171
- wait_for_stdin_buffer
172
- write(@redmine_root)
173
-
174
- wait_for_stdin_buffer
175
- write(package_v503)
176
-
177
- go_down
178
- go_down
179
- expected_output('‣ Nothing')
180
- select_choice
181
- write('y')
182
-
183
- expected_output("Your application contains plugins that are not present in the package (#{plugin_name}). Would you like to copy them?")
184
-
185
- write(answer)
186
- expected_successful_upgrade
187
- expected_redmine_version('5.0.3')
188
-
189
- expect(Dir.exist?(plugin_dir)).to be(result)
190
- end
191
-
192
- it 'yes' do
193
- upgrade_it('y', true)
194
- end
195
-
196
- it 'no' do
197
- upgrade_it('n', false)
198
- end
199
-
200
- end
201
-
202
- end
@@ -1,31 +0,0 @@
1
- module PackagesHelper
2
-
3
- def packages_dir
4
- File.expand_path(File.join(__dir__, 'packages'))
5
- end
6
-
7
- def package_v345
8
- File.join(packages_dir, 'redmine-3.4.5.zip')
9
- end
10
-
11
- def package_v345_rys
12
- File.join(packages_dir, 'redmine-3.4.5-rys.zip')
13
- end
14
-
15
- def package_v503
16
- File.join(packages_dir, 'redmine-5.0.3.zip')
17
- end
18
-
19
- def package_someting_else
20
- File.join(packages_dir, 'something-else.zip')
21
- end
22
-
23
- def package_high_installer_version
24
- File.join(packages_dir, 'high-installer-version.zip')
25
- end
26
-
27
- def package_default_db
28
- File.join(packages_dir, 'redmine-3.4.5-default-db.zip')
29
- end
30
-
31
- end
@@ -1,13 +0,0 @@
1
- RSpec.shared_context 'run installer' do
2
-
3
- around(:each) do |example|
4
- @process = InstallerProcess.new(example.metadata[:command], example.metadata[:args])
5
- @process.run do
6
- Dir.mktmpdir('redmine_root') do |dir|
7
- @redmine_root = dir
8
- example.run
9
- end
10
- end
11
- end
12
-
13
- end
data/spec/spec_helper.rb DELETED
@@ -1,51 +0,0 @@
1
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../gems.rb', __dir__)
2
-
3
- require 'bundler'
4
- Bundler.require(:default, :development)
5
-
6
- lib = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
7
- $LOAD_PATH.unshift(lib) if !$LOAD_PATH.include?(lib)
8
-
9
- require 'redmine-installer'
10
-
11
- require 'custom_matchers'
12
- require 'shared_contexts'
13
-
14
- require 'installer_process'
15
- require 'installer_helper'
16
- require 'packages_helper'
17
-
18
- RSpec.configure do |config|
19
- config.default_formatter = 'doc'
20
- config.color = true
21
- config.tty = true
22
-
23
- config.disable_monkey_patching!
24
-
25
- config.include_context 'run installer', :command
26
-
27
- config.include PackagesHelper
28
- config.extend PackagesHelper
29
- config.include InstallerHelper
30
-
31
- config.before(:all, :install_first) do
32
- @redmine_root = @origin_redmine = Dir.mktmpdir('redmine_root')
33
- @process = InstallerProcess.new('install', package_v503, @origin_redmine)
34
- @process.run do
35
- expected_successful_configuration
36
- expected_successful_installation
37
-
38
- expected_redmine_version('5.0.3')
39
- end
40
- @backup_dir = Dir.mktmpdir('backup_dir')
41
- end
42
-
43
- config.after(:all, :install_first) do
44
- FileUtils.remove_entry(@origin_redmine)
45
- FileUtils.remove_entry(@backup_dir)
46
- end
47
-
48
- config.before(:each, :install_first) do
49
- FileUtils.cp_r(File.join(@origin_redmine, '.'), @redmine_root)
50
- end
51
- end