Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

Commit

Permalink
translate organization_id to organization
Browse files Browse the repository at this point in the history
  • Loading branch information
durandom committed Apr 24, 2017
1 parent dd23b4f commit ee76157
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ansible_tower_client/base_models/credential.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module AnsibleTowerClient
class Credential < BaseModel
def override_raw_attributes
{ :organization => :organization_id }
end
end
end
12 changes: 12 additions & 0 deletions spec/credential_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,16 @@
expect(obj.username).to be_a String
expect(obj.name).to be_a String
end

context 'override_raw_attributes' do
let(:obj) { described_class.new(instance_double("Faraday::Connection"), raw_instance) }
let(:instance_api) { obj.instance_variable_get(:@api) }

it 'translates :organization to :organization_id for update_attributes' do
raw_instance[:organization_id] = 10
expect(instance_api).to receive(:patch).and_return(instance_double("Faraday::Result", :body => raw_instance.to_json))
expect(obj.update_attributes(:organization => '5')).to eq true
expect(obj.organization_id).to eq '5'
end
end
end

0 comments on commit ee76157

Please sign in to comment.