Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix services always invisibile #14403

Merged
merged 1 commit into from
Mar 20, 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
8 changes: 4 additions & 4 deletions app/models/service_template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ def create_service(service_task, parent_svc = nil)
(nh.keys - Service.column_names + %w(created_at guid service_template_id updated_at id type prov_type)).each { |key| nh.delete(key) }

# Hide child services by default
nh[:display] = false if parent_svc
nh['display'] = false if parent_svc

# If display is nil, set it to false
nh[:display] = false if nh[:display].nil?
nh['display'] ||= false

# convert template class name to service class name by naming convention
nh[:type] = self.class.name.sub('Template', '')
nh['type'] = self.class.name.sub('Template', '')

nh[:initiator] = service_task.options[:initiator] if service_task.options[:initiator]
nh['initiator'] = service_task.options[:initiator] if service_task.options[:initiator]

# Determine service name
# target_name = self.get_option(:target_name)
Expand Down
16 changes: 16 additions & 0 deletions spec/models/service_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,22 @@

@svc_a.create_service(sub_svc)
end

it "should pass display attribute to created top level service" do
@svc_a.display = true
expect(@svc_a.create_service(double(:options => {:dialog => {}})).display).to eq(true)
end

it "should set created child service's display to false" do
@svc_a.display = true
allow(@svc_b).to receive(:add_resource!)
expect(@svc_a.create_service(double(:options => {:dialog => {}}), @svc_b).display).to eq(false)
end

it "should set created service's display to false by default" do
expect(@svc_a.create_service(double(:options => {:dialog => {}})).display).to eq(false)
end

it "should return all parent services for a service" do
add_and_save_service(@svc_a, @svc_b)
add_and_save_service(@svc_a, @svc_c)
Expand Down