Skip to content

Commit

Permalink
When creating repositories, factor in the provided user if any.
Browse files Browse the repository at this point in the history
This enables creation of repositories under organizations.
  • Loading branch information
danp committed Jan 13, 2011
1 parent 31d862f commit 658ded1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/octopi/repository.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ def languages
def self.create(options={})
raise AuthenticationRequired, "To create a repository you must be authenticated." if Api.api.read_only?
self.validate_args(options[:name] => :repo)
if options[:user]
self.validate_args(options[:user] => :user)
options[:name] = "#{options[:user]}/#{options[:name]}"
end
new(Api.api.post(path_for(:create), options.merge( :cache => false ))["repository"])
end

Expand Down
6 changes: 6 additions & 0 deletions test/repository_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ def setup
end
end

should "be able to create a repository under another user (or organization)" do
auth do
Repository.create(:name => "octopus", :user => "other-user")
end
end

should "be able to delete a repository" do
auth do
@repository.delete!
Expand Down

0 comments on commit 658ded1

Please sign in to comment.