Skip to content

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

Mark correct today date for the my time tracking page

Klaus Zandersb34319aeb17e
diff --git a/modules/costs/app/controllers/my/time_tracking_controller.rb b/modules/costs/app/controllers/my/time_tracking_controller.rb
index da455856fa3..028ba832e54 100644
--- a/modules/costs/app/controllers/my/time_tracking_controller.rb
+++ b/modules/costs/app/controllers/my/time_tracking_controller.rb
@@ -118,11 +118,7 @@ module My
end
def current_date
- case mode
- when :day then Time.zone.today
- when :week, :workweek then Time.zone.today.beginning_of_week(week_start_day)
- when :month then Time.zone.today.beginning_of_month
- end
+ Time.zone.today
end
def load_time_entries(time_scope)
diff --git a/modules/costs/lib/costs/engine.rb b/modules/costs/lib/costs/engine.rb
index 99067fe8b73..a6a56ad0c1d 100644
--- a/modules/costs/lib/costs/engine.rb
+++ b/modules/costs/lib/costs/engine.rb
@@ -144,7 +144,7 @@ module Costs
menu :global_menu,
:my_time_tracking,
- { controller: "/my/time_tracking", action: "index" },
+ { controller: "/my/time_tracking", action: "index", date: "today" },
after: :my_page,
caption: :label_my_time_tracking,
if: ->(*) do
diff --git a/modules/costs/spec/controllers/my/time_tracking_controller_spec.rb b/modules/costs/spec/controllers/my/time_tracking_controller_spec.rb
index 78473e5f92e..243f3fad367 100644
--- a/modules/costs/spec/controllers/my/time_tracking_controller_spec.rb
+++ b/modules/costs/spec/controllers/my/time_tracking_controller_spec.rb
@@ -117,9 +117,9 @@ RSpec.describe My::TimeTrackingController do
end
describe "GET /my/time-tracking/week" do
- it "without a date param it uses the beginning of current week" do
+ it "without a date param it uses the current day" do
get :index, params: { mode: :week }
- expect(assigns(:date)).to eq(Date.current.beginning_of_week)
+ expect(assigns(:date)).to eq(Date.current)
end
it "with a date param it uses the given date" do
@@ -127,16 +127,16 @@ RSpec.describe My::TimeTrackingController do
expect(assigns(:date)).to eq(Date.parse("2023-12-31"))
end
- it "with an invalid date param it uses the beginning of current week" do
+ it "with an invalid date param it uses the current day" do
get :index, params: { mode: :week, date: "invalid-date" }
- expect(assigns(:date)).to eq(Date.current.beginning_of_week)
+ expect(assigns(:date)).to eq(Date.current)
end
end
describe "GET /my/time-tracking/month" do
- it "without a date param it uses the beginning of current month" do
+ it "without a date param it uses the current day" do
get :index, params: { mode: :month }
- expect(assigns(:date)).to eq(Date.current.beginning_of_month)
+ expect(assigns(:date)).to eq(Date.current)
end
it "with a date param it uses the given date" do
@@ -144,9 +144,9 @@ RSpec.describe My::TimeTrackingController do
expect(assigns(:date)).to eq(Date.parse("2023-12-31"))
end
- it "with an invalid date param it uses the beginning of current month" do
+ it "with an invalid date param it uses the current day" do
get :index, params: { mode: :month, date: "invalid-date" }
- expect(assigns(:date)).to eq(Date.current.beginning_of_month)
+ expect(assigns(:date)).to eq(Date.current)
end
end
end