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

Add the Organization model #79

Merged
merged 1 commit into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/ansible_tower_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
require "ansible_tower_client/base_models/job"
require "ansible_tower_client/base_models/job_event"
require "ansible_tower_client/base_models/job_template"
require "ansible_tower_client/base_models/organization"
require "ansible_tower_client/base_models/project"

require "ansible_tower_client/v2/job_template_v2"
Expand Down
8 changes: 8 additions & 0 deletions lib/ansible_tower_client/api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def job_templates
Collection.new(self, job_template_class)
end

def organizations
Collection.new(self, organization_class)
end

def projects
Collection.new(self, project_class)
end
Expand Down Expand Up @@ -146,6 +150,10 @@ def job_template_class
end
end

def organization_class
@organization_class ||= AnsibleTowerClient::Organization
end

def project_class
@project_class ||= AnsibleTowerClient::Project
end
Expand Down
4 changes: 4 additions & 0 deletions lib/ansible_tower_client/base_models/organization.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module AnsibleTowerClient
class Organization < BaseModel
end
end
23 changes: 23 additions & 0 deletions spec/organization_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require 'json'

describe AnsibleTowerClient::Organization do
let(:url) { "example.com/api/v1/organizations/13" }
let(:api) { AnsibleTowerClient::Api.new(instance_double("Faraday::Connection")) }
let(:collection) { api.organizations }
let(:raw_collection) { build(:response_collection, :klass => described_class) }
let(:raw_url_collection) { build(:response_url_collection, :klass => described_class, :url => url) }
let(:raw_instance) { build(:response_instance, :organization, :klass => described_class, :description => "The Organization", :name => "MyOrg") }

include_examples "Collection Methods"
include_examples "Crud Methods"

it "#initialize instantiates an #{described_class} from a hash" do
obj = described_class.new(instance_double("AnsibleTowerClient::Api"), raw_instance)

expect(obj).to be_a described_class
expect(obj.id).to be_a Integer
expect(obj.url).to be_a String
expect(obj.description).to eq "The Organization"
expect(obj.name).to be_a String
end
end