Sha256: d987a90178485e45b5889bd0cd929a17b97de6c3173e7e4deaee2fdcfce83ac3
Contents?: true
Size: 1.07 KB
Versions: 6
Compression:
Stored size: 1.07 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"] error!(:invalid, details: { "name" => [ { "description" => "Name cannot be blank" } ]}) end if self.data[:organizations].values.find{|o| o["name"] == record["name"]} error!(:invalid, 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
6 entries across 6 versions & 1 rubygems