summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThom May <thom@may.lt>2016-12-01 21:18:11 +0000
committerGitHub <noreply@github.com>2016-12-01 21:18:11 +0000
commit76dd752ac2641faf4c24c802762a3b9970882a8c (patch)
tree70f64763f0edadec978d06514486a4a6e24eb221
parent12c7d21e439ef23a5f77cf276f98edfa3e477c80 (diff)
parent937faa7e42c6df03b1deec0e8bbc785b7ba33e90 (diff)
downloadchef-76dd752ac2641faf4c24c802762a3b9970882a8c.tar.gz
Merge pull request #5599 from shortdudey123/mount_action_unmount
Alias unmount to umount for mount resource
-rw-r--r--RELEASE_NOTES.md9
-rw-r--r--lib/chef/provider/mount.rb2
-rw-r--r--lib/chef/resource/mount.rb2
-rw-r--r--spec/unit/provider/mount_spec.rb7
-rw-r--r--spec/unit/resource/mount_spec.rb3
5 files changed, 21 insertions, 2 deletions
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 56191bae74..71161cb3da 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -29,4 +29,13 @@ _This file holds "in progress" release notes for the current release under devel
end
```
+- Alias `unmount` to `umount` for mount resource
+Example:
+
+ ```ruby
+ mount '/mount/tmp' do
+ action :unmount
+ end
+ ```
+
## Highlighted bug fixes for this release:
diff --git a/lib/chef/provider/mount.rb b/lib/chef/provider/mount.rb
index 9e9ee29bde..5168c93348 100644
--- a/lib/chef/provider/mount.rb
+++ b/lib/chef/provider/mount.rb
@@ -108,6 +108,8 @@ class Chef
end
end
+ alias :action_unmount :action_umount
+
#
# Abstract Methods to be implemented by subclasses
#
diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb
index 2d85b3897c..3e35325246 100644
--- a/lib/chef/resource/mount.rb
+++ b/lib/chef/resource/mount.rb
@@ -28,7 +28,7 @@ class Chef
state_attrs :mount_point, :device_type, :fstype, :username, :password, :domain
default_action :mount
- allowed_actions :mount, :umount, :remount, :enable, :disable
+ allowed_actions :mount, :umount, :unmount, :remount, :enable, :disable
def initialize(name, run_context = nil)
super
diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb
index 19967e8496..b2497cf1b2 100644
--- a/spec/unit/provider/mount_spec.rb
+++ b/spec/unit/provider/mount_spec.rb
@@ -70,6 +70,13 @@ describe Chef::Provider::Mount do
expect(new_resource).to be_updated_by_last_action
end
+ it "should unmount the filesystem if it is mounted" do
+ allow(current_resource).to receive(:mounted).and_return(true)
+ expect(provider).to receive(:umount_fs).and_return(true)
+ provider.run_action(:unmount)
+ expect(new_resource).to be_updated_by_last_action
+ end
+
it "should not umount the filesystem if it is not mounted" do
allow(current_resource).to receive(:mounted).and_return(false)
expect(provider).not_to receive(:umount_fs)
diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb
index 188eaa67d6..832f7644ac 100644
--- a/spec/unit/resource/mount_spec.rb
+++ b/spec/unit/resource/mount_spec.rb
@@ -41,9 +41,10 @@ describe Chef::Resource::Mount do
expect(@resource.action).to eql([:mount])
end
- it "should accept mount, umount and remount as actions" do
+ it "should accept mount, umount, unmount and remount as actions" do
expect { @resource.action :mount }.not_to raise_error
expect { @resource.action :umount }.not_to raise_error
+ expect { @resource.action :unmount }.not_to raise_error
expect { @resource.action :remount }.not_to raise_error
expect { @resource.action :brooklyn }.to raise_error(ArgumentError)
end