Skip to content

Commit

Permalink
Merge pull request ManageIQ#14968 from mkanoor/bz_1446452
Browse files Browse the repository at this point in the history
Allow for ansible tower service to be added to service
  • Loading branch information
gmcculloug authored May 3, 2017
2 parents 0e06d76 + f6f81b0 commit dd8c13c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/mixins/service_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def add_resource(rsc, options = {})
sr = service_resources.new(nh.merge(:resource => rsc))
set_service_type if self.respond_to?(:set_service_type)
# Create link between services
rsc.update_attributes(:parent => self) if self.class == Service && rsc.class == Service
rsc.update_attributes(:parent => self) if self.class == Service && rsc.kind_of?(Service)
end
end
sr
Expand Down
6 changes: 6 additions & 0 deletions spec/models/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@
expect(@service.service_resources.size).to eq(1)
end

it "should allow a service to connect to ansible tower service" do
s2 = FactoryGirl.create(:service_ansible_tower, :name => 'ansible')
@service.add_resource(s2)
expect(s2.parent).to eq(@service)
end

it "should not allow service to connect to itself" do
expect { @service << @service }.to raise_error(MiqException::MiqServiceCircularReferenceError)
end
Expand Down

0 comments on commit dd8c13c

Please sign in to comment.