Skip to content

Commit

Permalink
Merge pull request #9089 from kbrock/supports_orders
Browse files Browse the repository at this point in the history
convert ServiceTemplate.orderable? to supports?(:order)
  • Loading branch information
agrare authored Apr 12, 2024
2 parents 583cd46 + 8a51b79 commit cdfcfc5
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
4 changes: 2 additions & 2 deletions app/controllers/orchestration_stack_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def textual_group_list
def make_ot_orderable
stack = find_record_with_rbac(OrchestrationStack, params[:id])
template = stack.orchestration_template
if template.orderable?
if template.supports?(:order)
add_flash(_("Orchestration template \"%{name}\" is already orderable") % {:name => template.name}, :error)
render_flash
else
Expand All @@ -198,7 +198,7 @@ def make_ot_orderable

def orchestration_template_copy
@record = find_record_with_rbac(OrchestrationStack, params[:id])
if @record.orchestration_template.orderable?
if @record.orchestration_template.supports?(:order)
add_flash(_("Orchestration template \"%{name}\" is already orderable") %
{:name => @record.orchestration_template.name}, :error)
render_flash
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ApplicationHelper::Button::OrchestrationTemplateOrderable < ApplicationHelper::Button::Basic
def disabled?
@error_message = _('This Template is already orderable') if @record.orchestration_template.orderable?
@error_message = _('This Template is already orderable') if @record.orchestration_template.supports?(:order)
@error_message.present?
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class ApplicationHelper::Button::OrchestrationTemplateViewInCatalog < ApplicationHelper::Button::Basic
def disabled?
@error_message = _('This Template is not orderable') unless @record.orchestration_template.orderable?
@error_message = _('This Template is not orderable') unless @record.orchestration_template.supports?(:order)
@error_message.present?
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@
= label
%td
- case sym
- when :draft, :orderable?
= @record.orchestration_template.send(sym) ? _("True") : _("False")
- when :draft
= @record.orchestration_template.draft ? _("True") : _("False")
- when :orderable?
= @record.orchestration_template.supports?(:order) ? _("True") : _("False")
- when :read_only
= @record.orchestration_template.in_use? ? _("True") : _("False")
- else
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/orchestration_stack_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def validate_format
it "won't allow making stack's orchestration template orderable when already orderable" do
record = FactoryBot.create(:orchestration_stack_cloud_with_template)
post :button, :params => {:id => record.id, :pressed => "make_ot_orderable"}
expect(record.orchestration_template.orderable?).to be_truthy
expect(record.orchestration_template.supports?(:order)).to be_truthy
expect(response.status).to eq(200)
expect(response).to render_template(:partial => "layouts/_flash_msg")
expect(assigns(:flash_array).first[:message]).to include('is already orderable')
Expand All @@ -128,7 +128,7 @@ def validate_format
it "makes stack's orchestration template orderable" do
record = FactoryBot.create(:orchestration_stack_cloud, :orchestration_template => non_orderable_template)
post :button, :params => {:id => record.id, :pressed => "make_ot_orderable"}
expect(record.orchestration_template.orderable?).to be_falsey
expect(record.orchestration_template.supports?(:order)).to be_falsey
expect(response.status).to eq(200)
expect(response).to render_template(:partial => "layouts/_flash_msg")
expect(assigns(:flash_array).first[:message]).to include('is now orderable')
Expand All @@ -139,7 +139,7 @@ def validate_format
it "won't allow copying stack's orchestration template orderable when already orderable" do
record = FactoryBot.create(:orchestration_stack_cloud_with_template)
post :button, :params => {:id => record.id, :pressed => "orchestration_template_copy"}
expect(record.orchestration_template.orderable?).to be_truthy
expect(record.orchestration_template.supports?(:order)).to be_truthy
expect(response.status).to eq(200)
expect(response).to render_template(:partial => "layouts/_flash_msg")
expect(assigns(:flash_array).first[:message]).to include('is already orderable')
Expand All @@ -148,7 +148,7 @@ def validate_format
it "renders orchestration template copying form" do
record = FactoryBot.create(:orchestration_stack_cloud, :orchestration_template => non_orderable_template)
post :button, :params => {:id => record.id, :pressed => "orchestration_template_copy"}
expect(record.orchestration_template.orderable?).to be_falsey
expect(record.orchestration_template.supports?(:order)).to be_falsey
expect(response.status).to eq(200)
expect(response).to render_template(:partial => "orchestration_stack/_copy_orchestration_template")
end
Expand Down

0 comments on commit cdfcfc5

Please sign in to comment.