summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/chef/provider/osx_profile.rb11
-rw-r--r--spec/unit/provider/osx_profile_spec.rb2
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb
index 071b4b0462..dccda49e1d 100644
--- a/lib/chef/provider/osx_profile.rb
+++ b/lib/chef/provider/osx_profile.rb
@@ -54,10 +54,13 @@ class Chef
@new_resource.profile_name
end
- current_profile = all_profiles["_computerlevel"].find {
- |item| item["ProfileIdentifier"] ==
- @new_profile_identifier
- }
+ if all_profiles.empty?
+ current_profile = nil
+ else
+ current_profile = all_profiles["_computerlevel"].find do |item|
+ item["ProfileIdentifier"] == @new_profile_identifier
+ end
+ end
@current_resource.profile(current_profile)
end
diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb
index 76bfc3b4eb..f1e16d08db 100644
--- a/spec/unit/provider/osx_profile_spec.rb
+++ b/spec/unit/provider/osx_profile_spec.rb
@@ -106,7 +106,7 @@ describe Chef::Provider::OsxProfile do
}
end
let(:no_profiles) do
- { "_computerlevel"=> [] }
+ { }
end
before(:each) do