Skip to content

Commit

Permalink
Do not keep settings radio button state when navigating
Browse files Browse the repository at this point in the history
  • Loading branch information
cbliard authored and oliverguenther committed Sep 20, 2024
1 parent 43d3a96 commit 3b34fd7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/forms/settings_form_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def radio_button_group(name:, values: [], disabled: false, button_options: {}, *
**button_options.reverse_merge(
value:,
checked: setting_value(name) == value,
autocomplete: "off",
label: setting_label(name, value),
caption: setting_caption(name, value)
)
Expand Down
19 changes: 16 additions & 3 deletions spec/features/admin/progress_tracking_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
include Toasts::Expectations

shared_let(:admin) { create(:admin) }
current_user { admin }

it "displays a warning when changing progress calculation mode" do
Setting.work_package_done_ratio = "field"
login_as(admin)
visit admin_settings_progress_tracking_path

# change from work-based to status-based
Expand Down Expand Up @@ -71,8 +71,6 @@
end

it "disables the status closed radio button when changing to status-based" do
login_as(admin)

Setting.work_package_done_ratio = "field"
visit admin_settings_progress_tracking_path
expect(page).to have_field("No change", disabled: false)
Expand All @@ -91,4 +89,19 @@
expect(page).to have_field("No change", disabled: true)
expect(page).to have_field("Automatically set to 100%", disabled: true)
end

it "does not keep radio button state when navigating to another page and back" do
Setting.work_package_done_ratio = "field"
visit admin_settings_progress_tracking_path

find(:radio_button, "Status-based").click

# navigate to another page, then back
click_on "General"
wait_for { page.current_path }.to include(admin_settings_work_packages_general_path)
page.go_back

# browser should not keep the radio button state (autocomplete="off")
expect(page).to have_field("Work-based", checked: true)
end
end

0 comments on commit 3b34fd7

Please sign in to comment.