Skip to content

Commit

Permalink
Merge pull request ManageIQ#16056 from gmcculloug/service_add_to_serv…
Browse files Browse the repository at this point in the history
…ice_fix

Fix for add_to_service refactoring
  • Loading branch information
mkanoor authored Sep 27, 2017
2 parents fa6d79e + cb8d963 commit af5b956
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions app/models/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,13 @@ def perf_rollup_parents(interval_name = nil)
end

def add_resource(rsc, options = {})
service_resource = super
return if service_resource.nil?
super.tap do |service_resource|
break if service_resource.nil?

# Create ancestry link between services
resource = service_resource.resource
resource.update_attributes(:parent => self) if resource.kind_of?(Service)
# Create ancestry link between services
resource = service_resource.resource
resource.update_attributes(:parent => self) if resource.kind_of?(Service)
end
end

def enforce_single_service_parent?
Expand Down
2 changes: 1 addition & 1 deletion spec/models/service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@
let(:child_service) { FactoryGirl.create(:service) }

it 'associates a child_service to the service' do
child_service.add_to_service(service)
expect(child_service.add_to_service(service)).to be_kind_of(ServiceResource)

expect(service.reload.services).to include(child_service)
end
Expand Down

0 comments on commit af5b956

Please sign in to comment.