Skip to content
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

Files listed under other files are not authorized #385

Merged
merged 3 commits into from Mar 13, 2015

Conversation

andreeap
Copy link
Contributor

@andreeap andreeap commented Feb 1, 2015

This is a new pull request for #110 because I cleaned my commit history and rebased and somehow the pull request got closed automatically. This commit is ready for review.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 88.68% when pulling 88c74c2 on andreeap:issue-110 into 141117f on CPAN-API:master.

@oalders
Copy link
Member

oalders commented Feb 11, 2015

To me, this looks to be ready to merge. @rwstauner any comments?

@@ -212,6 +212,13 @@ subtest 'Packages starting with underscore are not indexed' => sub {
is( $file->module->[0]->indexed, 0, 'Package is not indexed' );
};

subtest 'files listed under other files' => sub {
my $file = new_file_doc( name => 'Makefile.PL' );
$file->set_authorized( $file->module => $file->author );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These arguments ( $file->module => $file->author ) are confusing as they don't match the sub definition.
They would probably throw an error except that your change returns from the sub before the arguments are used.
Please remove them to avoid someone looking at the code and then wondering the same thing that I just did.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, after reading the pod for the sub I see that you were perhaps intending to emulate the $perms argument
in which case there are different problems:
$file->module is an array ref (see the previous test) not a module name, and the method accepts a hash ref so you'd need curly braces around the module/author pair, something like
( { $file->module->[0]->{name} => $file->author } ).
Problem there is that these "other" files are unlikely to ever have modules.

I think passing an empty hash ref would suffice: ( {} ).
That way if the code goes past the "other files" check it won't error on not getting a hashref.
Files that are not "other files" should still get authorized then (which would be what you want in this case).

@rwstauner
Copy link
Contributor

I wasn't sure why we were using "authorized" for this until I read through #110 and found that exact suggestion.
I question whether it should be "indexed" or "authorized" that is used for this (see #323 for comparison).

It would be an easy swap.
Does any one have any thoughts on that?

@andreeap
Copy link
Contributor Author

I made the change in the test, but I am not sure what to do about the authorized/indexed issue. After I read #323, I understood better the difference between them and now it makes more sense to set indexed => false.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 88.68% when pulling 1539923 on andreeap:issue-110 into 141117f on CPAN-API:master.

@oalders
Copy link
Member

oalders commented Feb 18, 2015

@rwstauner does this look good to you now?

@rwstauner
Copy link
Contributor

@oalders I was hoping you'd chime in on the "indexed vs authorized" question ;-)

@oalders
Copy link
Member

oalders commented Feb 18, 2015

@rwstauner I just had another look #110. You're correct. indexed => false is really what we want here. We don't want these files to show up in searches, so that's clearly the right flag here.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 88.61% when pulling c8ac5ba on andreeap:issue-110 into 141117f on CPAN-API:master.

@andreeap
Copy link
Contributor Author

I think this is ready if you can take a look at it.

@oalders
Copy link
Member

oalders commented Feb 18, 2015

Looks good. @rwstauner ?

@rwstauner
Copy link
Contributor

The test passes because the file doesn't contain any content that would get it indexed.

The original issue (#110) mentioned a Makefile.PL with some (specific) pod, so that would be a good thing to test.

If you add something like this to your subtest:

    $file = new_file_doc( name => 'Makefile.PL', content => \<<EOF, );
=head1 NAME

Makefile.PL - blah

=head1 SYNOPSIS
EOF
    is( $file->indexed, 0, 'Makefile.PL with pod not indexed' );

it will expose a small (but familiar) bug in your code.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 88.74% when pulling b1c0cd1 on andreeap:issue-110 into 916b0e3 on CPAN-API:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 88.81% when pulling b1c0cd1 on andreeap:issue-110 into 916b0e3 on CPAN-API:master.

@andreeap
Copy link
Contributor Author

@rwstauner I did this mistake before, but again I didn't see it because of the test. I hope now it's better.

content_cb => sub { \$content }
);

$file->set_indexed( {} );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This lines isn't necessary, new_file_doc calls set_indexed.

@rwstauner
Copy link
Contributor

Glad to see you're learning ;-)

@coveralls
Copy link

Coverage Status

Coverage increased (+0.0%) to 88.74% when pulling 1e714ed on andreeap:issue-110 into 916b0e3 on CPAN-API:master.

@andreeap
Copy link
Contributor Author

@rwstauner Thanks, I am glad too :)
I removed the line and please let me know if there is something else I could do.
@oalders It's ready for review.

@oalders
Copy link
Member

oalders commented Mar 13, 2015

👍

oalders added a commit that referenced this pull request Mar 13, 2015
Files listed under other files are not authorized
@oalders oalders merged commit be4d4d8 into metacpan:master Mar 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants