Skip to content

Commit cdfcfc5

Browse files
authored
Merge pull request #9089 from kbrock/supports_orders
convert ServiceTemplate.orderable? to supports?(:order)
2 parents 583cd46 + 8a51b79 commit cdfcfc5

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

app/controllers/orchestration_stack_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def textual_group_list
174174
def make_ot_orderable
175175
stack = find_record_with_rbac(OrchestrationStack, params[:id])
176176
template = stack.orchestration_template
177-
if template.orderable?
177+
if template.supports?(:order)
178178
add_flash(_("Orchestration template \"%{name}\" is already orderable") % {:name => template.name}, :error)
179179
render_flash
180180
else
@@ -198,7 +198,7 @@ def make_ot_orderable
198198

199199
def orchestration_template_copy
200200
@record = find_record_with_rbac(OrchestrationStack, params[:id])
201-
if @record.orchestration_template.orderable?
201+
if @record.orchestration_template.supports?(:order)
202202
add_flash(_("Orchestration template \"%{name}\" is already orderable") %
203203
{:name => @record.orchestration_template.name}, :error)
204204
render_flash
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class ApplicationHelper::Button::OrchestrationTemplateOrderable < ApplicationHelper::Button::Basic
22
def disabled?
3-
@error_message = _('This Template is already orderable') if @record.orchestration_template.orderable?
3+
@error_message = _('This Template is already orderable') if @record.orchestration_template.supports?(:order)
44
@error_message.present?
55
end
66
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class ApplicationHelper::Button::OrchestrationTemplateViewInCatalog < ApplicationHelper::Button::Basic
22
def disabled?
3-
@error_message = _('This Template is not orderable') unless @record.orchestration_template.orderable?
3+
@error_message = _('This Template is not orderable') unless @record.orchestration_template.supports?(:order)
44
@error_message.present?
55
end
66
end

app/views/orchestration_stack/_stack_orchestration_template.html.haml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
= label
1919
%td
2020
- case sym
21-
- when :draft, :orderable?
22-
= @record.orchestration_template.send(sym) ? _("True") : _("False")
21+
- when :draft
22+
= @record.orchestration_template.draft ? _("True") : _("False")
23+
- when :orderable?
24+
= @record.orchestration_template.supports?(:order) ? _("True") : _("False")
2325
- when :read_only
2426
= @record.orchestration_template.in_use? ? _("True") : _("False")
2527
- else

spec/controllers/orchestration_stack_controller_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def validate_format
119119
it "won't allow making stack's orchestration template orderable when already orderable" do
120120
record = FactoryBot.create(:orchestration_stack_cloud_with_template)
121121
post :button, :params => {:id => record.id, :pressed => "make_ot_orderable"}
122-
expect(record.orchestration_template.orderable?).to be_truthy
122+
expect(record.orchestration_template.supports?(:order)).to be_truthy
123123
expect(response.status).to eq(200)
124124
expect(response).to render_template(:partial => "layouts/_flash_msg")
125125
expect(assigns(:flash_array).first[:message]).to include('is already orderable')
@@ -128,7 +128,7 @@ def validate_format
128128
it "makes stack's orchestration template orderable" do
129129
record = FactoryBot.create(:orchestration_stack_cloud, :orchestration_template => non_orderable_template)
130130
post :button, :params => {:id => record.id, :pressed => "make_ot_orderable"}
131-
expect(record.orchestration_template.orderable?).to be_falsey
131+
expect(record.orchestration_template.supports?(:order)).to be_falsey
132132
expect(response.status).to eq(200)
133133
expect(response).to render_template(:partial => "layouts/_flash_msg")
134134
expect(assigns(:flash_array).first[:message]).to include('is now orderable')
@@ -139,7 +139,7 @@ def validate_format
139139
it "won't allow copying stack's orchestration template orderable when already orderable" do
140140
record = FactoryBot.create(:orchestration_stack_cloud_with_template)
141141
post :button, :params => {:id => record.id, :pressed => "orchestration_template_copy"}
142-
expect(record.orchestration_template.orderable?).to be_truthy
142+
expect(record.orchestration_template.supports?(:order)).to be_truthy
143143
expect(response.status).to eq(200)
144144
expect(response).to render_template(:partial => "layouts/_flash_msg")
145145
expect(assigns(:flash_array).first[:message]).to include('is already orderable')
@@ -148,7 +148,7 @@ def validate_format
148148
it "renders orchestration template copying form" do
149149
record = FactoryBot.create(:orchestration_stack_cloud, :orchestration_template => non_orderable_template)
150150
post :button, :params => {:id => record.id, :pressed => "orchestration_template_copy"}
151-
expect(record.orchestration_template.orderable?).to be_falsey
151+
expect(record.orchestration_template.supports?(:order)).to be_falsey
152152
expect(response.status).to eq(200)
153153
expect(response).to render_template(:partial => "orchestration_stack/_copy_orchestration_template")
154154
end

0 commit comments

Comments
 (0)