Skip to content

Commit

Permalink
Add specs for create_from_params and edit_with_params
Browse files Browse the repository at this point in the history
  • Loading branch information
agrare committed Jun 30, 2020
1 parent ccb02da commit dc9feda
Showing 1 changed file with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,48 @@
describe ManageIQ::Providers::Foreman::ConfigurationManager do
let(:provider) { configuration_manager.provider }
let(:configuration_manager) do
FactoryBot.build(:configuration_manager_foreman)
end

describe "#connect" do
let(:provider) { configuration_manager.provider }
let(:configuration_manager) do
FactoryBot.build(:configuration_manager_foreman)
end

it "delegates to the provider" do
expect(provider).to receive(:connect)
configuration_manager.connect
end
end

describe ".create_from_params" do
it "delegates endpoints, zone, name to provider" do
params = {:zone => FactoryBot.create(:zone), :name => "Foreman"}
endpoints = [{"role" => "default", "url" => "https://foreman", "verify_ssl" => 0}]
authentications = [{"authtype" => "default", "userid" => "admin", "password" => "smartvm"}]

config_manager = described_class.create_from_params(params, endpoints, authentications)

expect(config_manager.provider.name).to eq("Foreman")
expect(config_manager.provider.endpoints.count).to eq(1)
end
end

describe "#edit_with_params" do
let(:configuration_manager) do
FactoryBot.build(:configuration_manager_foreman, :name => "Foreman", :url => "https://localhost")
end

it "updates the provider" do
params = {:zone => FactoryBot.create(:zone), :name => "Foreman 2"}
endpoints = [{"role" => "default", "url" => "https://foreman", "verify_ssl" => 0}]
authentications = [{"authtype" => "default", "userid" => "admin", "password" => "smartvm"}]

provider = configuration_manager.provider
expect(provider.name).to eq("Foreman")
expect(provider.url).to eq("https://localhost")

configuration_manager.edit_with_params(params, endpoints, authentications)

provider.reload
expect(provider.name).to eq("Foreman 2")
expect(provider.url).to eq("https://foreman")
end
end
end

0 comments on commit dc9feda

Please sign in to comment.