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

Commit

Permalink
Merge pull request #85 from bzwei/job_events
Browse files Browse the repository at this point in the history
Add job_events to job class and remove job_plays
  • Loading branch information
bdunne authored Apr 13, 2017
2 parents 7ba0aa4 + afd2225 commit 1a56e64
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 38 deletions.
1 change: 0 additions & 1 deletion lib/ansible_tower_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
require "ansible_tower_client/base_models/inventory_update"
require "ansible_tower_client/base_models/job"
require "ansible_tower_client/base_models/job_event"
require "ansible_tower_client/base_models/job_play"
require "ansible_tower_client/base_models/job_template"
require "ansible_tower_client/base_models/organization"
require "ansible_tower_client/base_models/project"
Expand Down
4 changes: 2 additions & 2 deletions lib/ansible_tower_client/base_models/job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ def extra_vars_hash
extra_vars.empty? ? {} : hashify(:extra_vars)
end

def job_plays
Collection.new(api, api.job_play_class).find_all_by_url(related["job_plays"])
def job_events(options = nil)
Collection.new(api, api.job_event_class).find_all_by_url(related["job_events"], options)
end

def stdout(format = 'txt')
Expand Down
4 changes: 0 additions & 4 deletions lib/ansible_tower_client/base_models/job_play.rb

This file was deleted.

1 change: 0 additions & 1 deletion spec/factories/responses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
trait(:job) { [description, extra_vars] }
trait(:project) { [description, organization] }
trait(:job_event) { [url] }
trait(:job_play) { [url] }

initialize_with { AnsibleTowerClient::FactoryHelper.stringify_attribute_keys(attributes) }
end
Expand Down
21 changes: 0 additions & 21 deletions spec/job_play_spec.rb

This file was deleted.

18 changes: 9 additions & 9 deletions spec/job_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@
end
end

context '#job_plays' do
let(:url) { "example.com/api/v1/job_plays" }
context '#job_events' do
let(:url) { "example.com/api/v1/job_events" }
let(:job_collection) { build(:response_collection, :klass => described_class) }
let(:job_plays) { build(:response_url_collection, :klass => AnsibleTowerClient::JobPlay, :url => url) }
it "returns a collection of AnsibleTowerClient::JobPlays" do
expect(AnsibleTowerClient::Collection).to receive(:new).with(api, api.job_play_class).and_return(job_collection)
expect(job_collection).to receive(:find_all_by_url).and_return(job_plays['results'])
results = described_class.new(api, raw_instance).job_plays.first
let(:job_events) { build(:response_url_collection, :klass => AnsibleTowerClient::JobEvent, :url => url) }
it "returns a collection of AnsibleTowerClient::JobEvents" do
expect(AnsibleTowerClient::Collection).to receive(:new).with(api, api.job_event_class).and_return(job_collection)
expect(job_collection).to receive(:find_all_by_url).and_return(job_events['results'])
results = described_class.new(api, raw_instance).job_events.first
expect(results).to include(
"type" => "job_play",
"url" => "example.com/api/v1/job_plays",
"type" => "job_event",
"url" => "example.com/api/v1/job_events",
)
end
end
Expand Down

0 comments on commit 1a56e64

Please sign in to comment.