bower / registry

The Bower registry
https://registry.bower.io/packages
MIT License
292 stars 66 forks source link

Send a 406 when package is already registered #75

Closed patrickkettner closed 9 years ago

patrickkettner commented 10 years ago

The registry-client is already listening for this code, so we should send it.

benschwarz commented 10 years ago

@patrickkettner I know the test suite is non-existent … but do you think you'd be able to add a test for this?

patrickkettner commented 10 years ago

fer sure

patrickkettner commented 10 years ago

actually quick bikeshedding question -

Obviously I would get this error if I try to reregister a package that is already in the registry, but should there be a different response for packages that are already registered vs conflicting pacakges.

e.g. if I was to register github.com/patrickkettner/jquery, should I get a Package Already Registered err or a Conflict err?

benschwarz commented 10 years ago

Hmm. In your example the issue is the package name, so it should be a Conflict. Package Already Registered is a bit ambiguous. Perhaps the message could be:

<pkgName> is already registered


fer sure

You rule :metal:

rayshan commented 10 years ago

@patrickkettner sorry for the delay, but a few things had to happen before this PR. I'd like to merge it. Could you be so kind to rebase your PR?

patrickkettner commented 10 years ago

sorry for dropping this - the change is incredibly minimal, but the tests proved to be a pain in the arse (getting travis to set up a postgres db, specifically). I'll dig into this more soon

rayshan commented 10 years ago

Np, would stubbing w/ sinonjs help?

http://stackoverflow.com/a/10124424/2152076

patrickkettner commented 10 years ago

Im not sure - having to stub out all of the underlying db calls may be more work than just getting a DB running

rayshan commented 10 years ago

Sorry quick question - shouldn't this be a 409?

409 - Conflict - Indicates that the request could not be processed because of conflict in the request, such as an edit conflict in the case of multiple updates.

406 - Not Acceptable - The requested resource is only capable of generating content not acceptable according to the Accept headers sent in the request.

patrickkettner commented 10 years ago

That was my original iea, however the bower client is already listening for a 406

sheerun commented 9 years ago

Client has been already updated to handle 403, but I liked the tests, so I commited them: https://github.com/bower/registry/commit/c36cfdb979f234ca2d6b4974778cd73bd4af661d