Sha256: 1b9bf854826866c42b58f52f2479b9dd189b04551e2511aa081eaa22b47fcd64

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

require 'rubygems'
require 'test_helper'


# To add log for non-rails app, see  http://rails-nutshell.labs.oreilly.com/ch08.html
class Salesforce::Rest::RestCreateDeleteTest < ActiveSupport::TestCase

  #Find a single object with REST API
  def test_update
    #Again the delete feature from ActiveResource does not work out of the box.
    #Using custom delete function
    
    Salesforce::Rest::Account.format = ActiveResource::Formats::JsonFormat

  puts "--create a new account--"
  new_acct = Salesforce::Rest::Account.new(:Name => "test numero uno", :BillingStreet=> "Fairway Meadows",
    :BillingState => "NY", :ShippingCity => "New York")
  resp = new_acct.save()
    # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
    # HTTP Code 201 is created successfully.
    assert (resp.code == "201")
    j = ActiveSupport::JSON
    @sf_oid = j.decode(resp.body)["id"]      
    puts "New Object created: id -> "  + @sf_oid    

    puts "--update that account with json--"
    serialized_json = '{"BillingState":"FL"}'
    resp = Salesforce::Rest::Account.update(@sf_oid, serialized_json)
    assert (resp.code == "204")
  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
asf-rest-adapter-0.4.6 test/asf-rest-adapter-rails-app/test/unit/rest_update_resource.rb
asf-rest-adapter-0.4.5 test/asf-rest-adapter-rails-app/test/unit/rest_update_resource.rb
asf-rest-adapter-0.4.4 test/asf-rest-adapter-rails-app/test/unit/rest_update_resource.rb
asf-rest-adapter-0.4.3 test/asf-rest-adapter-rails-app/test/unit/rest_update_resource.rb
asf-rest-adapter-0.4.2 test/asf-rest-adapter-rails-app/test/unit/rest_update_resource.rb
asf-rest-adapter-0.3.3 test/asf-rest-adapter-rails-app/test/unit/rest_update_resource.rb
asf-rest-adapter-0.3.2 test/asf-rest-adapter-rails-app/test/unit/rest_update_resource.rb