mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Expire hid_counter on db_next_hid() call
This commit is contained in:
@@ -51,6 +51,7 @@ def db_next_hid(self, n=1):
|
||||
else:
|
||||
stmt = table.update().where(table.c.id == model.cached_id(self)).values(hid_counter=(table.c.hid_counter + n)).returning(table.c.hid_counter)
|
||||
next_hid = session.execute(stmt).scalar() - n
|
||||
session.expire(self, ['hid_counter'])
|
||||
return next_hid
|
||||
|
||||
|
||||
|
||||
@@ -920,6 +920,21 @@ class MappingTests(BaseModelTestCase):
|
||||
assert security_agent.can_manage_dataset(u_from.all_roles(), d1.dataset)
|
||||
assert not security_agent.can_manage_dataset(u_other.all_roles(), d1.dataset)
|
||||
|
||||
def test_history_hid_counter_is_expired_after_next_hid_call(self):
|
||||
u = model.User(email="hid_abuser@example.com", password="password")
|
||||
h = model.History(name="History for hid testing", user=u)
|
||||
self.persist(u, h)
|
||||
state = inspect(h)
|
||||
assert h.hid_counter == 1
|
||||
assert 'hid_counter' not in state.unloaded
|
||||
assert 'id' not in state.unloaded
|
||||
|
||||
h._next_hid()
|
||||
|
||||
assert 'hid_counter' in state.unloaded # this attribute has been expired
|
||||
assert 'id' not in state.unloaded # but other attributes have NOT been expired
|
||||
assert h.hid_counter == 2 # check this last: this causes thie hid_counter to be reloaded
|
||||
|
||||
def _three_users(self, suffix):
|
||||
email_from = f"user_{suffix}e1@example.com"
|
||||
email_to = f"user_{suffix}e2@example.com"
|
||||
|
||||
Reference in New Issue
Block a user