mirror of
https://github.com/rickbarrette/stopwatch.git
synced 2026-11-17 11:50:36 -05:00
- Maximum timer length setting (default 10h): a timer that runs past it is stopped at the limit and its entry's comment is flagged, so a forgotten timer can't add a night or weekend of hours - StopwatchTimerTickJob saves a running timer's time every minute on the server (no browser needed) and stops it at the limit on time; open tabs keep saving too - Timer updates lock the user's preference row and re-read the timer, so simultaneous saves (several tabs, the job) never add time twice - Closing an issue stops timers running on it before anything else (e.g. billing) uses its time; deleting a time entry only stops the timer running on that entry - Issue timers require a visible issue; starting again moves the timer instead of raising "timer is already running" - Tests updated and extended (limit, locking, tick job, close, delete, visibility, issue context menu); CI runs on Redmine 7.0 - Upstream's German notes translated Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
43 lines
1.5 KiB
Ruby
43 lines
1.5 KiB
Ruby
require File.expand_path('../../test_helper', __FILE__)
|
|
|
|
class IssueCloseTest < ActiveSupport::TestCase
|
|
fixtures :projects, :users, :user_preferences, :roles, :members, :member_roles,
|
|
:trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
|
|
:enumerations, :time_entries
|
|
|
|
setup do
|
|
@user = User.find 2
|
|
@issue = Issue.find 1
|
|
@time_entry = TimeEntry.create!(project: @issue.project, issue: @issue, user: @user, author: @user,
|
|
spent_on: Date.today, hours: 1, activity: TimeEntryActivity.first)
|
|
@timer = Stopwatch::Timer.new(@user)
|
|
@timer.start @time_entry
|
|
data = @timer.send(:data)
|
|
data[:started_at] = 1.hour.ago.to_i
|
|
@timer.save
|
|
end
|
|
|
|
test "closing an issue stops a timer running on it and saves the time" do
|
|
@issue.status = IssueStatus.where(is_closed: true).first
|
|
@issue.save!
|
|
|
|
refute Stopwatch::Timer.new(User.find(@user.id)).running?
|
|
assert_in_delta 2, @time_entry.reload.hours, 0.01
|
|
end
|
|
|
|
test "other changes to the issue leave the timer running" do
|
|
@issue.subject = 'Renamed'
|
|
@issue.save!
|
|
|
|
assert Stopwatch::Timer.new(User.find(@user.id)).running?
|
|
end
|
|
|
|
test "deleting another time entry leaves the timer running" do
|
|
other = TimeEntry.create!(project: @issue.project, issue: @issue, user: @user, author: @user,
|
|
spent_on: Date.today, hours: 1, activity: TimeEntryActivity.first)
|
|
other.destroy
|
|
|
|
assert Stopwatch::Timer.new(User.find(@user.id)).running?
|
|
end
|
|
end
|