Skip to content
Permalink
Browse files

Add a LicenseTranslationsButton widget

  • Loading branch information...
imobachgs committed Feb 9, 2018
1 parent 14066fc commit e16458639bfbd0bc865604db3a4405babb01a3da
@@ -0,0 +1,46 @@
# ------------------------------------------------------------------------------
# Copyright (c) 2018 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.
# ------------------------------------------------------------------------------

require "yast"
require "cwm"
require "y2packager/dialogs/product_license"

module Y2Packager
module Widgets
# This button launches the licenses translations dialog when pushed
class LicenseTranslationsButton < CWM::PushButton
# @return [Y2Packager::Product] Product
attr_reader :product

def initialize(product)
super()
@product = product
end

# Widget label
#
# @teturn [String] Translated label
# @see CWM::AbstractWidget#label
def label
_("License &Translations...")
end

# Launch the product license translations dialog
#
# @see CWM::AbstractWidget#handle
def handle
Y2Packager::Dialogs::ProductLicense.new(product).run
nil
end
end
end
end
@@ -0,0 +1,40 @@
#!/usr/bin/env rspec
# ------------------------------------------------------------------------------
# Copyright (c) 2017 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.
# ------------------------------------------------------------------------------

require_relative "../../test_helper"
require "cwm/rspec"
require "y2packager/widgets/license_translations_button"
require "y2packager/product"

describe Y2Packager::Widgets::LicenseTranslationsButton do
subject(:widget) { described_class.new(product) }
let(:product) { instance_double(Y2Packager::Product, license: "content") }

describe "#handle" do
let(:dialog) { instance_double(Y2Packager::Dialogs::ProductLicense, run: nil) }

before do
allow(Y2Packager::Dialogs::ProductLicense).to receive(:new)
.with(product).and_return(dialog)
end

it "opens a dialog" do
expect(dialog).to receive(:run)
widget.handle
end

it "returns nil" do
expect(widget.handle).to be_nil
end
end
end

0 comments on commit e164586

Please sign in to comment.
You can’t perform that action at this time.