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

fix specs

Klaus Zandersfbdbecfa12dd
diff --git a/modules/costs/app/contracts/time_entries/update_contract.rb b/modules/costs/app/contracts/time_entries/update_contract.rb
index ddc228b08fa..7084f2ddd88 100644
--- a/modules/costs/app/contracts/time_entries/update_contract.rb
+++ b/modules/costs/app/contracts/time_entries/update_contract.rb
@@ -62,9 +62,10 @@ module TimeEntries
end
def user_allowed_to_modify_ongoing?(time_entry)
- model.user == user && (user.allowed_in_project?(:log_time,
- time_entry.project) || user.allowed_in_work_package?(:log_own_time,
- time_entry.work_package))
+ model.user == user && (
+ user.allowed_in_project?(:log_time, time_entry.project) ||
+ user.allowed_in_work_package?(:log_own_time, time_entry.work_package)
+ )
end
end
end
diff --git a/modules/costs/app/controllers/time_entries_controller.rb b/modules/costs/app/controllers/time_entries_controller.rb
index d2b9de27bcf..3cc1e5d412c 100644
--- a/modules/costs/app/controllers/time_entries_controller.rb
+++ b/modules/costs/app/controllers/time_entries_controller.rb
@@ -168,10 +168,11 @@ class TimeEntriesController < ApplicationController
def load_or_build_and_authorize_time_entry
@time_entry = if params[:id]
- TimeEntry.visible.find_by(id: params[:id]).tap do |entry|
- if entry.blank? || !TimeEntries::UpdateContract.new(entry, current_user).user_allowed_to_update?
- deny_access(not_found: true)
- end
+ entry = TimeEntry.find_by(id: params[:id])
+ if entry.blank? || !TimeEntries::UpdateContract.new(entry, current_user).user_allowed_to_update?
+ deny_access(not_found: true)
+ else
+ entry
end
else
TimeEntry.new(project: @project, work_package: @work_package, user: User.current)
diff --git a/modules/costs/spec/features/timer_spec.rb b/modules/costs/spec/features/timer_spec.rb
index 3e52fac5169..0165bfa407e 100644
--- a/modules/costs/spec/features/timer_spec.rb
+++ b/modules/costs/spec/features/timer_spec.rb
@@ -28,7 +28,7 @@
require_relative "../spec_helper"
-RSpec.describe "Work Package timer", :js do
+RSpec.describe "Work Package timer", :js, :selenium do
shared_let(:project) { create(:project_with_types) }
shared_let(:work_package_a) { create(:work_package, subject: "WP A", project:) }
@@ -128,7 +128,7 @@ RSpec.describe "Work Package timer", :js do
end
context "when user has permission to log time" do
- let(:permissions) { %i[log_own_time edit_own_time_entries view_own_time_entries view_work_packages] }
+ let(:permissions) { %i[log_own_time edit_own_time_entries view_own_time_entries view_work_packages view_project] }
it_behaves_like "allows time tracking"
@@ -164,7 +164,7 @@ RSpec.describe "Work Package timer", :js do
expect(page).to have_css(".op-timer-stop-modal")
expect(page).to have_text("Tracking time:")
- page.within(".spot-modal") { click_button "Stop current timer" }
+ page.within(".spot-modal") { click_on "Stop current timer" }
time_logging_modal.is_visible true
time_logging_modal.has_field_with_value "spent_on", Date.current.strftime
@@ -197,7 +197,7 @@ RSpec.describe "Work Package timer", :js do
end
context "when user has no permission to log time" do
- let(:permissions) { %i[view_work_packages] }
+ let(:permissions) { %i[view_work_packages view_project] }
it "does not show the timer" do
wp_view_a.visit!
@@ -209,13 +209,13 @@ RSpec.describe "Work Package timer", :js do
end
context "when user has permission to add, but not edit or view" do
- let(:permissions) { %i[view_work_packages log_own_time] }
+ let(:permissions) { %i[view_work_packages log_own_time view_project] }
it_behaves_like "allows time tracking"
end
context "when user has permission to add and view but not edit" do
- let(:permissions) { %i[view_work_packages log_own_time view_own_logged_time] }
+ let(:permissions) { %i[view_work_packages log_own_time view_own_logged_time view_project] }
it_behaves_like "allows time tracking"
end
diff --git a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
index a253a85f858..d665a26664b 100644
--- a/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
+++ b/modules/my_page/spec/features/my/time_entries_current_user_spec.rb
@@ -30,7 +30,8 @@ require "spec_helper"
require_relative "../../support/pages/my/page"
-RSpec.describe "My page time entries current user widget spec", :js do
+# Test is flaky when using cuprite, but steady with selenium
+RSpec.describe "My page time entries current user widget spec", :js, :selenium do
let!(:type) { create(:type) }
let!(:project) { create(:project, types: [type]) }
let!(:activity) { create(:time_entry_activity) }
@@ -288,7 +289,7 @@ RSpec.describe "My page time entries current user widget spec", :js do
uncheck "Monday" # the day visible_time_entry is logged for
- click_button "Apply"
+ click_on "Apply"
within entries_area.area do
expect(page)
diff --git a/spec/features/support/components/time_logging_modal.rb b/spec/features/support/components/time_logging_modal.rb
index 338642f5a50..ba5664bb7bb 100644
--- a/spec/features/support/components/time_logging_modal.rb
+++ b/spec/features/support/components/time_logging_modal.rb
@@ -145,7 +145,7 @@ module Components
private
def modal_container
- page.find("dialog#time-entry-dialog")
+ page.find("dialog#time-entry-dialog", visible: :all)
end
end
end