Skip to content

Add Time Zone Select#6437

Open
tvdeyen wants to merge 8 commits into
solidusio:mainfrom
blish:timezone-select
Open

Add Time Zone Select#6437
tvdeyen wants to merge 8 commits into
solidusio:mainfrom
blish:timezone-select

Conversation

@tvdeyen

@tvdeyen tvdeyen commented Apr 15, 2026

Copy link
Copy Markdown
Member

Summary

Adding a timezone select into the various admin/backend navigations we have. Allows for users to see dates in the admin in the selected timezone. If the current solidus user record has a preferred timezone this is used instead. The resolved timezone is stored in the users session.

Checklist

Check out our PR guidelines for more details.

The following are mandatory for all PRs:

The following are not always needed:

  • 📖 I have updated the README to account for my changes.
  • 📑 I have documented new code with YARD.
  • 🛣️ I have opened a PR to update the guides.
  • ✅ I have added automated tests to cover my changes.
  • 📸 I have attached screenshots to demo visual changes.

@tvdeyen tvdeyen added the type:enhancement Proposed or newly added feature label Apr 15, 2026
@tvdeyen tvdeyen self-assigned this Apr 15, 2026
@github-actions github-actions Bot added changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem changelog:solidus_admin labels Apr 15, 2026
@codecov

codecov Bot commented Apr 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.70%. Comparing base (8d781ac) to head (b703657).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6437      +/-   ##
==========================================
+ Coverage   89.68%   89.70%   +0.01%     
==========================================
  Files         993      994       +1     
  Lines       20863    20886      +23     
==========================================
+ Hits        18712    18735      +23     
  Misses       2151     2151              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@tvdeyen tvdeyen force-pushed the timezone-select branch 4 times, most recently from 899d5a5 to c8011a0 Compare April 23, 2026 08:11
@tvdeyen tvdeyen marked this pull request as ready for review April 23, 2026 08:12
@tvdeyen tvdeyen requested a review from a team as a code owner April 23, 2026 08:12
@tvdeyen tvdeyen removed their assignment Apr 24, 2026
tvdeyen added 8 commits June 10, 2026 17:04
By including this module into a controller it will
run all controller actions within the defined timezone.

The timezone is taken from the params, the session, user preference (if existing), or the default timezone of the app.
The resolved timezone is then stored in the session for future
reference.
Use the `Spree::Core::ControllerHelpers::Timezone` module
to wrap all admin actions inside the selected timezone.
Use the `Spree::Core::ControllerHelpers::Timezone` module
to wrap all admin actions inside the selected timezone.

Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
Spans do not self close and this actually has a closing tag
anyway.

Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
Signed-off-by: Thomas von Deyen <vondeyen@blish.cloud>
If the user has a timezone column we show
a select to let admins set the preferred time
zone of the user.
If the user has a timezone column we show
a select to let admins set the preferred time
zone of the user.
it "sets timezone by param" do
get :index, params: {solidus_timezone: "Hawaii"}
expect(session).to have_key(:solidus_timezone)
expect(session[:solidus_timezone]).to eq("Hawaii")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end

it "sets timezone by param" do
get :index, params: {solidus_timezone: "Hawaii"}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/SpaceInsideHashLiteralBraces: Space inside { missing.
Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.
Layout/SpaceInsideHashLiteralBraces: Space inside } missing.

expect(response.code).to eq "200"
end

it "sets timezone by param" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

end

context "successful request" do
context "authorized request" do

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

let(:sign_in_date) { DateTime.now }

before do
allow_any_instance_of(Spree.user_class).to receive(:try).with(:timezone) { nil }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [86/80]

let!(:user) { create :user }

before { expect(controller).to receive(:spree_current_user).and_return(user) }
before { expect(controller).to receive(:spree_current_user).twice.and_return(user) }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [92/80]


# Checks if we need to change the timezone or not.
def timezone_change_needed?
params[:solidus_timezone].present? || session[:solidus_timezone].blank?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Metrics/LineLength: Line is too long. [81/80]

resolved_timezone || Time.zone.name
else
session[:solidus_timezone]
end

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/EndAlignment: end at 26, 10 is not aligned with if at 22, 21.

def set_timezone(&action)
timezone = if timezone_change_needed?
resolved_timezone || Time.zone.name
else

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/ElseAlignment: Align else with if.

#
def set_timezone(&action)
timezone = if timezone_change_needed?
resolved_timezone || Time.zone.name

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/IndentationWidth: Use 2 (not -9) spaces for indentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:solidus_admin changelog:solidus_backend Changes to the solidus_backend gem changelog:solidus_core Changes to the solidus_core gem type:enhancement Proposed or newly added feature

Projects

Status: No status
Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants