OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
restructure i18n spec - use Time.use_zone instead of Time.zone
ulferts0495a96cae36
diff --git a/spec/lib/redmine/i18n_spec.rb b/spec/lib/redmine/i18n_spec.rbindex 34585e021e7..e51c7d5b9f8 100644--- a/spec/lib/redmine/i18n_spec.rb+++ b/spec/lib/redmine/i18n_spec.rb@@ -35,43 +35,45 @@ module OpenProjectlet(:format) { "%d/%m/%Y" }let(:user) { build_stubbed(:user) }- after do- Time.zone = nil- end-- describe "with user time zone" do- before do- login_as user- allow(user).to receive(:time_zone).and_return(ActiveSupport::TimeZone["Athens"])- end+ describe "#format_time_as_date" do+ describe "with user time zone" do+ before do+ login_as user+ allow(user).to receive(:time_zone).and_return(ActiveSupport::TimeZone["Athens"])+ end- it "returns a date in the user timezone for a utc timestamp" do- Time.zone = "UTC"- time = Time.zone.local(2013, 6, 30, 23, 59)- expect(format_time_as_date(time, format)).to eq "01/07/2013"- end+ it "returns a date in the user timezone for a utc timestamp" do+ Time.use_zone("UTC") do+ time = Time.zone.local(2013, 6, 30, 23, 59)+ expect(format_time_as_date(time, format)).to eq "01/07/2013"+ end+ end- it "returns a date in the user timezone for a non-utc timestamp" do- Time.zone = "Berlin"- time = Time.zone.local(2013, 6, 30, 23, 59)- expect(format_time_as_date(time, format)).to eq "01/07/2013"+ it "returns a date in the user timezone for a non-utc timestamp" do+ Time.use_zone("Berlin") do+ time = Time.zone.local(2013, 6, 30, 23, 59)+ expect(format_time_as_date(time, format)).to eq "01/07/2013"+ end+ endend- end- describe "without user time zone" do- before { allow(User.current).to receive(:time_zone).and_return(nil) }+ describe "without user time zone" do+ before { allow(User.current).to receive(:time_zone).and_return(nil) }- it "returns a date in the local system timezone for a utc timestamp" do- Time.zone = "UTC"- time = Time.zone.local(2013, 6, 30, 23, 59)- allow(time).to receive(:localtime).and_return(ActiveSupport::TimeZone["Athens"].local(2013, 7, 1, 1, 59))- expect(format_time_as_date(time, format)).to eq "01/07/2013"- end+ it "returns a date in the local system timezone for a utc timestamp" do+ Time.use_zone("UTC") do+ time = Time.zone.local(2013, 6, 30, 23, 59)+ allow(time).to receive(:localtime).and_return(ActiveSupport::TimeZone["Athens"].local(2013, 7, 1, 1, 59))+ expect(format_time_as_date(time, format)).to eq "01/07/2013"+ end+ end- it "returns a date in the original timezone for a non-utc timestamp" do- Time.zone = "Berlin"- time = Time.zone.local(2013, 6, 30, 23, 59)- expect(format_time_as_date(time, format)).to eq "30/06/2013"+ it "returns a date in the original timezone for a non-utc timestamp" do+ Time.use_zone("Berlin") do+ time = Time.zone.local(2013, 6, 30, 23, 59)+ expect(format_time_as_date(time, format)).to eq "30/06/2013"+ end+ endendend