Skip to content

Commit

Permalink
make filter beta addons button persistent (bnc#996891)
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Oct 3, 2016
1 parent 327ab34 commit adf0111
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/registration/ui/addon_selection_base_dialog.rb
Expand Up @@ -23,6 +23,10 @@ class AddonSelectionBaseDialog
Yast.import "Stage"
Yast.import "Arch"

class << self
attr_accessor :filter_beta
end

FILTER_BETAS_INITIALLY = true

# constructor
Expand All @@ -35,7 +39,9 @@ def initialize(registration)
# sort the addons
@all_addons.sort!(&::Registration::ADDON_SORTER)

filter_beta_releases(FILTER_BETAS_INITIALLY)
self.class.filter_beta = FILTER_BETAS_INITIALLY if self.class.filter_beta.nil?

filter_beta_releases(self.class.filter_beta)

@old_selection = Addon.selected.dup

Expand Down Expand Up @@ -64,6 +70,7 @@ def addon_widget_id(addon)
# Enables or disables beta addons filtering
# @param [Boolean] enable true for filtering beta releases
def filter_beta_releases(enable)
self.class.filter_beta = enable
@addons = enable ? @all_addons.reject(&:beta_release?) : @all_addons
end

Expand Down
11 changes: 11 additions & 0 deletions test/addon_selection_dialog_test.rb
Expand Up @@ -17,6 +17,17 @@
addon_reset_cache
end

describe "#initialize" do
it "sets filter beta to previous state" do
fake_ref = double.as_null_object
res = described_class.new(fake_ref)
res.send(:filter_beta_releases, false)

expect_any_instance_of(described_class).to receive(:filter_beta_releases).with(false)
described_class.new(fake_ref)
end
end

describe ".run" do
subject { Registration::UI::AddonSelectionRegistrationDialog }

Expand Down

0 comments on commit adf0111

Please sign in to comment.