Commit 80c352c2 authored by MARGERY David's avatar MARGERY David
Browse files

Migrate to Rails 4.1.x & adapt code so tests pass

parent 7f8fd725
#source 'http://g5k-campaign.gforge.inria.fr/pkg'
source 'https://rubygems.org'
gem 'rake'
gem 'rails', '~> 4.0.0'
gem 'rails', '~> 4.1.0'
# jQuery is the default JavaScript library in Rails 3.1
gem 'jquery-rails'
......@@ -27,9 +26,9 @@ gem 'nokogiri', '~> 1.5.6' #oldest version that blather handles
gem 'blather', '>= 1.2.0'
gem 'sass-rails', "~> 4.0.0"
gem 'coffee-rails', "~> 4.0.0"
gem 'uglifier', ">= 1.0.3"
gem 'sass-rails'
gem 'coffee-rails'
gem 'uglifier'
group :test do
gem 'webmock'
......
......@@ -10,50 +10,46 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.22.5)
actionpack (= 3.2.22.5)
mail (~> 2.5.4)
actionpack (3.2.22.5)
activemodel (= 3.2.22.5)
activesupport (= 3.2.22.5)
builder (~> 3.0.0)
erubis (~> 2.7.0)
actionmailer (4.1.16)
actionpack (= 4.1.16)
actionview (= 4.1.16)
mail (~> 2.5, >= 2.5.4)
actionpack (4.1.16)
actionview (= 4.1.16)
activesupport (= 4.1.16)
rack (~> 1.5.2)
rack-test (~> 0.6.2)
activemodel (4.0.13)
activesupport (= 4.0.13)
builder (~> 3.1.0)
activerecord (4.0.13)
activemodel (= 4.0.13)
activerecord-deprecated_finders (~> 1.0.2)
activesupport (= 4.0.13)
arel (~> 4.0.0)
activerecord-deprecated_finders (1.0.4)
activesupport (4.0.13)
actionview (4.1.16)
activesupport (= 4.1.16)
builder (~> 3.1)
erubis (~> 2.7.0)
activemodel (4.1.16)
activesupport (= 4.1.16)
builder (~> 3.1)
activerecord (4.1.16)
activemodel (= 4.1.16)
activesupport (= 4.1.16)
arel (~> 5.0.0)
activesupport (4.1.16)
i18n (~> 0.6, >= 0.6.9)
minitest (~> 4.2)
multi_json (~> 1.3)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
tzinfo (~> 1.1)
addressable (2.5.2)
public_suffix (>= 2.0.2, < 4.0)
arel (4.0.2)
autotest (4.4.6)
ZenTest (>= 4.4.1)
autotest-growl (0.2.16)
awesome_print (1.8.0)
backports (3.11.3)
arel (5.0.1.20140414130214)
blather (1.2.0)
activesupport (>= 2.3.11)
eventmachine (>= 1.0.0)
girl_friday
niceogiri (~> 1.0)
nokogiri (~> 1.5, >= 1.5.6, <= 1.6.1)
builder (3.0.4)
builder (3.2.3)
charlock_holmes (0.7.6)
coffee-rails (4.0.1)
coffee-rails (4.2.2)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
railties (>= 4.0.0)
coffee-script (2.4.1)
coffee-script-source
execjs
......@@ -84,6 +80,7 @@ GEM
factory_bot_rails (4.11.0)
factory_bot (~> 4.11.0)
railties (>= 3.0.0)
ffi (1.9.25)
girl_friday (0.11.2)
connection_pool (~> 1.0)
rubinius-actor
......@@ -95,7 +92,6 @@ GEM
haml (4.0.7)
tilt
hashdiff (0.3.7)
hike (1.2.3)
http_parser.rb (0.6.0)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
......@@ -105,10 +101,11 @@ GEM
json (1.8.6)
mail (2.7.0)
mini_mime (>= 0.1.1)
mime-types (2.99.3)
mime-types (3.2.2)
mime-types-data (~> 3.2015)
mime-types-data (3.2018.0812)
mini_mime (1.0.1)
minitest (4.7.5)
multi_json (1.13.1)
minitest (5.11.3)
mysql2 (0.3.21)
net-ssh (4.2.0)
net-ssh-gateway (2.0.0)
......@@ -123,38 +120,34 @@ GEM
posix-spawn (0.3.13)
public_suffix (3.0.3)
rack (1.5.5)
rack-cache (1.8.0)
rack (>= 0.4)
rack-fiber_pool (0.9.3)
rack-jsonp (1.3.1)
rack
rack-test (0.6.3)
rack (>= 1.0)
rails (4.0.13)
actionmailer (= 4.0.13)
actionpack (= 4.0.13)
activerecord (= 4.0.13)
activesupport (= 4.0.13)
rails (4.1.16)
actionmailer (= 4.1.16)
actionpack (= 4.1.16)
actionview (= 4.1.16)
activemodel (= 4.1.16)
activerecord (= 4.1.16)
activesupport (= 4.1.16)
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.13)
railties (= 4.1.16)
sprockets-rails (~> 2.0)
railties (4.0.13)
actionpack (= 4.0.13)
activesupport (= 4.0.13)
railties (4.1.16)
actionpack (= 4.1.16)
activesupport (= 4.1.16)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
rdoc (3.12.2)
json (~> 1.4)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-autotest (1.0.0)
rspec-core (>= 2.99.0.beta1, < 4.0.0)
rspec-core (3.8.0)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.1)
......@@ -179,22 +172,25 @@ GEM
rubinius-core-api (0.0.1)
ruby-mysql (2.9.14)
safe_yaml (1.0.4)
sass (3.2.19)
sass-rails (4.0.5)
railties (>= 4.0.0, < 5.0)
sass (~> 3.2.2)
sprockets (~> 2.8, < 3.0)
sprockets-rails (~> 2.0)
sass (3.5.7)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (>= 1.1, < 3)
simplecov (0.16.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
sprockets (2.12.5)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sprockets (3.7.2)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-rails (2.3.3)
actionpack (>= 3.0)
activesupport (>= 3.0)
......@@ -207,8 +203,9 @@ GEM
rack (>= 1.0.0)
thor (0.20.0)
thread_safe (0.3.6)
tilt (1.4.1)
tzinfo (0.3.54)
tilt (2.0.8)
tzinfo (1.2.5)
thread_safe (~> 0.1)
uglifier (4.1.18)
execjs (>= 0.3.0, < 3)
webmock (3.4.2)
......@@ -222,7 +219,7 @@ PLATFORMS
DEPENDENCIES
addressable (~> 2.2)
blather (>= 1.2.0)
coffee-rails (~> 4.0.0)
coffee-rails
em-http-request
em-postgresql-adapter!
em-synchrony
......@@ -238,18 +235,18 @@ DEPENDENCIES
pg (< 1.0.0)
rack-fiber_pool (~> 0.9)
rack-jsonp
rails (~> 4.0.0)
rails (~> 4.1.0)
rake
rspec
rspec-rails
rspec_junit_formatter (~> 0.3.0)
ruby-mysql
sass-rails (~> 4.0.0)
sass-rails
simplecov
state_machine
syslogger
thin (~> 1.5.0)
uglifier (>= 1.0.3)
uglifier
webmock
BUNDLED WITH
......
......@@ -178,9 +178,8 @@ class ApplicationController < ActionController::Base
def render_error(exception, options = {})
log_exception(exception)
message = options[:message] || exception.message
render :text => message,
:status => options[:status],
:content_type => 'text/plain'
render :plain => message,
:status => options[:status]
end
def log_exception(exception)
......
......@@ -24,7 +24,7 @@ class JobsController < ApplicationController
limit = [(params[:limit] || LIMIT).to_i, LIMIT_MAX].min
jobs = OAR::Job.list(params)
total = jobs.count
total = jobs.count(:all)
jobs = jobs.offset(offset).limit(limit).includes(:job_types, :job_events, :gantt)
......@@ -97,7 +97,7 @@ class JobsController < ApplicationController
:in, :absolute
)
render :text => "",
render :plain => "",
:head => :ok,
:location => location_uri,
:status => 202
......
......@@ -53,7 +53,7 @@ class NotificationsController < ApplicationController
head :accepted
else
render :status => :bad_request,
:text => "Your notification is invalid: #{@notification.errors.join("; ")}."
:plain => "Your notification is invalid: #{@notification.errors.join("; ")}."
end
end
......
# coding: utf-8
# Copyright (c) 2018 David Margery, INRIA Rennes - Bretagne Atlantique
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Api::Application.config.secret_key_base = 'Ne sert à rien, nous n\'utilisons pas de sessions'
......@@ -21,17 +21,6 @@ module OAR
has_many :job_events, -> { order "date ASC" }
belongs_to :gantt, :foreign_key => 'assigned_moldable_job', :class_name => 'Gantt'
# There may be a way to do that more cleanly ;-)
# abasu : 4 lines introduced below by for correction to bug ref 5694 -- 2015.01.26
# GROUP BY resources.network_address
# ORDER BY resources.network_address ASC
# abasu : Removed "GROUP BY resources.network_address" for bug ref 5694 -- 2015.04.17
# abasu : To show all cores (even if same network address). Required by MPI programme
#has_many :resources, -> {select QUERY_RESOURCES}
attr_accessor :links
def self.list(params = {})
......@@ -214,7 +203,7 @@ module OAR
def expanded
Job.select("jobs.*, moldable_job_descriptions.moldable_walltime AS walltime, gantt_jobs_predictions.start_time AS predicted_start_time, moldable_job_descriptions.moldable_id").
joins("LEFT OUTER JOIN moldable_job_descriptions ON jobs.job_id = moldable_job_descriptions.moldable_job_id").
joins("LEFT OUTER JOIN gantt_jobs_predictions ON gantt_jobs_predictions.moldable_job_id = moldable_job_descriptions.moldable_id")
joins("LEFT OUTER JOIN gantt_jobs_predictions ON gantt_jobs_predictions.moldable_job_id = moldable_job_descriptions.moldable_id")
end # def expanded
end
end
......
......@@ -75,7 +75,7 @@ describe JobsController do
it "should return 404 if the job does not exist" do
get :show, :site_id => "rennes", :id => "doesnotexist", :format => :json
expect(response.status).to eq 404
expect(response.body).to eq "Couldn't find OAR::Job with job_id=doesnotexist"
expect(response.body).to eq "Couldn't find OAR::Job with 'job_id'=doesnotexist"
end
it "should return 200 and the job" do
get :show, :site_id => "rennes", :id => @job_uids[5], :format => :json
......@@ -236,7 +236,7 @@ describe JobsController do
authenticate_as("crohr")
delete :destroy, :site_id => "rennes", :id => "doesnotexist", :format => :json
expect(response.status).to eq 404
expect(response.body).to eq "Couldn't find OAR::Job with job_id=doesnotexist"
expect(response.body).to eq "Couldn't find OAR::Job with 'job_id'=doesnotexist"
end
it "should return 403 if the requester does not own the job" do
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment