Skip to content

Commit 13da7a3

Browse files
committed
controllers/krate/publish: Extract MISSING_RIGHTS_ERROR_MESSAGE constant
This will allow us to use the constant in tests
1 parent 4c56629 commit 13da7a3

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/controllers/krate/publish.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ use crate::render;
1616
use crate::util::{read_fill, read_le_u32, Maximums};
1717
use crate::views::{EncodableCrateUpload, GoodCrate, PublishWarnings};
1818

19+
pub const MISSING_RIGHTS_ERROR_MESSAGE: &str =
20+
"this crate exists but you don't seem to be an owner. \
21+
If you believe this is a mistake, perhaps you need \
22+
to accept an invitation to be an owner before \
23+
publishing.";
24+
1925
/// Handles the `PUT /crates/new` route.
2026
/// Used by `cargo publish` to publish a new crate or to publish a new version of an
2127
/// existing crate.
@@ -98,12 +104,7 @@ pub fn publish(req: &mut dyn RequestExt) -> EndpointResult {
98104

99105
let owners = krate.owners(&conn)?;
100106
if user.rights(req.app(), &owners)? < Rights::Publish {
101-
return Err(cargo_err(
102-
"this crate exists but you don't seem to be an owner. \
103-
If you believe this is a mistake, perhaps you need \
104-
to accept an invitation to be an owner before \
105-
publishing.",
106-
));
107+
return Err(cargo_err(MISSING_RIGHTS_ERROR_MESSAGE));
107108
}
108109

109110
if krate.name != *name {

0 commit comments

Comments
 (0)