Skip to content

Don't return 404 if .cargo-ok file exists #830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/web/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl FileList {

// skip .cargo-ok generated by cargo
if path == ".cargo-ok" {
return None;
continue;
}

// look only files for req_path
Expand Down Expand Up @@ -261,6 +261,7 @@ pub fn source_browser_handler(req: &mut Request) -> IronResult<Response> {
#[cfg(test)]
mod tests {
use super::*;
use crate::test::{assert_success, wrapper};
use serde_json::json;

#[test]
Expand Down Expand Up @@ -306,4 +307,20 @@ mod tests {

assert_eq!(correct_json, serde_json::to_value(&file_list).unwrap(),);
}

#[test]
fn cargo_ok_not_skipped() {
wrapper(|env| {
let db = env.db();
db.fake_release()
.name("fake")
.version("0.1.0")
.source_file(".cargo-ok", b"ok")
.source_file("README.md", b"hello")
.create()?;
let web = env.frontend();
assert_success("/crate/fake/0.1.0/source/", web)?;
Ok(())
});
}
}