Skip to content
Browse files

Don't break on invalid or missing environment.

  • Loading branch information...
1 parent d835a7b commit 201cb8637e84fe7904a194a94b8ace51be2a03cc @Manfred Manfred committed Mar 7, 2011
Showing with 7 additions and 1 deletion.
  1. +1 −1 app/models/Application.m
  2. +6 −0 test/passenger_pane/application_test.nu
View
2 app/models/Application.m
@@ -69,7 +69,7 @@ - (NSMutableDictionary*) toDictionary {
[data setValue:self.host forKey:@"host"];
[data setValue:self.aliases forKey:@"aliases"];
[data setValue:self.path forKey:@"path"];
- if (environment) {
+ if (environment && environment < [environments count]) {
[data setValue:[environments objectAtIndex:environment] forKey:@"environment"];
} else {
[data setValue:[environments objectAtIndex:0] forKey:@"environment"];
View
6 test/passenger_pane/application_test.nu
@@ -74,6 +74,12 @@
(set arguments (@application toArgumentArray))
(~ (arguments list) should equal:`("-path" "/path/to/test" "-environment" "production" "-host" "test.local" "-config_filename" "/path/to/test.conf" "-aliases" "assets.test.local"))
))
+
+ (it "doesn't break when updating with an invalid environment" (do ()
+ (@attributes setValue:nil forKey:"environment")
+ (@application updateAttributes:@attributes)
+ (~ (@application environment) should be:0)
+ ))
))
(describe "An Application, concering validation" `(

0 comments on commit 201cb86

Please sign in to comment.
Something went wrong with that request. Please try again.