Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Commit

Permalink
Fix an error when creating an app that already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
frodenas committed Dec 11, 2011
1 parent 72af83b commit dd93ad9
Show file tree
Hide file tree
Showing 5 changed files with 233 additions and 114 deletions.
6 changes: 6 additions & 0 deletions app/models/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ def find_app_instances_states(app_info)
def create(name, instances, memsize, url, framework, runtime, service)
raise "Application name cannot be blank" if name.nil? || name.empty?
raise "Invalid application name: \"" + name + "\". Must contain only word characters (letter, number, underscore)" if (name =~ /^[\w-]+$/).nil?
begin
app_info = @cf_client.app_info(name)
rescue
app_info = nil
end
raise "Application name already exists" if !app_info.nil?
raise "Number of instances cannot be blank" if instances.nil? || instances.empty?
raise "Number of instances must be numeric" if (instances =~ /^\d+$/).nil?
raise "There must be at least 1 instance" if instances.to_i < 1
Expand Down
201 changes: 111 additions & 90 deletions spec/fixtures/models/logged/app_create_action.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions spec/fixtures/models/logged/app_create_duplicate_action.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit dd93ad9

Please sign in to comment.