Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add the create option to partition section
  • Loading branch information
dgdavid committed May 20, 2020
1 parent cbad6fc commit a4246d5
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/lib/autoinstall/widgets/storage/create.rb
@@ -0,0 +1,41 @@
# Copyright (c) [2020] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require "yast"
require "autoinstall/widgets/storage/boolean_selector"

module Y2Autoinstallation
module Widgets
module Storage
# Widget to specify if a partition or logical volume must be created
class Create < BooleanSelector
# Constructor
def initialize
textdomain "autoinst"
super
end

# @macro seeAbstractWidget
def label
_("Create")
end
end
end
end
end
9 changes: 9 additions & 0 deletions src/lib/autoinstall/widgets/storage/partition_general_tab.rb
Expand Up @@ -22,6 +22,7 @@
require "cwm/replace_point"
require "cwm/common_widgets"
require "autoinstall/widgets/storage/lvm_partition_attrs"
require "autoinstall/widgets/storage/create"
require "autoinstall/widgets/storage/size_selector"

module Y2Autoinstallation
Expand Down Expand Up @@ -50,6 +51,7 @@ def contents
HWeight(1, size_widget),
HWeight(2, HStretch())
),
Left(create_widget),
Left(section_related_attrs),
VStretch()
)
Expand Down Expand Up @@ -85,6 +87,13 @@ def size_widget
@size_widget ||= SizeSelector.new
end

# Widget to set if the partition should be created or not
#
# @return [Create]
def create_widget
@create_widget ||= Create.new
end

# Convenience method to call proper widget depending on the drive type
def section_related_attrs
method_name = "#{partition.drive_type}_partition_attrs".downcase
Expand Down
34 changes: 34 additions & 0 deletions test/lib/widgets/storage/create_test.rb
@@ -0,0 +1,34 @@
# Copyright (c) [2020] SUSE LLC
#
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of version 2 of the GNU General Public License as published
# by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, contact SUSE LLC.
#
# To contact SUSE LLC about this file by physical or electronic mail, you may
# find current contact information at www.suse.com.

require_relative "../../../test_helper"
require_relative "./shared_examples"
require "autoinstall/widgets/storage/create"

describe Y2Autoinstallation::Widgets::Storage::Create do
subject(:widget) { described_class.new }

include_examples "Y2Autoinstallation::Widgets::Storage::BooleanSelector"

describe "#include_blank?" do
it "returns true" do
expect(subject.include_blank?).to eq(true)
end
end
end

0 comments on commit a4246d5

Please sign in to comment.