-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
34 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -823,6 +823,39 @@ def build_user_double_with_expired_password(is_expired) | |
end | ||
end | ||
|
||
describe "#time_zone" do | ||
let(:user) { build(:user, preferences:) } | ||
|
||
context "with an existing time zone in the prefs" do | ||
let(:preferences) { { "time_zone" => "Europe/Athens" } } | ||
|
||
it "returns the matching ActiveSupport::TimeZone" do | ||
expect(user.time_zone) | ||
.to eql ActiveSupport::TimeZone["Europe/Athens"] | ||
end | ||
end | ||
|
||
context "with an invalid time zone" do | ||
# Would need to be Etc/UTC or UTC to be valid | ||
let(:preferences) { { "time_zone" => "utc" } } | ||
|
||
it "returns the utc ActiveSupport::TimeZone" do | ||
expect(user.time_zone) | ||
.to eql ActiveSupport::TimeZone["Etc/UTC"] | ||
end | ||
end | ||
|
||
context "without a time zone" do | ||
# Would need to be Etc/UTC or UTC to be valid | ||
let(:preferences) { {} } | ||
|
||
it "returns the utc ActiveSupport::TimeZone" do | ||
expect(user.time_zone) | ||
.to eql ActiveSupport::TimeZone["Etc/UTC"] | ||
end | ||
end | ||
end | ||
|
||
describe "#find_by_mail" do | ||
let!(:user1) { create(:user, mail: "[email protected]") } | ||
let!(:user2) { create(:user, mail: "[email protected]") } | ||
|