mirror of
https://github.com/opf/openproject.git
synced 2026-06-13 19:20:00 +00:00
Fix specs
This commit is contained in:
@@ -41,19 +41,21 @@ example:
|
||||
elements:
|
||||
- _type: UserNonWorkingTime
|
||||
id: 7
|
||||
date: "2025-06-18"
|
||||
startDate: "2025-06-16"
|
||||
endDate: "2025-06-20"
|
||||
_links:
|
||||
self:
|
||||
href: /api/v3/users/42/non_working_times/2025-06-16
|
||||
href: /api/v3/users/42/non_working_times/7
|
||||
user:
|
||||
href: /api/v3/users/42
|
||||
title: Jane Doe
|
||||
- _type: UserNonWorkingTime
|
||||
id: 8
|
||||
date: "2025-12-24"
|
||||
startDate: "2025-12-24"
|
||||
endDate: "2025-12-24"
|
||||
_links:
|
||||
self:
|
||||
href: /api/v3/users/42/non_working_times/2025-12-24
|
||||
href: /api/v3/users/42/non_working_times/8
|
||||
user:
|
||||
href: /api/v3/users/42
|
||||
title: Jane Doe
|
||||
|
||||
@@ -38,13 +38,32 @@ RSpec.describe UserWorkingHours do
|
||||
|
||||
it { is_expected.to validate_presence_of(:valid_from) }
|
||||
|
||||
# The *_hours virtual attributes have a converting setter (hours → minutes), so
|
||||
# shoulda-matchers cannot induce invalid states through it. We bypass the setter
|
||||
# and write directly to the underlying minute column instead.
|
||||
%i[monday tuesday wednesday thursday friday saturday sunday].each do |day|
|
||||
it { is_expected.to validate_presence_of(:"#{day}_hours") }
|
||||
describe "##{day}_hours" do
|
||||
it "is invalid when exceeding 24 hours" do
|
||||
subject.public_send(:"#{day}=", (24.5 * 60).round)
|
||||
expect(subject).not_to be_valid
|
||||
expect(subject.errors[:"#{day}_hours"]).to be_present
|
||||
end
|
||||
|
||||
it do
|
||||
expect(subject).to validate_numericality_of(:"#{day}_hours")
|
||||
.is_greater_than_or_equal_to(0)
|
||||
.is_less_than_or_equal_to(24)
|
||||
it "is invalid when negative" do
|
||||
subject.public_send(:"#{day}=", -60)
|
||||
expect(subject).not_to be_valid
|
||||
expect(subject.errors[:"#{day}_hours"]).to be_present
|
||||
end
|
||||
|
||||
it "is valid at 0 hours" do
|
||||
subject.public_send(:"#{day}=", 0)
|
||||
expect(subject).to be_valid
|
||||
end
|
||||
|
||||
it "is valid at 24 hours" do
|
||||
subject.public_send(:"#{day}=", 24 * 60)
|
||||
expect(subject).to be_valid
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ module Pages
|
||||
end
|
||||
|
||||
def expect_working_days_count(count)
|
||||
expect(page).to have_field(I18n.t(:label_working_days), disabled: true, with: count.to_s)
|
||||
expect(page).to have_field(I18n.t(:label_working_days), with: count.to_s)
|
||||
end
|
||||
|
||||
def expect_sidebar_entry(text)
|
||||
|
||||
Reference in New Issue
Block a user