Sha256: e4ef6c818ab4c9868e3437c1d06b098b4aaef6511b3e944d9cdf7762dae104c0

Contents?: true

Size: 1.68 KB

Versions: 15

Compression:

Stored size: 1.68 KB

Contents

require File.join(File.dirname(__FILE__),'..','api_helper')

describe "RhoconnectApiUserSetDbDoc" do
  include_examples "ApiHelper"

  it "should set user's db document by doc key and data" do
    data = {'1' => {'foo' => 'bar'}}
    dockey = 'myuserdoc'
    sdocname = @s2.docname(dockey)

    post "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{@s2.name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
    last_response.should be_ok
    verify_result(sdocname => data)
  end

  it "should append data to the user's db document by doc name and data" do
    data = {'1' => {'foo' => 'bar'}}
    data2 = {'2' => {'foo1' => 'bar1'}}
    data3 = data.merge(data2)
    dockey = 'abc:abc'
    sdocname = @s2.docname(dockey)
    post "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{@s2.name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
    last_response.should be_ok
    verify_result(sdocname => data)

    post "/rc/#{Rhoconnect::API_VERSION}/users/#{@u.id}/sources/#{@s2.name}/docs/#{dockey}", {:data => data2, :append => true}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
    last_response.should be_ok
    verify_result(sdocname => data3)
  end

  it "should error out in ateempt to set a db doc for a non-existent user" do
    data = {'1' => {'foo' => 'bar'}}
    data2 = {'2' => {'foo1' => 'bar1'}}
    data3 = data.merge(data2)
    dockey = 'abc:abc'
    sdocname = @s2.docname(dockey)
    post "/rc/#{Rhoconnect::API_VERSION}/users/invalid_user/sources/#{@s2.name}/docs/#{dockey}", {:data => data}, {Rhoconnect::API_TOKEN_HEADER => @api_token}
    last_response.status.should == 500
    last_response.should_not be_ok
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rhoconnect-7.6.0 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-7.5.1 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-7.4.1 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-7.1.17 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-6.2.0 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-6.0.11 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-5.5.18 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-5.5.17 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-5.5.15 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-5.5.0.22 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-5.5.2 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-5.5.0.7 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-5.5.0.3 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-5.5.0 spec/api/user/user_set_db_doc_spec.rb
rhoconnect-5.1.1 spec/api/user/user_set_db_doc_spec.rb