Skip to content

Commit

Permalink
Merge pull request #15988 from gmcculloug/force_placement_auto
Browse files Browse the repository at this point in the history
Allow forcing the provision task placement_auto method to true.
  • Loading branch information
mkanoor authored Sep 18, 2017
2 parents 9dab567 + 6cc6195 commit 286add2
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 286add2

Please sign in to comment.