Skip to content

Commit

Permalink
Allow forcing the provision task placement_auto method to true.
Browse files Browse the repository at this point in the history
Supports dialogs where the user has access to limited environment tab placement fields, such
as folder or cluster, and auto-placement is still required to select the remaining fields.

https://bugzilla.redhat.com/show_bug.cgi?id=1483636
https://bugzilla.redhat.com/show_bug.cgi?id=1484024
  • Loading branch information
gmcculloug committed Sep 18, 2017
1 parent 067343f commit 6cc6195
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/miq_provision.rb
Expand Up @@ -53,7 +53,7 @@ def execute_queue
end

def placement_auto
get_option(:placement_auto)
get_option(:force_placement_auto) || get_option(:placement_auto)
end

def after_request_task_create
Expand Down
40 changes: 40 additions & 0 deletions spec/models/miq_provision_spec.rb
Expand Up @@ -155,4 +155,44 @@
prov.eligible_resources(:hosts)
end
end

describe "#placement_auto" do
let(:miq_provision) { FactoryGirl.build(:miq_provision, :options => {:placement_auto => placement_option}) }

context "when option[:placement_auto] is true" do
let(:placement_option) { [true, 1] }

it "without force_placement_auto" do
expect(miq_provision.placement_auto).to eq(true)
end

it "with force_placement_auto set to false" do
miq_provision.options[:force_placement_auto] = false
expect(miq_provision.placement_auto).to eq(true)
end

it "with force_placement_auto set to true" do
miq_provision.options[:force_placement_auto] = true
expect(miq_provision.placement_auto).to eq(true)
end
end

context "when option[:placement_auto] is false" do
let(:placement_option) { [false, 0] }

it "without force_placement_auto" do
expect(miq_provision.placement_auto).to eq(false)
end

it "with force_placement_auto set to false" do
miq_provision.options[:force_placement_auto] = false
expect(miq_provision.placement_auto).to eq(false)
end

it "with force_placement_auto set to true" do
miq_provision.options[:force_placement_auto] = true
expect(miq_provision.placement_auto).to eq(true)
end
end
end
end

0 comments on commit 6cc6195

Please sign in to comment.