From 53ce4475748e1cadf1acbe7f2caf038896fa5465 Mon Sep 17 00:00:00 2001 From: Jeremy Deininger Date: Tue, 22 Jun 2010 20:03:41 -0700 Subject: [PATCH] [simpleDB] - not populating the :replace attributes with keys from :expect. --- lib/fog/aws/requests/simpledb/put_attributes.rb | 4 +--- spec/aws/requests/simpledb/put_attributes_spec.rb | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/fog/aws/requests/simpledb/put_attributes.rb b/lib/fog/aws/requests/simpledb/put_attributes.rb index d5b5386f3..810066b7a 100644 --- a/lib/fog/aws/requests/simpledb/put_attributes.rb +++ b/lib/fog/aws/requests/simpledb/put_attributes.rb @@ -16,7 +16,7 @@ module Fog # and sequences not allowed in xml are not valid. Each name and value can # be up to 1024 bytes long. # * options<~Hash> - Accepts the following keys. - # :replace => [Array of keys to replace, will be combined with any keys from :expect] + # :replace => [Array of keys to replace] # :expect => {name/value pairs for performing conditional put} # # ==== Returns @@ -27,7 +27,6 @@ module Fog def put_attributes(domain_name, item_name, attributes, options = {}) options[:expect] = {} unless options[:expect] options[:replace] = [] unless options[:replace] - options[:replace] += options[:expect].keys request({ 'Action' => 'PutAttributes', 'DomainName' => domain_name, @@ -43,7 +42,6 @@ module Fog def put_attributes(domain_name, item_name, attributes, options = {}) options[:expect] = {} unless options[:expect] options[:replace] = [] unless options[:replace] - options[:replace] += options[:expect].keys response = Excon::Response.new if @data[:domains][domain_name] options[:expect].each do |ck, cv| diff --git a/spec/aws/requests/simpledb/put_attributes_spec.rb b/spec/aws/requests/simpledb/put_attributes_spec.rb index 1254ecaa9..2d25354e5 100644 --- a/spec/aws/requests/simpledb/put_attributes_spec.rb +++ b/spec/aws/requests/simpledb/put_attributes_spec.rb @@ -20,8 +20,8 @@ describe 'SimpleDB.put_attributes' do it 'conditional put should succeed' do AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '1' }) - AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :expect => { 'version' => '1' }) - actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '3' }, :expect => { 'version' => '2' }) + AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :expect => { 'version' => '1' }, :replace => ['version']) + actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '3' }, :expect => { 'version' => '2' }, :replace => ['version']) actual.body['RequestId'].should be_a(String) actual.body['BoxUsage'].should be_a(Float) end @@ -32,7 +32,7 @@ describe 'SimpleDB.put_attributes' do actual.body['BoxUsage'].should be_a(Float) lambda { - actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :expect => { 'version' => '1' }) + actual = AWS[:sdb].put_attributes(@domain_name, 'foo', { 'version' => '2' }, :expect => { 'version' => '1' }, :replace => ['version']) }.should raise_error(Excon::Errors::Conflict) end