diff --git a/Gemfile b/Gemfile index c8ab5e68..4659a23f 100644 --- a/Gemfile +++ b/Gemfile @@ -4,7 +4,7 @@ gem 'activerecord-jdbcpostgresql-adapter', platform: :jruby gem 'bcrypt', '~> 3.1.7' gem 'bootstrap-will_paginate' gem 'carrierwave' -gem 'coffee-rails', '~> 4.0.0' +gem 'coffee-rails', '~> 4.1.0' gem 'concurrent-ruby' gem 'concurrent-ruby-ext', platform: :ruby gem 'docker-api', require: 'docker' @@ -20,11 +20,11 @@ gem 'pg', platform: :ruby gem 'pry' gem 'puma' gem 'pundit' -gem 'rails', '~> 4.1.2' +gem 'rails', '~> 4.2.0' gem 'rails-i18n', '~> 4.0.0' gem 'ransack' gem 'rubytree' -gem 'sass-rails', '~> 4.0.3' +gem 'sass-rails', '~> 5.0' gem 'sdoc', '~> 0.4.0', group: :doc gem 'slim' gem 'sorcery' @@ -43,7 +43,12 @@ group :development do gem 'capistrano-upload-config' gem 'rubocop', require: false gem 'rubocop-rspec' +end + +group :development, :test do + gem 'byebug' gem 'spring' + gem 'web-console', '~> 2.0' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 5148d938..42716639 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -2,46 +2,49 @@ GEM remote: https://rubygems.org/ specs: ZenTest (4.11.0) - actionmailer (4.1.9) - actionpack (= 4.1.9) - actionview (= 4.1.9) + actionmailer (4.2.0) + actionpack (= 4.2.0) + actionview (= 4.2.0) + activejob (= 4.2.0) mail (~> 2.5, >= 2.5.4) - actionpack (4.1.9) - actionview (= 4.1.9) - activesupport (= 4.1.9) - rack (~> 1.5.2) + rails-dom-testing (~> 1.0, >= 1.0.5) + actionpack (4.2.0) + actionview (= 4.2.0) + activesupport (= 4.2.0) + rack (~> 1.6.0) rack-test (~> 0.6.2) - actionview (4.1.9) - activesupport (= 4.1.9) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + actionview (4.2.0) + activesupport (= 4.2.0) builder (~> 3.1) erubis (~> 2.7.0) - activemodel (4.1.9) - activesupport (= 4.1.9) + rails-dom-testing (~> 1.0, >= 1.0.5) + rails-html-sanitizer (~> 1.0, >= 1.0.1) + activejob (4.2.0) + activesupport (= 4.2.0) + globalid (>= 0.3.0) + activemodel (4.2.0) + activesupport (= 4.2.0) builder (~> 3.1) - activerecord (4.1.9) - activemodel (= 4.1.9) - activesupport (= 4.1.9) - arel (~> 5.0.0) - activerecord-jdbc-adapter (1.3.14) - activerecord (>= 2.2) - activerecord-jdbcpostgresql-adapter (1.3.14) - activerecord-jdbc-adapter (~> 1.3.14) - jdbc-postgres (>= 9.1) - activesupport (4.1.9) - i18n (~> 0.6, >= 0.6.9) + activerecord (4.2.0) + activemodel (= 4.2.0) + activesupport (= 4.2.0) + arel (~> 6.0) + activesupport (4.2.0) + i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) - thread_safe (~> 0.1) + thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) archive-tar-minitar (0.5.2) - arel (5.0.1.20140414130214) + arel (6.0.0) ast (2.0.0) astrolabe (1.3.0) parser (>= 2.2.0.pre.3, < 3.0) autotest-rails (4.2.1) ZenTest (~> 4.5) bcrypt (3.1.10) - bcrypt (3.1.10-java) better_errors (2.1.1) coderay (>= 1.0.0) erubis (>= 2.6.6) @@ -51,6 +54,10 @@ GEM bootstrap-will_paginate (0.0.10) will_paginate builder (3.2.2) + byebug (3.5.1) + columnize (~> 0.8) + debugger-linecache (~> 1.2) + slop (~> 3.6) capistrano (3.2.1) i18n rake (>= 10.0.0) @@ -85,7 +92,7 @@ GEM codeclimate-test-reporter (0.4.6) simplecov (>= 0.7.1, < 1.0.0) coderay (1.1.0) - coffee-rails (4.0.1) + coffee-rails (4.1.0) coffee-script (>= 2.2.0) railties (>= 4.0.0, < 5.0) coffee-script (2.3.0) @@ -93,21 +100,22 @@ GEM execjs coffee-script-source (1.9.0) colorize (0.7.5) + columnize (0.9.0) concurrent-ruby (0.8.0) ref (~> 1.0, >= 1.0.5) - concurrent-ruby (0.8.0-java) concurrent-ruby-ext (0.8.0) concurrent-ruby (~> 0.8.0) database_cleaner (1.4.0) debug_inspector (0.0.2) + debugger-linecache (1.2.0) diff-lcs (1.2.5) docile (1.1.5) - docker-api (1.17.0) + docker-api (1.19.0) archive-tar-minitar excon (>= 0.38.0) json erubis (2.7.0) - excon (0.44.1) + excon (0.44.2) execjs (2.3.0) factory_girl (4.5.0) activesupport (>= 3.0.0) @@ -117,8 +125,9 @@ GEM faraday (0.9.1) multipart-post (>= 1.2, < 3) ffi (1.9.6) - ffi (1.9.6-java) forgery (0.6.0) + globalid (0.3.3) + activesupport (>= 4.1.0) highline (1.6.21) hike (1.2.3) i18n (0.7.0) @@ -126,20 +135,21 @@ GEM builder oauth (~> 0.4.5) uuid - jbuilder (2.2.6) + jbuilder (2.2.7) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) - jdbc-postgres (9.3.1102) - jquery-rails (3.1.2) - railties (>= 3.0, < 5.0) + jquery-rails (4.0.3) + rails-dom-testing (~> 1.0) + railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-turbolinks (2.1.0) railties (>= 3.1.0) turbolinks json (1.8.2) - json (1.8.2-java) jwt (1.2.1) kramdown (1.5.0) + loofah (2.0.1) + nokogiri (>= 1.5.9) macaddr (1.7.1) systemu (~> 2.6.2) mail (2.6.3) @@ -156,7 +166,6 @@ GEM net-ssh (2.9.2) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) - nokogiri (1.6.6.2-java) nyan-cat-formatter (0.11) rspec (>= 2.99, >= 2.14.2, < 4) oauth (0.4.7) @@ -166,7 +175,7 @@ GEM multi_json (~> 1.3) multi_xml (~> 0.5) rack (~> 1.2) - parser (2.2.0.2) + parser (2.2.0.3) ast (>= 1.1, < 3.0) pg (0.18.1) polyamorous (1.1.0) @@ -176,36 +185,38 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) - pry (0.10.1-java) - coderay (~> 1.1.0) - method_source (~> 0.8.1) - slop (~> 3.4) - spoon (~> 0.0) - puma (2.11.0) - rack (>= 1.1, < 2.0) - puma (2.11.0-java) + puma (2.11.1) rack (>= 1.1, < 2.0) pundit (0.3.0) activesupport (>= 3.0.0) - rack (1.5.2) + rack (1.6.0) rack-test (0.6.3) rack (>= 1.0) - rails (4.1.9) - actionmailer (= 4.1.9) - actionpack (= 4.1.9) - actionview (= 4.1.9) - activemodel (= 4.1.9) - activerecord (= 4.1.9) - activesupport (= 4.1.9) + rails (4.2.0) + actionmailer (= 4.2.0) + actionpack (= 4.2.0) + actionview (= 4.2.0) + activejob (= 4.2.0) + activemodel (= 4.2.0) + activerecord (= 4.2.0) + activesupport (= 4.2.0) bundler (>= 1.3.0, < 2.0) - railties (= 4.1.9) - sprockets-rails (~> 2.0) + railties (= 4.2.0) + sprockets-rails + rails-deprecated_sanitizer (1.0.3) + activesupport (>= 4.2.0.alpha) + rails-dom-testing (1.0.5) + activesupport (>= 4.2.0.beta, < 5.0) + nokogiri (~> 1.6.0) + rails-deprecated_sanitizer (>= 1.0.1) + rails-html-sanitizer (1.0.1) + loofah (~> 2.0) rails-i18n (4.0.3) i18n (~> 0.6) railties (~> 4.0) - railties (4.1.9) - actionpack (= 4.1.9) - activesupport (= 4.1.9) + railties (4.2.0) + actionpack (= 4.2.0) + activesupport (= 4.2.0) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rainbow (2.0.0) @@ -252,12 +263,13 @@ GEM json (~> 1.8) structured_warnings (~> 0.1) rubyzip (1.1.7) - sass (3.2.19) - sass-rails (4.0.5) + sass (3.4.12) + sass-rails (5.0.1) railties (>= 4.0.0, < 5.0) - sass (~> 3.2.2) - sprockets (~> 2.8, < 3.0) - sprockets-rails (~> 2.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (~> 1.1) sdoc (0.4.1) json (~> 1.7, >= 1.7.7) rdoc (~> 4.0) @@ -279,9 +291,7 @@ GEM bcrypt (~> 3.1) oauth (~> 0.4, >= 0.4.4) oauth2 (>= 0.8.0) - spoon (0.0.4) - ffi - spring (1.3.0) + spring (1.3.2) sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) @@ -300,7 +310,6 @@ GEM temple (0.7.5) thor (0.19.1) thread_safe (0.3.4) - thread_safe (0.3.4-java) tilt (1.4.1) turbolinks (2.5.3) coffee-rails @@ -311,13 +320,17 @@ GEM json (>= 1.8.0) uuid (2.3.7) macaddr (~> 1.0) + web-console (2.0.0) + activemodel (~> 4.0) + binding_of_caller (>= 0.7.2) + railties (~> 4.0) + sprockets-rails (>= 2.0, < 4.0) websocket (1.2.1) will_paginate (3.0.7) xpath (2.0.0) nokogiri (~> 1.3) PLATFORMS - java ruby DEPENDENCIES @@ -327,6 +340,7 @@ DEPENDENCIES better_errors binding_of_caller bootstrap-will_paginate + byebug capistrano (~> 3.2.1) capistrano-rails (~> 1.1) capistrano-rvm @@ -335,7 +349,7 @@ DEPENDENCIES capybara carrierwave codeclimate-test-reporter - coffee-rails (~> 4.0.0) + coffee-rails (~> 4.1.0) concurrent-ruby concurrent-ruby-ext database_cleaner @@ -353,7 +367,7 @@ DEPENDENCIES pry puma pundit - rails (~> 4.1.2) + rails (~> 4.2.0) rails-i18n (~> 4.0.0) rake ransack @@ -362,7 +376,7 @@ DEPENDENCIES rubocop rubocop-rspec rubytree - sass-rails (~> 4.0.3) + sass-rails (~> 5.0) sdoc (~> 0.4.0) selenium-webdriver simplecov @@ -372,4 +386,5 @@ DEPENDENCIES thread_safe turbolinks uglifier (>= 1.3.0) + web-console (~> 2.0) will_paginate (~> 3.0) diff --git a/bin/rails b/bin/rails index 728cd85a..4d608ede 100755 --- a/bin/rails +++ b/bin/rails @@ -1,4 +1,8 @@ #!/usr/bin/env ruby -APP_PATH = File.expand_path('../../config/application', __FILE__) +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end +APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' require 'rails/commands' diff --git a/bin/rake b/bin/rake index 17240489..8017a027 100755 --- a/bin/rake +++ b/bin/rake @@ -1,4 +1,8 @@ #!/usr/bin/env ruby +begin + load File.expand_path("../spring", __FILE__) +rescue LoadError +end require_relative '../config/boot' require 'rake' Rake.application.run diff --git a/bin/setup b/bin/setup new file mode 100755 index 00000000..acdb2c13 --- /dev/null +++ b/bin/setup @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +require 'pathname' + +# path to your application root. +APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) + +Dir.chdir APP_ROOT do + # This script is a starting point to setup your application. + # Add necessary setup steps to this file: + + puts "== Installing dependencies ==" + system "gem install bundler --conservative" + system "bundle check || bundle install" + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # system "cp config/database.yml.sample config/database.yml" + # end + + puts "\n== Preparing database ==" + system "bin/rake db:setup" + + puts "\n== Removing old logs and tempfiles ==" + system "rm -f log/*" + system "rm -rf tmp/cache" + + puts "\n== Restarting application server ==" + system "touch tmp/restart.txt" +end diff --git a/bin/spring b/bin/spring index 253ec37c..e0918249 100755 --- a/bin/spring +++ b/bin/spring @@ -1,17 +1,14 @@ #!/usr/bin/env ruby -# This file loads spring without using Bundler, in order to be fast -# It gets overwritten when you run the `spring binstub` command +# This file loads spring without using Bundler, in order to be fast. +# It gets overwritten when you run the `spring binstub` command. unless defined?(Spring) require "rubygems" require "bundler" - if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) - ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) - ENV["GEM_HOME"] = "" - Gem.paths = ENV - + if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m) + Gem.paths = { "GEM_PATH" => Bundler.bundle_path.to_s } gem "spring", match[1] require "spring/binstub" end diff --git a/config.ru b/config.ru index 5bc2a619..bd83b254 100644 --- a/config.ru +++ b/config.ru @@ -1,4 +1,4 @@ # This file is used by Rack-based servers to start the application. -require ::File.expand_path('../config/environment', __FILE__) +require ::File.expand_path('../config/environment', __FILE__) run Rails.application diff --git a/config/application.rb b/config/application.rb index 91dec8cf..325455bc 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,13 +1,6 @@ require File.expand_path('../boot', __FILE__) -# Pick the frameworks you want: -require "active_model/railtie" -require "active_record/railtie" -require "action_controller/railtie" -require "action_mailer/railtie" -require "action_view/railtie" -require "sprockets/railtie" -# require "rails/test_unit/railtie" +require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -28,6 +21,9 @@ module CodeOcean # config.i18n.default_locale = :de config.i18n.available_locales = [:de, :en] + # Do not swallow errors in after_commit/after_rollback callbacks. + config.active_record.raise_in_transactional_callbacks = true + config.autoload_paths << Rails.root.join('lib') config.eager_load_paths << Rails.root.join('lib') end diff --git a/config/boot.rb b/config/boot.rb index 5e5f0c1f..6b750f00 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,4 +1,3 @@ -# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) +require 'bundler/setup' # Set up gems listed in the Gemfile. diff --git a/config/environments/development.rb b/config/environments/development.rb index 9ceddb73..89ac1623 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -13,8 +13,6 @@ Rails.application.configure do config.consider_all_requests_local = true config.action_controller.perform_caching = false - config.action_mailer.perform_deliveries = true - # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false @@ -24,6 +22,15 @@ Rails.application.configure do # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load + # Debug mode disables concatenation and preprocessing of assets. + # This option may cause significant delays in view rendering with a large + # number of complex assets. + config.assets.debug = true + + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. + config.assets.digest = true + # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. # Raises helpful error messages. diff --git a/config/environments/production.rb b/config/environments/production.rb index 47d3553b..5c1b32e4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -16,11 +16,13 @@ Rails.application.configure do # Enable Rack::Cache to put a simple HTTP cache in front of your application # Add `rack-cache` to your Gemfile before enabling this. - # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. + # For large-scale production use, consider using a caching reverse proxy like + # NGINX, varnish or squid. # config.action_dispatch.rack_cache = true - # Disable Rails's static asset server (Apache or nginx will already do this). - config.serve_static_assets = false + # Disable serving static files from the `/public` folder by default since + # Apache or NGINX already handles this. + config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier @@ -29,21 +31,22 @@ Rails.application.configure do # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false - # Generate digests for assets URLs. + # Asset digests allow you to set far-future HTTP expiration dates on all assets, + # yet still be able to expire them through the digest params. config.assets.digest = true - # Version of your assets, change this if you want to expire all your assets. - config.assets.version = '1.0' + # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # Specifies the header that your server uses for sending files. - # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache - # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx + # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true - # Set to :debug to see everything in the log. - config.log_level = :info + # Use the lowest log level to ensure availability of diagnostic information + # when problems arise. + config.log_level = :debug # Prepend all log lines with the following tags. # config.log_tags = [ :subdomain, :uuid ] @@ -55,11 +58,7 @@ Rails.application.configure do # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server. - # config.action_controller.asset_host = "http://assets.example.com" - - # Precompile additional assets. - # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. - # config.assets.precompile += %w( search.js ) + # config.action_controller.asset_host = 'http://assets.example.com' # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. @@ -72,9 +71,6 @@ Rails.application.configure do # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify - # Disable automatic flushing of the log to improve performance. - # config.autoflush_log = false - # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new diff --git a/config/environments/test.rb b/config/environments/test.rb index 053f5b66..1c19f08b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -12,8 +12,8 @@ Rails.application.configure do # preloads Rails for running tests, you may have to set it to true. config.eager_load = false - # Configure static asset server for tests with Cache-Control for performance. - config.serve_static_assets = true + # Configure static file server for tests with Cache-Control for performance. + config.serve_static_files = true config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching. @@ -31,6 +31,9 @@ Rails.application.configure do # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test + # Randomize the order test cases are executed. + config.active_support.test_order = :random + # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 00000000..01ef3e66 --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,11 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = '1.0' + +# Add additional assets to the asset load path +# Rails.application.config.assets.paths << Emoji.images_path + +# Precompile additional assets. +# application.js, application.css, and all non-JS/CSS in app/assets folder are already added. +# Rails.application.config.assets.precompile += %w( search.js ) diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 1e5f1e1d..b9aa7526 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,3 +1,3 @@ # Be sure to restart your server when you modify this file. -Rails.application.config.session_store :cookie_store, key: '_hands-on-programming_session' +Rails.application.config.session_store :cookie_store, key: '_CodeOcean_session' diff --git a/config/routes.rb b/config/routes.rb index 9ba066ce..76f2325a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,20 +1,20 @@ FILENAME_REGEXP = /[\w\.]+/ unless Kernel.const_defined?(:FILENAME_REGEXP) Rails.application.routes.draw do - root to: 'application#welcome' + root 'application#welcome' namespace :admin do - get 'dashboard', to: 'dashboard#show' + get 'dashboard' => 'dashboard#show' end - get '/help', to: 'application#help' + get '/help' => 'application#help' resources :consumers resources :execution_environments do member do get :shell - post 'shell', as: :execute_command, to: :execute_command + post 'shell' => :execute_command, as: :execute_command end resources :errors, only: [:create, :index, :show] @@ -40,29 +40,29 @@ Rails.application.routes.draw do resources :internal_users do member do - match 'activate', to: 'internal_users#activate', via: [:get, :patch, :put] - match 'reset_password', to: 'internal_users#reset_password', via: [:get, :patch, :put] + match 'activate' => 'internal_users#activate', via: [:get, :patch, :put] + match 'reset_password' => 'internal_users#reset_password', via: [:get, :patch, :put] end end - match '/forgot_password', as: 'forgot_password', to: 'internal_users#forgot_password', via: [:get, :post] + match '/forgot_password' => 'internal_users#forgot_password', as: 'forgot_password', via: [:get, :post] resources :sessions, only: [:create, :destroy, :new] - post '/lti/launch', as: 'lti_launch', to: 'sessions#create_through_lti' - get '/lti/return', as: 'lti_return', to: 'sessions#destroy_through_lti' - get '/sign_in', as: 'sign_in', to: 'sessions#new' - delete '/sign_out', as: 'sign_out', to: 'sessions#destroy' + post '/lti/launch' => 'sessions#create_through_lti', as: 'lti_launch' + get '/lti/return' => 'sessions#destroy_through_lti', as: 'lti_return' + get '/sign_in' => 'sessions#new', as: 'sign_in' + delete '/sign_out' => 'sessions#destroy', as: 'sign_out' resources :submissions, only: [:create, :index, :show] do member do - get 'download/:filename', as: :download, constraints: {filename: FILENAME_REGEXP}, to: :download_file - get 'render/:filename', as: :render, constraints: {filename: FILENAME_REGEXP}, to: :render_file - get 'run/:filename', as: :run, constraints: {filename: FILENAME_REGEXP}, to: :run + get 'download/:filename' => :download_file, as: :download, constraints: {filename: FILENAME_REGEXP} + get 'render/:filename' => :render_file, as: :render, constraints: {filename: FILENAME_REGEXP} + get 'run/:filename' => :run, as: :run, constraints: {filename: FILENAME_REGEXP} get :score get :statistics post :stop - get 'test/:filename', as: :test, constraints: {filename: FILENAME_REGEXP}, to: :test + get 'test/:filename' => :test, as: :test, constraints: {filename: FILENAME_REGEXP} end end diff --git a/spec/controllers/exercises_controller_spec.rb b/spec/controllers/exercises_controller_spec.rb index e70df41d..cc10c8b9 100644 --- a/spec/controllers/exercises_controller_spec.rb +++ b/spec/controllers/exercises_controller_spec.rb @@ -31,7 +31,8 @@ describe ExercisesController do end context 'with a file upload' do - let(:files_attributes) { {'0' => FactoryGirl.build(:file, content: fixture_file_upload('upload.rb', 'text/x-ruby')).attributes} } + let(:file_upload) { fixture_file_upload('upload.rb', 'text/x-ruby') } + let(:files_attributes) { {'0' => FactoryGirl.build(:file).attributes.merge(content: file_upload)} } let(:request) { proc { post :create, exercise: exercise_attributes.merge(files_attributes: files_attributes) } } it 'creates the file' do