-
Notifications
You must be signed in to change notification settings - Fork 46
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
1 parent
8628ae6
commit 7c3e725
Showing
3 changed files
with
45 additions
and
0 deletions.
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
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 |
---|---|---|
|
@@ -6,11 +6,41 @@ class TeamTest < ActiveSupport::TestCase | |
assert_equal "UTC", team.time_zone | ||
end | ||
|
||
test "explicitly set time_zone is not clobbered by first user" do | ||
team = Team.create!(name: "new test team", time_zone: "Eastern Time (US & Canada)") | ||
user = User.create!(email: "[email protected]", password: "password", password_confirmation: "password", time_zone: "Central Time (US & Canada)") | ||
Membership.create!(team: team, user: user) | ||
team.reload | ||
assert_equal "Eastern Time (US & Canada)", team.time_zone | ||
end | ||
|
||
test "a new team gets the time_zone of the first user when they join" do | ||
team = Team.create!(name: "new test team") | ||
user = User.create!(email: "[email protected]", password: "password", password_confirmation: "password", time_zone: "Central Time (US & Canada)") | ||
Membership.create!(team: team, user: user) | ||
team.reload | ||
assert_equal "Central Time (US & Canada)", team.time_zone | ||
end | ||
|
||
test "default UTC time_zone is not clobbered if first user doesn't have a time zone set" do | ||
team = Team.create!(name: "new test team") | ||
user = User.create!(email: "[email protected]", password: "password", password_confirmation: "password", time_zone: nil) | ||
Membership.create!(team: team, user: user) | ||
team.reload | ||
assert_equal "UTC", team.time_zone | ||
end | ||
|
||
test "default UTC time_zone is overwritten once the first user sets a time zone" do | ||
team = Team.create!(name: "new test team") | ||
user = User.create!(email: "[email protected]", password: "password", password_confirmation: "password", time_zone: nil) | ||
Membership.create!(team: team, user: user) | ||
team.reload | ||
assert_equal "UTC", team.time_zone | ||
|
||
user.time_zone = "Central Time (US & Canada)" | ||
user.save | ||
|
||
team.reload | ||
assert_equal "Central Time (US & Canada)", team.time_zone | ||
end | ||
end |