output_changed? or
log_changed? or
tasks_summary_changed? or
- state_changed? or
+ (state_changed? && state != Cancelled) or
components_changed?
logger.warn "User #{current_user.uuid if current_user} tried to change protected job attributes on locked #{self.class.to_s} #{uuid_was}"
return false
I18n.enforce_available_locales = false
+ # Before using the filesystem backend for Rails.cache, check
+ # whether we own the relevant directory. If we don't, using it is
+ # likely to either fail or (if we're root) pollute it and cause
+ # other processes to fail later.
default_cache_path = Rails.root.join('tmp', 'cache')
if not File.owned?(default_cache_path)
- # If we don't own the cache dir, using it will either fail or
- # (if we're root) pollute it so other processes fail later.
STDERR.puts("Defaulting to memory cache, because #{default_cache_path} " \
"owner (uid=#{File::Stat.new(default_cache_path).uid}) " \
"is not me (uid=#{Process.euid})")
assert_equal "Failed", job.state
end
+ test "admin user can cancel a running job despite lock" do
+ set_user_from_auth :active_trustedclient
+ job = Job.create! job_attrs
+ job.lock current_user.uuid
+ assert_equal Job::Running, job.state
+
+ set_user_from_auth :spectator
+ assert_raises do
+ job.update_attributes!(state: Job::Cancelled)
+ end
+
+ set_user_from_auth :admin
+ job.reload
+ assert_equal Job::Running, job.state
+ job.update_attributes!(state: Job::Cancelled)
+ assert_equal Job::Cancelled, job.state
+ end
+
test "verify job queue position" do
job1 = Job.create! job_attrs
assert_equal 'Queued', job1.state, "Incorrect job state for newly created job1"