Sha256: 94df678102247755160fadae7b60a460272de4e9098fb36955c885a2bb879305

Contents?: true

Size: 1.94 KB

Versions: 1

Compression:

Stored size: 1.94 KB

Contents

require 'test_plugin_helper'

class ForemanBootdisk::Api::V2::DisksControllerTest < ActionController::TestCase
  setup :setup_bootdisk

  test "should generate generic image" do
    ForemanBootdisk::ISOGenerator.expects(:generate).with(has_entry(:ipxe => regexp_matches(/disk generic host template/))).yields("temp ISO")
    File.expects(:read).with("temp ISO").returns("ISO image")
    get :generic, {}
    assert_response :success
    assert_equal "ISO image", @response.body
  end

  describe "#host" do
    setup :setup_host_env

    test "should generate host image" do
      ForemanBootdisk::ISOGenerator.expects(:generate).with(has_entry(:ipxe => regexp_matches(/disk host template/))).yields("temp ISO")
      File.expects(:read).with("temp ISO").returns("ISO image")
      get :host, {:id => @host.name}
      assert_response :success
      assert_equal "ISO image", @response.body
    end

    test "should generate full host image" do
      ForemanBootdisk::ISOGenerator.expects(:generate_full_host).with(@host).yields("temp ISO")
      File.expects(:read).with("temp ISO").returns("ISO image")
      get :host, {:id => @host.name, :full => true}
      assert_response :success
      assert_equal "ISO image", @response.body
    end
  end

  describe "default API version 2" do
    setup :setup_host_env

    test "path - /api/hosts/:host_id routes to #host" do
      assert_routing "/api/hosts/#{@host.id}",
                     :format     => "json",
                     :apiv       => "v2",
                     :controller => "foreman_bootdisk/api/v2/disks",
                     :action     => "host",
                     :id         => @host.id.to_s
    end

    test "path - /api/generic routes to #generic" do
      assert_routing "/api/generic",
                     :format     => "json",
                     :apiv       => "v2",
                     :controller => "foreman_bootdisk/api/v2/disks",
                     :action     => "generic"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
foreman_bootdisk-8.1.0 test/functional/foreman_bootdisk/api/v2/disks_controller_test.rb