diff options
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/route_way_cost_unit_converter.rb | 14 | ||||
| -rw-r--r-- | lib/tasks/ci.rake | 17 |
2 files changed, 21 insertions, 10 deletions
diff --git a/lib/route_way_cost_unit_converter.rb b/lib/route_way_cost_unit_converter.rb index 45edbf538..52515e52c 100644 --- a/lib/route_way_cost_unit_converter.rb +++ b/lib/route_way_cost_unit_converter.rb @@ -8,18 +8,24 @@ class RouteWayCostUnitConverter end end - private - # Round to 2 decimal places to appease JavaScript validation def self.meters_to_kilometers(num) return 0 unless num - (num / 1000.0).to_i + snap_to_one(num / 1000.0).to_i end def self.seconds_to_minutes(num) return 0 unless num - num / 60 + snap_to_one(num / 60.0).to_i + end + + private + + def self.snap_to_one(decimal) + return 1 if decimal > 0 && decimal <= 1 + + decimal end end diff --git a/lib/tasks/ci.rake b/lib/tasks/ci.rake index 5b2c8ae3c..d025a9bf1 100644 --- a/lib/tasks/ci.rake +++ b/lib/tasks/ci.rake @@ -10,6 +10,7 @@ namespace :ci do desc "Prepare CI build" task :setup do + cp "config/database.yml", "config/database.yml.orig" cp "config/database/ci.yml", "config/database.yml" puts "Use #{database_name} database" sh "RAILS_ENV=test rake db:drop db:create db:migrate" @@ -28,6 +29,7 @@ namespace :ci do end def deploy_env + return ENV["DEPLOY_ENV"] if ENV["DEPLOY_ENV"] if git_branch == "master" "dev" elsif git_branch.in?(deploy_envs) @@ -54,12 +56,12 @@ namespace :ci do desc "Deploy after CI" task :deploy do - return if ENV["CHOUETTE_DEPLOY_DISABLED"] - - if deploy_env - sh "cap #{deploy_env} deploy:migrations" - else - puts "No deploy for branch #{git_branch}" + unless ENV["CHOUETTE_DEPLOY_DISABLED"] + if deploy_env + sh "cap #{deploy_env} deploy:migrations deploy:seed" + else + puts "No deploy for branch #{git_branch}" + end end end @@ -75,6 +77,9 @@ namespace :ci do task :clean do puts "Drop #{database_name} database" sh "RAILS_ENV=test rake db:drop" + + # Restore projet config/database.yml + cp "config/database.yml.orig", "config/database.yml" if File.exists?("config/database.yml.orig") end end |
