vagrant-hypconfigmgmt 0.0.1 → 0.0.2
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/.gitignore +3 -0
- data/.rspec +1 -0
- data/Makefile +3 -1
- data/README.md +2 -3
- data/lib/vagrant-hypconfigmgmt/.command.rb.swo +0 -0
- data/lib/vagrant-hypconfigmgmt/command.rb +224 -183
- data/lib/vagrant-hypconfigmgmt/version.rb +1 -1
- data/pkg/vagrant-hypconfigmgmt-0.0.2.gem +0 -0
- data/spec/spec_helper.rb +15 -0
- data/spec/unit/command/call_spec.rb +93 -0
- data/spec/unit/command/configure_magento_spec.rb +35 -0
- data/spec/unit/command/configure_php_spec.rb +35 -0
- data/spec/unit/command/configure_synced_folders_spec.rb +35 -0
- data/spec/unit/command/configure_vagrant_spec.rb +33 -0
- data/spec/unit/command/configure_varnish_spec.rb +35 -0
- data/spec/unit/command/ensure_attribute_configured_spec.rb +100 -0
- data/spec/unit/command/ensure_magento_mounts_configured_spec.rb +268 -0
- data/spec/unit/command/ensure_required_plugins_are_installed_spec.rb +78 -0
- data/spec/unit/command/ensure_setting_exists_spec.rb +50 -0
- data/spec/unit/command/ensure_settings_are_configured_spec.rb +71 -0
- data/spec/unit/command/ensure_vagrant_box_type_configured_spec.rb +78 -0
- data/spec/unit/command/get_magento_version_spec.rb +57 -0
- data/spec/unit/command/get_options_string_spec.rb +48 -0
- data/spec/unit/command/get_php_version_spec.rb +56 -0
- data/spec/unit/command/get_setting_spec.rb +55 -0
- data/spec/unit/command/get_varnish_state_spec.rb +56 -0
- data/spec/unit/command/inform_if_gatling_not_installed_spec.rb +67 -0
- data/spec/unit/command/retrieve_settings_spec.rb +39 -0
- data/spec/unit/command/update_settings_spec.rb +30 -0
- data/spec/unit/command/use_default_input_if_input_empty_spec.rb +30 -0
- data/spec/unit/command/validate_magento2_root_spec.rb +101 -0
- data/vagrant-hypconfigmgmt.gemspec +3 -0
- metadata +70 -3
- data/pkg/vagrant-hypconfigmgmt-0.0.1.gem +0 -0
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
require 'coveralls'
|
3
|
+
|
4
|
+
SimpleCov.formatter = Coveralls::SimpleCov::Formatter
|
5
|
+
SimpleCov.start do
|
6
|
+
add_group "Command", "lib/vagrant-hypconfigmgmt/command.rb"
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
def get_random_string()
|
11
|
+
# random a-z0-9 string
|
12
|
+
# http://stackoverflow.com/a/3572953
|
13
|
+
length = 10
|
14
|
+
return rand(36 ** length).to_s(36)
|
15
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { lambda { |env| } }
|
10
|
+
let(:env) { { :machine => machine, :ui => ui } }
|
11
|
+
|
12
|
+
# pretend env contains the Vagrant ui element
|
13
|
+
let(:ui) do
|
14
|
+
double('ui').tap do |ui|
|
15
|
+
allow(ui).to receive(:info) { nil }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# pretend env[:machine].config.hypconfigmgmt.enabled is false
|
20
|
+
let(:machine) do
|
21
|
+
double('machine').tap do |machine|
|
22
|
+
allow(machine).to receive(:config) { config }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
let(:config) do
|
26
|
+
double('config').tap do |config|
|
27
|
+
allow(config).to receive(:hypconfigmgmt) { hypconfigmgmt }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
let(:hypconfigmgmt) do
|
31
|
+
double('hypconfigmgmt').tap do |config|
|
32
|
+
allow(config).to receive(:enabled) { enabled }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
let(:enabled) { false }
|
36
|
+
|
37
|
+
|
38
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
39
|
+
after do
|
40
|
+
subject.call(env)
|
41
|
+
end
|
42
|
+
|
43
|
+
# instantiate class of which a method is to be tested
|
44
|
+
subject { described_class.new(app, env) }
|
45
|
+
|
46
|
+
# the method that we are going to test
|
47
|
+
describe "#call" do
|
48
|
+
|
49
|
+
context "when config hypconfigmgmt disabled (default)" do
|
50
|
+
it "does nothing but call the super" do
|
51
|
+
# check ensure_settings_configured is not called when plugin is disabled
|
52
|
+
expect(subject).to receive(:ensure_settings_configured).never
|
53
|
+
# check ensure_required_plugins_are_installed is not called when plugin is disabled
|
54
|
+
expect(subject).to receive(:ensure_required_plugins_are_installed).never
|
55
|
+
# check super is still called when plugin is disabled
|
56
|
+
expect(app).to receive(:call).with(env)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when config hypconfigmgmt enabled and no settings changed" do
|
61
|
+
# pretend env[:machine].config.hypconfigmgmt.enabled is true
|
62
|
+
let(:enabled) { true }
|
63
|
+
|
64
|
+
it "ensures settings configured" do
|
65
|
+
# check ensure_settings_configured is called when plugin is enabled
|
66
|
+
expect(subject).to receive(:ensure_settings_configured).with(env).and_return(false) # no changed settings
|
67
|
+
# check ensure_required_plugins_are_installed is called when plugin is enabled
|
68
|
+
expect(subject).to receive(:ensure_required_plugins_are_installed).with(env).and_return(nil)
|
69
|
+
# check if we do not print the "please run vagrant up again" notice
|
70
|
+
expect(ui).to receive(:info).never.with("Your hypernode-vagrant is now configured. Please run \"vagrant up\" again.")
|
71
|
+
# check super is also called when plugin is enabled
|
72
|
+
expect(app).to receive(:call).with(env)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context "when config hypconfigmgmt enabled and settings changed" do
|
77
|
+
# pretend env[:machine].config.hypconfigmgmt.enabled is true
|
78
|
+
let(:enabled) { true }
|
79
|
+
|
80
|
+
it "ensures settings configured" do
|
81
|
+
# check ensure_settings_configured is called when plugin is enabled
|
82
|
+
expect(subject).to receive(:ensure_settings_configured).with(env).and_return(true) # changed settings
|
83
|
+
# check ensure_required_plugins_are_installed is called when plugin is enabled
|
84
|
+
expect(subject).to receive(:ensure_required_plugins_are_installed).with(env).and_return(nil)
|
85
|
+
# check if we print the "please run vagrant up again" notice
|
86
|
+
expect(ui).to receive(:info).once.with("Your hypernode-vagrant is now configured. Please run \"vagrant up\" again.")
|
87
|
+
# interrupt the super call to make the user run 'vagrant up' again so changed settings take effect
|
88
|
+
expect(app).to receive(:call).never
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { }
|
11
|
+
|
12
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
13
|
+
after do
|
14
|
+
subject.configure_magento(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
# instantiate class of which a method is to be tested
|
18
|
+
subject { described_class.new(app, env) }
|
19
|
+
|
20
|
+
# the method that we are going to test
|
21
|
+
describe "#configure_magento" do
|
22
|
+
|
23
|
+
context "when env is passed" do
|
24
|
+
it "configures the settings for magento" do
|
25
|
+
# check the magento settings is ensured to exist in the configuration file
|
26
|
+
expect(subject).to receive(:ensure_setting_exists).with('magento')
|
27
|
+
# check the magento version is ensured to be configured
|
28
|
+
expect(subject).to receive(:ensure_attribute_configured).with(
|
29
|
+
env, 'magento', 'version', AVAILABLE_MAGENTO_VERSIONS
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { }
|
11
|
+
|
12
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
13
|
+
after do
|
14
|
+
subject.configure_php(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
# instantiate class of which a method is to be tested
|
18
|
+
subject { described_class.new(app, env) }
|
19
|
+
|
20
|
+
# the method that we are going to test
|
21
|
+
describe "#configure_php" do
|
22
|
+
|
23
|
+
context "when env is passed" do
|
24
|
+
it "configures the settings for php" do
|
25
|
+
# check the php settings is ensured to exist in the configuration file
|
26
|
+
expect(subject).to receive(:ensure_setting_exists).with('php')
|
27
|
+
# check the php version is ensured to be configured
|
28
|
+
expect(subject).to receive(:ensure_attribute_configured).with(
|
29
|
+
env, 'php', 'version', AVAILABLE_PHP_VERSIONS
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { }
|
11
|
+
|
12
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
13
|
+
after do
|
14
|
+
subject.configure_synced_folders(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
# instantiate class of which a method is to be tested
|
18
|
+
subject { described_class.new(app, env) }
|
19
|
+
|
20
|
+
# the method that we are going to test
|
21
|
+
describe "#configure_synced_folders" do
|
22
|
+
|
23
|
+
context "when env is passed" do
|
24
|
+
it "configures all the settings for the synced folders" do
|
25
|
+
# check the magento mounts are configured
|
26
|
+
expect(subject).to receive(:ensure_magento_mounts_configured).with(env)
|
27
|
+
# check the directory to be mounted is validated against the magento version (pub symlink vs public)
|
28
|
+
expect(subject).to receive(:validate_magento2_root).with(env)
|
29
|
+
# check a message will be printed if gatling is not installed while the rsync fs type is specified
|
30
|
+
expect(subject).to receive(:inform_if_gatling_not_installed).with(env)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { }
|
11
|
+
|
12
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
13
|
+
after do
|
14
|
+
subject.configure_vagrant(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
# instantiate class of which a method is to be tested
|
18
|
+
subject { described_class.new(app, env) }
|
19
|
+
|
20
|
+
# the method that we are going to test
|
21
|
+
describe "#configure_vagrant" do
|
22
|
+
|
23
|
+
context "when env is passed" do
|
24
|
+
it "configures the settings for vagrant" do
|
25
|
+
# check the vagrant settings is ensured to exist in the configuration file
|
26
|
+
expect(subject).to receive(:ensure_setting_exists).with('vagrant')
|
27
|
+
# check the vagrant box type is set to the right box for the pPHP version
|
28
|
+
expect(subject).to receive(:ensure_vagrant_box_type_configured).with(env)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
describe VagrantHypconfigmgmt::Command do
|
8
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
9
|
+
let(:app) { }
|
10
|
+
let(:env) { }
|
11
|
+
|
12
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
13
|
+
after do
|
14
|
+
subject.configure_varnish(env)
|
15
|
+
end
|
16
|
+
|
17
|
+
# instantiate class of which a method is to be tested
|
18
|
+
subject { described_class.new(app, env) }
|
19
|
+
|
20
|
+
# the method that we are going to test
|
21
|
+
describe "#configure_varnish" do
|
22
|
+
|
23
|
+
context "when env is passed" do
|
24
|
+
it "configures the settings for varnish" do
|
25
|
+
# check the varnish settings is ensured to exist in the configuration file
|
26
|
+
expect(subject).to receive(:ensure_setting_exists).with('varnish')
|
27
|
+
# check the varnish state is ensured to be configured
|
28
|
+
expect(subject).to receive(:ensure_attribute_configured).with(
|
29
|
+
env, 'varnish', 'state', AVAILABLE_VARNISH_STATES
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
|
8
|
+
describe VagrantHypconfigmgmt::Command do
|
9
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
10
|
+
let(:app) { }
|
11
|
+
let(:env) { { :ui => ui } }
|
12
|
+
let(:setting_name) { get_random_string() }
|
13
|
+
let(:attribute_name) { get_random_string() }
|
14
|
+
let(:available) { [ ] }
|
15
|
+
|
16
|
+
# pretend env contains the Vagrant ui element
|
17
|
+
let(:ui) do
|
18
|
+
double('ui').tap do |ui|
|
19
|
+
allow(ui).to receive(:error) { nil }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
# instantiate class of which a method is to be tested
|
24
|
+
subject { described_class.new(app, env) }
|
25
|
+
|
26
|
+
# the method that we are going to test
|
27
|
+
describe "#ensure_attribute_configured" do
|
28
|
+
|
29
|
+
context "when the attribute is defined for and is valid" do
|
30
|
+
let(:retrieved_settings) { { setting_name => { attribute_name => 'value2'} } }
|
31
|
+
it "does not print an error and does not update the setting" do
|
32
|
+
# pretend we retrieve the settings and they contain a valid value
|
33
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
34
|
+
# check if an error message is not printed
|
35
|
+
expect(ui).to receive(:error).never
|
36
|
+
# check if the settings are not changed because they are already correct
|
37
|
+
expect(subject).to receive(:update_settings).once.with(retrieved_settings)
|
38
|
+
|
39
|
+
# call the method with a code block (anonymous function) that is not executed because there
|
40
|
+
# is already a correct value in the config: 'value2'
|
41
|
+
subject.ensure_attribute_configured(
|
42
|
+
env, setting_name, attribute_name, ['value1', 'value2']
|
43
|
+
) { | env | 'value1' }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
context "when the attribute is defined for the name but not in allowed value list" do
|
48
|
+
let(:retrieved_settings) { { setting_name => { attribute_name => 'invalid_value'} } }
|
49
|
+
let(:expected_settings) { { setting_name => { attribute_name => 'value1' } } }
|
50
|
+
it "prints an error about the invalid value, defines the attribute and writes it back to disk" do
|
51
|
+
# pretend we retrieve the settings and they contain an invalid value
|
52
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
53
|
+
# check if an error message is printed
|
54
|
+
expect(ui).to receive(:error).once.with(/.*#{setting_name}.*#{attribute_name}.*/)
|
55
|
+
# check if the settings are updated with the yielded value passed as a block into the function
|
56
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
57
|
+
|
58
|
+
subject.ensure_attribute_configured(
|
59
|
+
env, setting_name, attribute_name, ['value1', 'value2']
|
60
|
+
) { | env | 'value1' }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "when the attribute is defined for the name but the allowed list has the value as an int" do
|
65
|
+
let(:retrieved_settings) { { setting_name => { attribute_name => '1'} } }
|
66
|
+
it "does not update the setting because it is already valid" do
|
67
|
+
# pretend we retrieve the settings and they contain a string value
|
68
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
69
|
+
# check if no error message is printed
|
70
|
+
expect(ui).to receive(:error).never
|
71
|
+
# check if the settings are not updated
|
72
|
+
expect(subject).to receive(:update_settings).once.with(retrieved_settings)
|
73
|
+
|
74
|
+
subject.ensure_attribute_configured(
|
75
|
+
env, setting_name, attribute_name, [1, 2]
|
76
|
+
) { | env | 2 }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "when the attribute is not defined for the name" do
|
81
|
+
let(:retrieved_settings) { { setting_name => { } } }
|
82
|
+
let(:expected_settings) { { setting_name => { attribute_name => 'value1' } } }
|
83
|
+
it "defines the attribute and writes it back to disk" do
|
84
|
+
# pretend we retrieve the settings and they do not contain the attribute already
|
85
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
86
|
+
# check if no error message is printed
|
87
|
+
expect(ui).to receive(:error).never
|
88
|
+
# check if the settings are updated with the yielded value passed as a block into the function
|
89
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
90
|
+
|
91
|
+
# a code block like "{ 'value1' }" is an anonymous function without a paramters
|
92
|
+
# like: "{ | | 'value1' }", (or "lambda: 'value1'" in python)
|
93
|
+
subject.ensure_attribute_configured(
|
94
|
+
env, setting_name, attribute_name, ['value1', 'value2']
|
95
|
+
) { 'value1' }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
@@ -0,0 +1,268 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# vim: set fileencoding=utf-8
|
3
|
+
|
4
|
+
require 'spec_helper'
|
5
|
+
require "vagrant-hypconfigmgmt/command"
|
6
|
+
|
7
|
+
|
8
|
+
describe VagrantHypconfigmgmt::Command do
|
9
|
+
# create a fake app and env to pass into the VagrantHypconfigmgmt::Command constructor
|
10
|
+
let(:app) { }
|
11
|
+
let(:env) { { :ui => ui } }
|
12
|
+
let(:setting_name) { get_random_string() }
|
13
|
+
|
14
|
+
# pretend env contains the Vagrant ui element
|
15
|
+
let(:ui) do
|
16
|
+
double('ui').tap do |ui|
|
17
|
+
allow(ui).to receive(:info) { nil }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
22
|
+
after do
|
23
|
+
subject.ensure_magento_mounts_configured(env)
|
24
|
+
end
|
25
|
+
|
26
|
+
# instantiate class of which a method is to be tested
|
27
|
+
subject { described_class.new(app, env) }
|
28
|
+
|
29
|
+
# the method that we are going to test
|
30
|
+
describe "#ensure_magento_mounts_configured" do
|
31
|
+
|
32
|
+
context "when magento version is 1 and there is a magento 2 mount" do
|
33
|
+
let(:retrieved_settings) { {
|
34
|
+
"magento" => { "version" => 1 },
|
35
|
+
"fs" => {
|
36
|
+
"folders" => {
|
37
|
+
"magento2" => { "host" => "data/web/magento2", "guest" => "/data/web/magento2" }
|
38
|
+
}
|
39
|
+
}
|
40
|
+
} }
|
41
|
+
let(:expected_settings) { {
|
42
|
+
"magento" => { "version" => 1 },
|
43
|
+
"fs" => {
|
44
|
+
"folders" => { },
|
45
|
+
"disabled_folders" => {
|
46
|
+
"magento2" => { "host" => "data/web/magento2", "guest" => "/data/web/magento2" }
|
47
|
+
}
|
48
|
+
}
|
49
|
+
} }
|
50
|
+
it "disables the magento 2 mount" do
|
51
|
+
# pretend we retrieve the settings and they specify magent->version 1 and a magento 2 mount
|
52
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
53
|
+
# check if we notify the user that the magento 2 mount is disabled
|
54
|
+
expect(ui).to receive(:info).once.with(/Disabling fs->folders->magento2.*/)
|
55
|
+
# check if the magento 2 mount is disabled
|
56
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when magento version is 2 and there is a magento 1 mount" do
|
61
|
+
let(:retrieved_settings) { {
|
62
|
+
"magento" => { "version" => 2 },
|
63
|
+
"fs" => {
|
64
|
+
"folders" => {
|
65
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
66
|
+
}
|
67
|
+
}
|
68
|
+
} }
|
69
|
+
let(:expected_settings) { {
|
70
|
+
"magento" => { "version" => 2 },
|
71
|
+
"fs" => {
|
72
|
+
"folders" => { },
|
73
|
+
"disabled_folders" => {
|
74
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
75
|
+
}
|
76
|
+
}
|
77
|
+
} }
|
78
|
+
it "disables the magento 1 mount" do
|
79
|
+
# pretend we retrieve the settings and they specify magent->version 2 and a magento 1 mount
|
80
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
81
|
+
# check if we notify the user that the magento 1 mount is disabled
|
82
|
+
expect(ui).to receive(:info).once.with(/Disabling fs->folders->magento1.*/)
|
83
|
+
# check if the magento 1 mount is disabled
|
84
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
context "when magento version is 1 and there are mounts for both magento 1 and 2" do
|
89
|
+
let(:retrieved_settings) { {
|
90
|
+
"magento" => { "version" => 1 },
|
91
|
+
"fs" => {
|
92
|
+
"folders" => {
|
93
|
+
"magento2" => { "host" => "data/web/magento2", "guest" => "/data/web/magento2" },
|
94
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
95
|
+
}
|
96
|
+
}
|
97
|
+
} }
|
98
|
+
let(:expected_settings) { {
|
99
|
+
"magento" => { "version" => 1 },
|
100
|
+
"fs" => {
|
101
|
+
"folders" => {
|
102
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
103
|
+
},
|
104
|
+
"disabled_folders" => {
|
105
|
+
"magento2" => { "host" => "data/web/magento2", "guest" => "/data/web/magento2" }
|
106
|
+
}
|
107
|
+
}
|
108
|
+
} }
|
109
|
+
it "disables the magento 2 mount but keeps the magento 1 mount enabled" do
|
110
|
+
# pretend we retrieve the settings and they specify magent->version 1 and mounts for both magento 1 and 2
|
111
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
112
|
+
# check if we notify the user that the magento 2 mount is disabled
|
113
|
+
expect(ui).to receive(:info).once.with(/Disabling fs->folders->magento2.*/)
|
114
|
+
# check if the magento 2 mount is disabled but the magento 1 mount is still enabled
|
115
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "when magento version is 2 and there are mounts for both magento 1 and 2" do
|
120
|
+
let(:retrieved_settings) { {
|
121
|
+
"magento" => { "version" => 2 },
|
122
|
+
"fs" => {
|
123
|
+
"folders" => {
|
124
|
+
"magento2" => { "host" => "data/web/magento2", "guest" => "/data/web/magento2" },
|
125
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
126
|
+
}
|
127
|
+
}
|
128
|
+
} }
|
129
|
+
let(:expected_settings) { {
|
130
|
+
"magento" => { "version" => 2 },
|
131
|
+
"fs" => {
|
132
|
+
"folders" => {
|
133
|
+
"magento2" => { "host" => "data/web/magento2", "guest" => "/data/web/magento2" }
|
134
|
+
},
|
135
|
+
"disabled_folders" => {
|
136
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
137
|
+
}
|
138
|
+
}
|
139
|
+
} }
|
140
|
+
it "disables the magento 1 mount but keeps the magento 2 mount enabled" do
|
141
|
+
# pretend we retrieve the settings and they specify magent->version 2 and mounts for both magento 1 and 2
|
142
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
143
|
+
# check if we notify the user that the magento 1 mount is disabled
|
144
|
+
expect(ui).to receive(:info).once.with(/Disabling fs->folders->magento1.*/)
|
145
|
+
# check if the magento 1 mount is disabled but the magento 2 mount is still enabled
|
146
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
context "when magento version is whatever and there are no magento1 or magento2 mounts" do
|
151
|
+
let(:retrieved_settings) { {
|
152
|
+
"magento" => { "version" => 1234 },
|
153
|
+
"fs" => {
|
154
|
+
"nginx" => { "host" => "data/web/nginx", "guest" => "/data/web/nginx" }
|
155
|
+
}
|
156
|
+
} }
|
157
|
+
it "does not change the settings" do
|
158
|
+
# pretend we retrieve the settings and they specify a random magent->version and no mounts we should automatically enable/disable
|
159
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
160
|
+
# check if we don't notify the user
|
161
|
+
expect(ui).to receive(:info).never.with(/Disabling.*/)
|
162
|
+
expect(ui).to receive(:info).never.with(/Re-enabling.*/)
|
163
|
+
# check if no settings were changed
|
164
|
+
expect(subject).to receive(:update_settings).once.with(retrieved_settings)
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
context "when magento version is 2 and there is a disabled magento 2 mount" do
|
169
|
+
let(:retrieved_settings) { {
|
170
|
+
"magento" => { "version" => 2 },
|
171
|
+
"fs" => {
|
172
|
+
"folders" => {
|
173
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
174
|
+
},
|
175
|
+
"disabled_folders" => {
|
176
|
+
"magento2" => { "host" => "data/web/magento2", "guest" => "/data/web/magento2" },
|
177
|
+
}
|
178
|
+
}
|
179
|
+
} }
|
180
|
+
let(:expected_settings) { {
|
181
|
+
"magento" => { "version" => 2 },
|
182
|
+
"fs" => {
|
183
|
+
"folders" => {
|
184
|
+
"magento2" => { "host" => "data/web/magento2", "guest" => "/data/web/magento2" },
|
185
|
+
},
|
186
|
+
"disabled_folders" => {
|
187
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
188
|
+
}
|
189
|
+
}
|
190
|
+
} }
|
191
|
+
it "disables the magento 1 mount and re-enabled the magento 2 mount" do
|
192
|
+
# pretend we retrieve the settings and they specify magent->version 2 and mounts for both magento 1 and 2
|
193
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
194
|
+
# check if we notify the user that the magento 1 mount is disabled
|
195
|
+
expect(ui).to receive(:info).once.with(/Disabling fs->folders->magento1.*/)
|
196
|
+
# check if we notify the user that the magento 2 mount is re-enabled
|
197
|
+
expect(ui).to receive(:info).once.with(/Re-enabling fs->disabled_folders->magento2.*/)
|
198
|
+
# check if the magento 1 mount is disabled and the magento 2 mount is re-enabled
|
199
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
context "when magento version is 1 and there is a disabled magento 1 mount" do
|
204
|
+
let(:retrieved_settings) { {
|
205
|
+
"magento" => { "version" => 1 },
|
206
|
+
"fs" => {
|
207
|
+
"folders" => {
|
208
|
+
"magento2" => { "host" => "data/web/magento2", "guest" => "/data/web/magento2" },
|
209
|
+
},
|
210
|
+
"disabled_folders" => {
|
211
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
212
|
+
}
|
213
|
+
}
|
214
|
+
} }
|
215
|
+
let(:expected_settings) { {
|
216
|
+
"magento" => { "version" => 1 },
|
217
|
+
"fs" => {
|
218
|
+
"folders" => {
|
219
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
220
|
+
},
|
221
|
+
"disabled_folders" => {
|
222
|
+
"magento2" => { "host" => "data/web/magento2", "guest" => "/data/web/magento2" },
|
223
|
+
}
|
224
|
+
}
|
225
|
+
} }
|
226
|
+
it "disables the magento 2 mount and re-enabled the magento 1 mount" do
|
227
|
+
# pretend we retrieve the settings and they specify magent->version 1 and mounts for both magento 1 and 2
|
228
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
229
|
+
# check if we notify the user that the magento 2 mount is disabled
|
230
|
+
expect(ui).to receive(:info).once.with(/Disabling fs->folders->magento2.*/)
|
231
|
+
# check if we notify the user that the magento 1 mount is re-enabled
|
232
|
+
expect(ui).to receive(:info).once.with(/Re-enabling fs->disabled_folders->magento1.*/)
|
233
|
+
# check if the magento 2 mount is disabled and the magento 1 mount is re-enabled
|
234
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
context "when no disabled folders settings has to be kept" do
|
239
|
+
let(:retrieved_settings) { {
|
240
|
+
"magento" => { "version" => 1 },
|
241
|
+
"fs" => {
|
242
|
+
"folders" => { },
|
243
|
+
"disabled_folders" => {
|
244
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
245
|
+
}
|
246
|
+
}
|
247
|
+
} }
|
248
|
+
let(:expected_settings) { {
|
249
|
+
"magento" => { "version" => 1 },
|
250
|
+
"fs" => {
|
251
|
+
"folders" => {
|
252
|
+
"magento1" => { "host" => "data/web/public", "guest" => "/data/web/public" }
|
253
|
+
}
|
254
|
+
}
|
255
|
+
} }
|
256
|
+
it "re-enables the magento 1 mount and removes the empty disabled_folders hash" do
|
257
|
+
# pretend we retrieve the settings and they specify magent->version 1 and mounts for magento 1
|
258
|
+
expect(subject).to receive(:retrieve_settings).once.with(no_args).and_return(retrieved_settings)
|
259
|
+
# check if we notify the user that the magento 1 mount is re-enabled
|
260
|
+
expect(ui).to receive(:info).once.with(/Re-enabling fs->disabled_folders->magento1.*/)
|
261
|
+
# check if the disabled_folders hash is deleted and the magento 1 mount is re-enabled
|
262
|
+
expect(subject).to receive(:update_settings).once.with(expected_settings)
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|