fix: Split database name from rules at the last possible function

When updating database rules, the database name should come from the
rules. Enforce this by only taking the rules as a parameter, rather than
having two arguments that could possibly disagree with each other.
pull/24376/head
Carol (Nichols || Goulding) 2021-10-28 14:59:52 -04:00
parent ddd207bccd
commit c02e476175
No known key found for this signature in database
GPG Key ID: E907EE5A736F87D4
2 changed files with 4 additions and 8 deletions

View File

@ -157,10 +157,9 @@ where
description: e.to_string(),
})?;
let db_name = provided_rules.db_name().clone();
let updated_rules = self
.server
.update_db_rules(&db_name, provided_rules)
.update_db_rules(provided_rules)
.await
.map_err(default_server_error_handler)?;

View File

@ -1008,10 +1008,10 @@ where
/// Update database rules and save on success.
pub async fn update_db_rules(
&self,
db_name: &DatabaseName<'_>,
rules: ProvidedDatabaseRules,
) -> Result<Arc<ProvidedDatabaseRules>> {
let database = self.database(db_name)?;
let db_name = rules.db_name().clone();
let database = self.database(&db_name)?;
// attempt to save provided rules in the current state
Ok(database
@ -2417,10 +2417,7 @@ mod tests {
};
let provided_rules = make_provided_rules(rules);
server
.update_db_rules(&db_name, provided_rules)
.await
.unwrap();
server.update_db_rules(provided_rules).await.unwrap();
}
#[tokio::test]