diff options
author | tylercloke <tylercloke@gmail.com> | 2015-07-01 21:32:45 -0700 |
---|---|---|
committer | tylercloke <tylercloke@gmail.com> | 2015-07-06 14:36:03 -0700 |
commit | 96f1e1a4f2dcd6acfb5657da28fc004c038c6422 (patch) | |
tree | 6d697fe3eae313166499a47f5abd0bae6d4f285c | |
parent | e35250325f6836b464841441d33336c988b8ccc6 (diff) | |
download | chef-96f1e1a4f2dcd6acfb5657da28fc004c038c6422.tar.gz |
Remove _rest from http methods.
-rw-r--r-- | lib/chef/user.rb | 12 | ||||
-rw-r--r-- | spec/unit/user_spec.rb | 16 |
2 files changed, 14 insertions, 14 deletions
diff --git a/lib/chef/user.rb b/lib/chef/user.rb index bc9705c092..b1b8d812e8 100644 --- a/lib/chef/user.rb +++ b/lib/chef/user.rb @@ -92,13 +92,13 @@ class Chef end def destroy - chef_rest_v0.delete_rest("users/#{@name}") + chef_rest_v0.delete("users/#{@name}") end def create payload = {:name => self.name, :admin => self.admin, :password => self.password } payload[:public_key] = public_key if public_key - new_user = chef_rest_v0.post_rest("users", payload) + new_user = chef_rest_v0.post("users", payload) Chef::User.from_hash(self.to_hash.merge(new_user)) end @@ -106,7 +106,7 @@ class Chef payload = {:name => name, :admin => admin} payload[:private_key] = new_key if new_key payload[:password] = password if password - updated_user = chef_rest_v0.put_rest("users/#{name}", payload) + updated_user = chef_rest_v0.put("users/#{name}", payload) Chef::User.from_hash(self.to_hash.merge(updated_user)) end @@ -123,7 +123,7 @@ class Chef end def reregister - reregistered_self = chef_rest_v0.put_rest("users/#{name}", { :name => name, :admin => admin, :private_key => true }) + reregistered_self = chef_rest_v0.put("users/#{name}", { :name => name, :admin => admin, :private_key => true }) private_key(reregistered_self["private_key"]) self end @@ -158,7 +158,7 @@ class Chef end def self.list(inflate=false) - response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"}).get_rest('users') + response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"}).get('users') users = if response.is_a?(Array) transform_ohc_list_response(response) # OHC/OPC else @@ -175,7 +175,7 @@ class Chef end def self.load(name) - response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"}).get_rest("users/#{name}") + response = Chef::ServerAPI.new(Chef::Config[:chef_server_url], {:api_version => "0"}).get("users/#{name}") Chef::User.from_hash(response) end diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb index 777a4e6ef0..97cc32eb3e 100644 --- a/spec/unit/user_spec.rb +++ b/spec/unit/user_spec.rb @@ -219,24 +219,24 @@ describe Chef::User do end it "lists all clients on an OSC server" do - allow(@http_client).to receive(:get_rest).with("users").and_return(@osc_response) + allow(@http_client).to receive(:get).with("users").and_return(@osc_response) expect(Chef::User.list).to eq(@osc_response) end it "inflate all clients on an OSC server" do - allow(@http_client).to receive(:get_rest).with("users").and_return(@osc_response) + allow(@http_client).to receive(:get).with("users").and_return(@osc_response) expect(Chef::User.list(true)).to eq(@osc_inflated_response) end it "lists all clients on an OHC/OPC server" do - allow(@http_client).to receive(:get_rest).with("users").and_return(@ohc_response) + allow(@http_client).to receive(:get).with("users").and_return(@ohc_response) # We expect that Chef::User.list will give a consistent response # so OHC API responses should be transformed to OSC-style output. expect(Chef::User.list).to eq(@osc_response) end it "inflate all clients on an OHC/OPC server" do - allow(@http_client).to receive(:get_rest).with("users").and_return(@ohc_response) + allow(@http_client).to receive(:get).with("users").and_return(@ohc_response) expect(Chef::User.list(true)).to eq(@osc_inflated_response) end end @@ -244,14 +244,14 @@ describe Chef::User do describe "create" do it "creates a new user via the API" do @user.password "password" - expect(@http_client).to receive(:post_rest).with("users", {:name => "foobar", :admin => false, :password => "password"}).and_return({}) + expect(@http_client).to receive(:post).with("users", {:name => "foobar", :admin => false, :password => "password"}).and_return({}) @user.create end end describe "read" do it "loads a named user from the API" do - expect(@http_client).to receive(:get_rest).with("users/foobar").and_return({"name" => "foobar", "admin" => true, "public_key" => "pubkey"}) + expect(@http_client).to receive(:get).with("users/foobar").and_return({"name" => "foobar", "admin" => true, "public_key" => "pubkey"}) user = Chef::User.load("foobar") expect(user.name).to eq("foobar") expect(user.admin).to eq(true) @@ -261,14 +261,14 @@ describe Chef::User do describe "update" do it "updates an existing user on via the API" do - expect(@http_client).to receive(:put_rest).with("users/foobar", {:name => "foobar", :admin => false}).and_return({}) + expect(@http_client).to receive(:put).with("users/foobar", {:name => "foobar", :admin => false}).and_return({}) @user.update end end describe "destroy" do it "deletes the specified user via the API" do - expect(@http_client).to receive(:delete_rest).with("users/foobar") + expect(@http_client).to receive(:delete).with("users/foobar") @user.destroy end end |