Sha256: 9ed0728bf63d67290e12a4256c409abd2eb63d71174a6cca7a054af54c5bda38
Contents?: true
Size: 1.79 KB
Versions: 11
Compression:
Stored size: 1.79 KB
Contents
class Zendesk2::Client class Real def create_organization(params={}) request( :body => {"organization" => params}, :method => :post, :path => "/organizations.json", ) end end # Real class Mock def create_organization(params={}) identity = self.class.new_id record = { "id" => identity, "url" => url_for("/organizations/#{identity}.json"), "created_at" => Time.now.iso8601, "updated_at" => Time.now.iso8601, }.merge(params) unless record["name"] response( :status => 422, :headers => { "status" => "422 Unprocessable Entity", }, :body => { "error" => "RecordInvalid", "description" => "Record validation errors", "details" => { "name" => [ { "description" => "Name: cannot be blank" } ] } } ) end if self.data[:organizations].values.find{|o| o["name"] == record["name"]} response( :status => 422, :headers => { "status" => "422 Unprocessable Entity", }, :body => { "error" => "RecordInvalid", "description" => "Record validation errors", "details" => { "name" => [ { "description" => "Name: has already been taken" } ] } } ) end self.data[:organizations][identity]= record response( :method => :post, :body => {"organization" => record}, :path => "/organizations.json" ) end end # Mock end
Version data entries
11 entries across 11 versions & 1 rubygems