diff options
author | Bryan McLellan <btm@opscode.com> | 2011-06-01 17:50:21 -0700 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2011-06-01 17:50:21 -0700 |
commit | 2c62426976dbe0e2a46fe99d35e8fc1062a6d028 (patch) | |
tree | 5ce0b166a228283ab88cd8a63f5508eeb4d5e981 | |
parent | 608eaf772b13f7cf52d2154e4ea7813edb451e7a (diff) | |
parent | ae18dcf183e160810c4bfd662d3453b0c090fc34 (diff) | |
download | chef-2c62426976dbe0e2a46fe99d35e8fc1062a6d028.tar.gz |
Merge branch 'CHEF-1982'
-rw-r--r-- | chef/lib/chef/provider/mount/mount.rb | 3 | ||||
-rw-r--r-- | chef/spec/unit/provider/mount/mount_spec.rb | 16 |
2 files changed, 15 insertions, 4 deletions
diff --git a/chef/lib/chef/provider/mount/mount.rb b/chef/lib/chef/provider/mount/mount.rb index e1e4077dac..7419182d6e 100644 --- a/chef/lib/chef/provider/mount/mount.rb +++ b/chef/lib/chef/provider/mount/mount.rb @@ -64,7 +64,8 @@ class Chef @current_resource.dump($3.to_i) @current_resource.pass($4.to_i) Chef::Log.debug("Found mount #{device_fstab} to #{@new_resource.mount_point} in /etc/fstab") - when /^[\/\w]+\s+#{Regexp.escape(@new_resource.mount_point)}/ + next + when /^[\/\w]+\s+#{Regexp.escape(@new_resource.mount_point)}\s+/ enabled = false Chef::Log.debug("Found conflicting mount point #{@new_resource.mount_point} in /etc/fstab") end diff --git a/chef/spec/unit/provider/mount/mount_spec.rb b/chef/spec/unit/provider/mount/mount_spec.rb index 673150f9ff..bad3ec47d5 100644 --- a/chef/spec/unit/provider/mount/mount_spec.rb +++ b/chef/spec/unit/provider/mount/mount_spec.rb @@ -134,10 +134,20 @@ describe Chef::Provider::Mount::Mount do end it "should set enabled to true if the mount point is last in fstab" do - fstab = "/dev/sdy1 /tmp/foo ext3 defaults 1 2\n" - fstab << "/dev/sdz1 /tmp/foo ext3 defaults 1 2\n" + fstab1 = "/dev/sdy1 /tmp/foo ext3 defaults 1 2\n" + fstab2 = "#{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n" - ::File.stub!(:foreach).with("/etc/fstab").and_yield fstab + ::File.stub!(:foreach).with("/etc/fstab").and_yield(fstab1).and_yield(fstab2) + + @provider.load_current_resource + @provider.current_resource.enabled.should be_true + end + + it "should set enabled to true if the mount point is not last in fstab and mount_point is a substring of another mount" do + fstab1 = "#{@new_resource.device} #{@new_resource.mount_point} ext3 defaults 1 2\n" + fstab2 = "/dev/sdy1 /tmp/foo/bar ext3 defaults 1 2\n" + + ::File.stub!(:foreach).with("/etc/fstab").and_yield(fstab1).and_yield(fstab2) @provider.load_current_resource @provider.current_resource.enabled.should be_true |